Browse Source

fix:edit employee API

jimmyyem 7 months ago
parent
commit
0b15ea63da

+ 2 - 2
internal/logic/employee/get_employee_by_id_logic.go

@@ -36,7 +36,7 @@ func (l *GetEmployeeByIdLogic) GetEmployeeById(req *types.IDReq) (*types.Employe
 		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
 	}
 
-	workExperience := make([]types.WorkExperienceInfo, 0)
+	workExperience := make([]types.WorkExperienceInfo, 0, len(data.Edges.EmWorkExperiences))
 	for _, work := range data.Edges.EmWorkExperiences {
 		workExperience = append(workExperience, types.WorkExperienceInfo{
 			BaseIDInfo: types.BaseIDInfo{
@@ -54,7 +54,7 @@ func (l *GetEmployeeByIdLogic) GetEmployeeById(req *types.IDReq) (*types.Employe
 		})
 	}
 
-	tutorial := make([]types.TutorialInfo, 0)
+	tutorial := make([]types.TutorialInfo, 0, len(data.Edges.EmTutorial))
 	for _, tt := range data.Edges.EmTutorial {
 		tutorial = append(tutorial, types.TutorialInfo{
 			BaseIDInfo: types.BaseIDInfo{

+ 2 - 2
internal/logic/employee/get_employee_list_logic.go

@@ -52,7 +52,7 @@ func (l *GetEmployeeListLogic) GetEmployeeList(req *types.EmployeeListReq) (*typ
 	resp.Data.Total = data.PageDetails.Total
 
 	for _, v := range data.List {
-		workExperience := make([]types.WorkExperienceInfo, 0)
+		workExperience := make([]types.WorkExperienceInfo, 0, len(v.Edges.EmWorkExperiences))
 		for _, work := range v.Edges.EmWorkExperiences {
 			workExperience = append(workExperience, types.WorkExperienceInfo{
 				BaseIDInfo: types.BaseIDInfo{
@@ -70,7 +70,7 @@ func (l *GetEmployeeListLogic) GetEmployeeList(req *types.EmployeeListReq) (*typ
 			})
 		}
 
-		tutorial := make([]types.TutorialInfo, 0)
+		tutorial := make([]types.TutorialInfo, 0, len(v.Edges.EmTutorial))
 		for _, tt := range v.Edges.EmTutorial {
 			tutorial = append(tutorial, types.TutorialInfo{
 				BaseIDInfo: types.BaseIDInfo{