mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
Feat(BE-36,37,38,39): master area, customer, kandang, location, warehouse
This commit is contained in:
+20
-11
@@ -3,7 +3,8 @@
|
||||
import (
|
||||
"time"
|
||||
|
||||
model "gitlab.com/mbugroup/lti-api.git/internal/modules/{{Kebab .FeatName}}s/models"
|
||||
entity "gitlab.com/mbugroup/lti-api.git/internal/entities"
|
||||
userDTO "gitlab.com/mbugroup/lti-api.git/internal/modules/users/dto"
|
||||
)
|
||||
|
||||
// === DTO Structs ===
|
||||
@@ -15,6 +16,7 @@ type {{Pascal .Entity}}BaseDTO struct {
|
||||
|
||||
type {{Pascal .Entity}}ListDTO struct {
|
||||
{{Pascal .Entity}}BaseDTO
|
||||
CreatedUser *userDTO.UserBaseDTO `json:"created_user"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
@@ -25,24 +27,31 @@ type {{Pascal .Entity}}DetailDTO struct {
|
||||
|
||||
// === Mapper Functions ===
|
||||
|
||||
func To{{Pascal .Entity}}BaseDTO(m model.{{Pascal .Entity}}) {{Pascal .Entity}}BaseDTO {
|
||||
func To{{Pascal .Entity}}BaseDTO(e entity.{{Pascal .Entity}}) {{Pascal .Entity}}BaseDTO {
|
||||
return {{Pascal .Entity}}BaseDTO{
|
||||
Id: m.Id,
|
||||
Name: m.Name,
|
||||
Id: e.Id,
|
||||
Name: e.Name,
|
||||
}
|
||||
}
|
||||
|
||||
func To{{Pascal .Entity}}ListDTO(m model.{{Pascal .Entity}}) {{Pascal .Entity}}ListDTO {
|
||||
func To{{Pascal .Entity}}ListDTO(e entity.{{Pascal .Entity}}) {{Pascal .Entity}}ListDTO {
|
||||
var createdUser *userDTO.UserBaseDTO
|
||||
if e.CreatedUser.Id != 0 {
|
||||
mapped := userDTO.ToUserBaseDTO(e.CreatedUser)
|
||||
createdUser = &mapped
|
||||
}
|
||||
|
||||
return {{Pascal .Entity}}ListDTO{
|
||||
{{Pascal .Entity}}BaseDTO: To{{Pascal .Entity}}BaseDTO(m),
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
{{Pascal .Entity}}BaseDTO: To{{Pascal .Entity}}BaseDTO(e),
|
||||
CreatedAt: e.CreatedAt,
|
||||
UpdatedAt: e.UpdatedAt,
|
||||
CreatedUser: createdUser,
|
||||
}
|
||||
}
|
||||
|
||||
func To{{Pascal .Entity}}ListDTOs(m []model.{{Pascal .Entity}}) []{{Pascal .Entity}}ListDTO {
|
||||
result := make([]{{Pascal .Entity}}ListDTO, len(m))
|
||||
for i, r := range m {
|
||||
func To{{Pascal .Entity}}ListDTOs(e []entity.{{Pascal .Entity}}) []{{Pascal .Entity}}ListDTO {
|
||||
result := make([]{{Pascal .Entity}}ListDTO, len(e))
|
||||
for i, r := range e {
|
||||
result[i] = To{{Pascal .Entity}}ListDTO(r)
|
||||
}
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user