1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- package credit_usage
- import (
- "context"
- "wechat-api/internal/svc"
- "wechat-api/internal/types"
- "wechat-api/internal/utils/dberrorhandler"
- "github.com/suyuan32/simple-admin-common/msg/errormsg"
- "github.com/suyuan32/simple-admin-common/utils/pointy"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type GetCreditUsageByIdLogic struct {
- ctx context.Context
- svcCtx *svc.ServiceContext
- logx.Logger
- }
- func NewGetCreditUsageByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetCreditUsageByIdLogic {
- return &GetCreditUsageByIdLogic{
- ctx: ctx,
- svcCtx: svcCtx,
- Logger: logx.WithContext(ctx),
- }
- }
- func (l *GetCreditUsageByIdLogic) GetCreditUsageById(req *types.IDReq) (*types.CreditUsageInfoResp, error) {
- data, err := l.svcCtx.DB.CreditUsage.Get(l.ctx, req.Id)
- if err != nil {
- return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
- }
- return &types.CreditUsageInfoResp{
- BaseDataInfo: types.BaseDataInfo{
- Code: 0,
- Msg: errormsg.Success,
- },
- Data: types.CreditUsageInfo{
- BaseIDInfo: types.BaseIDInfo{
- Id: &data.ID,
- CreatedAt: pointy.GetPointer(data.CreatedAt.UnixMilli()),
- UpdatedAt: pointy.GetPointer(data.UpdatedAt.UnixMilli()),
- },
- UserId: &data.UserID,
- Number: &data.Number,
- Status: &data.Status,
- Ntype: &data.Ntype,
- Table: &data.Table,
- OrganizationId: &data.OrganizationID,
- Nid: &data.Nid,
- Reason: &data.Reason,
- Operator: &data.Operator,
- },
- }, nil
- }
|