Feat(BE-36,37,38,39): master area, customer, kandang, location, warehouse

This commit is contained in:
Hafizh A. Y
2025-10-02 10:51:15 +07:00
parent dbc1f79a36
commit e8905be856
79 changed files with 3745 additions and 169 deletions
+24 -15
View File
@@ -3,20 +3,22 @@ package dto
import (
"time"
model "gitlab.com/mbugroup/lti-api.git/internal/modules/master/uoms/models"
entity "gitlab.com/mbugroup/lti-api.git/internal/entities"
userDTO "gitlab.com/mbugroup/lti-api.git/internal/modules/users/dto"
)
// === DTO Structs ===
type UomBaseDTO struct {
Id uint `json:"id"`
Name string `json:"name"`
Id uint `json:"id"`
Name string `json:"name"`
}
type UomListDTO struct {
UomBaseDTO
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CreatedUser *userDTO.UserBaseDTO `json:"created_user"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type UomDetailDTO struct {
@@ -25,24 +27,31 @@ type UomDetailDTO struct {
// === Mapper Functions ===
func ToUomBaseDTO(m model.Uom) UomBaseDTO {
func ToUomBaseDTO(e entity.Uom) UomBaseDTO {
return UomBaseDTO{
Id: m.Id,
Name: m.Name,
Id: e.Id,
Name: e.Name,
}
}
func ToUomListDTO(m model.Uom) UomListDTO {
func ToUomListDTO(e entity.Uom) UomListDTO {
var createdUser *userDTO.UserBaseDTO
if e.CreatedUser.Id != 0 {
mapped := userDTO.ToUserBaseDTO(e.CreatedUser)
createdUser = &mapped
}
return UomListDTO{
UomBaseDTO: ToUomBaseDTO(m),
CreatedAt: m.CreatedAt,
UpdatedAt: m.UpdatedAt,
UomBaseDTO: ToUomBaseDTO(e),
CreatedAt: e.CreatedAt,
UpdatedAt: e.UpdatedAt,
CreatedUser: createdUser,
}
}
func ToUomListDTOs(m []model.Uom) []UomListDTO {
result := make([]UomListDTO, len(m))
for i, r := range m {
func ToUomListDTOs(e []entity.Uom) []UomListDTO {
result := make([]UomListDTO, len(e))
for i, r := range e {
result[i] = ToUomListDTO(r)
}
return result