feat/user: adjust some entities
This commit is contained in:
@@ -23,9 +23,9 @@ type FilterDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id *uint16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
Employee_Id *uint `json:"employee_id"`
|
||||
Id *uint `json:"id"`
|
||||
Employee_Id *uint `json:"employee_id"`
|
||||
Includes string `json:"includes"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
|
||||
@@ -24,8 +24,9 @@ type CreateDto struct {
|
||||
Employee *EmployeUpdateDto `json:"employee"`
|
||||
IHS_Number *string `json:"ihs_number" validate:"maxLength=20"`
|
||||
SIP_Number *string `json:"sip_number" validate:"maxLength=20"`
|
||||
Unit_Code *string `json:"unit_code"`
|
||||
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"`
|
||||
|
||||
@@ -2,6 +2,8 @@ package personaddress
|
||||
|
||||
import (
|
||||
e "simrs-vx/internal/domain/main-entities/person-address"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
plh "simrs-vx/pkg/lib-helper"
|
||||
pl "simrs-vx/pkg/logger"
|
||||
@@ -179,10 +181,19 @@ func CreateOrUpdateBatch(input []e.UpdateDto, event *pl.Event, tx ...*gorm.DB) e
|
||||
}
|
||||
setData(&input[idx], &data[idx])
|
||||
if err := dbx.Create(&data[idx]).Error; err != nil {
|
||||
errMsg := err.Error()
|
||||
additionalMessage := ""
|
||||
// FK error
|
||||
if strings.Contains(errMsg, "violates foreign key") {
|
||||
pos := strings.Index(errMsg, "violates foreign key")
|
||||
additionalMessage = ", " + errMsg[pos:]
|
||||
}
|
||||
// Got another errot, put it down below
|
||||
// ....
|
||||
event.Status = "failed"
|
||||
event.ErrInfo = pl.ErrorInfo{
|
||||
Code: "data-create-fail",
|
||||
Detail: "Database insert failed",
|
||||
Detail: "data insert failed at PersonAddres[" + strconv.Itoa(idx) + "]" + additionalMessage,
|
||||
Raw: err,
|
||||
}
|
||||
return pl.SetLogError(event, input)
|
||||
|
||||
Reference in New Issue
Block a user