add postalcode

This commit is contained in:
dpurbosakti
2025-10-09 11:29:49 +07:00
parent 8b9fabd5e1
commit 63d2f2342c
7 changed files with 128 additions and 42 deletions
@@ -0,0 +1,60 @@
package postalcode
import (
ecore "simrs-vx/internal/domain/base-entities/core"
)
type CreateDto struct {
Code string `json:"code" validate:"numeric;maxLength=10"`
Village_Code string `json:"district_code" validate:"numeric;maxLength=10"`
}
type ReadListDto struct {
District_Code string `json:"district_code"`
Code string `json:"code"`
Name string `json:"name"`
Pagination ecore.Pagination
}
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"`
Code string `json:"code"`
}
func (d PostalCode) ToResponse() ResponseDto {
resp := ResponseDto{
Id: d.Id,
Village_Code: d.Village_Code,
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
}
@@ -0,0 +1,7 @@
package postalcode
type PostalCode struct {
Id uint32 `json:"id" gorm:"primaryKey"`
Code string `json:"code" gorm:"unique;size:5"`
Village_Code string `json:"village_code" gorm:"size:10"`
}