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
+6 -6
View File
@@ -9,7 +9,7 @@ import (
// === DTO Structs ===
type {{Pascal .Entity}}BaseDTO struct {
type {{Pascal .Entity}}RelationDTO struct {
Id uint `json:"id"`
Name string `json:"name"`
}
@@ -17,7 +17,7 @@ type {{Pascal .Entity}}BaseDTO struct {
type {{Pascal .Entity}}ListDTO struct {
Id uint `json:"id"`
Name string `json:"name"`
CreatedUser *userDTO.UserBaseDTO `json:"created_user"`
CreatedUser *userDTO.UserRelationDTO `json:"created_user"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
@@ -28,17 +28,17 @@ type {{Pascal .Entity}}DetailDTO struct {
// === Mapper Functions ===
func To{{Pascal .Entity}}BaseDTO(e entity.{{Pascal .Entity}}) {{Pascal .Entity}}BaseDTO {
return {{Pascal .Entity}}BaseDTO{
func To{{Pascal .Entity}}RelationDTO(e entity.{{Pascal .Entity}}) {{Pascal .Entity}}RelationDTO {
return {{Pascal .Entity}}RelationDTO{
Id: e.Id,
Name: e.Name,
}
}
func To{{Pascal .Entity}}ListDTO(e entity.{{Pascal .Entity}}) {{Pascal .Entity}}ListDTO {
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
}