package logic import ( "context" "member/gen_result/pb/member" "member/internal/domain" ers "member/internal/lib/error" "member/internal/svc" "github.com/zeromicro/go-zero/core/logx" ) type GetUserAccountInfoLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } func NewGetUserAccountInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserAccountInfoLogic { return &GetUserAccountInfoLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } type getUserAccountReq struct { LoginId string `json:"login_id" validate:"account"` } // GetUserAccountInfo 取得帳號密碼資料 func (l *GetUserAccountInfoLogic) GetUserAccountInfo(in *member.GetUIDByAccountReq) (*member.GetAccountInfoResp, error) { // 驗證資料 if err := l.svcCtx.Validate.ValidateAll(getUserAccountReq{ LoginId: in.GetAccount(), }); err != nil { return nil, ers.InvalidFormat(err.Error()) } account, err := l.svcCtx.AccountModel.FindOneByAccount(l.ctx, in.GetAccount()) if err != nil { return nil, ers.DBError(err.Error()) } return &member.GetAccountInfoResp{ Status: &member.BaseResp{ Code: domain.CodeOk.ToString(), }, Data: &member.CreateLoginUserReq{ LoginId: account.Account, Token: account.Token, Platform: account.Platform, }, }, nil }