add addresse

This commit is contained in:
Aditya Siregar
2025-09-21 21:06:04 +07:00
parent 24e1d265d3
commit 7c3d6451bd
8 changed files with 71 additions and 0 deletions
+6
View File
@@ -43,8 +43,10 @@ type CreateIncomingLetterRequest struct {
PriorityID *uuid.UUID `json:"priority_id,omitempty"`
SenderInstitutionID *uuid.UUID `json:"sender_institution_id,omitempty"`
SenderName *string `json:"sender_name,omitempty"`
Addressee *string `json:"addressee,omitempty"`
ReceivedDate time.Time `json:"received_date"`
DueDate *time.Time `json:"due_date,omitempty"`
Type string `json:"type"` // UTAMA or TEMBUSAN
Attachments []CreateIncomingLetterAttachment `json:"attachments,omitempty"`
}
@@ -65,8 +67,10 @@ type IncomingLetterResponse struct {
Priority *PriorityResponse `json:"priority,omitempty"`
SenderInstitution *InstitutionResponse `json:"sender_institution,omitempty"`
SenderName *string `json:"sender_name,omitempty"`
Addressee *string `json:"addressee,omitempty"`
ReceivedDate time.Time `json:"received_date"`
DueDate *time.Time `json:"due_date,omitempty"`
Type string `json:"type"`
Status string `json:"status"`
CreatedBy uuid.UUID `json:"created_by"`
CreatedAt time.Time `json:"created_at"`
@@ -82,8 +86,10 @@ type UpdateIncomingLetterRequest struct {
PriorityID *uuid.UUID `json:"priority_id,omitempty"`
SenderInstitutionID *uuid.UUID `json:"sender_institution_id,omitempty"`
SenderName *string `json:"sender_name,omitempty"`
Addressee *string `json:"addressee,omitempty"`
ReceivedDate *time.Time `json:"received_date,omitempty"`
DueDate *time.Time `json:"due_date,omitempty"`
Type *string `json:"type,omitempty"`
Status *string `json:"status,omitempty"`
}
+9
View File
@@ -14,6 +14,13 @@ const (
LetterIncomingStatusCompleted LetterIncomingStatus = "completed"
)
type LetterIncomingType string
const (
LetterIncomingTypeUtama LetterIncomingType = "UTAMA"
LetterIncomingTypeTembusan LetterIncomingType = "TEMBUSAN"
)
type LetterIncoming struct {
ID uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
LetterNumber string `gorm:"uniqueIndex;not null" json:"letter_number"`
@@ -23,8 +30,10 @@ type LetterIncoming struct {
PriorityID *uuid.UUID `json:"priority_id,omitempty"`
SenderInstitutionID *uuid.UUID `json:"sender_institution_id,omitempty"`
SenderName *string `json:"sender_name,omitempty"`
Addressee *string `json:"addressee,omitempty"`
ReceivedDate time.Time `json:"received_date"`
DueDate *time.Time `json:"due_date,omitempty"`
Type LetterIncomingType `gorm:"not null;default:'UTAMA'" json:"type"`
Status LetterIncomingStatus `gorm:"not null;default:'new'" json:"status"`
CreatedBy uuid.UUID `gorm:"not null" json:"created_by"`
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
+13
View File
@@ -60,6 +60,11 @@ func NewLetterProcessor(letterRepo *repository.LetterIncomingRepository, attachR
func (p *LetterProcessorImpl) CreateIncomingLetter(ctx context.Context, req *contract.CreateIncomingLetterRequest) (*contract.IncomingLetterResponse, error) {
userID := appcontext.FromGinContext(ctx).UserID
letterType := entities.LetterIncomingTypeUtama
if req.Type == "TEMBUSAN" {
letterType = entities.LetterIncomingTypeTembusan
}
entity := &entities.LetterIncoming{
LetterNumber: req.LetterNumber,
ReferenceNumber: req.ReferenceNumber,
@@ -68,8 +73,10 @@ func (p *LetterProcessorImpl) CreateIncomingLetter(ctx context.Context, req *con
PriorityID: req.PriorityID,
SenderInstitutionID: req.SenderInstitutionID,
SenderName: req.SenderName,
Addressee: req.Addressee,
ReceivedDate: req.ReceivedDate,
DueDate: req.DueDate,
Type: letterType,
Status: entities.LetterIncomingStatusNew,
CreatedBy: userID,
}
@@ -256,12 +263,18 @@ func (p *LetterProcessorImpl) UpdateIncomingLetter(ctx context.Context, id uuid.
if req.SenderName != nil {
entity.SenderName = req.SenderName
}
if req.Addressee != nil {
entity.Addressee = req.Addressee
}
if req.ReceivedDate != nil {
entity.ReceivedDate = *req.ReceivedDate
}
if req.DueDate != nil {
entity.DueDate = req.DueDate
}
if req.Type != nil {
entity.Type = entities.LetterIncomingType(*req.Type)
}
if req.Status != nil {
entity.Status = entities.LetterIncomingStatus(*req.Status)
}
@@ -15,8 +15,10 @@ func LetterEntityToContract(e *entities.LetterIncoming, attachments []entities.L
Subject: e.Subject,
Description: e.Description,
SenderName: e.SenderName,
Addressee: e.Addressee,
ReceivedDate: e.ReceivedDate,
DueDate: e.DueDate,
Type: string(e.Type),
Status: string(e.Status),
CreatedBy: e.CreatedBy,
CreatedAt: e.CreatedAt,
@@ -77,8 +79,10 @@ func LetterIncomingEntityToContract(e *entities.LetterIncoming) *contract.Incomi
Subject: e.Subject,
Description: e.Description,
SenderName: e.SenderName,
Addressee: e.Addressee,
ReceivedDate: e.ReceivedDate,
DueDate: e.DueDate,
Type: string(e.Type),
Status: string(e.Status),
CreatedBy: e.CreatedBy, // Will be set conditionally
CreatedAt: e.CreatedAt,