adjustment detail installation
This commit is contained in:
@@ -120,10 +120,10 @@ func GenToken(input eu.LoginDto) (*d.Data, error) {
|
||||
outputData["employee_id"] = employee.Id
|
||||
role = append(role, "emp-"+string(*employee.Position_Code))
|
||||
|
||||
if employee.Division_Code != nil {
|
||||
atClaims["employee_division_code"] = employee.Division_Code
|
||||
outputData["employee_division_code"] = employee.Division_Code
|
||||
}
|
||||
//if employee.Division_Code != nil {
|
||||
// atClaims["employee_division_code"] = employee.Division_Code
|
||||
// outputData["employee_division_code"] = employee.Division_Code
|
||||
//}
|
||||
|
||||
// employee position
|
||||
if employee.Id > 0 && employee.Position_Code != nil {
|
||||
@@ -159,7 +159,7 @@ func GenToken(input eu.LoginDto) (*d.Data, error) {
|
||||
errorGetPosition := d.FieldErrors{"authentication": d.FieldError{Code: "auth-getData-failed", Message: el.GenMessage("auth-getData-failed")}}
|
||||
|
||||
// division position
|
||||
divsionPositions, err := getDivisionPosition(employee.Id)
|
||||
divisionPositions, err := getDivisionPosition(employee.Id)
|
||||
if err != nil {
|
||||
return nil, errorGetPosition
|
||||
}
|
||||
@@ -188,7 +188,7 @@ func GenToken(input eu.LoginDto) (*d.Data, error) {
|
||||
return nil, errorGetPosition
|
||||
}
|
||||
|
||||
role = append(role, divsionPositions...)
|
||||
role = append(role, divisionPositions...)
|
||||
role = append(role, installationPositions...)
|
||||
role = append(role, unitPositions...)
|
||||
role = append(role, specialistPositions...)
|
||||
|
||||
@@ -2,11 +2,8 @@ package division
|
||||
|
||||
import (
|
||||
e "simrs-vx/internal/domain/main-entities/division"
|
||||
edp "simrs-vx/internal/domain/main-entities/division-position"
|
||||
"strconv"
|
||||
|
||||
udp "simrs-vx/internal/use-case/main-use-case/division-position"
|
||||
|
||||
dg "github.com/karincake/apem/db-gorm-pg"
|
||||
d "github.com/karincake/dodol"
|
||||
|
||||
@@ -64,7 +61,7 @@ func Create(input e.CreateDto) (*d.Data, error) {
|
||||
"structure": "single-data",
|
||||
"status": "created",
|
||||
},
|
||||
Data: data.ToResponse(nil),
|
||||
Data: data.ToResponse(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -145,40 +142,6 @@ func ReadDetail(input e.ReadDetailDto) (*d.Data, error) {
|
||||
return err
|
||||
}
|
||||
|
||||
// get data divisionPositions
|
||||
dataDivisionPosition, err := udp.ReadList(edp.ReadListDto{
|
||||
FilterDto: edp.FilterDto{
|
||||
Division_Id: &input.Id,
|
||||
},
|
||||
Includes: "employee,employee.User",
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
list, _ := dataDivisionPosition.Data.([]edp.ResponseDto)
|
||||
if len(list) > 0 {
|
||||
for _, dp := range list {
|
||||
dataDP = append(dataDP, e.ResponseDivisionPosition{
|
||||
SmallMain: dp.SmallMain,
|
||||
Division_Id: &dp.Id,
|
||||
Code: dp.Code,
|
||||
Name: dp.Name,
|
||||
HeadStatus: dp.HeadStatus,
|
||||
Employee_Id: dp.Employee_Id,
|
||||
Employee: e.ResponseDivisionEmployee{
|
||||
Main: dp.Employee.Main,
|
||||
User_Id: dp.Employee.User_Id,
|
||||
User: dp.Employee.User,
|
||||
Person_Id: dp.Employee.Person_Id,
|
||||
Person: dp.Employee.Person,
|
||||
Number: dp.Employee.Number,
|
||||
Status_Code: dp.Employee.Status_Code,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
mwRunner.setMwType(pu.MWTPost)
|
||||
// Run post-middleware
|
||||
if err := mwRunner.RunReadDetailMiddleware(readDetailPostMw, &input, data); err != nil {
|
||||
@@ -198,7 +161,7 @@ func ReadDetail(input e.ReadDetailDto) (*d.Data, error) {
|
||||
"structure": "single-data",
|
||||
"status": "fetched",
|
||||
},
|
||||
Data: data.ToResponse(dataDP),
|
||||
Data: data.ToResponse(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -253,7 +216,7 @@ func Update(input e.UpdateDto) (*d.Data, error) {
|
||||
"structure": "single-data",
|
||||
"status": "updated",
|
||||
},
|
||||
Data: data.ToResponse(nil),
|
||||
Data: data.ToResponse(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
@@ -307,7 +270,7 @@ func Delete(input e.DeleteDto) (*d.Data, error) {
|
||||
"structure": "single-data",
|
||||
"status": "deleted",
|
||||
},
|
||||
Data: data.ToResponse(nil),
|
||||
Data: data.ToResponse(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Employee) {
|
||||
|
||||
data.User_Id = inputSrc.User_Id
|
||||
data.Person_Id = inputSrc.Person_Id
|
||||
data.Division_Code = inputSrc.Division_Code
|
||||
data.Number = inputSrc.Number
|
||||
data.Status_Code = inputSrc.Status_Code
|
||||
data.Position_Code = inputSrc.Position_Code
|
||||
|
||||
@@ -81,7 +81,9 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e
|
||||
tx = dg.I
|
||||
}
|
||||
|
||||
if err := tx.First(&data, input.Id).Error; err != nil {
|
||||
if err := tx.
|
||||
Scopes(gh.Preload(input.Includes)).
|
||||
First(&data, input.Id).Error; err != nil {
|
||||
if processedErr := pu.HandleReadError(err, event, source, input.Id, data); processedErr != nil {
|
||||
return nil, processedErr
|
||||
}
|
||||
|
||||
@@ -81,7 +81,9 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e
|
||||
tx = dg.I
|
||||
}
|
||||
|
||||
if err := tx.First(&data, input.Id).Error; err != nil {
|
||||
if err := tx.
|
||||
Scopes(gh.Preload(input.Includes)).
|
||||
First(&data, input.Id).Error; err != nil {
|
||||
if processedErr := pu.HandleReadError(err, event, source, input.Id, data); processedErr != nil {
|
||||
return nil, processedErr
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@ func setDataEmployeeUpdate(src e.EmployeUpdateDto) ee.UpdateDto {
|
||||
CreateDto: ee.CreateDto{
|
||||
User_Id: src.User_Id,
|
||||
Person_Id: src.Person_Id,
|
||||
Division_Code: src.Division_Code,
|
||||
Number: src.Number,
|
||||
Status_Code: src.Status_Code,
|
||||
Position_Code: &src.Position_Code,
|
||||
|
||||
Reference in New Issue
Block a user