|
@@ -6,6 +6,7 @@ import (
|
|
|
"github.com/suyuan32/simple-admin-common/msg/errormsg"
|
|
|
"github.com/zeromicro/go-zero/core/errorx"
|
|
|
"net/http"
|
|
|
+ "wechat-api/ent"
|
|
|
"wechat-api/ent/predicate"
|
|
|
"wechat-api/ent/sopnode"
|
|
|
"wechat-api/hook"
|
|
@@ -30,7 +31,7 @@ func NewGetApiSopNodeListLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
|
|
svcCtx: svcCtx}
|
|
|
}
|
|
|
|
|
|
-func (l *GetApiSopNodeListLogic) GetApiSopNodeList(req *types.BatchSopNodeListReq, r *http.Request) (*types.SopNodeListResp, error) {
|
|
|
+func (l *GetApiSopNodeListLogic) GetApiSopNodeList(req *types.BatchSopNodeListReq, r *http.Request) (*types.SopNodeListResp2, error) {
|
|
|
tokenStr := r.Header.Get("Authorization")
|
|
|
_, err := hook.CheckDesktopAuth(tokenStr, l.svcCtx.DB)
|
|
|
if err != nil {
|
|
@@ -49,12 +50,68 @@ func (l *GetApiSopNodeListLogic) GetApiSopNodeList(req *types.BatchSopNodeListRe
|
|
|
return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
|
|
|
}
|
|
|
|
|
|
- resp := &types.SopNodeListResp{}
|
|
|
+ resp := &types.SopNodeListResp2{}
|
|
|
resp.Msg = errormsg.Success
|
|
|
|
|
|
- childNodeList, _ := GetSopNodeListByParentId(0, data)
|
|
|
-
|
|
|
+ childNodeList, _ := getSopNodeList(data)
|
|
|
resp.Data = childNodeList
|
|
|
|
|
|
return resp, nil
|
|
|
}
|
|
|
+
|
|
|
+// 从node列表中找到指定 ParentId 的所有节点
|
|
|
+func getSopNodeList(nodeList []*ent.SopNode) ([]*types.SopNodeInfo, error) {
|
|
|
+ // 遍历 nodeList 找到 ParentId 为指定 parentId 的所有节点
|
|
|
+ var result []*types.SopNodeInfo
|
|
|
+ for _, node := range nodeList {
|
|
|
+ var actionMessage []types.Action
|
|
|
+ if len(node.ActionMessage) > 0 {
|
|
|
+ actionMessage = make([]types.Action, len(node.ActionMessage))
|
|
|
+ for i, condition := range node.ActionMessage {
|
|
|
+ actionMessage[i] = types.Action{
|
|
|
+ Type: condition.Type,
|
|
|
+ Content: condition.Content,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var actionForward *types.ActionForward
|
|
|
+ if node.ActionForward != nil {
|
|
|
+ actionForward = &types.ActionForward{}
|
|
|
+ actionForward.Wxid = node.ActionForward.Wxid
|
|
|
+ if len(node.ActionForward.Action) > 0 {
|
|
|
+ forwardAction := make([]types.Action, len(node.ActionForward.Action))
|
|
|
+ for i, condition := range node.ActionForward.Action {
|
|
|
+ forwardAction[i] = types.Action{
|
|
|
+ Type: condition.Type,
|
|
|
+ Content: condition.Content,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ actionForward.Action = forwardAction
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ actionForward = nil
|
|
|
+ }
|
|
|
+
|
|
|
+ child := types.SopNodeInfo{
|
|
|
+ BaseIDInfo: types.BaseIDInfo{
|
|
|
+ Id: &node.ID,
|
|
|
+ },
|
|
|
+ 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,
|
|
|
+ }
|
|
|
+ result = append(result, &child)
|
|
|
+
|
|
|
+ }
|
|
|
+ return result, nil
|
|
|
+}
|