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 GetUidByAccountLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } func NewGetUidByAccountLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUidByAccountLogic { return &GetUidByAccountLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } type getUidByAccountReq struct { Account string `json:"account" validate:"account"` } // GetUidByAccount 用帳號換取 UID func (l *GetUidByAccountLogic) GetUidByAccount(in *member.GetUIDByAccountReq) (*member.GetUidByAccountResp, error) { // 驗證資料 if err := l.svcCtx.Validate.ValidateAll(&getUidByAccountReq{ Account: in.GetAccount(), }); err != nil { return nil, ers.InvalidFormat(err.Error()) } account, err := l.svcCtx.AccountToUidModel.FindOneByAccount(l.ctx, in.GetAccount()) if err != nil { return nil, err } return &member.GetUidByAccountResp{ Status: &member.BaseResp{ Code: domain.CodeOk.ToString(), Message: "success", Error: "", }, Data: &member.UID{ Uid: account.Uid, }, }, nil }