restructure area
This commit is contained in:
@@ -0,0 +1,8 @@
|
|||||||
|
-- Modify "Regency" table
|
||||||
|
ALTER TABLE "public"."Regency" DROP CONSTRAINT "fk_Province_Regencies", ALTER COLUMN "Id" TYPE bigint, ADD CONSTRAINT "fk_Regency_Province" FOREIGN KEY ("Province_Code") REFERENCES "public"."Province" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION;
|
||||||
|
-- Modify "District" table
|
||||||
|
ALTER TABLE "public"."District" DROP CONSTRAINT "fk_Regency_Districts", ADD CONSTRAINT "fk_District_Regency" FOREIGN KEY ("Regency_Code") REFERENCES "public"."Regency" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION;
|
||||||
|
-- Modify "Village" table
|
||||||
|
ALTER TABLE "public"."Village" DROP CONSTRAINT "fk_District_Villages", ADD CONSTRAINT "fk_Village_District" FOREIGN KEY ("District_Code") REFERENCES "public"."District" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION;
|
||||||
|
-- Modify "PostalCode" table
|
||||||
|
ALTER TABLE "public"."PostalCode" DROP CONSTRAINT "fk_Village_PostalCodes", ADD CONSTRAINT "fk_PostalCode_Village" FOREIGN KEY ("Village_Code") REFERENCES "public"."Village" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
h1:CAMxY9M2WLkhsnD/5ItPa0kDPKJwprjDft26U+FW3vE=
|
h1:TrdoKKXrICvDA283WGDf33WtWHglk1twvjDpYrNwc8o=
|
||||||
20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k=
|
20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k=
|
||||||
20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0=
|
20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0=
|
||||||
20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI=
|
20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI=
|
||||||
@@ -33,3 +33,4 @@ h1:CAMxY9M2WLkhsnD/5ItPa0kDPKJwprjDft26U+FW3vE=
|
|||||||
20251008052346.sql h1:nxnXmooIJ6r1mmzwnw+6efxLfc/k9h2aE6RMptPRons=
|
20251008052346.sql h1:nxnXmooIJ6r1mmzwnw+6efxLfc/k9h2aE6RMptPRons=
|
||||||
20251008073620.sql h1:6YsJp1W4SmQJ1lxpqF27BBlDC1zqhw7Yhc7pLzQTY6M=
|
20251008073620.sql h1:6YsJp1W4SmQJ1lxpqF27BBlDC1zqhw7Yhc7pLzQTY6M=
|
||||||
20251009042854.sql h1:vK7bDqUDTxjHMSh1wrQiKITeqbB/7aqkWaPut8nGA68=
|
20251009042854.sql h1:vK7bDqUDTxjHMSh1wrQiKITeqbB/7aqkWaPut8nGA68=
|
||||||
|
20251009052657.sql h1:I0rBPBg1o6zuRaxqWqCh82rI+NN7Gr6C//8ItUaLmtY=
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package base
|
||||||
|
|
||||||
|
type Basic struct {
|
||||||
|
Id uint32 `json:"id" gorm:"primaryKey"`
|
||||||
|
Regency_Code string `json:"regency_code" gorm:"size:4"`
|
||||||
|
Code string `json:"code" gorm:"unique;size:6"` // NOTE: THE PROPER SIZE IS 6
|
||||||
|
Name string `json:"name" gorm:"size:50"`
|
||||||
|
}
|
||||||
@@ -2,7 +2,9 @@ package district
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||||
ev "simrs-vx/internal/domain/main-entities/village"
|
edb "simrs-vx/internal/domain/main-entities/district/base"
|
||||||
|
er "simrs-vx/internal/domain/main-entities/regency"
|
||||||
|
evb "simrs-vx/internal/domain/main-entities/village/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CreateDto struct {
|
type CreateDto struct {
|
||||||
@@ -39,11 +41,9 @@ type MetaDto struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ResponseDto struct {
|
type ResponseDto struct {
|
||||||
Id uint32 `json:"id"`
|
edb.Basic
|
||||||
Regency_Code string `json:"regency_code"`
|
Regency *er.Regency `json:"regency,omitempty"`
|
||||||
Code string `json:"code"`
|
Villages []*evb.Basic `json:"villages,omitempty"`
|
||||||
Name string `json:"name"`
|
|
||||||
Villages []*ev.Village `json:"villages,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d District) ToResponse() ResponseDto {
|
func (d District) ToResponse() ResponseDto {
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
package district
|
package district
|
||||||
|
|
||||||
import ev "simrs-vx/internal/domain/main-entities/village"
|
import (
|
||||||
|
edb "simrs-vx/internal/domain/main-entities/district/base"
|
||||||
|
er "simrs-vx/internal/domain/main-entities/regency"
|
||||||
|
evb "simrs-vx/internal/domain/main-entities/village/base"
|
||||||
|
)
|
||||||
|
|
||||||
type District struct {
|
type District struct {
|
||||||
Id uint32 `json:"id" gorm:"primaryKey"`
|
edb.Basic
|
||||||
Regency_Code string `json:"regency_code" gorm:"size:4"`
|
Regency *er.Regency `json:"regency,omitempty" gorm:"foreignKey:Regency_Code;references:Code"`
|
||||||
Code string `json:"code" gorm:"unique;size:6"` // NOTE: THE PROPER SIZE IS 6
|
Villages []*evb.Basic `json:"villages,omitempty" gorm:"foreignKey:District_Code;references:Code"`
|
||||||
Name string `json:"name" gorm:"size:50"`
|
|
||||||
Villages []*ev.Village `json:"villages,omitempty" gorm:"foreignKey:District_Code;references:Code"`
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package base
|
||||||
|
|
||||||
|
type Basic struct {
|
||||||
|
Id uint32 `json:"id" gorm:"primaryKey"`
|
||||||
|
Village_Code string `json:"village_code" gorm:"size:10"`
|
||||||
|
Code string `json:"code" gorm:"unique;size:5"`
|
||||||
|
}
|
||||||
@@ -1,7 +1,11 @@
|
|||||||
package postalcode
|
package postalcode
|
||||||
|
|
||||||
|
import (
|
||||||
|
ep "simrs-vx/internal/domain/main-entities/postal-code/base"
|
||||||
|
ev "simrs-vx/internal/domain/main-entities/village"
|
||||||
|
)
|
||||||
|
|
||||||
type PostalCode struct {
|
type PostalCode struct {
|
||||||
Id uint32 `json:"id" gorm:"primaryKey"`
|
ep.Basic
|
||||||
Code string `json:"code" gorm:"unique;size:5"`
|
Village *ev.Village `json:"village,omitempty" gorm:"foreignKey:Village_Code;references:Code"`
|
||||||
Village_Code string `json:"village_code" gorm:"size:10"`
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package province
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||||
|
erb "simrs-vx/internal/domain/main-entities/regency/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CreateDto struct {
|
type CreateDto struct {
|
||||||
@@ -36,16 +37,18 @@ type MetaDto struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ResponseDto struct {
|
type ResponseDto struct {
|
||||||
Id int16 `json:"id"`
|
Id int16 `json:"id"`
|
||||||
Code string `json:"code"`
|
Code string `json:"code"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
Regencies []erb.Basic `json:"regencies,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d Province) ToResponse() ResponseDto {
|
func (d Province) ToResponse() ResponseDto {
|
||||||
resp := ResponseDto{
|
resp := ResponseDto{
|
||||||
Id: d.Id,
|
Id: d.Id,
|
||||||
Code: d.Code,
|
Code: d.Code,
|
||||||
Name: d.Name,
|
Name: d.Name,
|
||||||
|
Regencies: d.Regencies,
|
||||||
}
|
}
|
||||||
return resp
|
return resp
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package province
|
package province
|
||||||
|
|
||||||
import er "simrs-vx/internal/domain/main-entities/regency"
|
import erb "simrs-vx/internal/domain/main-entities/regency/base"
|
||||||
|
|
||||||
type Province struct {
|
type Province struct {
|
||||||
Id int16 `json:"id" gorm:"primaryKey"`
|
Id int16 `json:"id" gorm:"primaryKey"`
|
||||||
Code string `json:"code" gorm:"unique;size:2"`
|
Code string `json:"code" gorm:"unique;size:2"`
|
||||||
Name string `json:"name" gorm:"size:50"`
|
Name string `json:"name" gorm:"size:50"`
|
||||||
Regencies []*er.Regency `json:"regencies,omitempty" gorm:"foreignKey:Province_Code;references:Code"`
|
Regencies []erb.Basic `json:"regencies,omitempty" gorm:"foreignKey:Province_Code;references:Code"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package base
|
||||||
|
|
||||||
|
type Basic struct {
|
||||||
|
Id uint32 `json:"id" gorm:"primaryKey"`
|
||||||
|
Province_Code string `json:"province_code" gorm:"size:2"`
|
||||||
|
Code string `json:"code" gorm:"unique;size:4"`
|
||||||
|
Name string `json:"name" gorm:"size:50"`
|
||||||
|
}
|
||||||
@@ -2,7 +2,9 @@ package regency
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||||
ed "simrs-vx/internal/domain/main-entities/district"
|
edb "simrs-vx/internal/domain/main-entities/district/base"
|
||||||
|
ep "simrs-vx/internal/domain/main-entities/province"
|
||||||
|
erb "simrs-vx/internal/domain/main-entities/regency/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CreateDto struct {
|
type CreateDto struct {
|
||||||
@@ -39,15 +41,17 @@ type MetaDto struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ResponseDto struct {
|
type ResponseDto struct {
|
||||||
Id uint16 `json:"id"`
|
erb.Basic
|
||||||
Province_Code string `json:"province_code"`
|
Province *ep.Province `json:"province,omitempty"`
|
||||||
Code string `json:"code"`
|
Districts []*edb.Basic `json:"districts,omitempty"`
|
||||||
Name string `json:"name"`
|
|
||||||
Districts []*ed.District `json:"districts,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d Regency) ToResponse() ResponseDto {
|
func (d Regency) ToResponse() ResponseDto {
|
||||||
resp := ResponseDto(d)
|
resp := ResponseDto{
|
||||||
|
Basic: d.Basic,
|
||||||
|
Province: d.Province,
|
||||||
|
Districts: d.Districts,
|
||||||
|
}
|
||||||
return resp
|
return resp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
package regency
|
package regency
|
||||||
|
|
||||||
import ed "simrs-vx/internal/domain/main-entities/district"
|
import (
|
||||||
|
edb "simrs-vx/internal/domain/main-entities/district/base"
|
||||||
|
ep "simrs-vx/internal/domain/main-entities/province"
|
||||||
|
erb "simrs-vx/internal/domain/main-entities/regency/base"
|
||||||
|
)
|
||||||
|
|
||||||
type Regency struct {
|
type Regency struct {
|
||||||
Id uint16 `json:"id" gorm:"primaryKey"`
|
erb.Basic
|
||||||
Province_Code string `json:"province_code" gorm:"size:2"`
|
Province *ep.Province `json:"province,omitempty" gorm:"foreignKey:Province_Code;references:Code"`
|
||||||
Code string `json:"code" gorm:"unique;size:4"`
|
Districts []*edb.Basic `json:"districts,omitempty" gorm:"foreignKey:Regency_Code;references:Code"`
|
||||||
Name string `json:"name" gorm:"size:50"`
|
|
||||||
Districts []*ed.District `json:"districts,omitempty" gorm:"foreignKey:Regency_Code;references:Code"`
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package base
|
||||||
|
|
||||||
|
type Basic struct {
|
||||||
|
Id uint32 `json:"id" gorm:"primaryKey"`
|
||||||
|
District_Code string `json:"district_code" gorm:"size:6"`
|
||||||
|
Code string `json:"code" gorm:"unique;size:10"`
|
||||||
|
Name string `json:"name" gorm:"size:50"`
|
||||||
|
}
|
||||||
@@ -2,7 +2,9 @@ package village
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||||
ep "simrs-vx/internal/domain/main-entities/postal-code"
|
ed "simrs-vx/internal/domain/main-entities/district"
|
||||||
|
epb "simrs-vx/internal/domain/main-entities/postal-code/base"
|
||||||
|
evb "simrs-vx/internal/domain/main-entities/village/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CreateDto struct {
|
type CreateDto struct {
|
||||||
@@ -39,15 +41,17 @@ type MetaDto struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ResponseDto struct {
|
type ResponseDto struct {
|
||||||
Id uint32 `json:"id"`
|
evb.Basic
|
||||||
District_Code string `json:"district_code"`
|
District *ed.District `json:"district,omitempty"`
|
||||||
Code string `json:"code"`
|
PostalCodes []epb.Basic `json:"postalCodes,omitempty"`
|
||||||
Name string `json:"name"`
|
|
||||||
PostalCodes []ep.PostalCode `json:"postalCodes,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d Village) ToResponse() ResponseDto {
|
func (d Village) ToResponse() ResponseDto {
|
||||||
resp := ResponseDto(d)
|
resp := ResponseDto{
|
||||||
|
Basic: d.Basic,
|
||||||
|
District: d.District,
|
||||||
|
PostalCodes: d.PostalCodes,
|
||||||
|
}
|
||||||
return resp
|
return resp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package village
|
package village
|
||||||
|
|
||||||
import (
|
import (
|
||||||
ep "simrs-vx/internal/domain/main-entities/postal-code"
|
ed "simrs-vx/internal/domain/main-entities/district"
|
||||||
|
epb "simrs-vx/internal/domain/main-entities/postal-code/base"
|
||||||
|
evb "simrs-vx/internal/domain/main-entities/village/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Village struct {
|
type Village struct {
|
||||||
Id uint32 `json:"id" gorm:"primaryKey"`
|
evb.Basic
|
||||||
District_Code string `json:"district_code" gorm:"size:6"` // NOT: THE PROPER SIZE IS 6
|
District *ed.District `json:"district,omitempty" gorm:"foreignKey:District_Code;references:Code"`
|
||||||
Code string `json:"code" gorm:"unique;size:10"`
|
PostalCodes []epb.Basic `json:"postalCodes,omitempty" gorm:"foreignKey:Village_Code;references:Code"`
|
||||||
Name string `json:"name" gorm:"size:50"`
|
|
||||||
PostalCodes []ep.PostalCode `json:"postalCodes,omitempty" gorm:"foreignKey:Village_Code;references:Code"`
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user