letter outgoint attachment

This commit is contained in:
efrilm 2025-12-05 22:40:16 +07:00
parent 43f67a5381
commit 7b9db24c83
5 changed files with 11 additions and 5 deletions

View File

@ -43,6 +43,7 @@ type CreateOutgoingLetterAttachment struct {
FileURL string `json:"file_url" validate:"required"` FileURL string `json:"file_url" validate:"required"`
FileName string `json:"file_name" validate:"required"` FileName string `json:"file_name" validate:"required"`
FileType string `json:"file_type" validate:"required"` FileType string `json:"file_type" validate:"required"`
IsFinal bool `json:"is_final" validate:"omitempty"`
} }
type CreateOutgoingLetterRequest struct { type CreateOutgoingLetterRequest struct {
@ -79,6 +80,7 @@ type OutgoingLetterAttachmentResponse struct {
FileName string `json:"file_name"` FileName string `json:"file_name"`
FileType string `json:"file_type"` FileType string `json:"file_type"`
UploadedAt time.Time `json:"uploaded_at"` UploadedAt time.Time `json:"uploaded_at"`
IsFinal bool `json:"is_final"`
} }
type OutgoingLetterApprovalResponse struct { type OutgoingLetterApprovalResponse struct {

View File

@ -76,6 +76,7 @@ type LetterOutgoingAttachment struct {
FileType string `gorm:"not null" json:"file_type"` FileType string `gorm:"not null" json:"file_type"`
UploadedBy *uuid.UUID `json:"uploaded_by,omitempty"` UploadedBy *uuid.UUID `json:"uploaded_by,omitempty"`
UploadedAt time.Time `gorm:"autoCreateTime" json:"uploaded_at"` UploadedAt time.Time `gorm:"autoCreateTime" json:"uploaded_at"`
IsFinal bool `gorm:"default:false" json:"is_final"`
} }
func (LetterOutgoingAttachment) TableName() string { return "letter_outgoing_attachments" } func (LetterOutgoingAttachment) TableName() string { return "letter_outgoing_attachments" }

View File

@ -911,11 +911,11 @@ func (s *LetterOutgoingServiceImpl) AddAttachments(ctx context.Context, letterID
attachments := make([]entities.LetterOutgoingAttachment, len(req.Attachments)) attachments := make([]entities.LetterOutgoingAttachment, len(req.Attachments))
for i, a := range req.Attachments { for i, a := range req.Attachments {
attachments[i] = entities.LetterOutgoingAttachment{ attachments[i] = entities.LetterOutgoingAttachment{
LetterID: letterID, LetterID: letterID,
FileURL: a.FileURL, FileURL: a.FileURL,
FileName: a.FileName, FileName: a.FileName,
FileType: a.FileType, FileType: a.FileType,
UploadedBy: &userID, IsFinal: a.IsFinal,
} }
} }
@ -1589,6 +1589,7 @@ func transformLetterToResponse(letter *entities.LetterOutgoing) *contract.Outgoi
FileName: attachment.FileName, FileName: attachment.FileName,
FileType: attachment.FileType, FileType: attachment.FileType,
UploadedAt: attachment.UploadedAt, UploadedAt: attachment.UploadedAt,
IsFinal: attachment.IsFinal,
} }
} }
} }

View File

@ -0,0 +1,2 @@
ALTER TABLE letter_outgoing_attachments
ADD COLUMN IF NOT EXISTS is_final BOOLEAN NOT NULL DEFAULT FALSE;