1、add queryservice
2、fix docker compose port
This commit is contained in:
parent
1edbd79e4c
commit
67f02ece93
@ -53,6 +53,8 @@ var productProcessors = map[string]func(*QueryServiceLogic, *types.QueryServiceR
|
||||
"rentalinfo": (*QueryServiceLogic).ProcessRentalInfoLogic,
|
||||
"preloanbackgroundcheck": (*QueryServiceLogic).ProcessPreLoanBackgroundCheckLogic,
|
||||
"backgroundcheck": (*QueryServiceLogic).ProcessBackgroundCheckLogic,
|
||||
"personalLawsuit": (*QueryServiceLogic).ProcessPersonalLawsuitLogic,
|
||||
"enterpriseLawsuit": (*QueryServiceLogic).ProcessEnterpriseLawsuitLogic,
|
||||
}
|
||||
|
||||
func (l *QueryServiceLogic) PreprocessLogic(req *types.QueryServiceReq, product string) (*types.QueryServiceResp, error) {
|
||||
@ -483,6 +485,124 @@ func (l *QueryServiceLogic) ProcessBackgroundCheckLogic(req *types.QueryServiceR
|
||||
RefreshAfter: now + l.svcCtx.Config.JwtAuth.RefreshAfter,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (l *QueryServiceLogic) ProcessPersonalLawsuitLogic(req *types.QueryServiceReq) (*types.QueryServiceResp, error) {
|
||||
// AES解密
|
||||
decryptData, DecryptDataErr := l.DecryptData(req.Data)
|
||||
if DecryptDataErr != nil {
|
||||
return nil, DecryptDataErr
|
||||
}
|
||||
|
||||
// 校验参数
|
||||
var data types.PersonalLawsuitReq
|
||||
if unmarshalErr := json.Unmarshal(decryptData, &data); unmarshalErr != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 解密后的数据格式不正确: %+v", unmarshalErr)
|
||||
}
|
||||
|
||||
if validatorErr := validator.Validate(data); validatorErr != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.PARAM_VERIFICATION_ERROR, validatorErr.Error()), "查询服务, 参数不正确: %+v", validatorErr)
|
||||
}
|
||||
|
||||
// 校验验证码
|
||||
verifyCodeErr := l.VerifyCode(data.Mobile, data.Code)
|
||||
if verifyCodeErr != nil {
|
||||
return nil, verifyCodeErr
|
||||
}
|
||||
|
||||
twoVerification := service.TwoFactorVerificationRequest{
|
||||
Name: data.Name,
|
||||
IDCard: data.IDCard,
|
||||
}
|
||||
verification, err := l.svcCtx.VerificationService.TwoFactorVerificationWest(twoVerification)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "二要素验证失败: %v", err)
|
||||
}
|
||||
if !verification.Passed {
|
||||
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.SERVER_COMMON_ERROR, verification.Err.Error()), "二要素验证不通过: %v", err)
|
||||
}
|
||||
|
||||
// 缓存
|
||||
params := map[string]interface{}{
|
||||
"name": data.Name,
|
||||
"id_card": data.IDCard,
|
||||
"mobile": data.Mobile,
|
||||
}
|
||||
userID, err := l.GetOrCreateUser()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 处理用户失败: %v", err)
|
||||
}
|
||||
cacheNo, cacheDataErr := l.CacheData(params, "personallawsuit", userID)
|
||||
if cacheDataErr != nil {
|
||||
return nil, cacheDataErr
|
||||
}
|
||||
|
||||
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, model.UserTypeNormal)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 生成token失败 : %d", userID)
|
||||
}
|
||||
|
||||
// 获取当前时间戳
|
||||
now := time.Now().Unix()
|
||||
return &types.QueryServiceResp{
|
||||
Id: cacheNo,
|
||||
AccessToken: token,
|
||||
AccessExpire: now + l.svcCtx.Config.JwtAuth.AccessExpire,
|
||||
RefreshAfter: now + l.svcCtx.Config.JwtAuth.RefreshAfter,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (l *QueryServiceLogic) ProcessEnterpriseLawsuitLogic(req *types.QueryServiceReq) (*types.QueryServiceResp, error) {
|
||||
// AES解密
|
||||
decryptData, DecryptDataErr := l.DecryptData(req.Data)
|
||||
if DecryptDataErr != nil {
|
||||
return nil, DecryptDataErr
|
||||
}
|
||||
|
||||
// 校验参数
|
||||
var data types.EntLawsuitReq
|
||||
if unmarshalErr := json.Unmarshal(decryptData, &data); unmarshalErr != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 解密后的数据格式不正确: %+v", unmarshalErr)
|
||||
}
|
||||
|
||||
if validatorErr := validator.Validate(data); validatorErr != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.PARAM_VERIFICATION_ERROR, validatorErr.Error()), "查询服务, 参数不正确: %+v", validatorErr)
|
||||
}
|
||||
|
||||
// 校验验证码
|
||||
verifyCodeErr := l.VerifyCode(data.Mobile, data.Code)
|
||||
if verifyCodeErr != nil {
|
||||
return nil, verifyCodeErr
|
||||
}
|
||||
|
||||
// 缓存
|
||||
params := map[string]interface{}{
|
||||
"ent_name": data.EntName,
|
||||
"ent_code": data.EntCode,
|
||||
}
|
||||
userID, err := l.GetOrCreateUser()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 处理用户失败: %v", err)
|
||||
}
|
||||
cacheNo, cacheDataErr := l.CacheData(params, "enterpriselawsuit", userID)
|
||||
if cacheDataErr != nil {
|
||||
return nil, cacheDataErr
|
||||
}
|
||||
|
||||
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, model.UserTypeNormal)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 生成token失败 : %d", userID)
|
||||
}
|
||||
|
||||
// 获取当前时间戳
|
||||
now := time.Now().Unix()
|
||||
return &types.QueryServiceResp{
|
||||
Id: cacheNo,
|
||||
AccessToken: token,
|
||||
AccessExpire: now + l.svcCtx.Config.JwtAuth.AccessExpire,
|
||||
RefreshAfter: now + l.svcCtx.Config.JwtAuth.RefreshAfter,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (l *QueryServiceLogic) DecryptData(data string) ([]byte, error) {
|
||||
secretKey := l.svcCtx.Config.Encrypt.SecretKey
|
||||
key, decodeErr := hex.DecodeString(secretKey)
|
||||
|
@ -58,48 +58,11 @@ type EntLawsuitReq struct {
|
||||
Mobile string `json:"mobile" validate:"required,mobile"`
|
||||
Code string `json:"code" validate:"required"`
|
||||
}
|
||||
type TocPhoneThreeElements struct {
|
||||
type PersonalLawsuitReq struct {
|
||||
Name string `json:"name" validate:"required,name"`
|
||||
IDCard string `json:"id_card" validate:"required,idCard"`
|
||||
Mobile string `json:"mobile" validate:"required,mobile"`
|
||||
}
|
||||
type TocPhoneTwoElements struct {
|
||||
Name string `json:"name" validate:"required,name"`
|
||||
Mobile string `json:"mobile" validate:"required,mobile"`
|
||||
}
|
||||
type TocIDCardTwoElements struct {
|
||||
Name string `json:"name" validate:"required,name"`
|
||||
IDCard string `json:"id_card" validate:"required,idCard"`
|
||||
}
|
||||
type TocDualMarriage struct {
|
||||
NameMan string `json:"name_man" validate:"required,name"`
|
||||
IDCardMan string `json:"id_card_man" validate:"required,idCard"`
|
||||
NameWoman string `json:"name_woman" validate:"required,name"`
|
||||
IDCardWoman string `json:"id_card_woman" validate:"required,idCard"`
|
||||
}
|
||||
type TocPersonVehicleVerification struct {
|
||||
Name string `json:"name" validate:"required,name"`
|
||||
CarType string `json:"car_type" validate:"required"`
|
||||
CarLicense string `json:"car_license" validate:"required"`
|
||||
}
|
||||
|
||||
// 银行卡黑名单
|
||||
type TocBankCardBlacklist struct {
|
||||
Name string `json:"name" validate:"required,name"`
|
||||
IDCard string `json:"id_card" validate:"required,idCard"`
|
||||
Mobile string `json:"mobile" validate:"required,mobile"`
|
||||
BankCard string `json:"bank_card" validate:"required"`
|
||||
}
|
||||
|
||||
// 手机号码风险
|
||||
type TocPhoneNumberRisk struct {
|
||||
Mobile string `json:"mobile" validate:"required,mobile"`
|
||||
}
|
||||
|
||||
// 手机二次卡
|
||||
type TocPhoneSecondaryCard struct {
|
||||
Mobile string `json:"mobile" validate:"required,mobile"`
|
||||
StartDate string `json:"start_date" validate:"required"`
|
||||
Code string `json:"code" validate:"required"`
|
||||
}
|
||||
|
||||
type AgentQueryData struct {
|
||||
|
@ -13,7 +13,7 @@ services:
|
||||
MYSQL_USER: ycc
|
||||
MYSQL_PASSWORD: 5vg67b3UNHu8
|
||||
ports:
|
||||
- "21001:3306"
|
||||
- "25001:3306"
|
||||
volumes:
|
||||
# 数据挂载 - Data mounting
|
||||
- ./data/mysql/data:/var/lib/mysql
|
||||
@ -36,7 +36,7 @@ services:
|
||||
image: redis:7.4.0
|
||||
container_name: ycc_redis
|
||||
ports:
|
||||
- "21002:6379"
|
||||
- "25002:6379"
|
||||
environment:
|
||||
# 时区上海 - Time zone Shanghai (Change if needed)
|
||||
TZ: Asia/Shanghai
|
||||
@ -53,7 +53,7 @@ services:
|
||||
image: hibiken/asynqmon:latest
|
||||
container_name: ycc_asynqmon
|
||||
ports:
|
||||
- "21003:8080"
|
||||
- "25003:8080"
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
command:
|
||||
@ -71,7 +71,7 @@ services:
|
||||
context: .
|
||||
dockerfile: app/main/api/Dockerfile
|
||||
ports:
|
||||
- "21004:8888"
|
||||
- "25004:8888"
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
- ENV=production
|
||||
|
Loading…
Reference in New Issue
Block a user