feat (postal-code): add crud for postal-code

This commit is contained in:
dpurbosakti
2025-10-09 12:49:19 +07:00
parent 935e5d780c
commit 9a68982afa
13 changed files with 720 additions and 9 deletions
@@ -6,3 +6,7 @@ type Basic struct {
Code string `json:"code" gorm:"unique;size:6"` // NOTE: THE PROPER SIZE IS 6
Name string `json:"name" gorm:"size:50"`
}
func (Basic) TableName() string {
return "District"
}
@@ -5,3 +5,7 @@ type Basic struct {
Village_Code string `json:"village_code" gorm:"size:10"`
Code string `json:"code" gorm:"unique;size:5"`
}
func (Basic) TableName() string {
return "PostalCode"
}
@@ -2,18 +2,26 @@ 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=10"`
Village_Code string `json:"district_code" validate:"numeric;maxLength=10"`
Code string `json:"code" validate:"numeric;maxLength=5"`
Village_Code string `json:"village_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
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 {
@@ -37,15 +45,17 @@ type MetaDto struct {
}
type ResponseDto struct {
Id uint32 `json:"id"`
Village_Code string `json:"village_code"`
Code string `json:"code"`
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
@@ -6,3 +6,7 @@ type Basic struct {
Code string `json:"code" gorm:"unique;size:4"`
Name string `json:"name" gorm:"size:50"`
}
func (Basic) TableName() string {
return "Regency"
}
@@ -6,3 +6,7 @@ type Basic struct {
Code string `json:"code" gorm:"unique;size:10"`
Name string `json:"name" gorm:"size:50"`
}
func (Basic) TableName() string {
return "Village"
}