Pārlūkot izejas kodu

fix:edit employee/search

jimmyyem 3 mēneši atpakaļ
vecāks
revīzija
888c877d20
1 mainītis faili ar 11 papildinājumiem un 11 dzēšanām
  1. 11 11
      internal/logic/employee/get_employee_search_logic.go

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

@@ -4,7 +4,6 @@ import (
 	"context"
 	"github.com/suyuan32/simple-admin-common/msg/errormsg"
 	"github.com/suyuan32/simple-admin-common/utils/pointy"
-	"github.com/zeromicro/go-zero/core/errorx"
 	"wechat-api/ent"
 	"wechat-api/ent/allocagent"
 	"wechat-api/ent/employee"
@@ -54,20 +53,21 @@ func (l *GetEmployeeSearchLogic) GetEmployeeSearch(req *types.EmployeeListReq, t
 	employeeIds := make([]uint64, 0)
 	if isLogin {
 		allocAgentItem, err := l.svcCtx.DB.AllocAgent.Query().Where(
-			allocagent.Or(
-				allocagent.UserIDEQ(userId),
-				allocagent.OrganizationID(organizationID),
-			),
+			allocagent.UserIDEQ(userId),
 		).Only(l.ctx)
-		if err != nil {
-			l.Logger.Errorf("getEmployeeSearch err: %v", err)
-			if !ent.IsNotFound(err) {
-				return nil, errorx.NewApiInternalError("获取智能体信息失败")
-			}
 
-		} else {
+		if err == nil && len(allocAgentItem.Agents) > 0 {
 			employeeIds = append(employeeIds, allocAgentItem.Agents...)
 		}
+
+		if len(employeeIds) == 0 {
+			allocAgentItem, err = l.svcCtx.DB.AllocAgent.Query().Where(
+				allocagent.OrganizationID(organizationID),
+			).First(l.ctx)
+			if err == nil && len(allocAgentItem.Agents) > 0 {
+				employeeIds = append(employeeIds, allocAgentItem.Agents...)
+			}
+		}
 	}
 
 	var data *ent.EmployeePageList