mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
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:
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
// === DTO Structs ===
|
||||
|
||||
type CustomerBaseDTO struct {
|
||||
type CustomerRelationDTO struct {
|
||||
Id uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
PicId uint `json:"pic_id"`
|
||||
@@ -20,14 +20,14 @@ type CustomerBaseDTO struct {
|
||||
AccountNumber string `json:"account_number"`
|
||||
Balance float64 `json:"balance"`
|
||||
|
||||
Pic *userDTO.UserBaseDTO `json:"pic,omitempty"`
|
||||
Pic *userDTO.UserRelationDTO `json:"pic,omitempty"`
|
||||
}
|
||||
|
||||
type CustomerListDTO struct {
|
||||
CustomerBaseDTO
|
||||
CreatedUser *userDTO.UserBaseDTO `json:"created_user"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
CustomerRelationDTO
|
||||
CreatedUser *userDTO.UserRelationDTO `json:"created_user"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
type CustomerDetailDTO struct {
|
||||
@@ -36,14 +36,14 @@ type CustomerDetailDTO struct {
|
||||
|
||||
// === Mapper Functions ===
|
||||
|
||||
func ToCustomerBaseDTO(e entity.Customer) CustomerBaseDTO {
|
||||
var pic *userDTO.UserBaseDTO
|
||||
func ToCustomerRelationDTO(e entity.Customer) CustomerRelationDTO {
|
||||
var pic *userDTO.UserRelationDTO
|
||||
if e.Pic.Id != 0 {
|
||||
mapped := userDTO.ToUserBaseDTO(e.Pic)
|
||||
mapped := userDTO.ToUserRelationDTO(e.Pic)
|
||||
pic = &mapped
|
||||
}
|
||||
|
||||
return CustomerBaseDTO{
|
||||
return CustomerRelationDTO{
|
||||
Id: e.Id,
|
||||
Name: e.Name,
|
||||
PicId: e.PicId,
|
||||
@@ -57,17 +57,17 @@ func ToCustomerBaseDTO(e entity.Customer) CustomerBaseDTO {
|
||||
}
|
||||
|
||||
func ToCustomerListDTO(e entity.Customer) CustomerListDTO {
|
||||
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
|
||||
}
|
||||
|
||||
return CustomerListDTO{
|
||||
CustomerBaseDTO: ToCustomerBaseDTO(e),
|
||||
CreatedAt: e.CreatedAt,
|
||||
UpdatedAt: e.UpdatedAt,
|
||||
CreatedUser: createdUser,
|
||||
CustomerRelationDTO: ToCustomerRelationDTO(e),
|
||||
CreatedAt: e.CreatedAt,
|
||||
UpdatedAt: e.UpdatedAt,
|
||||
CreatedUser: createdUser,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user