letter incoming
This commit is contained in:
@@ -190,3 +190,66 @@ func RoleWithPermissionsToContract(role entities.Role, perms []entities.Permissi
|
||||
UpdatedAt: role.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func LabelsToContract(list []entities.Label) []contract.LabelResponse {
|
||||
out := make([]contract.LabelResponse, 0, len(list))
|
||||
for _, e := range list {
|
||||
out = append(out, contract.LabelResponse{ID: e.ID.String(), Name: e.Name, Color: e.Color, CreatedAt: e.CreatedAt, UpdatedAt: e.UpdatedAt})
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func PrioritiesToContract(list []entities.Priority) []contract.PriorityResponse {
|
||||
out := make([]contract.PriorityResponse, 0, len(list))
|
||||
for _, e := range list {
|
||||
out = append(out, contract.PriorityResponse{ID: e.ID.String(), Name: e.Name, Level: e.Level, CreatedAt: e.CreatedAt, UpdatedAt: e.UpdatedAt})
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func InstitutionsToContract(list []entities.Institution) []contract.InstitutionResponse {
|
||||
out := make([]contract.InstitutionResponse, 0, len(list))
|
||||
for _, e := range list {
|
||||
out = append(out, contract.InstitutionResponse{ID: e.ID.String(), Name: e.Name, Type: string(e.Type), Address: e.Address, ContactPerson: e.ContactPerson, Phone: e.Phone, Email: e.Email, CreatedAt: e.CreatedAt, UpdatedAt: e.UpdatedAt})
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func DispositionActionsToContract(list []entities.DispositionAction) []contract.DispositionActionResponse {
|
||||
out := make([]contract.DispositionActionResponse, 0, len(list))
|
||||
for _, e := range list {
|
||||
out = append(out, contract.DispositionActionResponse{
|
||||
ID: e.ID.String(),
|
||||
Code: e.Code,
|
||||
Label: e.Label,
|
||||
Description: e.Description,
|
||||
RequiresNote: e.RequiresNote,
|
||||
GroupName: e.GroupName,
|
||||
SortOrder: e.SortOrder,
|
||||
IsActive: e.IsActive,
|
||||
CreatedAt: e.CreatedAt,
|
||||
UpdatedAt: e.UpdatedAt,
|
||||
})
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func DispositionRoutesToContract(list []entities.DispositionRoute) []contract.DispositionRouteResponse {
|
||||
out := make([]contract.DispositionRouteResponse, 0, len(list))
|
||||
for _, e := range list {
|
||||
var allowed map[string]interface{}
|
||||
if e.AllowedActions != nil {
|
||||
allowed = map[string]interface{}(e.AllowedActions)
|
||||
}
|
||||
out = append(out, contract.DispositionRouteResponse{
|
||||
ID: e.ID,
|
||||
FromDepartmentID: e.FromDepartmentID,
|
||||
ToDepartmentID: e.ToDepartmentID,
|
||||
IsActive: e.IsActive,
|
||||
AllowedActions: allowed,
|
||||
CreatedAt: e.CreatedAt,
|
||||
UpdatedAt: e.UpdatedAt,
|
||||
})
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package transformer
|
||||
|
||||
import (
|
||||
"eslogad-be/internal/contract"
|
||||
"eslogad-be/internal/entities"
|
||||
)
|
||||
|
||||
func LetterEntityToContract(e *entities.LetterIncoming, attachments []entities.LetterIncomingAttachment) *contract.IncomingLetterResponse {
|
||||
resp := &contract.IncomingLetterResponse{
|
||||
ID: e.ID,
|
||||
LetterNumber: e.LetterNumber,
|
||||
ReferenceNumber: e.ReferenceNumber,
|
||||
Subject: e.Subject,
|
||||
Description: e.Description,
|
||||
PriorityID: e.PriorityID,
|
||||
SenderInstitutionID: e.SenderInstitutionID,
|
||||
ReceivedDate: e.ReceivedDate,
|
||||
DueDate: e.DueDate,
|
||||
Status: string(e.Status),
|
||||
CreatedBy: e.CreatedBy,
|
||||
CreatedAt: e.CreatedAt,
|
||||
UpdatedAt: e.UpdatedAt,
|
||||
Attachments: make([]contract.IncomingLetterAttachmentResponse, 0, len(attachments)),
|
||||
}
|
||||
for _, a := range attachments {
|
||||
resp.Attachments = append(resp.Attachments, contract.IncomingLetterAttachmentResponse{
|
||||
ID: a.ID,
|
||||
FileURL: a.FileURL,
|
||||
FileName: a.FileName,
|
||||
FileType: a.FileType,
|
||||
UploadedAt: a.UploadedAt,
|
||||
})
|
||||
}
|
||||
return resp
|
||||
}
|
||||
|
||||
func DispositionsToContract(list []entities.LetterDisposition) []contract.DispositionResponse {
|
||||
out := make([]contract.DispositionResponse, 0, len(list))
|
||||
for _, d := range list {
|
||||
out = append(out, contract.DispositionResponse{
|
||||
ID: d.ID,
|
||||
LetterID: d.LetterID,
|
||||
FromDepartmentID: d.FromDepartmentID,
|
||||
ToDepartmentID: d.ToDepartmentID,
|
||||
Notes: d.Notes,
|
||||
Status: string(d.Status),
|
||||
CreatedBy: d.CreatedBy,
|
||||
CreatedAt: d.CreatedAt,
|
||||
})
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func DiscussionEntityToContract(e *entities.LetterDiscussion) *contract.LetterDiscussionResponse {
|
||||
var mentions map[string]interface{}
|
||||
if e.Mentions != nil {
|
||||
mentions = map[string]interface{}(e.Mentions)
|
||||
}
|
||||
return &contract.LetterDiscussionResponse{
|
||||
ID: e.ID,
|
||||
LetterID: e.LetterID,
|
||||
ParentID: e.ParentID,
|
||||
UserID: e.UserID,
|
||||
Message: e.Message,
|
||||
Mentions: mentions,
|
||||
CreatedAt: e.CreatedAt,
|
||||
UpdatedAt: e.UpdatedAt,
|
||||
EditedAt: e.EditedAt,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user