Merge branch 'migration' of github.com:dikstub-rssa/simrs-be into fix/anything-moko

This commit is contained in:
dpurbosakti
2025-10-10 14:17:14 +07:00
12 changed files with 62 additions and 43 deletions
@@ -0,0 +1,15 @@
-- Create "PostalRegion" table
CREATE TABLE "public"."PostalRegion" (
"Id" bigserial NOT NULL,
"Village_Code" character varying(10) NULL,
"Code" character varying(5) NULL,
PRIMARY KEY ("Id"),
CONSTRAINT "uni_PostalRegion_Code" UNIQUE ("Code"),
CONSTRAINT "fk_PostalRegion_Village" FOREIGN KEY ("Village_Code") REFERENCES "public"."Village" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION
);
-- Rename a column from "PostalCode_Code" to "PostalRegion_Code"
ALTER TABLE "public"."PersonAddress" RENAME COLUMN "PostalCode_Code" TO "PostalRegion_Code";
-- Modify "PersonAddress" table
ALTER TABLE "public"."PersonAddress" DROP CONSTRAINT "fk_PersonAddress_PostalCode", ADD COLUMN "LocationType_Code" character varying(10) NULL, ADD CONSTRAINT "fk_PersonAddress_PostalRegion" FOREIGN KEY ("PostalRegion_Code") REFERENCES "public"."PostalRegion" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION;
-- Drop "PostalCode" table
DROP TABLE "public"."PostalCode";
+3 -2
View File
@@ -1,4 +1,4 @@
h1:tvJWAAI1ENRhCwoYTUekIO7b9RxtkQllUFwCYQ/S17w=
h1:4FXkpgFh3UpHN247wDhhSP9RpYGEvS0rwSbd5mEeFZ4=
20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k=
20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0=
20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI=
@@ -34,4 +34,5 @@ h1:tvJWAAI1ENRhCwoYTUekIO7b9RxtkQllUFwCYQ/S17w=
20251008073620.sql h1:6YsJp1W4SmQJ1lxpqF27BBlDC1zqhw7Yhc7pLzQTY6M=
20251009042854.sql h1:nkBV+R6j0fg7/JY6wH3eb5Vv0asJLnXmb6lINfT/GLQ=
20251009052657.sql h1:EPvdsib5rzCGPryd10HShGKvFPwM/R5S2lIVwtYxpms=
20251010031743.sql h1:XGl/0//kV22jCXS+k+qZASm/zN6uapZjOCPBAGg7+yo=
20251010031743.sql h1:T8IZmx8/btRFKLzTe78MzcBsPJNodnLvB0tby9QkirQ=
20251010070721.sql h1:+tKik0+V3yNWiLX4rW3pxw93ceBCCtqXDFqSHyzwnXo=
@@ -12,7 +12,7 @@ type DivisionPosition struct {
Division *ed.Division `json:"division" gorm:"foreignKey:Division_Id"`
Code string `json:"code" gorm:"unique;size:10"`
Name string `json:"name" gorm:"size:50"`
HeadStatus bool `json:"head_status"`
HeadStatus bool `json:"headStatus"`
Employee_Id *uint `json:"employee_id"`
Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"`
}
@@ -2,16 +2,14 @@ package personaddress
import (
ecore "simrs-vx/internal/domain/base-entities/core"
epc "simrs-vx/internal/domain/main-entities/postal-code"
)
type CreateDto struct {
Person_Id uint `json:"person_id"`
Address string `json:"address" validate:"maxLength=150"`
Rt string `json:"rt" validate:"maxLength=2"`
Rw string `json:"rw" validate:"maxLength=2"`
Village_Code string `json:"village_code" validate:"maxLength=10"`
PostalCode_Code string `json:"postalCode_code" validate:"maxLength=6"`
Person_Id uint `json:"person_id"`
Address string `json:"address" validate:"maxLength=150"`
Rt string `json:"rt" validate:"maxLength=2"`
Rw string `json:"rw" validate:"maxLength=2"`
Village_Code *string `json:"village_code" validate:"maxLength=10"`
}
type ReadListDto struct {
@@ -40,13 +38,11 @@ type MetaDto struct {
type ResponseDto struct {
ecore.Main
Person_Id uint `json:"person_id"`
Address string `json:"address"`
Rt string `json:"rt"`
Rw string `json:"rw"`
Village_Code string `json:"village_code"`
PostalCode_Code string `json:"postalCode_code"`
PostalCode *epc.PostalCode `json:"postalCode,omitempty"`
Person_Id uint `json:"person_id"`
Address string `json:"address"`
Rt string `json:"rt"`
Rw string `json:"rw"`
Village_Code *string `json:"village_code"`
}
func (d PersonAddress) ToResponse() ResponseDto {
@@ -2,16 +2,19 @@ package personaddress
import (
ecore "simrs-vx/internal/domain/base-entities/core"
epc "simrs-vx/internal/domain/main-entities/postal-code"
epr "simrs-vx/internal/domain/main-entities/postal-region"
erp "simrs-vx/internal/domain/references/person"
)
type PersonAddress struct {
ecore.Main // adjust this according to the needs
Person_Id uint `json:"person_id"`
Address string `json:"address" gorm:"size:150"`
Rt string `json:"rt" gorm:"size:2"`
Rw string `json:"rw" gorm:"size:2"`
PostalCode_Code string `json:"postalCode_code" gorm:"size:6"`
PostalCode *epc.PostalCode `json:"postalCode,omitempty" gorm:"foreignKey:PostalCode_Code;references:Code"`
Village_Code string `json:"village_code" gorm:"size:10"`
ecore.Main // adjust this according to the needs
Person_Id uint `json:"person_id"`
Address string `json:"address" gorm:"size:150"`
LocationType_Code erp.AddressLocationTypeCode `json:"locationType_code" gorm:"size:10"`
Rt string `json:"rt" gorm:"size:2"`
Rw string `json:"rw" gorm:"size:2"`
PostalRegion_Code *string `json:"postalRegion_code" gorm:"size:6"`
PostalRegion *epr.PostalRegion `json:"postalRegion,omitempty" gorm:"foreignKey:PostalRegion_Code;references:Code"`
Village_Code *string `json:"village_code" gorm:"size:10"`
}
@@ -1,4 +1,4 @@
package postalcode
package postalregion
import (
ecore "simrs-vx/internal/domain/base-entities/core"
@@ -51,7 +51,7 @@ type ResponseDto struct {
Code string `json:"code"`
}
func (d PostalCode) ToResponse() ResponseDto {
func (d PostalRegion) ToResponse() ResponseDto {
resp := ResponseDto{
Id: d.Id,
Village_Code: d.Village_Code,
@@ -61,7 +61,7 @@ func (d PostalCode) ToResponse() ResponseDto {
return resp
}
func ToResponseList(data []PostalCode) []ResponseDto {
func ToResponseList(data []PostalRegion) []ResponseDto {
resp := make([]ResponseDto, len(data))
for i, u := range data {
resp[i] = u.ToResponse()
@@ -1,11 +1,11 @@
package postalcode
package postalregion
import (
ep "simrs-vx/internal/domain/main-entities/postal-code/base"
ep "simrs-vx/internal/domain/main-entities/postal-region/base"
ev "simrs-vx/internal/domain/main-entities/village"
)
type PostalCode struct {
type PostalRegion struct {
ep.Basic
Village *ev.Village `json:"village,omitempty" gorm:"foreignKey:Village_Code;references:Code"`
}
+6 -6
View File
@@ -3,7 +3,7 @@ package village
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ed "simrs-vx/internal/domain/main-entities/district"
epb "simrs-vx/internal/domain/main-entities/postal-code/base"
epb "simrs-vx/internal/domain/main-entities/postal-region/base"
evb "simrs-vx/internal/domain/main-entities/village/base"
)
@@ -50,15 +50,15 @@ type MetaDto struct {
type ResponseDto struct {
evb.Basic
District *ed.District `json:"district,omitempty"`
PostalCodes []epb.Basic `json:"postalCodes,omitempty"`
District *ed.District `json:"district,omitempty"`
PostalRegions []epb.Basic `json:"postalRegions,omitempty"`
}
func (d Village) ToResponse() ResponseDto {
resp := ResponseDto{
Basic: d.Basic,
District: d.District,
PostalCodes: d.PostalCodes,
Basic: d.Basic,
District: d.District,
PostalRegions: d.PostalRegions,
}
return resp
}
@@ -2,12 +2,12 @@ package village
import (
ed "simrs-vx/internal/domain/main-entities/district"
epb "simrs-vx/internal/domain/main-entities/postal-code/base"
epb "simrs-vx/internal/domain/main-entities/postal-region/base"
evb "simrs-vx/internal/domain/main-entities/village/base"
)
type Village struct {
evb.Basic
District *ed.District `json:"district,omitempty" gorm:"foreignKey:District_Code;references:Code"`
PostalCodes []epb.Basic `json:"postalCodes,omitempty" gorm:"foreignKey:Village_Code;references:Code"`
District *ed.District `json:"district,omitempty" gorm:"foreignKey:District_Code;references:Code"`
PostalRegions []epb.Basic `json:"postalRegions,omitempty" gorm:"foreignKey:Village_Code;references:Code"`
}
@@ -12,6 +12,7 @@ type (
RelativeCode string
ContactTypeCode string
RelationshipCode string
AddressLocationTypeCode string
)
const (
@@ -109,6 +110,9 @@ const (
RCNephew RelationshipCode = "nephew" // Keponakan
RCGdChild RelationshipCode = "gd-child" // Cucu
RCOther RelationshipCode = "other" // Lainnya
ALTCIdn AddressLocationTypeCode = "identity" // Sesuai Identitas
ALTCDom AddressLocationTypeCode = "domicile" // Sesuai Domisili
)
// func GetGenderCodes() map[GenderCode]string {
@@ -57,7 +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"
postalregion "simrs-vx/internal/domain/main-entities/postal-region"
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"
@@ -150,6 +150,6 @@ func getMainEntities() []any {
&consultation.Consultation{},
&chemo.Chemo{},
&midwife.Midwife{},
&postalcode.PostalCode{},
&postalregion.PostalRegion{},
}
}