get_sop_task_detail_logic.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. data, err := l.svcCtx.DB.SopTask.Query().
  25. Where(soptask.ID(req.Id)).
  26. WithTaskStages().
  27. Only(l.ctx)
  28. if err != nil {
  29. return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
  30. }
  31. return &types.SopTaskInfoResp{
  32. BaseDataInfo: types.BaseDataInfo{
  33. Code: 0,
  34. Msg: errormsg.Success,
  35. },
  36. Data: types.SopTaskInfo{
  37. BaseIDInfo: types.BaseIDInfo{
  38. Id: &data.ID,
  39. CreatedAt: pointy.GetPointer(data.CreatedAt.UnixMilli()),
  40. UpdatedAt: pointy.GetPointer(data.UpdatedAt.UnixMilli()),
  41. },
  42. Status: &data.Status,
  43. Name: &data.Name,
  44. BotWxidList: data.BotWxidList,
  45. Type: &data.Type,
  46. PlanStartTime: pointy.GetUnixMilliPointer(data.PlanStartTime.UnixMilli()),
  47. PlanEndTime: pointy.GetUnixMilliPointer(data.PlanEndTime.UnixMilli()),
  48. CreatorId: &data.CreatorID,
  49. },
  50. }, nil
  51. }