tianyuan-api-server/apps/user/internal/logic/walletservice/getwalletlogic.go

37 lines
762 B
Go
Raw Permalink Normal View History

2024-10-12 20:41:55 +08:00
package walletservicelogic
import (
"context"
"tianyuan-api/apps/user/internal/svc"
"tianyuan-api/apps/user/user"
"github.com/zeromicro/go-zero/core/logx"
)
type GetWalletLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetWalletLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWalletLogic {
return &GetWalletLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// 查询钱包信息
func (l *GetWalletLogic) GetWallet(in *user.GetWalletRequest) (*user.GetWalletResponse, error) {
2024-10-15 23:58:36 +08:00
wallet, err := l.svcCtx.WalletsModel.FindOne(l.ctx, in.Id)
if err != nil {
return nil, err
}
return &user.GetWalletResponse{
UserId: wallet.UserId,
Balance: wallet.Balance,
}, nil
2024-10-12 20:41:55 +08:00
}