package transformer import ( "eslogad-be/internal/contract" "eslogad-be/internal/entities" "github.com/google/uuid" ) func CreateRepositoryAttachmentRequestToEntity(req *contract.CreateRepositoryAttachmentRequest, userId uuid.UUID) *entities.RepositoryAttachment { if req == nil { return nil } return &entities.RepositoryAttachment{ FileName: req.FileName, FileType: req.FileType, FileURL: req.FileURL, UploadedBy: &userId, Category: req.Category, } } func RepositoryAttachmentEntityToContract(entity *entities.RepositoryAttachment) *contract.RepositoryAttachmentsResponse { resp := &contract.RepositoryAttachmentsResponse{ ID: entity.ID, FileName: entity.FileName, FileType: entity.FileType, FileURL: entity.FileURL, Category: entity.Category, UploadBy: *entity.UploadedBy, UploadAt: entity.UploadedAt, } return resp } func RepositoryAttachmentEntityToContracts(attachments []*entities.RepositoryAttachment) []contract.RepositoryAttachmentsResponse { if attachments == nil { return nil } responses := make([]contract.RepositoryAttachmentsResponse, len(attachments)) for i, u := range attachments { resp := RepositoryAttachmentEntityToContract(u) if resp != nil { responses[i] = *resp } } return responses }