feat/user: moved Registration to Registrator

This commit is contained in:
2025-12-09 15:50:17 +07:00
parent 36e65abfac
commit bd1d5bdde6
14 changed files with 105 additions and 69 deletions
@@ -1,4 +1,4 @@
package doctor
package registrator
import (
ecore "simrs-vx/internal/domain/base-entities/core"
@@ -51,7 +51,7 @@ type ResponseDto struct {
Installation *ei.Installation `json:"installation,omitempty"`
}
func (d Registration) ToResponse() ResponseDto {
func (d Registrator) ToResponse() ResponseDto {
resp := ResponseDto{
Employee_Id: d.Employee_Id,
Employee: d.Employee,
@@ -62,7 +62,7 @@ func (d Registration) ToResponse() ResponseDto {
return resp
}
func ToResponseList(data []Registration) []ResponseDto {
func ToResponseList(data []Registrator) []ResponseDto {
resp := make([]ResponseDto, len(data))
for i, u := range data {
resp[i] = u.ToResponse()
@@ -1,4 +1,4 @@
package doctor
package registrator
import (
ecore "simrs-vx/internal/domain/base-entities/core"
@@ -6,7 +6,7 @@ import (
ei "simrs-vx/internal/domain/main-entities/installation"
)
type Registration struct {
type Registrator 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"`
+27 -17
View File
@@ -13,23 +13,24 @@ import (
)
type CreateDto struct {
Name string `json:"name" validate:"maxLength=25"`
Password string `json:"password" validate:"maxLength=255"`
Name string `json:"name" validate:"required;maxLength=50"`
Password string `json:"password" validate:"required;maxLength=255"`
ContractPosition_Code erg.ContractPositionCode `json:"contractPosition_code" gorm:"not null;size:20" validate:"required"`
Status_Code erc.UserStatusCode `json:"status_code" validate:"maxLength=10"`
Person_Id *uint `json:"-"`
Person *ep.UpdateDto `json:"person"`
PersonAddresses []epa.UpdateDto `json:"personAddresses"`
PersonContacts []epc.UpdateDto `json:"personContacts"`
Code *string `json:"code" validate:"maxLength=20"`
Employee *EmployeUpdateDto `json:"employee"`
IHS_Number *string `json:"ihs_number" validate:"maxLength=20"`
SIP_Number *string `json:"sip_number" validate:"maxLength=20"`
Infra_Code *string `json:"infra_code"`
Installation_Code *string `json:"installation_code"`
Unit_Code *string `json:"unit_code"`
Specialist_Code *string `json:"specialist_code"`
Subspecialist_Code *string `json:"subspecialist_code"`
ContractPosition_Code erg.ContractPositionCode `json:"contractPosition_code" gorm:"not null;size:20"`
Employee *EmployeUpdateDto `json:"employee"`
Person *ep.UpdateDto `json:"person"`
PersonAddresses []epa.UpdateDto `json:"personAddresses"`
PersonContacts []epc.UpdateDto `json:"personContacts"`
Person_Id *uint `json:"-"`
Code *string `json:"code" validate:"maxLength=20"`
IHS_Number *string `json:"ihs_number" validate:"maxLength=20"`
SIP_Number *string `json:"sip_number" validate:"maxLength=20"`
Installation_Code *string `json:"installation_code"`
Unit_Code *string `json:"unit_code"`
Specialist_Code *string `json:"specialist_code"`
Subspecialist_Code *string `json:"subspecialist_code"`
Infra_Code *string `json:"infra_code"`
}
type ReadListDto struct {
@@ -88,11 +89,20 @@ func (d *User) ToResponse() ResponseDto {
type EmployeUpdateDto struct {
Id uint `json:"id"`
User_Id *uint `json:"-"`
Person_Id *uint `json:"-"`
Division_Code *string `json:"division_code"`
Number *string `json:"number" validate:"maxLength=20"`
Position_Code erg.EmployeePositionCode `json:"position_code" validate:"maxLength=20"`
Status_Code erc.ActiveStatusCode `json:"status_code" validate:"maxLength=10"`
Person_Id *uint `json:"-"`
// TODO: Extras
// Code *string `json:"code" validate:"maxLength=20"`
// IHS_Number *string `json:"ihs_number" validate:"maxLength=20"`
// SIP_Number *string `json:"sip_number" validate:"maxLength=20"`
// Installation_Code *string `json:"installation_code"`
// Unit_Code *string `json:"unit_code"`
// Specialist_Code *string `json:"specialist_code"`
// Subspecialist_Code *string `json:"subspecialist_code"`
// Infra_Code *string `json:"infra_code"`
}
func ToResponseList(data []User) []ResponseDto {