71 lines
1.5 KiB
Go
71 lines
1.5 KiB
Go
package postalcode
|
|
|
|
import (
|
|
ecore "simrs-vx/internal/domain/base-entities/core"
|
|
ev "simrs-vx/internal/domain/main-entities/village"
|
|
)
|
|
|
|
type CreateDto struct {
|
|
Code string `json:"code" validate:"numeric;maxLength=5"`
|
|
Village_Code string `json:"village_code" validate:"numeric;maxLength=10"`
|
|
}
|
|
|
|
type ReadListDto struct {
|
|
FilterDto
|
|
Includes string `json:"includes"`
|
|
Preloads []string `json:"-"`
|
|
Sort string `json:"sort"`
|
|
Pagination ecore.Pagination
|
|
}
|
|
|
|
type FilterDto struct {
|
|
Village_Code string `json:"village-code"`
|
|
Code string `json:"code"`
|
|
Search string `json:"search" gormhelper:"searchColumns=Code"`
|
|
}
|
|
|
|
type ReadDetailDto struct {
|
|
Id uint32 `json:"id"`
|
|
Code *string `json:"code"`
|
|
}
|
|
|
|
type UpdateDto struct {
|
|
Id uint32 `json:"id"`
|
|
CreateDto
|
|
}
|
|
|
|
type DeleteDto struct {
|
|
Id uint32 `json:"id"`
|
|
}
|
|
|
|
type MetaDto struct {
|
|
PageNumber int `json:"page_number"`
|
|
PageSize int `json:"page_size"`
|
|
Count int `json:"count"`
|
|
}
|
|
|
|
type ResponseDto struct {
|
|
Id uint32 `json:"id"`
|
|
Village_Code string `json:"village_code"`
|
|
Village *ev.Village `json:"village,omitempty"`
|
|
Code string `json:"code"`
|
|
}
|
|
|
|
func (d PostalCode) ToResponse() ResponseDto {
|
|
resp := ResponseDto{
|
|
Id: d.Id,
|
|
Village_Code: d.Village_Code,
|
|
Village: d.Village,
|
|
Code: d.Code,
|
|
}
|
|
return resp
|
|
}
|
|
|
|
func ToResponseList(data []PostalCode) []ResponseDto {
|
|
resp := make([]ResponseDto, len(data))
|
|
for i, u := range data {
|
|
resp[i] = u.ToResponse()
|
|
}
|
|
return resp
|
|
}
|