add postalcode
This commit is contained in:
@@ -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"`
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package village
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ep "simrs-vx/internal/domain/main-entities/postal-code"
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
@@ -38,10 +39,11 @@ type MetaDto struct {
|
||||
}
|
||||
|
||||
type ResponseDto struct {
|
||||
Id uint32 `json:"id"`
|
||||
District_Code string `json:"district_code"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Id uint32 `json:"id"`
|
||||
District_Code string `json:"district_code"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
PostalCodes []ep.PostalCode `json:"postalCodes,omitempty"`
|
||||
}
|
||||
|
||||
func (d Village) ToResponse() ResponseDto {
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
package village
|
||||
|
||||
import (
|
||||
ep "simrs-vx/internal/domain/main-entities/postal-code"
|
||||
)
|
||||
|
||||
type Village struct {
|
||||
Id uint32 `json:"id" gorm:"primaryKey"`
|
||||
District_Code string `json:"district_code" gorm:"size:6"` // NOT: THE PROPER SIZE IS 6
|
||||
Code string `json:"code" gorm:"unique;size:10"`
|
||||
Name string `json:"name" gorm:"size:50"`
|
||||
Id uint32 `json:"id" gorm:"primaryKey"`
|
||||
District_Code string `json:"district_code" gorm:"size:6"` // NOT: THE PROPER SIZE IS 6
|
||||
Code string `json:"code" gorm:"unique;size:10"`
|
||||
Name string `json:"name" gorm:"size:50"`
|
||||
PostalCodes []ep.PostalCode `json:"postalCodes,omitempty" gorm:"foreignKey:Village_Code;references:Code"`
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ import (
|
||||
personrelative "simrs-vx/internal/domain/main-entities/person-relative"
|
||||
pharmacist "simrs-vx/internal/domain/main-entities/pharmacist"
|
||||
pharmacycompany "simrs-vx/internal/domain/main-entities/pharmacy-company"
|
||||
postalcode "simrs-vx/internal/domain/main-entities/postal-code"
|
||||
practiceschedule "simrs-vx/internal/domain/main-entities/practice-schedule"
|
||||
prescription "simrs-vx/internal/domain/main-entities/prescription"
|
||||
prescriptionitem "simrs-vx/internal/domain/main-entities/prescription-item"
|
||||
@@ -149,5 +150,6 @@ func getMainEntities() []any {
|
||||
&consultation.Consultation{},
|
||||
&chemo.Chemo{},
|
||||
&midwife.Midwife{},
|
||||
&postalcode.PostalCode{},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user