package user import ( ecore "simrs-vx/internal/domain/base-entities/core" ep "simrs-vx/internal/domain/main-entities/person" epa "simrs-vx/internal/domain/main-entities/person-address" epc "simrs-vx/internal/domain/main-entities/person-contact" erc "simrs-vx/internal/domain/references/common" ero "simrs-vx/internal/domain/references/organization" "time" ) type CreateDto struct { Name string `json:"name" validate:"maxLength=25"` Password string `json:"password" validate:"maxLength=255"` Status_Code erc.UserStatusCode `json:"status_code" validate:"maxLength=10"` Position_Code ero.UserPosisitionCode `json:"position_code" validate:"maxLength=20"` Person_Id *uint `json:"-"` Person *ep.UpdateDto `json:"person"` PersonAddresses []epa.UpdateDto `json:"personAddresses"` PersonContacts []epc.UpdateDto `json:"personContacts"` Employee *EmployeUpdateDto `json:"employee"` IHS_Number *string `json:"ihs_number" validate:"maxLength=20"` SIP_Number *string `json:"sip_number" validate:"maxLength=20"` Unit_Id *uint16 `json:"unit_id"` Infra_Id *uint16 `json:"infra_id"` Specialist_Id *uint16 `json:"specialist_id"` Subspecialist_Id *uint16 `json:"subspecialist_id"` } type ReadListDto struct { Name string `json:"name"` Status_Code erc.UserStatusCode `json:"status_code"` Page int `json:"page"` PageSize int `json:"page_size"` NoPagination int `json:"no_pagination"` } type ReadDetailDto struct { Id uint `json:"id"` Name *string `json:"name"` } 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 LoginDto struct { Name string `json:"name" validate:"required"` Password string `json:"password" validate:"required"` Duration uint32 `json:"duration"` // in minutes } type ResponseDto struct { ecore.Main Name string `json:"name"` Status_Code erc.UserStatusCode `json:"status_code"` FailedLoginCount uint8 `json:"failedLoginCount"` LastSuccessLogin *time.Time `json:"lastSuccessLogin,omitempty"` LastAllowdLogin *time.Time `json:"lastAllowdLogin,omitempty"` } func (d *User) ToResponse() ResponseDto { resp := ResponseDto{ Name: d.Name, Status_Code: d.Status_Code, FailedLoginCount: d.FailedLoginCount, LastSuccessLogin: d.LastSuccessLogin, LastAllowdLogin: d.LastAllowdLogin, } resp.Main = d.Main return resp } 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"` Status_Code erc.ActiveStatusCode `json:"status_code" validate:"maxLength=10"` } func ToResponseList(data []User) []ResponseDto { resp := make([]ResponseDto, len(data)) for i, u := range data { resp[i] = u.ToResponse() } return resp } func (c CreateDto) Sanitize() CreateDto { sanitized := c sanitized.Password = "[REDACTED]" return sanitized }