Files
simrsx-be/internal/domain/main-entities/registration/dto.go

72 lines
1.6 KiB
Go

package doctor
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ee "simrs-vx/internal/domain/main-entities/employee"
ei "simrs-vx/internal/domain/main-entities/installation"
)
type CreateDto struct {
Employee_Id uint `json:"employee_id"`
Installation_Code string `json:"installation_code" validate:"maxLength=20"`
}
type ReadListDto struct {
FilterDto
Includes string `json:"includes"`
Pagination ecore.Pagination
}
type FilterDto struct {
Employee_Id *uint `json:"employee-id"`
Installation_Code *string `json:"installation-code"`
}
type ReadDetailDto struct {
Id *uint `json:"id"`
Employee_Id *uint `json:"employee_id"`
Includes string `json:"includes"`
}
type UpdateDto struct {
Id *uint `json:"id"`
CreateDto
}
type DeleteDto struct {
Id uint `json:"id"`
}
type MetaDto struct {
PageNumber int `json:"page_number"`
PageSize int `json:"page_size"`
Count int `json:"count"`
}
type ResponseDto struct {
ecore.Main
Employee_Id uint `json:"employee_id"`
Employee *ee.Employee `json:"employee,omitempty"`
Installation_Code string `json:"installation_code"`
Installation *ei.Installation `json:"installation,omitempty"`
}
func (d Registration) ToResponse() ResponseDto {
resp := ResponseDto{
Employee_Id: d.Employee_Id,
Employee: d.Employee,
Installation_Code: d.Installation_Code,
Installation: d.Installation,
}
resp.Main = d.Main
return resp
}
func ToResponseList(data []Registration) []ResponseDto {
resp := make([]ResponseDto, len(data))
for i, u := range data {
resp[i] = u.ToResponse()
}
return resp
}