fix(BE-273): add object nonstock and supplier in response get one and fix name base to relation in dto

This commit is contained in:
Hafizh A. Y
2025-11-20 14:59:50 +07:00
parent b4b860b9d4
commit 228aedc215
64 changed files with 964 additions and 3576 deletions
@@ -10,21 +10,21 @@ import (
// === DTO Structs ===
type LocationBaseDTO struct {
Id uint `json:"id"`
Name string `json:"name"`
Address string `json:"address"`
Area *areaDTO.AreaBaseDTO `json:"area,omitempty"`
type LocationRelationDTO struct {
Id uint `json:"id"`
Name string `json:"name"`
Address string `json:"address"`
Area *areaDTO.AreaRelationDTO `json:"area,omitempty"`
}
type LocationListDTO struct {
Id uint `json:"id"`
Name string `json:"name"`
Address string `json:"address"`
Area *areaDTO.AreaBaseDTO `json:"area"`
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"`
Address string `json:"address"`
Area *areaDTO.AreaRelationDTO `json:"area"`
CreatedUser *userDTO.UserRelationDTO `json:"created_user"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type LocationDetailDTO struct {
@@ -33,14 +33,14 @@ type LocationDetailDTO struct {
// === Mapper Functions ===
func ToLocationBaseDTO(e entity.Location) LocationBaseDTO {
var area *areaDTO.AreaBaseDTO
func ToLocationRelationDTO(e entity.Location) LocationRelationDTO {
var area *areaDTO.AreaRelationDTO
if e.Area.Id != 0 {
mapped := areaDTO.ToAreaBaseDTO(e.Area)
mapped := areaDTO.ToAreaRelationDTO(e.Area)
area = &mapped
}
return LocationBaseDTO{
return LocationRelationDTO{
Id: e.Id,
Name: e.Name,
Address: e.Address,
@@ -49,15 +49,15 @@ func ToLocationBaseDTO(e entity.Location) LocationBaseDTO {
}
func ToLocationListDTO(e entity.Location) LocationListDTO {
var createdUser *userDTO.UserBaseDTO
var createdUser *userDTO.UserRelationDTO
if e.CreatedUser.Id != 0 {
mapped := userDTO.ToUserBaseDTO(e.CreatedUser)
mapped := userDTO.ToUserRelationDTO(e.CreatedUser)
createdUser = &mapped
}
var area *areaDTO.AreaBaseDTO
var area *areaDTO.AreaRelationDTO
if e.Area.Id != 0 {
mapped := areaDTO.ToAreaBaseDTO(e.Area)
mapped := areaDTO.ToAreaRelationDTO(e.Area)
area = &mapped
}