Эх сурвалжийг харах

fix:edit api/sop_node/list

jimmyyem 5 сар өмнө
parent
commit
aba0c750b7

+ 1 - 1
desc/wechat/sop_node.api

@@ -15,7 +15,7 @@ type (
 		BaseDataInfo
 
 		// SopNode list data | SopNode列表数据
-		Data []*SopNodeInfo `json:"data"`
+		Data []*SopNodeInfoWithLable `json:"data"`
 	}
 
     // SopNode list data | SopNode列表数据

+ 44 - 0
desc/wechat/sop_stage.api

@@ -121,6 +121,50 @@ type (
         StageInfo  *SopStageInfo `json:"stageInfo,optional"`
     }
 
+	// The response data of sop node information | SopNode信息
+	SopNodeInfoWithLable {
+		BaseIDInfo
+
+		// Status 1: normal 2: ban | 状态 1 正常 2 禁用
+		Status  *uint8 `json:"status,optional"`
+
+		// 阶段 ID
+		StageId  *uint64 `json:"stageId,optional"`
+
+		// 父节点 ID
+		ParentId  *uint64 `json:"parentId,optional"`
+
+		// 节点名称
+		Name  *string `json:"name,optional"`
+
+		// 触发条件类型 1 客户回复后触发 2 超时后触发
+		ConditionType  *int `json:"conditionType,optional"`
+
+		// 触发语义列表 当为空时则代表用户回复任意内容后触发
+		ConditionList  []string `json:"conditionList,optional"`
+
+		// 超时触发时间(分钟)
+		NoReplyCondition  *uint64 `json:"noReplyCondition,optional"`
+
+		// 超时触发时间单位
+		NoReplyUnit  *string `json:"noReplyUnit,optional"`
+
+		// 命中后发送的消息内容
+		ActionMessage  []Action `json:"actionMessage,optional"`
+
+		// 命中后需要打的标签
+		ActionLabelAdd  []uint64 `json:"actionLabelAdd,optional"`
+
+		// 命中后需要移除的标签
+		ActionLabelDel  []uint64 `json:"actionLabelDel,optional"`
+
+		// 命中后转发的消息内容
+		ActionForward  *ActionForward `json:"actionForward,optional"`
+
+		ActionLabelAddList []string  `json:"actionLabelAddList"`
+		ActionLabelDelList  []string `json:"actionLabelDelList"`
+	}
+
     // The response data of sop stage list | SopStage列表数据
     SopStageListResp {
         BaseDataInfo

+ 37 - 16
internal/logic/sop_node/get_api_sop_node_list_logic.go

@@ -8,6 +8,7 @@ import (
 	"github.com/zeromicro/go-zero/core/errorx"
 	"net/http"
 	"wechat-api/ent"
+	"wechat-api/ent/label"
 	"wechat-api/ent/predicate"
 	"wechat-api/ent/sopnode"
 	"wechat-api/hook"
@@ -54,16 +55,16 @@ func (l *GetApiSopNodeListLogic) GetApiSopNodeList(req *types.BatchSopNodeListRe
 	resp := &types.SopNodeListResp2{}
 	resp.Msg = errormsg.Success
 
-	childNodeList, _ := getSopNodeList(data)
+	childNodeList, _ := getSopNodeList(l, data)
 	resp.Data = childNodeList
 
 	return resp, nil
 }
 
 // 从node列表中找到指定 ParentId 的所有节点
-func getSopNodeList(nodeList []*ent.SopNode) ([]*types.SopNodeInfo, error) {
+func getSopNodeList(l *GetApiSopNodeListLogic, nodeList []*ent.SopNode) ([]*types.SopNodeInfoWithLable, error) {
 	// 遍历 nodeList 找到 ParentId 为指定 parentId 的所有节点
-	var result []*types.SopNodeInfo
+	var result []*types.SopNodeInfoWithLable
 	for _, node := range nodeList {
 		var actionMessage []types.Action
 		if len(node.ActionMessage) > 0 {
@@ -94,24 +95,44 @@ func getSopNodeList(nodeList []*ent.SopNode) ([]*types.SopNodeInfo, error) {
 			actionForward = nil
 		}
 
-		child := types.SopNodeInfo{
+		actionLabelAddList := make([]string, 0)
+		labelList, err := l.svcCtx.DB.Label.Query().Where(label.IDIn(node.ActionLabelAdd...)).All(l.ctx)
+		if err != nil {
+			return nil, dberrorhandler.DefaultEntError(l.Logger, err, nil)
+		}
+		for _, val := range labelList {
+			actionLabelAddList = append(actionLabelAddList, val.Name)
+		}
+
+		actionLabelDelList := make([]string, 0)
+		labelList, err = l.svcCtx.DB.Label.Query().Where(label.IDIn(node.ActionLabelAdd...)).All(l.ctx)
+		if err != nil {
+			return nil, dberrorhandler.DefaultEntError(l.Logger, err, nil)
+		}
+		for _, val := range labelList {
+			actionLabelDelList = append(actionLabelDelList, val.Name)
+		}
+
+		child := types.SopNodeInfoWithLable{
 			BaseIDInfo: types.BaseIDInfo{
 				Id:        &node.ID,
 				CreatedAt: pointy.GetPointer(node.CreatedAt.UnixMilli()),
 				UpdatedAt: pointy.GetPointer(node.UpdatedAt.UnixMilli()),
 			},
-			Status:           &node.Status,
-			StageId:          &node.StageID,
-			ParentId:         &node.ParentID,
-			Name:             &node.Name,
-			ConditionType:    &node.ConditionType,
-			ConditionList:    node.ConditionList,
-			NoReplyCondition: &node.NoReplyCondition,
-			NoReplyUnit:      &node.NoReplyUnit,
-			ActionMessage:    actionMessage,
-			ActionLabelAdd:   node.ActionLabelAdd,
-			ActionLabelDel:   node.ActionLabelDel,
-			ActionForward:    actionForward,
+			Status:             &node.Status,
+			StageId:            &node.StageID,
+			ParentId:           &node.ParentID,
+			Name:               &node.Name,
+			ConditionType:      &node.ConditionType,
+			ConditionList:      node.ConditionList,
+			NoReplyCondition:   &node.NoReplyCondition,
+			NoReplyUnit:        &node.NoReplyUnit,
+			ActionMessage:      actionMessage,
+			ActionLabelAdd:     node.ActionLabelAdd,
+			ActionLabelDel:     node.ActionLabelDel,
+			ActionForward:      actionForward,
+			ActionLabelAddList: actionLabelAddList,
+			ActionLabelDelList: actionLabelDelList,
 		}
 		result = append(result, &child)
 

+ 32 - 1
internal/types/types.go

@@ -1311,6 +1311,37 @@ type SopNodeInfo struct {
 	StageInfo *SopStageInfo `json:"stageInfo,optional"`
 }
 
+// The response data of sop node information | SopNode信息
+type SopNodeInfoWithLable struct {
+	BaseIDInfo
+	// Status 1: normal 2: ban | 状态 1 正常 2 禁用
+	Status *uint8 `json:"status,optional"`
+	// 阶段 ID
+	StageId *uint64 `json:"stageId,optional"`
+	// 父节点 ID
+	ParentId *uint64 `json:"parentId,optional"`
+	// 节点名称
+	Name *string `json:"name,optional"`
+	// 触发条件类型 1 客户回复后触发 2 超时后触发
+	ConditionType *int `json:"conditionType,optional"`
+	// 触发语义列表 当为空时则代表用户回复任意内容后触发
+	ConditionList []string `json:"conditionList,optional"`
+	// 超时触发时间(分钟)
+	NoReplyCondition *uint64 `json:"noReplyCondition,optional"`
+	// 超时触发时间单位
+	NoReplyUnit *string `json:"noReplyUnit,optional"`
+	// 命中后发送的消息内容
+	ActionMessage []Action `json:"actionMessage,optional"`
+	// 命中后需要打的标签
+	ActionLabelAdd []uint64 `json:"actionLabelAdd,optional"`
+	// 命中后需要移除的标签
+	ActionLabelDel []uint64 `json:"actionLabelDel,optional"`
+	// 命中后转发的消息内容
+	ActionForward      *ActionForward `json:"actionForward,optional"`
+	ActionLabelAddList []string       `json:"actionLabelAddList"`
+	ActionLabelDelList []string       `json:"actionLabelDelList"`
+}
+
 // The response data of sop stage list | SopStage列表数据
 // swagger:model SopStageListResp
 type SopStageListResp struct {
@@ -1375,7 +1406,7 @@ type SopNodeListResp struct {
 type SopNodeListResp2 struct {
 	BaseDataInfo
 	// SopNode list data | SopNode列表数据
-	Data []*SopNodeInfo `json:"data"`
+	Data []*SopNodeInfoWithLable `json:"data"`
 }
 
 // SopNode list data | SopNode列表数据