get_sop_node_detail_logic.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package sop_node
  2. import (
  3. "context"
  4. "github.com/suyuan32/simple-admin-common/msg/errormsg"
  5. "github.com/suyuan32/simple-admin-common/utils/pointy"
  6. "wechat-api/internal/utils/dberrorhandler"
  7. "wechat-api/internal/svc"
  8. "wechat-api/internal/types"
  9. "github.com/zeromicro/go-zero/core/logx"
  10. )
  11. type GetSopNodeDetailLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewGetSopNodeDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetSopNodeDetailLogic {
  17. return &GetSopNodeDetailLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx}
  21. }
  22. func (l *GetSopNodeDetailLogic) GetSopNodeDetail(req *types.IDReq) (resp *types.SopNodeInfoResp, err error) {
  23. data, err := l.svcCtx.DB.SopNode.Get(l.ctx, req.Id)
  24. if err != nil {
  25. return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
  26. }
  27. var actionMessage []types.Action
  28. if len(data.ActionMessage) > 0 {
  29. actionMessage = make([]types.Action, len(data.ActionMessage))
  30. for i, condition := range data.ActionMessage {
  31. actionMessage[i] = types.Action{
  32. Type: condition.Type,
  33. Content: condition.Content,
  34. }
  35. }
  36. }
  37. return &types.SopNodeInfoResp{
  38. BaseDataInfo: types.BaseDataInfo{
  39. Code: 0,
  40. Msg: errormsg.Success,
  41. },
  42. Data: types.SopNodeInfo{
  43. BaseIDInfo: types.BaseIDInfo{
  44. Id: &data.ID,
  45. CreatedAt: pointy.GetPointer(data.CreatedAt.UnixMilli()),
  46. UpdatedAt: pointy.GetPointer(data.UpdatedAt.UnixMilli()),
  47. },
  48. Status: &data.Status,
  49. StageId: &data.StageID,
  50. ParentId: &data.ParentID,
  51. Name: &data.Name,
  52. ConditionType: &data.ConditionType,
  53. ConditionList: data.ConditionList,
  54. NoReplyCondition: &data.NoReplyCondition,
  55. ActionMessage: actionMessage,
  56. ActionLabel: data.ActionLabel,
  57. },
  58. }, nil
  59. }