97 lines
2.8 KiB
Go
97 lines
2.8 KiB
Go
package infra
|
|
|
|
import (
|
|
ecore "simrs-vx/internal/domain/base-entities/core"
|
|
ei "simrs-vx/internal/domain/main-entities/item"
|
|
erb "simrs-vx/internal/domain/main-entities/room/base"
|
|
|
|
ero "simrs-vx/internal/domain/references/organization"
|
|
)
|
|
|
|
type CreateDto struct {
|
|
Code string `json:"code" validate:"maxLength=10"`
|
|
Name string `json:"name" validate:"maxLength=50"`
|
|
InfraGroup_Code ero.InfraGroupCode `json:"infraGroup_code" validate:"maxLength=15"`
|
|
Parent_Id *uint16 `json:"parent_id"`
|
|
Item_Id *uint `json:"item_id"`
|
|
Unit_Id *uint16 `json:"unit_id"`
|
|
Specialist_Id *uint16 `json:"specialist_id"`
|
|
Subspecialist_Id *uint16 `json:"subspecialist_id"`
|
|
Infra_Id *uint16 `json:"-"` // for room
|
|
}
|
|
|
|
type ReadListDto struct {
|
|
FilterDto
|
|
Includes string `json:"includes"`
|
|
Sort string `json:"sort"`
|
|
Pagination ecore.Pagination
|
|
OnlyHaveChildren bool `json:"only-have-children"`
|
|
}
|
|
|
|
type FilterDto struct {
|
|
Code string `json:"code"`
|
|
Name string `json:"name"`
|
|
InfraGroup_Code ero.InfraGroupCode `json:"infraGroup-code"`
|
|
Parent_Id *uint16 `json:"parent-id"`
|
|
Item_Id *uint `json:"item-id"`
|
|
Search string `json:"search" gormhelper:"searchColumns=Code,Name"`
|
|
}
|
|
|
|
type ReadDetailDto struct {
|
|
Id uint16 `json:"id"`
|
|
Code *string `json:"code"`
|
|
Item_Id *uint `json:"item_id"`
|
|
}
|
|
|
|
type UpdateDto struct {
|
|
Id uint16 `json:"id"`
|
|
CreateDto
|
|
}
|
|
|
|
type DeleteDto struct {
|
|
Id uint16 `json:"id"`
|
|
}
|
|
|
|
type MetaDto struct {
|
|
PageNumber int `json:"page_number"`
|
|
PageSize int `json:"page_size"`
|
|
Count int `json:"count"`
|
|
}
|
|
|
|
type ResponseDto struct {
|
|
ecore.SmallMain
|
|
Code string `json:"code"`
|
|
Name string `json:"name"`
|
|
InfraGroup_Code ero.InfraGroupCode `json:"infraGroup_code"`
|
|
Parent_Id *uint16 `json:"parent_id"`
|
|
Parent *Infra `json:"parent,omitempty"`
|
|
Childrens []Infra `json:"childrens,omitempty"`
|
|
Item_Id *uint `json:"item_id"`
|
|
Item *ei.Item `json:"item,omitempty"`
|
|
Rooms []erb.Basic `json:"rooms,omitempty"`
|
|
}
|
|
|
|
func (d Infra) ToResponse() ResponseDto {
|
|
resp := ResponseDto{
|
|
Code: d.Code,
|
|
Name: d.Name,
|
|
InfraGroup_Code: d.InfraGroup_Code,
|
|
Parent_Id: d.Parent_Id,
|
|
Parent: d.Parent,
|
|
Childrens: d.Childrens,
|
|
Item_Id: d.Item_Id,
|
|
Item: d.Item,
|
|
Rooms: d.Rooms,
|
|
}
|
|
resp.SmallMain = d.SmallMain
|
|
return resp
|
|
}
|
|
|
|
func ToResponseList(data []Infra) []ResponseDto {
|
|
resp := make([]ResponseDto, len(data))
|
|
for i, u := range data {
|
|
resp[i] = u.ToResponse()
|
|
}
|
|
return resp
|
|
}
|