get_sop_task_detail_logic.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package sop_task
  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/ent/soptask"
  7. "wechat-api/internal/utils/dberrorhandler"
  8. "wechat-api/internal/svc"
  9. "wechat-api/internal/types"
  10. "github.com/zeromicro/go-zero/core/logx"
  11. )
  12. type GetSopTaskDetailLogic struct {
  13. logx.Logger
  14. ctx context.Context
  15. svcCtx *svc.ServiceContext
  16. }
  17. func NewGetSopTaskDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetSopTaskDetailLogic {
  18. return &GetSopTaskDetailLogic{
  19. Logger: logx.WithContext(ctx),
  20. ctx: ctx,
  21. svcCtx: svcCtx}
  22. }
  23. func (l *GetSopTaskDetailLogic) GetSopTaskDetail(req *types.IDReq) (resp *types.SopTaskInfoResp, err error) {
  24. organizationId := l.ctx.Value("organizationId").(uint64)
  25. data, err := l.svcCtx.DB.SopTask.Query().
  26. Where(soptask.ID(req.Id), soptask.OrganizationIDEQ(organizationId)).
  27. WithTaskStages().
  28. Only(l.ctx)
  29. if err != nil {
  30. return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
  31. }
  32. return &types.SopTaskInfoResp{
  33. BaseDataInfo: types.BaseDataInfo{
  34. Code: 0,
  35. Msg: errormsg.Success,
  36. },
  37. Data: types.SopTaskInfo{
  38. BaseIDInfo: types.BaseIDInfo{
  39. Id: &data.ID,
  40. CreatedAt: pointy.GetPointer(data.CreatedAt.UnixMilli()),
  41. UpdatedAt: pointy.GetPointer(data.UpdatedAt.UnixMilli()),
  42. },
  43. Status: &data.Status,
  44. Name: &data.Name,
  45. BotWxidList: data.BotWxidList,
  46. Type: &data.Type,
  47. PlanStartTime: pointy.GetUnixMilliPointer(data.PlanStartTime.UnixMilli()),
  48. PlanEndTime: pointy.GetUnixMilliPointer(data.PlanEndTime.UnixMilli()),
  49. CreatorId: &data.CreatorID,
  50. },
  51. }, nil
  52. }