adjustment detail division
This commit is contained in:
@@ -2,6 +2,10 @@ package division
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ep "simrs-vx/internal/domain/main-entities/person"
|
||||
eu "simrs-vx/internal/domain/main-entities/user"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
erg "simrs-vx/internal/domain/references/organization"
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
@@ -26,8 +30,9 @@ type FilterDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
Id uint16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
Includes string `json:"includes"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
@@ -47,14 +52,36 @@ type MetaDto struct {
|
||||
|
||||
type ResponseDto struct {
|
||||
ecore.SmallMain
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Parent_Id *uint16 `json:"parent_id"`
|
||||
Parent *Division `json:"parent,omitempty"`
|
||||
Childrens []Division `json:"childrens,omitempty"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Parent_Id *uint16 `json:"parent_id"`
|
||||
Parent *Division `json:"parent,omitempty"`
|
||||
Childrens []Division `json:"childrens,omitempty"`
|
||||
DivisionPosition []ResponseDivisionPosition `json:"divisionPositions,omitempty"`
|
||||
}
|
||||
|
||||
func (d Division) ToResponse() ResponseDto {
|
||||
type ResponseDivisionPosition struct {
|
||||
ecore.SmallMain // adjust this according to the needs
|
||||
Division_Id *uint16 `json:"division_id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
HeadStatus bool `json:"headStatus"`
|
||||
Employee_Id *uint `json:"employee_id"`
|
||||
Employee ResponseDivisionEmployee `json:"employee"`
|
||||
}
|
||||
|
||||
type ResponseDivisionEmployee struct {
|
||||
ecore.Main // adjust this according to the needs
|
||||
User_Id *uint `json:"user_id"`
|
||||
User *eu.User `json:"user,omitempty"`
|
||||
Person_Id *uint `json:"person_id"`
|
||||
Person *ep.Person `json:"person,omitempty"`
|
||||
Position_Code *erg.EmployeePositionCode `json:"position_code"`
|
||||
Number *string `json:"number"`
|
||||
Status_Code erc.ActiveStatusCode `json:"status_code"`
|
||||
}
|
||||
|
||||
func (d Division) ToResponse(divPos []ResponseDivisionPosition) ResponseDto {
|
||||
resp := ResponseDto{
|
||||
Code: d.Code,
|
||||
Name: d.Name,
|
||||
@@ -63,13 +90,17 @@ func (d Division) ToResponse() ResponseDto {
|
||||
Childrens: d.Childrens,
|
||||
}
|
||||
resp.SmallMain = d.SmallMain
|
||||
|
||||
if divPos != nil {
|
||||
resp.DivisionPosition = divPos
|
||||
}
|
||||
return resp
|
||||
}
|
||||
|
||||
func ToResponseList(data []Division) []ResponseDto {
|
||||
resp := make([]ResponseDto, len(data))
|
||||
for i, u := range data {
|
||||
resp[i] = u.ToResponse()
|
||||
resp[i] = u.ToResponse(nil)
|
||||
}
|
||||
return resp
|
||||
}
|
||||
|
||||
@@ -27,8 +27,9 @@ type FilterDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
Id uint16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
Includes string `json:"includes"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
|
||||
@@ -29,6 +29,7 @@ type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Installation_Id *uint16 `json:"installation_id"`
|
||||
Code *string `json:"code"`
|
||||
Includes string `json:"includes"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
|
||||
Reference in New Issue
Block a user