Explorar o código

fix:修复sop_task bug

jimmyyem hai 1 mes
pai
achega
e88116a39b

+ 2 - 2
desc/openapi/chat.api

@@ -86,8 +86,8 @@ type (
     }
 
 	FastgptSpecResp {
-		ResponseData []map[string]any `json:"responseData,omitempty"`
-		NewVariables map[string]any `json:"newVariables,omitempty"`
+		ResponseData []map[string]interface{} `json:"responseData,omitempty"`
+		NewVariables map[string]interface{} `json:"newVariables,omitempty"`
 	}
 	
 	ChatCompletionAudio {

+ 1 - 2
desc/wechat/sop_task.api

@@ -57,8 +57,7 @@ type (
         // SOP 任务名称 
         Name  *string `json:"name,optional"`
 
-        // 创建者 id 
-        CreatorId  *string `json:"creatorId,optional"`
+        Status  *uint8 `json:"status,optional"`
     }
 
     // SopTask information response | SopTask信息返回体

+ 2 - 2
internal/logic/sop_task/get_sop_task_list_logic.go

@@ -36,8 +36,8 @@ func (l *GetSopTaskListLogic) GetSopTaskList(req *types.SopTaskListReq) (*types.
 	if req.Name != nil {
 		predicates = append(predicates, soptask.NameContains(*req.Name))
 	}
-	if req.CreatorId != nil {
-		predicates = append(predicates, soptask.CreatorIDContains(*req.CreatorId))
+	if req.Status != nil && *req.Status > 0 {
+		predicates = append(predicates, soptask.Status(*req.Status))
 	}
 	data, err := l.svcCtx.DB.SopTask.Query().Where(predicates...).Page(l.ctx, req.Page, req.PageSize)
 

+ 8 - 0
internal/logic/sop_task/publish_sop_task_logic.go

@@ -4,6 +4,7 @@ import (
 	"context"
 	"errors"
 	"github.com/suyuan32/simple-admin-common/msg/errormsg"
+	"github.com/zeromicro/go-zero/core/errorx"
 	"regexp"
 	"strconv"
 	"strings"
@@ -65,6 +66,13 @@ func (l *PublishSopTaskLogic) PublishSopTask(req *types.IDReq) (resp *types.Base
 			return nil, errors.New(errormsg.ValidationError)
 		}
 
+		if len(sopTask.BotWxidList) == 0 {
+			return nil, errorx.NewInvalidArgumentError("发信人不能为空")
+		}
+		if len(sopTask.Edges.TaskStages) == 0 {
+			return nil, errorx.NewInvalidArgumentError("SOP阶段不能为空")
+		}
+
 		// 查询任务的所有 sop_stages
 		err = l.svcCtx.DB.SopTask.UpdateOneID(req.Id).
 			SetStatus(3).

+ 4 - 0
internal/logic/sop_task/update_sop_task_logic.go

@@ -36,6 +36,10 @@ func (l *UpdateSopTaskLogic) UpdateSopTask(req *types.SopTaskInfo) (*types.BaseM
 		return nil, dberrorhandler.DefaultEntError(l.Logger, fmt.Errorf("planEndTime must be greater than planStartTime"), req)
 	}
 
+	if len(req.BotWxidList) == 0 {
+		return nil, errorx.NewInvalidArgumentError("发信人不能为空")
+	}
+
 	err := l.svcCtx.DB.SopTask.UpdateOneID(*req.Id).
 		Where(soptask.StatusEQ(1), soptask.OrganizationID(organizationId)).
 		SetNotNilStatus(req.Status).

+ 4 - 5
internal/types/types.go

@@ -1280,9 +1280,8 @@ type SopTaskListInfo struct {
 type SopTaskListReq struct {
 	PageInfo
 	// SOP 任务名称
-	Name *string `json:"name,optional"`
-	// 创建者 id
-	CreatorId *string `json:"creatorId,optional"`
+	Name   *string `json:"name,optional"`
+	Status *uint8  `json:"status,optional"`
 }
 
 // SopTask information response | SopTask信息返回体
@@ -1986,8 +1985,8 @@ type StdCompApiResp struct {
 
 // swagger:model FastgptSpecResp
 type FastgptSpecResp struct {
-	ResponseData []map[string]any `json:"responseData,omitempty"`
-	NewVariables map[string]any   `json:"newVariables,omitempty"`
+	ResponseData []map[string]interface{} `json:"responseData,omitempty"`
+	NewVariables map[string]interface{}   `json:"newVariables,omitempty"`
 }
 
 type ChatCompletionAudio struct {