feat: add feedbacks and update article comments

This commit is contained in:
hanif salafi 2025-03-06 21:43:05 +07:00
parent b322cccfff
commit 1c259c2bc0
5 changed files with 7 additions and 1 deletions

View File

@ -10,7 +10,7 @@ type Feedbacks struct {
StatusId int `json:"status_id" gorm:"type:int4;default:0"` StatusId int `json:"status_id" gorm:"type:int4;default:0"`
ApprovedAt *time.Time `json:"approved_at" gorm:"type:timestamp"` ApprovedAt *time.Time `json:"approved_at" gorm:"type:timestamp"`
ReplyMessage *string `json:"reply_message" gorm:"type:varchar"` ReplyMessage *string `json:"reply_message" gorm:"type:varchar"`
IsActive bool `json:"is_active" gorm:"type:bool"` IsActive bool `json:"is_active" gorm:"type:bool;default:true"`
CreatedAt time.Time `json:"created_at" gorm:"default:now()"` CreatedAt time.Time `json:"created_at" gorm:"default:now()"`
UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"`
} }

View File

@ -25,6 +25,7 @@ func ArticleCommentsResponseMapper(articleCommentsReq *entity.ArticleComments, u
CommentFromName: &commentFromName, CommentFromName: &commentFromName,
ParentId: articleCommentsReq.ParentId, ParentId: articleCommentsReq.ParentId,
IsPublic: articleCommentsReq.IsPublic, IsPublic: articleCommentsReq.IsPublic,
StatusId: articleCommentsReq.StatusId,
IsActive: articleCommentsReq.IsActive, IsActive: articleCommentsReq.IsActive,
CreatedAt: articleCommentsReq.CreatedAt, CreatedAt: articleCommentsReq.CreatedAt,
UpdatedAt: articleCommentsReq.UpdatedAt, UpdatedAt: articleCommentsReq.UpdatedAt,

View File

@ -51,6 +51,9 @@ func (_i *articleCommentsRepository) GetAll(req request.ArticleCommentsQueryRequ
if req.ParentId != nil { if req.ParentId != nil {
query = query.Where("parent_id = ?", req.ParentId) query = query.Where("parent_id = ?", req.ParentId)
} }
if req.IsPublic != nil {
query = query.Where("is_public = ?", req.IsPublic)
}
query.Count(&count) query.Count(&count)
if req.Pagination.SortBy != "" { if req.Pagination.SortBy != "" {

View File

@ -9,6 +9,7 @@ type ArticleCommentsResponse struct {
CommentFromId *uint `json:"commentFromId"` CommentFromId *uint `json:"commentFromId"`
CommentFromName *string `json:"commentFromName"` CommentFromName *string `json:"commentFromName"`
ParentId *int `json:"parentId"` ParentId *int `json:"parentId"`
StatusId int `json:"statusId"`
IsPublic bool `json:"isPublic"` IsPublic bool `json:"isPublic"`
IsActive bool `json:"isActive"` IsActive bool `json:"isActive"`
CreatedAt time.Time `json:"createdAt"` CreatedAt time.Time `json:"createdAt"`

View File

@ -31,6 +31,7 @@ func (req FeedbacksCreateRequest) ToEntity() *entity.Feedbacks {
CommentFromName: req.CommentFromName, CommentFromName: req.CommentFromName,
CommentFromEmail: req.CommentFromEmail, CommentFromEmail: req.CommentFromEmail,
StatusId: 0, StatusId: 0,
IsActive: true,
} }
} }