mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 12:17:24 +00:00
user details page
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"github.com/gofiber/fiber/v3/log"
|
||||
"nysoure/server/dao"
|
||||
"nysoure/server/model"
|
||||
|
||||
"github.com/gofiber/fiber/v3/log"
|
||||
)
|
||||
|
||||
func CreateComment(content string, userID uint, resourceID uint) (*model.CommentView, error) {
|
||||
@@ -51,3 +52,16 @@ func ListComments(resourceID uint, page int) ([]model.CommentView, int, error) {
|
||||
}
|
||||
return res, totalPages, nil
|
||||
}
|
||||
|
||||
func ListCommentsWithUser(username string, page int) ([]model.CommentWithResourceView, int, error) {
|
||||
comments, totalPages, err := dao.GetCommentsWithUser(username, page, pageSize)
|
||||
if err != nil {
|
||||
log.Error("Error getting comments:", err)
|
||||
return nil, 0, model.NewInternalServerError("Error getting comments")
|
||||
}
|
||||
res := make([]model.CommentWithResourceView, 0, len(comments))
|
||||
for _, c := range comments {
|
||||
res = append(res, *c.ToViewWithResource())
|
||||
}
|
||||
return res, totalPages, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user