Prechádzať zdrojové kódy

fix:edit employee/search

jimmyyem 2 mesiacov pred
rodič
commit
ffd2c60390

+ 11 - 5
internal/logic/employee/get_employee_search_logic.go

@@ -4,11 +4,13 @@ import (
 	"context"
 	"github.com/suyuan32/simple-admin-common/msg/errormsg"
 	"github.com/suyuan32/simple-admin-common/utils/pointy"
+	"github.com/suyuan32/simple-admin-core/rpc/types/core"
 	"wechat-api/ent"
 	"wechat-api/ent/allocagent"
 	"wechat-api/ent/employee"
 	"wechat-api/ent/employeeconfig"
 	"wechat-api/ent/predicate"
+	"wechat-api/internal/utils"
 	"wechat-api/internal/utils/dberrorhandler"
 	jwtutils "wechat-api/internal/utils/jwt"
 
@@ -41,13 +43,17 @@ func (l *GetEmployeeSearchLogic) GetEmployeeSearch(req *types.EmployeeListReq, t
 	}
 
 	var userId string
-	var departmentId float64
 	var organizationID uint64
 	if _, ok := claims["userId"]; ok {
 		userId = claims["userId"].(string)
-		departmentId = claims["deptId"].(float64)
-		organizationID = uint64(departmentId)
-		isLogin = true
+		if userId != "" {
+			userInfo, _ := l.svcCtx.CoreRpc.GetUserById(l.ctx, &core.UUIDReq{Id: userId})
+			valid := utils.CheckGptLogin(userInfo.RoleIds)
+			if valid {
+				organizationID = *userInfo.DepartmentId
+				isLogin = true
+			}
+		}
 	}
 
 	employeeIds := make([]uint64, 0)
@@ -60,7 +66,7 @@ func (l *GetEmployeeSearchLogic) GetEmployeeSearch(req *types.EmployeeListReq, t
 			employeeIds = append(employeeIds, allocAgentItem.Agents...)
 		}
 
-		if len(employeeIds) == 0 {
+		if len(employeeIds) == 0 && organizationID > 0 {
 			allocAgentItem, err = l.svcCtx.DB.AllocAgent.Query().Where(
 				allocagent.OrganizationID(organizationID),
 			).First(l.ctx)