feat: openid login

This commit is contained in:
zzw
2026-09-02 17:37:12 +08:00
parent 540f74f9b7
commit bb14f9e324
38 changed files with 1627 additions and 1091 deletions
+9 -5
View File
@@ -101,13 +101,17 @@ func maskSaleMobile(info *dao.SaleInfo) {
info.Mobile = utils.DecryptPhoneReplace(mobile)
}
// querySaleInfo 查询销售详情并附带分组;mobile 脱敏,origin_mobile 为加密串。
// 未找到时返回 (nil, nil)。
func querySaleInfo(id int64) (*dao.SaleInfo, error) {
return querySaleInfoByEq(map[string]string{"id": strconv.FormatInt(id, 10)})
}
func querySaleInfoByUserId(userId int64) (*dao.SaleInfo, error) {
return querySaleInfoByEq(map[string]string{"user_id": strconv.FormatInt(userId, 10)})
}
func querySaleInfoByEq(eq map[string]string) (*dao.SaleInfo, error) {
var info dao.SaleInfo
if err := (model.SaleModel{}.Init().GetOne(modelbase.Params{
Eq: map[string]string{"id": strconv.FormatInt(id, 10)},
}, &info)); err != nil {
if err := (model.SaleModel{}.Init().GetOne(modelbase.Params{Eq: eq}, &info)); err != nil {
return nil, err
}
if info.Id < utils.NumberOne {
@@ -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
}
@@ -50,6 +50,7 @@ func (l *InfoInternalLogic) InfoInternal(in *sale.InfoReq) (*sale.InfoData, erro
func toSaleInfoData(info *dao.SaleInfo) *sale.InfoData {
data := &sale.InfoData{
Id: info.Id,
UserId: info.UserId,
SaleId: info.SaleId,
Mobile: info.Mobile,
OriginMobile: info.OriginMobile,
+7 -1
View File
@@ -86,7 +86,13 @@ func (s *SaleServer) InfoInternal(ctx context.Context, in *sale.InfoReq) (*sale.
return l.InfoInternal(in)
}
// 按 id 批量查销售 id+name(内部)
// 按 user_id 查销售详情(内部)
func (s *SaleServer) InfoByUserId(ctx context.Context, in *sale.InfoByUserIdReq) (*sale.InfoData, error) {
l := logic.NewInfoByUserIdLogic(ctx, s.svcCtx)
return l.InfoByUserId(in)
}
// ids 批量查销售
func (s *SaleServer) NamesByIds(ctx context.Context, in *sale.NamesByIdsReq) (*sale.NamesByIdsData, error) {
l := logic.NewNamesByIdsLogic(ctx, s.svcCtx)
return l.NamesByIds(in)