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,8 +1,9 @@
package model
import (
"gorm.io/gorm"
"time"
"gorm.io/gorm"
)
type Comment struct {
@@ -29,3 +30,21 @@ func (c *Comment) ToView() *CommentView {
User: c.User.ToView(),
}
}
type CommentWithResourceView struct {
ID uint `json:"id"`
Content string `json:"content"`
CreatedAt time.Time `json:"created_at"`
Resource ResourceView `json:"resource"`
User UserView `json:"user"`
}
func (c *Comment) ToViewWithResource() *CommentWithResourceView {
return &CommentWithResourceView{
ID: c.ID,
Content: c.Content,
CreatedAt: c.CreatedAt,
Resource: c.Resource.ToView(),
User: c.User.ToView(),
}
}