diff --git a/cmd/main-migration/migrations/20251024074315.sql b/cmd/main-migration/migrations/20251024074315.sql new file mode 100644 index 00000000..99b3b76b --- /dev/null +++ b/cmd/main-migration/migrations/20251024074315.sql @@ -0,0 +1,2 @@ +-- Modify "Employee" table +ALTER TABLE "public"."Employee" DROP COLUMN "Division_Code"; diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index f65af68d..9a03ed9b 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:iDCRTkq1AjDg/YtmmPXwu6TAXJeoXQuXfDZG99Pi6cY= +h1:ieMeKh35/dro1YBBO11ZP0nZan9aJ5aFSqnEAi+T+WQ= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -56,4 +56,5 @@ h1:iDCRTkq1AjDg/YtmmPXwu6TAXJeoXQuXfDZG99Pi6cY= 20251021041042.sql h1:wMgSivBV2A0NDcsLmKGIp0kMcVh2IODSG9b4dgzCaOM= 20251021075552.sql h1:8gfSMAglflNO6L0sSzxFNEubYN8/O4thT7OQT+WH+3M= 20251023044432.sql h1:MkvajJs3bfk9+wHvQ43/ccAluJEBARm1gWr1u92ccLA= -20251024034832.sql h1:SoqYFfkaTTiY18PWY+l8+dqUlZtCUjSsbC0L1swsD3s= +20251024034832.sql h1:x3s3VEVYLOSKLAFxJGb2+c1FyTMMvPE+9k4Ew7rKQaI= +20251024074315.sql h1:EjAjelgi5qAfcRq/8vPTlGGYHvAKxNTllm8f0SzZDns= diff --git a/internal/domain/main-entities/division-position/base/entity.go b/internal/domain/main-entities/division-position/base/entity.go new file mode 100644 index 00000000..ce8f3175 --- /dev/null +++ b/internal/domain/main-entities/division-position/base/entity.go @@ -0,0 +1,20 @@ +package base + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ee "simrs-vx/internal/domain/main-entities/employee" +) + +type Basic struct { + ecore.SmallMain // adjust this according to the needs + Division_Id *uint16 `json:"division_id"` + Code string `json:"code" gorm:"unique;size:10"` + Name string `json:"name" gorm:"size:50"` + HeadStatus bool `json:"headStatus"` + Employee_Id *uint `json:"employee_id"` + Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"` +} + +func (Basic) TableName() string { + return "DivisionPosition" +} diff --git a/internal/domain/main-entities/division-position/entity.go b/internal/domain/main-entities/division-position/entity.go index c7d70968..d71ba01c 100644 --- a/internal/domain/main-entities/division-position/entity.go +++ b/internal/domain/main-entities/division-position/entity.go @@ -1,18 +1,11 @@ package divisionposition import ( - ecore "simrs-vx/internal/domain/base-entities/core" ed "simrs-vx/internal/domain/main-entities/division" - ee "simrs-vx/internal/domain/main-entities/employee" + eb "simrs-vx/internal/domain/main-entities/division-position/base" ) type DivisionPosition struct { - ecore.SmallMain // adjust this according to the needs - Division_Id *uint16 `json:"division_id"` - Division *ed.Division `json:"division" gorm:"foreignKey:Division_Id;references:Id"` - Code string `json:"code" gorm:"unique;size:10"` - Name string `json:"name" gorm:"size:50"` - HeadStatus bool `json:"headStatus"` - Employee_Id *uint `json:"employee_id"` - Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"` + eb.Basic + Division *ed.Division `json:"division" gorm:"foreignKey:Division_Id;references:Id"` } diff --git a/internal/domain/main-entities/division/entity.go b/internal/domain/main-entities/division/entity.go index 470fab0d..4051c138 100644 --- a/internal/domain/main-entities/division/entity.go +++ b/internal/domain/main-entities/division/entity.go @@ -2,13 +2,15 @@ package division import ( ecore "simrs-vx/internal/domain/base-entities/core" + edpb "simrs-vx/internal/domain/main-entities/division-position/base" ) type Division struct { - ecore.SmallMain // adjust this according to the needs - Code string `json:"code" gorm:"unique;size:10"` - Name string `json:"name" gorm:"size:50"` - Parent_Id *uint16 `json:"parent_id"` - Parent *Division `json:"parent" gorm:"foreignKey:Parent_Id;references:Id"` - Childrens []Division `json:"childrens" gorm:"foreignKey:Parent_Id"` // may need references to self + ecore.SmallMain // adjust this according to the needs + Code string `json:"code" gorm:"unique;size:10"` + Name string `json:"name" gorm:"size:50"` + Parent_Id *uint16 `json:"parent_id"` + Parent *Division `json:"parent" gorm:"foreignKey:Parent_Id;references:Id"` + Childrens []Division `json:"childrens" gorm:"foreignKey:Parent_Id"` // may need references to self + DivisionPositions []edpb.Basic `json:"divisionPositions,omitempty" gorm:"foreignKey:Division_Id;references:Id"` } diff --git a/internal/domain/main-entities/employee/dto.go b/internal/domain/main-entities/employee/dto.go index 9e0e93d2..d11ccae0 100644 --- a/internal/domain/main-entities/employee/dto.go +++ b/internal/domain/main-entities/employee/dto.go @@ -2,7 +2,6 @@ package employee import ( ecore "simrs-vx/internal/domain/base-entities/core" - ed "simrs-vx/internal/domain/main-entities/division" ep "simrs-vx/internal/domain/main-entities/person" eu "simrs-vx/internal/domain/main-entities/user" @@ -10,11 +9,10 @@ import ( ) type CreateDto struct { - User_Id *uint `json:"user_id"` - Person_Id *uint `json:"person_id"` - Division_Code *string `json:"division_code"` - Number *string `json:"number" validate:"maxLength=20"` - Status_Code erc.ActiveStatusCode `json:"status_code" validate:"maxLength=10"` + User_Id *uint `json:"user_id"` + Person_Id *uint `json:"person_id"` + Number *string `json:"number" validate:"maxLength=20"` + Status_Code erc.ActiveStatusCode `json:"status_code" validate:"maxLength=10"` } type ReadListDto struct { @@ -26,7 +24,6 @@ type ReadListDto struct { type FilterDto struct { User_Id *uint `json:"user-id"` Person_Id *uint `json:"person-id"` - Division_Code *string `json:"division-code"` Position_Code *string `json:"position-code"` Number *string `json:"number"` Status_Code erc.ActiveStatusCode `json:"status-code"` @@ -56,26 +53,22 @@ type MetaDto struct { type ResponseDto struct { ecore.Main - User_Id *uint `json:"user_id"` - User *eu.User `json:"user,omitempty"` - Person_Id *uint `json:"person_id"` - Person *ep.Person `json:"person,omitempty"` - Division_Code *string `json:"division_code"` - Division *ed.Division `json:"division,omitempty"` - Number *string `json:"number"` - Status_Code erc.ActiveStatusCode `json:"status_code"` + User_Id *uint `json:"user_id"` + User *eu.User `json:"user,omitempty"` + Person_Id *uint `json:"person_id"` + Person *ep.Person `json:"person,omitempty"` + Number *string `json:"number"` + Status_Code erc.ActiveStatusCode `json:"status_code"` } func (d Employee) ToResponse() ResponseDto { resp := ResponseDto{ - User_Id: d.User_Id, - User: d.User, - Person_Id: d.Person_Id, - Person: d.Person, - Division_Code: d.Division_Code, - Division: d.Division, - Number: d.Number, - Status_Code: d.Status_Code, + User_Id: d.User_Id, + User: d.User, + Person_Id: d.Person_Id, + Person: d.Person, + Number: d.Number, + Status_Code: d.Status_Code, } resp.Main = d.Main return resp diff --git a/internal/domain/main-entities/employee/entity.go b/internal/domain/main-entities/employee/entity.go index 1177abe9..7a770be0 100644 --- a/internal/domain/main-entities/employee/entity.go +++ b/internal/domain/main-entities/employee/entity.go @@ -2,7 +2,6 @@ package employee import ( ecore "simrs-vx/internal/domain/base-entities/core" - ed "simrs-vx/internal/domain/main-entities/division" ep "simrs-vx/internal/domain/main-entities/person" eu "simrs-vx/internal/domain/main-entities/user" erc "simrs-vx/internal/domain/references/common" @@ -16,8 +15,6 @@ type Employee struct { Person_Id *uint `json:"person_id"` Person *ep.Person `json:"person,omitempty" gorm:"foreignKey:Person_Id;references:Id"` Position_Code *erg.EmployeePositionCode `json:"position_code" gorm:"size:20"` - Division_Code *string `json:"division_code"` - Division *ed.Division `json:"division,omitempty" gorm:"foreignKey:Division_Code;references:Code"` Number *string `json:"number" gorm:"size:20"` Status_Code erc.ActiveStatusCode `json:"status_code" gorm:"not null;size:10"` } diff --git a/internal/domain/main-entities/installation-position/base/entity.go b/internal/domain/main-entities/installation-position/base/entity.go new file mode 100644 index 00000000..02fbbe84 --- /dev/null +++ b/internal/domain/main-entities/installation-position/base/entity.go @@ -0,0 +1,20 @@ +package base + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ee "simrs-vx/internal/domain/main-entities/employee" +) + +type Basic struct { + ecore.SmallMain // adjust this according to the needs + Installation_Id *uint16 `json:"installation_id" gorm:"not null"` + Code string `json:"code" gorm:"unique;size:10;not null"` + Name string `json:"name" gorm:"size:30;not null"` + HeadStatus bool `json:"headStatus"` + Employee_Id *uint `json:"employee_id"` + Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"` +} + +func (Basic) TableName() string { + return "InstallationPosition" +} diff --git a/internal/domain/main-entities/installation-position/entity.go b/internal/domain/main-entities/installation-position/entity.go index 03571326..48e95ac5 100644 --- a/internal/domain/main-entities/installation-position/entity.go +++ b/internal/domain/main-entities/installation-position/entity.go @@ -1,18 +1,11 @@ package installation_position import ( - ecore "simrs-vx/internal/domain/base-entities/core" - ee "simrs-vx/internal/domain/main-entities/employee" ei "simrs-vx/internal/domain/main-entities/installation" + eib "simrs-vx/internal/domain/main-entities/installation-position/base" ) type InstallationPosition struct { - ecore.SmallMain // adjust this according to the needs - Installation_Id *uint16 `json:"installation_id" gorm:"not null"` - Installation *ei.Installation `json:"installation,omitempty" gorm:"foreignKey:Installation_Id;references:Id"` - Code string `json:"code" gorm:"unique;size:10;not null"` - Name string `json:"name" gorm:"size:30;not null"` - HeadStatus bool `json:"headStatus"` - Employee_Id *uint `json:"employee_id"` - Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"` + eib.Basic // adjust this according to the needs + Installation *ei.Installation `json:"installation,omitempty" gorm:"foreignKey:Installation_Id;references:Id"` } diff --git a/internal/domain/main-entities/installation/entity.go b/internal/domain/main-entities/installation/entity.go index 0cd5b7dd..dea63a45 100644 --- a/internal/domain/main-entities/installation/entity.go +++ b/internal/domain/main-entities/installation/entity.go @@ -2,12 +2,14 @@ package installation import ( ecore "simrs-vx/internal/domain/base-entities/core" + eipb "simrs-vx/internal/domain/main-entities/installation-position/base" ere "simrs-vx/internal/domain/references/encounter" ) type Installation struct { - ecore.SmallMain // adjust this according to the needs - Code string `json:"code" gorm:"unique;size:10"` - Name string `json:"name" gorm:"size:50"` - EncounterClass_Code ere.EncounterClassCode `json:"encounterClass_code" gorm:"size:10"` + ecore.SmallMain // adjust this according to the needs + Code string `json:"code" gorm:"unique;size:10"` + Name string `json:"name" gorm:"size:50"` + EncounterClass_Code ere.EncounterClassCode `json:"encounterClass_code" gorm:"size:10"` + InstallationPositions []eipb.Basic `json:"installationPositions,omitempty" gorm:"foreignKey:Installation_Id;references:Id"` } diff --git a/internal/domain/main-entities/specialist-position/base/entity.go b/internal/domain/main-entities/specialist-position/base/entity.go new file mode 100644 index 00000000..5910689e --- /dev/null +++ b/internal/domain/main-entities/specialist-position/base/entity.go @@ -0,0 +1,20 @@ +package base + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ee "simrs-vx/internal/domain/main-entities/employee" +) + +type Basic struct { + ecore.SmallMain // adjust this according to the needs + Specialist_Id *uint16 `json:"specialist_id" gorm:"not null"` + Code string `json:"code" gorm:"unique;size:10;not null"` + Name string `json:"name" gorm:"size:30;not null"` + HeadStatus bool `json:"headStatus"` + Employee_Id *uint `json:"employee_id"` + Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"` +} + +func (Basic) TableName() string { + return "SpecialistPosition" +} diff --git a/internal/domain/main-entities/specialist-position/entity.go b/internal/domain/main-entities/specialist-position/entity.go index 0afa5ba3..26c1d27f 100644 --- a/internal/domain/main-entities/specialist-position/entity.go +++ b/internal/domain/main-entities/specialist-position/entity.go @@ -1,18 +1,11 @@ package specialist_position import ( - ecore "simrs-vx/internal/domain/base-entities/core" - ee "simrs-vx/internal/domain/main-entities/employee" es "simrs-vx/internal/domain/main-entities/specialist" + esb "simrs-vx/internal/domain/main-entities/specialist-position/base" ) type SpecialistPosition struct { - ecore.SmallMain // adjust this according to the needs - Specialist_Id *uint16 `json:"specialist_id" gorm:"not null"` - Specialist *es.Specialist `json:"specialist,omitempty" gorm:"foreignKey:Specialist_Id;references:Id"` - Code string `json:"code" gorm:"unique;size:10;not null"` - Name string `json:"name" gorm:"size:30;not null"` - HeadStatus bool `json:"headStatus"` - Employee_Id *uint `json:"employee_id"` - Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"` + esb.Basic + Specialist *es.Specialist `json:"specialist,omitempty" gorm:"foreignKey:Specialist_Id;references:Id"` } diff --git a/internal/domain/main-entities/specialist/entity.go b/internal/domain/main-entities/specialist/entity.go index 3cea2ebd..5c2d5b89 100644 --- a/internal/domain/main-entities/specialist/entity.go +++ b/internal/domain/main-entities/specialist/entity.go @@ -2,13 +2,15 @@ package specialist import ( ecore "simrs-vx/internal/domain/base-entities/core" + eub "simrs-vx/internal/domain/main-entities/specialist-position/base" eu "simrs-vx/internal/domain/main-entities/unit" ) type Specialist struct { - ecore.SmallMain // adjust this according to the needs - Code string `json:"code" gorm:"unique;size:10"` - Name string `json:"name" gorm:"size:50"` - Unit_Id *uint16 `json:"unit_id"` - Unit *eu.Unit `json:"unit,omitempty" gorm:"foreignKey:Unit_Id"` + ecore.SmallMain // adjust this according to the needs + Code string `json:"code" gorm:"unique;size:10"` + Name string `json:"name" gorm:"size:50"` + Unit_Id *uint16 `json:"unit_id"` + Unit *eu.Unit `json:"unit,omitempty" gorm:"foreignKey:Unit_Id"` + SpecialistPositions []eub.Basic `json:"specialistPositions,omitempty" gorm:"foreignKey:Specialist_Id;references:Id"` } diff --git a/internal/domain/main-entities/subspecialist-position/base/entity.go b/internal/domain/main-entities/subspecialist-position/base/entity.go new file mode 100644 index 00000000..147fcecb --- /dev/null +++ b/internal/domain/main-entities/subspecialist-position/base/entity.go @@ -0,0 +1,20 @@ +package base + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ee "simrs-vx/internal/domain/main-entities/employee" +) + +type Basic struct { + ecore.SmallMain // adjust this according to the needs + Subspecialist_Id *uint16 `json:"subspecialist_id" gorm:"not null"` + Code string `json:"code" gorm:"unique;size:10;not null"` + Name string `json:"name" gorm:"size:30;not null"` + HeadStatus bool `json:"headStatus"` + Employee_Id *uint `json:"employee_id"` + Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"` +} + +func (Basic) TableName() string { + return "SubspecialistPosition" +} diff --git a/internal/domain/main-entities/subspecialist-position/entity.go b/internal/domain/main-entities/subspecialist-position/entity.go index 5d4bdcb8..28a205ed 100644 --- a/internal/domain/main-entities/subspecialist-position/entity.go +++ b/internal/domain/main-entities/subspecialist-position/entity.go @@ -1,18 +1,11 @@ package subspecialist_position import ( - ecore "simrs-vx/internal/domain/base-entities/core" - ee "simrs-vx/internal/domain/main-entities/employee" es "simrs-vx/internal/domain/main-entities/subspecialist" + esb "simrs-vx/internal/domain/main-entities/subspecialist-position/base" ) type SubspecialistPosition struct { - ecore.SmallMain // adjust this according to the needs - Subspecialist_Id *uint16 `json:"subspecialist_id" gorm:"not null"` - Subspecialist *es.Subspecialist `json:"subspecialist,omitempty" gorm:"foreignKey:Subspecialist_Id;references:Id"` - Code string `json:"code" gorm:"unique;size:10;not null"` - Name string `json:"name" gorm:"size:30;not null"` - HeadStatus bool `json:"headStatus"` - Employee_Id *uint `json:"employee_id"` - Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"` + esb.Basic + Subspecialist *es.Subspecialist `json:"subspecialist,omitempty" gorm:"foreignKey:Subspecialist_Id;references:Id"` } diff --git a/internal/domain/main-entities/subspecialist/entity.go b/internal/domain/main-entities/subspecialist/entity.go index 5de27442..a81d6ded 100644 --- a/internal/domain/main-entities/subspecialist/entity.go +++ b/internal/domain/main-entities/subspecialist/entity.go @@ -3,12 +3,14 @@ package subspecialist import ( ecore "simrs-vx/internal/domain/base-entities/core" es "simrs-vx/internal/domain/main-entities/specialist" + espb "simrs-vx/internal/domain/main-entities/subspecialist-position/base" ) type Subspecialist struct { - ecore.SmallMain // adjust this according to the needs - Code string `json:"code" gorm:"unique;size:10"` - Name string `json:"name" gorm:"size:50"` - Specialist_Id *uint16 `json:"specialist_id"` - Specialist *es.Specialist `json:"specialist,omitempty" gorm:"foreignKey:Specialist_Id"` + ecore.SmallMain // adjust this according to the needs + Code string `json:"code" gorm:"unique;size:10"` + Name string `json:"name" gorm:"size:50"` + Specialist_Id *uint16 `json:"specialist_id"` + Specialist *es.Specialist `json:"specialist,omitempty" gorm:"foreignKey:Specialist_Id"` + SubspecialistPositions []espb.Basic `json:"subspecialistPositions,omitempty" gorm:"foreignKey:Subspecialist_Id;references:Id"` } diff --git a/internal/domain/main-entities/unit-position/base/entity.go b/internal/domain/main-entities/unit-position/base/entity.go new file mode 100644 index 00000000..b8e6a63a --- /dev/null +++ b/internal/domain/main-entities/unit-position/base/entity.go @@ -0,0 +1,20 @@ +package base + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ee "simrs-vx/internal/domain/main-entities/employee" +) + +type Basic struct { + ecore.SmallMain // adjust this according to the needs + Unit_Id *uint16 `json:"unit_id" gorm:"not null"` + Code string `json:"code" gorm:"unique;size:10;not null"` + Name string `json:"name" gorm:"size:30;not null"` + HeadStatus bool `json:"headStatus"` + Employee_Id *uint `json:"employee_id"` + Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"` +} + +func (Basic) TableName() string { + return "UnitPosition" +} diff --git a/internal/domain/main-entities/unit-position/entity.go b/internal/domain/main-entities/unit-position/entity.go index 3bd10d9e..9966cd4a 100644 --- a/internal/domain/main-entities/unit-position/entity.go +++ b/internal/domain/main-entities/unit-position/entity.go @@ -1,18 +1,11 @@ package unit_position import ( - ecore "simrs-vx/internal/domain/base-entities/core" - ee "simrs-vx/internal/domain/main-entities/employee" eu "simrs-vx/internal/domain/main-entities/unit" + eub "simrs-vx/internal/domain/main-entities/unit-position/base" ) type UnitPosition struct { - ecore.SmallMain // adjust this according to the needs - Unit_Id *uint16 `json:"unit_id" gorm:"not null"` - Unit *eu.Unit `json:"unit,omitempty" gorm:"foreignKey:Unit_Id;references:Id"` - Code string `json:"code" gorm:"unique;size:10;not null"` - Name string `json:"name" gorm:"size:30;not null"` - HeadStatus bool `json:"headStatus"` - Employee_Id *uint `json:"employee_id"` - Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"` + eub.Basic + Unit *eu.Unit `json:"unit,omitempty" gorm:"foreignKey:Unit_Id;references:Id"` } diff --git a/internal/domain/main-entities/unit/entity.go b/internal/domain/main-entities/unit/entity.go index c86ad822..2142790f 100644 --- a/internal/domain/main-entities/unit/entity.go +++ b/internal/domain/main-entities/unit/entity.go @@ -3,6 +3,7 @@ package unit import ( ecore "simrs-vx/internal/domain/base-entities/core" ei "simrs-vx/internal/domain/main-entities/installation" + eub "simrs-vx/internal/domain/main-entities/unit-position/base" ero "simrs-vx/internal/domain/references/organization" ) @@ -13,4 +14,5 @@ type Unit struct { Code string `json:"code" gorm:"unique;size:10"` Name string `json:"name" gorm:"size:50"` Type_Code *ero.UnitTypeCode `json:"type_code"` + UnitPositions []eub.Basic `json:"unitPositions,omitempty" gorm:"foreignKey:Unit_Id;references:Id"` } diff --git a/internal/domain/references/organization/organization.go b/internal/domain/references/organization/organization.go index 0309cbee..1dfe93ad 100644 --- a/internal/domain/references/organization/organization.go +++ b/internal/domain/references/organization/organization.go @@ -11,6 +11,7 @@ type ( ) const ( + CSCSys ContractPositionCode = "system" // System CSCEmp ContractPositionCode = "employee" // Pegawai CSCInt ContractPositionCode = "intern" // PPDS