Feat(BE-127): create migration for transfer to laying and inisiate module

This commit is contained in:
aguhh18
2025-10-30 09:06:21 +07:00
parent a390d1d23a
commit 31bb28f7da
13 changed files with 532 additions and 1 deletions
@@ -0,0 +1,64 @@
package dto
import (
"time"
entity "gitlab.com/mbugroup/lti-api.git/internal/entities"
userDTO "gitlab.com/mbugroup/lti-api.git/internal/modules/users/dto"
)
// === DTO Structs ===
type TransferLayingBaseDTO struct {
Id uint `json:"id"`
Name string `json:"name"`
}
type TransferLayingListDTO struct {
TransferLayingBaseDTO
CreatedUser *userDTO.UserBaseDTO `json:"created_user"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type TransferLayingDetailDTO struct {
TransferLayingListDTO
}
// === Mapper Functions ===
func ToTransferLayingBaseDTO(e entity.TransferLaying) TransferLayingBaseDTO {
return TransferLayingBaseDTO{
Id: e.Id,
Name: e.Name,
}
}
func ToTransferLayingListDTO(e entity.TransferLaying) TransferLayingListDTO {
var createdUser *userDTO.UserBaseDTO
if e.CreatedUser.Id != 0 {
mapped := userDTO.ToUserBaseDTO(e.CreatedUser)
createdUser = &mapped
}
return TransferLayingListDTO{
TransferLayingBaseDTO: ToTransferLayingBaseDTO(e),
CreatedAt: e.CreatedAt,
UpdatedAt: e.UpdatedAt,
CreatedUser: createdUser,
}
}
func ToTransferLayingListDTOs(e []entity.TransferLaying) []TransferLayingListDTO {
result := make([]TransferLayingListDTO, len(e))
for i, r := range e {
result[i] = ToTransferLayingListDTO(r)
}
return result
}
func ToTransferLayingDetailDTO(e entity.TransferLaying) TransferLayingDetailDTO {
return TransferLayingDetailDTO{
TransferLayingListDTO: ToTransferLayingListDTO(e),
}
}