74 lines
1.6 KiB
Go
74 lines
1.6 KiB
Go
package unit
|
|
|
|
import (
|
|
ecore "simrs-vx/internal/domain/base-entities/core"
|
|
ei "simrs-vx/internal/domain/main-entities/installation"
|
|
)
|
|
|
|
type CreateDto struct {
|
|
Installation_Id *uint16 `json:"installation_id"`
|
|
Code string `json:"code"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
type ReadListDto struct {
|
|
Installation_Id *uint16 `json:"installation_id"`
|
|
Code string `json:"code"`
|
|
Name string `json:"name"`
|
|
|
|
Page int `json:"page"`
|
|
PageSize int `json:"page_size"`
|
|
NoPagination int `json:"no_pagination"`
|
|
}
|
|
|
|
type ReadDetailDto struct {
|
|
Installation_Id *uint16 `json:"installation_id"`
|
|
Id uint16 `json:"id"`
|
|
Code string `json:"code"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
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
|
|
Installation_Id *uint16 `json:"installation_id"`
|
|
Installation *ei.Installation
|
|
Code string `json:"code"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
func (d Unit) ToResponse() ResponseDto {
|
|
resp := ResponseDto{
|
|
Installation_Id: d.Installation_Id,
|
|
Code: d.Code,
|
|
Name: d.Name,
|
|
}
|
|
resp.SmallMain = d.SmallMain
|
|
if d.Installation != nil {
|
|
resp.Installation = d.Installation
|
|
}
|
|
return resp
|
|
}
|
|
|
|
func ToResponseList(data []Unit) []ResponseDto {
|
|
resp := make([]ResponseDto, len(data))
|
|
for i, u := range data {
|
|
resp[i] = u.ToResponse()
|
|
}
|
|
return resp
|
|
}
|