feat/user: added registration entity

This commit is contained in:
2025-12-09 13:43:41 +07:00
parent 7ac123d71a
commit 792c7cc9d4
5 changed files with 103 additions and 2 deletions
@@ -0,0 +1,12 @@
-- Create "Registration" table
CREATE TABLE "public"."Registration" (
"Id" bigserial NOT NULL,
"CreatedAt" timestamptz NULL,
"UpdatedAt" timestamptz NULL,
"DeletedAt" timestamptz NULL,
"Employee_Id" bigint NULL,
"Installation_Code" character varying(20) NULL,
PRIMARY KEY ("Id"),
CONSTRAINT "fk_Registration_Employee" FOREIGN KEY ("Employee_Id") REFERENCES "public"."Employee" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "fk_Registration_Installation" FOREIGN KEY ("Installation_Code") REFERENCES "public"."Installation" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION
);
+3 -2
View File
@@ -1,4 +1,4 @@
h1:qjr3k9/ymXjw1nopw49c6+fWtu0n+H8sQgsioqUC9Fo=
h1:JGe2DnXv3QZTmdne3HWeAGA4rppck8cJaiZ0RgoM+Sg=
20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k=
20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0=
20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI=
@@ -144,4 +144,5 @@ h1:qjr3k9/ymXjw1nopw49c6+fWtu0n+H8sQgsioqUC9Fo=
20251202160848.sql h1:Kd2/TziKSMezrt4XgbjQcYvY/Lo9rX0qw7/Lz0/oyKk=
20251202180207.sql h1:IHmSMIO3ia+YV5GULixbdlV1joaUAWtnjQHPd8+HKiM=
20251202231005.sql h1:lua0KKoeBptSfs/6ehZE6Azo6YUlNkOJwGFyb1HQWkY=
20251203205052.sql h1:az/hGpk7u4YKT7gU+UuEw9guqB9AqdckPF1cYavQ3CA=
20251203205052.sql h1:nk0VK2Uv4bHE3SBfHo/aevVZxtHzr7zAzvmMU8TCCtk=
20251209064304.sql h1:/vp48I71991yaVsOw/g+eFsFydgLGEo+Xfen7Lp8WB4=
@@ -0,0 +1,71 @@
package doctor
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"
)
type CreateDto struct {
Employee_Id uint `json:"employee_id"`
Installation_Code string `json:"installation_code" validate:"maxLength=20"`
}
type ReadListDto struct {
FilterDto
Includes string `json:"includes"`
Pagination ecore.Pagination
}
type FilterDto struct {
Employee_Id *uint `json:"employee-id"`
Installation_Code *string `json:"installation-code"`
}
type ReadDetailDto struct {
Id *uint16 `json:"id"`
Code *string `json:"code"`
Employee_Id *uint `json:"employee_id"`
}
type UpdateDto struct {
Id *uint `json:"id"`
CreateDto
}
type DeleteDto struct {
Id uint `json:"id"`
}
type MetaDto struct {
PageNumber int `json:"page_number"`
PageSize int `json:"page_size"`
Count int `json:"count"`
}
type ResponseDto struct {
ecore.Main
Employee_Id uint `json:"employee_id"`
Employee *ee.Employee `json:"employee,omitempty"`
Installation_Code string `json:"installation_code"`
Installation *ei.Installation `json:"installation,omitempty"`
}
func (d Registration) ToResponse() ResponseDto {
resp := ResponseDto{
Employee_Id: d.Employee_Id,
Employee: d.Employee,
Installation_Code: d.Installation_Code,
Installation: d.Installation,
}
resp.Main = d.Main
return resp
}
func ToResponseList(data []Registration) []ResponseDto {
resp := make([]ResponseDto, len(data))
for i, u := range data {
resp[i] = u.ToResponse()
}
return resp
}
@@ -0,0 +1,15 @@
package doctor
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"
)
type Registration struct {
ecore.Main // adjust this according to the needs
Employee_Id uint `json:"employee_id"`
Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"`
Installation_Code string `json:"installation_code" gorm:"size:20"`
Installation *ei.Installation `json:"installation,omitempty" gorm:"foreignKey:Installation_Code;references:Code"`
}
@@ -88,6 +88,7 @@ import (
proceduresrc "simrs-vx/internal/domain/main-entities/procedure-src"
province "simrs-vx/internal/domain/main-entities/province"
regency "simrs-vx/internal/domain/main-entities/regency"
registration "simrs-vx/internal/domain/main-entities/registration"
rehab "simrs-vx/internal/domain/main-entities/rehab"
responsibledoctorhist "simrs-vx/internal/domain/main-entities/responsible-doctor-hist"
resume "simrs-vx/internal/domain/main-entities/resume"
@@ -140,6 +141,7 @@ func getMainEntities() []any {
&proceduresrc.ProcedureSrc{},
&employee.Employee{},
&intern.Intern{},
&registration.Registration{},
&doctor.Doctor{},
&nurse.Nurse{},
&nutritionist.Nutritionist{},