feat: openid login
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"lone-services/pkg/utils"
|
||||
"lone-services/pkg/validate"
|
||||
sale "lone-services/rpc/sale/pb"
|
||||
"lone-services/services/sale/internal/svc"
|
||||
"lone-services/services/sale/validator"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
type InfoByUserIdLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewInfoByUserIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InfoByUserIdLogic {
|
||||
return &InfoByUserIdLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *InfoByUserIdLogic) InfoByUserId(in *sale.InfoByUserIdReq) (*sale.InfoData, error) {
|
||||
var req validator.InfoByUserIdValidator
|
||||
if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty {
|
||||
return nil, status.Error(codes.InvalidArgument, msg)
|
||||
}
|
||||
|
||||
info, err := querySaleInfoByUserId(req.UserId)
|
||||
if err != nil {
|
||||
l.Errorf("sale InfoByUserId: %v", err)
|
||||
return nil, status.Error(codes.Internal, utils.Fail.Msg)
|
||||
}
|
||||
if info == nil {
|
||||
return nil, status.Error(codes.NotFound, utils.ErrorNotFund.Msg)
|
||||
}
|
||||
|
||||
return toSaleInfoData(info), nil
|
||||
}
|
||||
Reference in New Issue
Block a user