|
@@ -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)
|
|
|
|