Browse Source

fix:optimize employee API

jimmyyem 7 months ago
parent
commit
52aa92734f

+ 7 - 1
internal/logic/employee/get_employee_by_id_logic.go

@@ -120,12 +120,18 @@ func FormatIds(str string) []uint64 {
 }
 
 func getEmployeeConfigList(l *GetEmployeeByIdLogic, ids string) []types.EmployeeConfigInfo {
+	sceneList := make([]types.EmployeeConfigInfo, 0)
+
 	sceneIds := FormatIds(ids)
+
+	if len(sceneIds) == 0 {
+		return sceneList
+	}
+
 	employeeConfigList, err := l.svcCtx.DB.EmployeeConfig.Query().Where(
 		employeeconfig.IDIn(sceneIds...),
 	).All(l.ctx)
 
-	sceneList := make([]types.EmployeeConfigInfo, 0)
 	if err == nil && len(employeeConfigList) > 0 {
 		for _, val := range employeeConfigList {
 			sceneList = append(sceneList, types.EmployeeConfigInfo{

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

@@ -120,12 +120,17 @@ func (l *GetEmployeeListLogic) GetEmployeeList(req *types.EmployeeListReq) (*typ
 }
 
 func getEmployeeConfigListByIds(l *GetEmployeeListLogic, ids string) []types.EmployeeConfigInfo {
+	sceneList := make([]types.EmployeeConfigInfo, 0)
+
 	sceneIds := FormatIds(ids)
+
+	if len(sceneIds) == 0 {
+		return sceneList
+	}
+
 	employeeConfigList, err := l.svcCtx.DB.EmployeeConfig.Query().Where(
 		employeeconfig.IDIn(sceneIds...),
 	).All(l.ctx)
-
-	sceneList := make([]types.EmployeeConfigInfo, 0)
 	if err == nil && len(employeeConfigList) > 0 {
 		for _, val := range employeeConfigList {
 			sceneList = append(sceneList, types.EmployeeConfigInfo{