feat(BE-229,234,235,230,231,232,233): purchase request and purchase order and fix master data dto

This commit is contained in:
ragilap
2025-11-17 09:39:30 +07:00
parent 8f74391f1e
commit 11f2389ec5
22 changed files with 2184 additions and 437 deletions
@@ -14,15 +14,19 @@ type KandangBaseDTO struct {
Id uint `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
Location *locationDTO.LocationBaseDTO `json:"location"`
Pic *userDTO.UserBaseDTO `json:"pic"`
Location *locationDTO.LocationBaseDTO `json:"location,omitempty"`
Pic *userDTO.UserBaseDTO `json:"pic,omitempty"`
}
type KandangListDTO struct {
KandangBaseDTO
CreatedUser *userDTO.UserBaseDTO `json:"created_user"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Id uint `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
Location *locationDTO.LocationBaseDTO `json:"location"`
Pic *userDTO.UserBaseDTO `json:"pic"`
CreatedUser *userDTO.UserBaseDTO `json:"created_user"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type KandangDetailDTO struct {
@@ -54,6 +58,18 @@ func ToKandangBaseDTO(e entity.Kandang) KandangBaseDTO {
}
func ToKandangListDTO(e entity.Kandang) KandangListDTO {
var location *locationDTO.LocationBaseDTO
if e.Location.Id != 0 {
mapped := locationDTO.ToLocationBaseDTO(e.Location)
location = &mapped
}
var pic *userDTO.UserBaseDTO
if e.Pic.Id != 0 {
mapped := userDTO.ToUserBaseDTO(e.Pic)
pic = &mapped
}
var createdUser *userDTO.UserBaseDTO
if e.CreatedUser.Id != 0 {
mapped := userDTO.ToUserBaseDTO(e.CreatedUser)
@@ -61,10 +77,14 @@ func ToKandangListDTO(e entity.Kandang) KandangListDTO {
}
return KandangListDTO{
KandangBaseDTO: ToKandangBaseDTO(e),
CreatedAt: e.CreatedAt,
UpdatedAt: e.UpdatedAt,
CreatedUser: createdUser,
Id: e.Id,
Name: e.Name,
Status: e.Status,
Location: location,
Pic: pic,
CreatedAt: e.CreatedAt,
UpdatedAt: e.UpdatedAt,
CreatedUser: createdUser,
}
}