From 1c259c2bc0e34ce92aac88f97d0258463f9c17b1 Mon Sep 17 00:00:00 2001 From: hanif salafi Date: Thu, 6 Mar 2025 21:43:05 +0700 Subject: [PATCH] feat: add feedbacks and update article comments --- app/database/entity/feedbacks.entity.go | 2 +- app/module/article_comments/mapper/article_comments.mapper.go | 1 + .../article_comments/repository/article_comments.repository.go | 3 +++ .../article_comments/response/article_comments.response.go | 1 + app/module/feedbacks/request/feedbacks.request.go | 1 + 5 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/database/entity/feedbacks.entity.go b/app/database/entity/feedbacks.entity.go index 5c475de..8f8b6f9 100644 --- a/app/database/entity/feedbacks.entity.go +++ b/app/database/entity/feedbacks.entity.go @@ -10,7 +10,7 @@ type Feedbacks struct { StatusId int `json:"status_id" gorm:"type:int4;default:0"` ApprovedAt *time.Time `json:"approved_at" gorm:"type:timestamp"` 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()"` UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` } diff --git a/app/module/article_comments/mapper/article_comments.mapper.go b/app/module/article_comments/mapper/article_comments.mapper.go index f833d23..1bc53e3 100644 --- a/app/module/article_comments/mapper/article_comments.mapper.go +++ b/app/module/article_comments/mapper/article_comments.mapper.go @@ -25,6 +25,7 @@ func ArticleCommentsResponseMapper(articleCommentsReq *entity.ArticleComments, u CommentFromName: &commentFromName, ParentId: articleCommentsReq.ParentId, IsPublic: articleCommentsReq.IsPublic, + StatusId: articleCommentsReq.StatusId, IsActive: articleCommentsReq.IsActive, CreatedAt: articleCommentsReq.CreatedAt, UpdatedAt: articleCommentsReq.UpdatedAt, diff --git a/app/module/article_comments/repository/article_comments.repository.go b/app/module/article_comments/repository/article_comments.repository.go index 3c78a16..f7d3c79 100644 --- a/app/module/article_comments/repository/article_comments.repository.go +++ b/app/module/article_comments/repository/article_comments.repository.go @@ -51,6 +51,9 @@ func (_i *articleCommentsRepository) GetAll(req request.ArticleCommentsQueryRequ if req.ParentId != nil { query = query.Where("parent_id = ?", req.ParentId) } + if req.IsPublic != nil { + query = query.Where("is_public = ?", req.IsPublic) + } query.Count(&count) if req.Pagination.SortBy != "" { diff --git a/app/module/article_comments/response/article_comments.response.go b/app/module/article_comments/response/article_comments.response.go index 668dbbd..ff86554 100644 --- a/app/module/article_comments/response/article_comments.response.go +++ b/app/module/article_comments/response/article_comments.response.go @@ -9,6 +9,7 @@ type ArticleCommentsResponse struct { CommentFromId *uint `json:"commentFromId"` CommentFromName *string `json:"commentFromName"` ParentId *int `json:"parentId"` + StatusId int `json:"statusId"` IsPublic bool `json:"isPublic"` IsActive bool `json:"isActive"` CreatedAt time.Time `json:"createdAt"` diff --git a/app/module/feedbacks/request/feedbacks.request.go b/app/module/feedbacks/request/feedbacks.request.go index 7983d2d..874e0f4 100644 --- a/app/module/feedbacks/request/feedbacks.request.go +++ b/app/module/feedbacks/request/feedbacks.request.go @@ -31,6 +31,7 @@ func (req FeedbacksCreateRequest) ToEntity() *entity.Feedbacks { CommentFromName: req.CommentFromName, CommentFromEmail: req.CommentFromEmail, StatusId: 0, + IsActive: true, } }