Explorar el Código

修复 wx/create 接口

boweniac hace 9 meses
padre
commit
92a44c85b5
Se han modificado 3 ficheros con 8 adiciones y 6 borrados
  1. 1 1
      desc/wechat/wx.api
  2. 6 4
      internal/logic/Wx/create_wx_logic.go
  3. 1 1
      internal/types/types.go

+ 1 - 1
desc/wechat/wx.api

@@ -40,7 +40,7 @@ type (
         OrganizationId *uint64 `json:"organizationId,optional"`
 
 		// 模式ID
-		AgentId *uint64 `json:"agentId"`
+		AgentId *uint64 `json:"agentId,optional"`
 
 		// 模式信息
 		AgentInfo *AgentInfo `json:"agentInfo,optional"`

+ 6 - 4
internal/logic/Wx/create_wx_logic.go

@@ -53,9 +53,11 @@ func (l *CreateWxLogic) CreateWx(req *types.WxInfo) (*types.BaseMsgResp, error)
 	}
 
 	// 判断所选模式是否可用
-	agent, err := l.svcCtx.DB.Agent.Query().Where(agentModel.Status(1), agentModel.ID(*req.AgentId)).First(l.ctx)
-	if err != nil && ent.IsNotFound(err) || agent == nil {
-		return nil, errors.New("所选模式不存在或者已被禁用,请选择其他模式")
+	if req.AgentId != nil {
+		agent, err := l.svcCtx.DB.Agent.Query().Where(agentModel.Status(1), agentModel.ID(*req.AgentId)).First(l.ctx)
+		if err != nil && ent.IsNotFound(err) || agent == nil {
+			return nil, errors.New("所选模式不存在或者已被禁用,请选择其他模式")
+		}
 	}
 
 	loginStatus, err := hook.IsLoginStatus()
@@ -92,7 +94,7 @@ func (l *CreateWxLogic) CreateWx(req *types.WxInfo) (*types.BaseMsgResp, error)
 				SetNotNilHeadBig(&selfInfo.HeadBig).
 				SetStatus(1).
 				SetOrganizationID(organizationId).
-				SetAgentID(*req.AgentId).
+				SetNotNilAgentID(req.AgentId).
 				Save(l.ctx)
 		} else {
 			if req.Callback != nil && *req.Callback != "" {

+ 1 - 1
internal/types/types.go

@@ -314,7 +314,7 @@ type WxInfo struct {
 	// 组织ID
 	OrganizationId *uint64 `json:"organizationId,optional"`
 	// 模式ID
-	AgentId *uint64 `json:"agentId"`
+	AgentId *uint64 `json:"agentId,optional"`
 	// 模式信息
 	AgentInfo *AgentInfo `json:"agentInfo,optional"`
 }