1、新增自定义用户私人价格2、优化api服务鉴权缓存3、新增管理员端对公充值

This commit is contained in:
2024-10-21 16:01:20 +08:00
parent 8896fd6b30
commit 2292d25d74
37 changed files with 1903 additions and 907 deletions

View File

@@ -0,0 +1,63 @@
package userlogic
import (
"context"
"tianyuan-api/apps/user/internal/svc"
"tianyuan-api/apps/user/user"
"github.com/zeromicro/go-zero/core/logx"
)
type GetUserListLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetUserListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserListLogic {
return &GetUserListLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *GetUserListLogic) GetUserList(in *user.UserListRequest) (*user.UserListResponse, error) {
list, total, err := l.svcCtx.UserModel.FindUserPageList(l.ctx, in.Page, in.PageSize)
if err != nil {
return nil, err
}
userIds := make([]int64, len(list))
for i, userItem := range list {
userIds[i] = userItem.Id
}
walletMap, err := l.svcCtx.WalletsModel.FindWalletsByUserIds(l.ctx, userIds)
if err != nil {
return nil, err
}
var userList []*user.UserItem
for _, userItem := range list {
balance := float64(0)
if wallet, ok := walletMap[userItem.Id]; ok {
balance = wallet.Balance
}
userList = append(userList, &user.UserItem{
Id: userItem.Id,
Username: userItem.Username,
Phone: userItem.Phone,
Disable: userItem.Disable,
QuotaExceeded: userItem.QuotaExceeded,
Balance: balance,
CreatedAt: userItem.CreatedAt.Format("2006-01-02 15:04:05"),
UpdatedAt: userItem.UpdatedAt.Format("2006-01-02 15:04:05"),
})
}
return &user.UserListResponse{
List: userList,
Total: total,
}, nil
}