diff --git a/internal/contract/letter_outgoing_contract.go b/internal/contract/letter_outgoing_contract.go index 1df1961..3439b90 100644 --- a/internal/contract/letter_outgoing_contract.go +++ b/internal/contract/letter_outgoing_contract.go @@ -43,6 +43,7 @@ type CreateOutgoingLetterAttachment struct { FileURL string `json:"file_url" validate:"required"` FileName string `json:"file_name" validate:"required"` FileType string `json:"file_type" validate:"required"` + IsFinal bool `json:"is_final" validate:"omitempty"` } type CreateOutgoingLetterRequest struct { @@ -79,6 +80,7 @@ type OutgoingLetterAttachmentResponse struct { FileName string `json:"file_name"` FileType string `json:"file_type"` UploadedAt time.Time `json:"uploaded_at"` + IsFinal bool `json:"is_final"` } type OutgoingLetterApprovalResponse struct { diff --git a/internal/entities/letter_outgoing.go b/internal/entities/letter_outgoing.go index 35e6fcf..756190e 100644 --- a/internal/entities/letter_outgoing.go +++ b/internal/entities/letter_outgoing.go @@ -76,6 +76,7 @@ type LetterOutgoingAttachment struct { FileType string `gorm:"not null" json:"file_type"` UploadedBy *uuid.UUID `json:"uploaded_by,omitempty"` UploadedAt time.Time `gorm:"autoCreateTime" json:"uploaded_at"` + IsFinal bool `gorm:"default:false" json:"is_final"` } func (LetterOutgoingAttachment) TableName() string { return "letter_outgoing_attachments" } diff --git a/internal/service/letter_outgoing_service.go b/internal/service/letter_outgoing_service.go index 504b741..ce3437f 100644 --- a/internal/service/letter_outgoing_service.go +++ b/internal/service/letter_outgoing_service.go @@ -911,11 +911,11 @@ func (s *LetterOutgoingServiceImpl) AddAttachments(ctx context.Context, letterID attachments := make([]entities.LetterOutgoingAttachment, len(req.Attachments)) for i, a := range req.Attachments { attachments[i] = entities.LetterOutgoingAttachment{ - LetterID: letterID, - FileURL: a.FileURL, - FileName: a.FileName, - FileType: a.FileType, - UploadedBy: &userID, + LetterID: letterID, + FileURL: a.FileURL, + FileName: a.FileName, + FileType: a.FileType, + IsFinal: a.IsFinal, } } @@ -1589,6 +1589,7 @@ func transformLetterToResponse(letter *entities.LetterOutgoing) *contract.Outgoi FileName: attachment.FileName, FileType: attachment.FileType, UploadedAt: attachment.UploadedAt, + IsFinal: attachment.IsFinal, } } } diff --git a/migrations/000045_add_is_final_to_letter_outgoing_attachments.down.sql b/migrations/000045_add_is_final_to_letter_outgoing_attachments.down.sql new file mode 100644 index 0000000..e69de29 diff --git a/migrations/000045_add_is_final_to_letter_outgoing_attachments.up.sql b/migrations/000045_add_is_final_to_letter_outgoing_attachments.up.sql new file mode 100644 index 0000000..cd08359 --- /dev/null +++ b/migrations/000045_add_is_final_to_letter_outgoing_attachments.up.sql @@ -0,0 +1,2 @@ +ALTER TABLE letter_outgoing_attachments + ADD COLUMN IF NOT EXISTS is_final BOOLEAN NOT NULL DEFAULT FALSE; \ No newline at end of file