user details page

This commit is contained in:
2025-05-14 16:48:52 +08:00
parent cbac071dd2
commit 3b7d52a7a8
20 changed files with 450 additions and 64 deletions

View File

@@ -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
}