2024-08-22 14:27:13 +00:00
|
|
|
package accountlogic
|
|
|
|
|
|
|
|
import (
|
|
|
|
"app-cloudep-member-server/gen_result/pb/member"
|
2024-08-22 15:13:09 +00:00
|
|
|
"app-cloudep-member-server/internal/model"
|
2024-08-22 14:27:13 +00:00
|
|
|
"app-cloudep-member-server/internal/svc"
|
2024-08-22 15:13:09 +00:00
|
|
|
ers "code.30cm.net/digimon/library-go/errors"
|
|
|
|
"context"
|
2024-08-22 14:27:13 +00:00
|
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
2024-08-22 15:13:09 +00:00
|
|
|
"google.golang.org/protobuf/proto"
|
2024-08-22 14:27:13 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type GetUserInfoLogic struct {
|
|
|
|
ctx context.Context
|
|
|
|
svcCtx *svc.ServiceContext
|
|
|
|
logx.Logger
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewGetUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserInfoLogic {
|
|
|
|
return &GetUserInfoLogic{
|
|
|
|
ctx: ctx,
|
|
|
|
svcCtx: svcCtx,
|
|
|
|
Logger: logx.WithContext(ctx),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetUserInfo 取得會員資訊
|
|
|
|
func (l *GetUserInfoLogic) GetUserInfo(in *member.GetUserInfoReq) (*member.GetUserInfoResp, error) {
|
|
|
|
var entity *model.UserTable
|
|
|
|
var err error
|
|
|
|
|
|
|
|
if in.GetUid() != "" {
|
|
|
|
entity, err = l.svcCtx.UserModel.FindOneByUid(l.ctx, in.GetUid())
|
|
|
|
if err != nil {
|
|
|
|
return nil, ers.DBError(err.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if in.GetNickName() != "" {
|
|
|
|
entity, err = l.svcCtx.UserModel.FindOneByNickName(l.ctx, in.GetNickName())
|
|
|
|
if err != nil {
|
|
|
|
return nil, ers.DBError(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if entity != nil {
|
2024-08-22 15:13:09 +00:00
|
|
|
return &member.GetUserInfoResp{
|
|
|
|
Data: &member.UserInfo{
|
|
|
|
Uid: entity.Uid,
|
|
|
|
AlarmType: member.AlarmType(entity.AlarmType),
|
|
|
|
VerifyType: member.VerifyType(entity.VerifyType),
|
|
|
|
Status: member.MemberStatus(entity.Status),
|
|
|
|
NickName: proto.String(entity.NickName),
|
|
|
|
Language: entity.Language,
|
|
|
|
Currency: entity.Currency,
|
|
|
|
Avatar: entity.Avatar,
|
|
|
|
CreateTime: entity.CreateTime,
|
|
|
|
UpdateTime: entity.UpdateTime,
|
|
|
|
},
|
|
|
|
}, nil
|
2024-08-22 14:27:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil, ers.ResourceNotFound("filed to get user info")
|
|
|
|
}
|