81 lines
1.9 KiB
Go
81 lines
1.9 KiB
Go
package mcusubsrc
|
|
|
|
import (
|
|
ecore "simrs-vx/internal/domain/base-entities/core"
|
|
ei "simrs-vx/internal/domain/main-entities/item"
|
|
ems "simrs-vx/internal/domain/main-entities/mcu-src"
|
|
)
|
|
|
|
type CreateDto struct {
|
|
Code *string `json:"code" validate:"maxLength=20"`
|
|
Name string `json:"name" validate:"maxLength=50"`
|
|
McuSrc_Code *string `json:"mcuSrc_code"`
|
|
Item_Code *string `json:"item_code"`
|
|
}
|
|
|
|
type ReadListDto struct {
|
|
FilterDto
|
|
Includes string `json:"includes"`
|
|
Sort string `json:"sort"`
|
|
Pagination ecore.Pagination
|
|
}
|
|
|
|
type FilterDto struct {
|
|
Code *string `json:"code"`
|
|
Name *string `json:"name"`
|
|
CheckupCategory_Code *string `json:"checkupCategory-code"`
|
|
Search string `json:"search" gormhelper:"searchColumns=Code,Name"`
|
|
}
|
|
|
|
type ReadDetailDto struct {
|
|
Id *uint16 `json:"id"`
|
|
Code *string `json:"code"`
|
|
}
|
|
|
|
type UpdateDto struct {
|
|
Id *uint16 `json:"id"`
|
|
CreateDto
|
|
}
|
|
|
|
type DeleteDto struct {
|
|
Id *uint16 `json:"id"`
|
|
Code *string `json:"code"`
|
|
}
|
|
|
|
type MetaDto struct {
|
|
PageNumber int `json:"page_number"`
|
|
PageSize int `json:"page_size"`
|
|
Count int `json:"count"`
|
|
}
|
|
|
|
type ResponseDto struct {
|
|
ecore.Main
|
|
Code string `json:"code"`
|
|
Name string `json:"name"`
|
|
McuSrc_Code *string `json:"mcuSrc_code"`
|
|
McuSrc *ems.McuSrc `json:"mcuSrc,omitempty"`
|
|
Item_Code *string `json:"item_code"`
|
|
Item *ei.Item `json:"item,omitempty"`
|
|
}
|
|
|
|
func (d McuSubSrc) ToResponse() ResponseDto {
|
|
resp := ResponseDto{
|
|
Code: d.Code,
|
|
Name: d.Name,
|
|
McuSrc_Code: d.McuSrc_Code,
|
|
McuSrc: d.McuSrc,
|
|
Item_Code: d.Item_Code,
|
|
Item: d.Item,
|
|
}
|
|
resp.Main = d.Main
|
|
return resp
|
|
}
|
|
|
|
func ToResponseList(data []McuSubSrc) []ResponseDto {
|
|
resp := make([]ResponseDto, len(data))
|
|
for i, u := range data {
|
|
resp[i] = u.ToResponse()
|
|
}
|
|
return resp
|
|
}
|