From f43d96c621f216ce2d5719b3a0e0a681729db2cd Mon Sep 17 00:00:00 2001 From: Sabda Yagra Date: Thu, 12 Feb 2026 17:32:11 +0700 Subject: [PATCH] fix: add parameters publishedFor in articles --- app/database/entity/articles.entity.go | 69 ++++++++++--------- .../articles/request/articles.request.go | 4 ++ docs/swagger/docs.go | 6 ++ docs/swagger/swagger.json | 6 ++ docs/swagger/swagger.yaml | 4 ++ 5 files changed, 55 insertions(+), 34 deletions(-) diff --git a/app/database/entity/articles.entity.go b/app/database/entity/articles.entity.go index ca6145b..8de25c2 100644 --- a/app/database/entity/articles.entity.go +++ b/app/database/entity/articles.entity.go @@ -7,39 +7,40 @@ import ( ) type Articles struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - Title string `json:"title" gorm:"type:varchar"` - Slug string `json:"slug" gorm:"type:varchar"` - Description string `json:"description" gorm:"type:varchar"` - CategoryId int `json:"category_id" gorm:"type:int4"` - HtmlDescription string `json:"html_description" gorm:"type:varchar"` - TypeId int `json:"type_id" gorm:"type:int4"` - Tags string `json:"tags" gorm:"type:varchar"` - ThumbnailName *string `json:"thumbnail_name" gorm:"type:varchar"` - ThumbnailPath *string `json:"thumbnail_path" gorm:"type:varchar"` - PageUrl *string `json:"page_url" gorm:"type:varchar"` - CreatedById *uint `json:"created_by_id" gorm:"type:int4"` - AiArticleId *int `json:"ai_article_id" gorm:"type:int4"` - CommentCount *int `json:"comment_count" gorm:"type:int4;default:0"` - ShareCount *int `json:"share_count" gorm:"type:int4;default:0"` - ViewCount *int `json:"view_count" gorm:"type:int4;default:0"` - StatusId *int `json:"status_id" gorm:"type:int4"` - OldId *uint `json:"old_id" gorm:"type:int4"` - NeedApprovalFrom *int `json:"need_approval_from" gorm:"type:int4"` - HasApprovedBy *string `json:"has_approved_by" gorm:"type:varchar"` - WorkflowId *uint `json:"workflow_id" gorm:"type:int4"` - CurrentApprovalStep *int `json:"current_approval_step" gorm:"type:int4;default:0"` // 0=not submitted, 1+=approval step + ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` + Title string `json:"title" gorm:"type:varchar"` + Slug string `json:"slug" gorm:"type:varchar"` + Description string `json:"description" gorm:"type:varchar"` + CategoryId int `json:"category_id" gorm:"type:int4"` + HtmlDescription string `json:"html_description" gorm:"type:varchar"` + TypeId int `json:"type_id" gorm:"type:int4"` + Tags string `json:"tags" gorm:"type:varchar"` + PublishedFor *string `json:"published_for" gorm:"type:varchar(100)"` + ThumbnailName *string `json:"thumbnail_name" gorm:"type:varchar"` + ThumbnailPath *string `json:"thumbnail_path" gorm:"type:varchar"` + PageUrl *string `json:"page_url" gorm:"type:varchar"` + CreatedById *uint `json:"created_by_id" gorm:"type:int4"` + AiArticleId *int `json:"ai_article_id" gorm:"type:int4"` + CommentCount *int `json:"comment_count" gorm:"type:int4;default:0"` + ShareCount *int `json:"share_count" gorm:"type:int4;default:0"` + ViewCount *int `json:"view_count" gorm:"type:int4;default:0"` + StatusId *int `json:"status_id" gorm:"type:int4"` + OldId *uint `json:"old_id" gorm:"type:int4"` + NeedApprovalFrom *int `json:"need_approval_from" gorm:"type:int4"` + HasApprovedBy *string `json:"has_approved_by" gorm:"type:varchar"` + WorkflowId *uint `json:"workflow_id" gorm:"type:int4"` + CurrentApprovalStep *int `json:"current_approval_step" gorm:"type:int4;default:0"` // 0=not submitted, 1+=approval step // New fields for no-approval support - BypassApproval *bool `json:"bypass_approval" gorm:"type:bool;default:false"` // true = skip approval process - ApprovalExempt *bool `json:"approval_exempt" gorm:"type:bool;default:false"` // true = permanently exempt from approval - IsPublish *bool `json:"is_publish" gorm:"type:bool;default:false"` - IsBanner *bool `json:"is_banner" gorm:"type:bool;default:false"` - PublishedAt *time.Time `json:"published_at" gorm:"type:timestamp"` - IsDraft *bool `json:"is_draft" gorm:"type:bool;default:false"` - DraftedAt *time.Time `json:"drafted_at" gorm:"type:timestamp"` - PublishSchedule *string `json:"publish_schedule" gorm:"type:varchar"` - ClientId *uuid.UUID `json:"client_id" gorm:"type:UUID"` - 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()"` + BypassApproval *bool `json:"bypass_approval" gorm:"type:bool;default:false"` // true = skip approval process + ApprovalExempt *bool `json:"approval_exempt" gorm:"type:bool;default:false"` // true = permanently exempt from approval + IsPublish *bool `json:"is_publish" gorm:"type:bool;default:false"` + IsBanner *bool `json:"is_banner" gorm:"type:bool;default:false"` + PublishedAt *time.Time `json:"published_at" gorm:"type:timestamp"` + IsDraft *bool `json:"is_draft" gorm:"type:bool;default:false"` + DraftedAt *time.Time `json:"drafted_at" gorm:"type:timestamp"` + PublishSchedule *string `json:"publish_schedule" gorm:"type:varchar"` + ClientId *uuid.UUID `json:"client_id" gorm:"type:UUID"` + 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/articles/request/articles.request.go b/app/module/articles/request/articles.request.go index 24871f0..aa6f789 100644 --- a/app/module/articles/request/articles.request.go +++ b/app/module/articles/request/articles.request.go @@ -42,6 +42,7 @@ type ArticlesCreateRequest struct { IsPublish *bool `json:"isPublish"` IsDraft *bool `json:"isDraft"` OldId *uint `json:"oldId"` + PublishedFor *string `json:"publishedFor"` } func (req ArticlesCreateRequest) ToEntity() *entity.Articles { @@ -56,6 +57,7 @@ func (req ArticlesCreateRequest) ToEntity() *entity.Articles { IsPublish: req.IsPublish, IsDraft: req.IsDraft, OldId: req.OldId, + PublishedFor: req.PublishedFor, } } @@ -73,6 +75,7 @@ type ArticlesUpdateRequest struct { IsPublish *bool `json:"isPublish"` IsDraft *bool `json:"isDraft"` StatusId *int `json:"statusId"` + PublishedFor *string `json:"publishedFor"` } func (req ArticlesUpdateRequest) ToEntity() *entity.Articles { @@ -89,6 +92,7 @@ func (req ArticlesUpdateRequest) ToEntity() *entity.Articles { IsPublish: req.IsPublish, IsDraft: req.IsDraft, UpdatedAt: time.Now(), + PublishedFor: req.PublishedFor, } } else { return &entity.Articles{ diff --git a/docs/swagger/docs.go b/docs/swagger/docs.go index a047c4e..1bffea9 100644 --- a/docs/swagger/docs.go +++ b/docs/swagger/docs.go @@ -20189,6 +20189,9 @@ const docTemplate = `{ "oldId": { "type": "integer" }, + "publishedFor": { + "type": "string" + }, "slug": { "type": "string" }, @@ -20239,6 +20242,9 @@ const docTemplate = `{ "isPublish": { "type": "boolean" }, + "publishedFor": { + "type": "string" + }, "slug": { "type": "string" }, diff --git a/docs/swagger/swagger.json b/docs/swagger/swagger.json index 7a0ed87..a8f70c4 100644 --- a/docs/swagger/swagger.json +++ b/docs/swagger/swagger.json @@ -20178,6 +20178,9 @@ "oldId": { "type": "integer" }, + "publishedFor": { + "type": "string" + }, "slug": { "type": "string" }, @@ -20228,6 +20231,9 @@ "isPublish": { "type": "boolean" }, + "publishedFor": { + "type": "string" + }, "slug": { "type": "string" }, diff --git a/docs/swagger/swagger.yaml b/docs/swagger/swagger.yaml index f38247d..9e25a89 100644 --- a/docs/swagger/swagger.yaml +++ b/docs/swagger/swagger.yaml @@ -554,6 +554,8 @@ definitions: type: boolean oldId: type: integer + publishedFor: + type: string slug: type: string tags: @@ -589,6 +591,8 @@ definitions: type: boolean isPublish: type: boolean + publishedFor: + type: string slug: type: string statusId: