get_xunji_by_id_logic.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package xunji
  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 GetXunjiByIdLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewGetXunjiByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetXunjiByIdLogic {
  17. return &GetXunjiByIdLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx}
  21. }
  22. func (l *GetXunjiByIdLogic) GetXunjiById(req *types.IDReq) (*types.XunjiInfoResp, error) {
  23. data, err := l.svcCtx.DB.Xunji.Get(l.ctx, req.Id)
  24. if err != nil {
  25. return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
  26. }
  27. return &types.XunjiInfoResp{
  28. BaseDataInfo: types.BaseDataInfo{
  29. Code: 0,
  30. Msg: errormsg.Success,
  31. },
  32. Data: types.XunjiInfo{
  33. BaseIDInfo: types.BaseIDInfo{
  34. Id: &data.ID,
  35. CreatedAt: pointy.GetPointer(data.CreatedAt.UnixMilli()),
  36. UpdatedAt: pointy.GetPointer(data.UpdatedAt.UnixMilli()),
  37. },
  38. Status: &data.Status,
  39. AppKey: &data.AppKey,
  40. AppSecret: &data.AppSecret,
  41. Token: &data.Token,
  42. EncodingKey: &data.EncodingKey,
  43. OrganizationId: &data.OrganizationID,
  44. },
  45. }, nil
  46. }