56 lines
1.4 KiB
Go
56 lines
1.4 KiB
Go
package accountlogic
|
|
|
|
import (
|
|
"context"
|
|
|
|
"code.30cm.net/digimon/app-cloudep-member-server/pkg/domain/usecase"
|
|
"code.30cm.net/digimon/library-go/errs"
|
|
|
|
"code.30cm.net/digimon/app-cloudep-member-server/gen_result/pb/member"
|
|
"code.30cm.net/digimon/app-cloudep-member-server/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 getUserAccountInfoReq struct {
|
|
Account string `validate:"required"`
|
|
}
|
|
|
|
// GetUserAccountInfo 取得帳號密碼資料
|
|
func (l *GetUserAccountInfoLogic) GetUserAccountInfo(in *member.GetUIDByAccountReq) (*member.GetAccountInfoResp, error) {
|
|
if err := l.svcCtx.Validate.ValidateAll(&getUserAccountInfoReq{
|
|
Account: in.GetAccount(),
|
|
}); err != nil {
|
|
return nil, errs.InvalidFormat(err.Error())
|
|
}
|
|
|
|
info, err := l.svcCtx.AccountUseCase.GetUserAccountInfo(l.ctx, usecase.GetUIDByAccountRequest{
|
|
Account: in.GetAccount(),
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &member.GetAccountInfoResp{
|
|
Data: &member.CreateLoginUserReq{
|
|
LoginId: info.Data.LoginID,
|
|
Token: info.Data.Token,
|
|
Platform: info.Data.Platform.ToInt64(),
|
|
},
|
|
}, nil
|
|
}
|