增加风险管控接口
This commit is contained in:
@ -0,0 +1,36 @@
|
|||||||
|
package com.chinaunicom.mall.ebtp.extend.feign.client;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 风险管控接口调用
|
||||||
|
* @author daixc
|
||||||
|
* @date 2021/08/18
|
||||||
|
*/
|
||||||
|
import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
|
||||||
|
import com.chinaunicom.mall.ebtp.extend.riskmanage.entity.RiskManageRegulation;
|
||||||
|
import com.chinaunicom.mall.ebtp.extend.riskmanage.entity.RiskManageRegulationGroupApply;
|
||||||
|
import com.chinaunicom.mall.ebtp.extend.feign.entity.risk.RiskManageRegulationGroupOuterVO;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@FeignClient(value = "${mconfig.feign.name.strategy-center}",path = "/outer/v1.0/riskManageRegulation")
|
||||||
|
public interface RiskManageRegulationService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询规则模型列表接口
|
||||||
|
* @param riskManageRegulation 风险管控规则模型
|
||||||
|
* @return 返回结果
|
||||||
|
*/
|
||||||
|
@PostMapping({"/findRegulationParams"})
|
||||||
|
BaseResponse<List<RiskManageRegulationGroupOuterVO>> findRegulationParams(@RequestBody RiskManageRegulation riskManageRegulation);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行风控规则
|
||||||
|
* @param regulationGroupApply 风控规则对象
|
||||||
|
* @return 返回结果
|
||||||
|
*/
|
||||||
|
@PostMapping({"/applyRegulation"})
|
||||||
|
BaseResponse<Object> applyRegulation(@RequestBody RiskManageRegulationGroupApply regulationGroupApply);
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package com.chinaunicom.mall.ebtp.extend.feign.entity.risk;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 风险管控规则接口返回对象
|
||||||
|
* @author daixc
|
||||||
|
* @date 2021/08/18
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel("风险管控规则接口返回对象")
|
||||||
|
public class RiskManageRegulationGroupOuterVO implements Serializable {
|
||||||
|
|
||||||
|
@ApiModelProperty("规则主键")
|
||||||
|
private String regulationGroupId;
|
||||||
|
@ApiModelProperty("规则集合编号")
|
||||||
|
private String regulationGroupCode;
|
||||||
|
@ApiModelProperty("规则名称")
|
||||||
|
private String regulationGroupName;
|
||||||
|
@ApiModelProperty("模型主键")
|
||||||
|
private String regulationId;
|
||||||
|
@ApiModelProperty("规则所需的字段标识")
|
||||||
|
private String regulationField;
|
||||||
|
@ApiModelProperty("产品范围类型")
|
||||||
|
private String regulationProductRangeType;
|
||||||
|
@ApiModelProperty("风险识别条件所需的字段标识")
|
||||||
|
private String regulationConditionField;
|
||||||
|
@ApiModelProperty("识别条件")
|
||||||
|
private String regulationCondition;
|
||||||
|
@ApiModelProperty("是否需要上传竞争合理性文件:Y:是 N:否")
|
||||||
|
private String regulationPromotionUploadFiles;
|
||||||
|
@ApiModelProperty("返回参数集")
|
||||||
|
private List<Map<String, Object>> regulations;
|
||||||
|
}
|
@ -0,0 +1,93 @@
|
|||||||
|
package com.chinaunicom.mall.ebtp.extend.feign.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
|
||||||
|
import com.chinaunicom.mall.ebtp.extend.feign.entity.risk.RiskManageRegulationGroupOuterVO;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 风险管控处理辅助类
|
||||||
|
* @author daixc
|
||||||
|
* @date 2021/08/18
|
||||||
|
*/
|
||||||
|
public class CallRegulationUtil {
|
||||||
|
|
||||||
|
public static List<RiskManageRegulationGroupOuterVO> getCallRegulationMap(Map<String,Object> param, BaseResponse<List<RiskManageRegulationGroupOuterVO>> regulationParams, String orgId) throws NoSuchFieldException, IllegalAccessException {
|
||||||
|
List<RiskManageRegulationGroupOuterVO> regulationParamsList = regulationParams.getData();
|
||||||
|
Iterator var4 = regulationParamsList.iterator();
|
||||||
|
|
||||||
|
while(var4.hasNext()) {
|
||||||
|
RiskManageRegulationGroupOuterVO groupOuterVo = (RiskManageRegulationGroupOuterVO)var4.next();
|
||||||
|
List<Map<String, Object>> regulationList = groupOuterVo.getRegulations();
|
||||||
|
List<Map<String, Object>> parameterList = new ArrayList();
|
||||||
|
Iterator var8 = regulationList.iterator();
|
||||||
|
|
||||||
|
while(var8.hasNext()) {
|
||||||
|
Map<String, Object> map = (Map)var8.next();
|
||||||
|
Map<String, Object> regulationObj = (Map)map.get("parameters");
|
||||||
|
Map<String, Object> regulationMap = new HashMap();
|
||||||
|
Map<String, Object> value = new HashMap();
|
||||||
|
if (regulationObj.get("fields") != null) {
|
||||||
|
Iterator var13 = ((List)regulationObj.get("fields")).iterator();
|
||||||
|
|
||||||
|
while(var13.hasNext()) {
|
||||||
|
Object field = var13.next();
|
||||||
|
// Class cls = param.getClass();
|
||||||
|
// Field f = cls.getDeclaredField(field.toString());
|
||||||
|
// f.setAccessible(true);
|
||||||
|
// Object object = f.get(param);
|
||||||
|
// value.put(field.toString(), object);
|
||||||
|
value.put(field.toString(), param.get(field));
|
||||||
|
}
|
||||||
|
|
||||||
|
regulationMap.put("fields", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> productList = (List)regulationObj.get("products");
|
||||||
|
if (CollUtil.isNotEmpty(productList) && productList.get(0) != null) {
|
||||||
|
value = new HashMap();
|
||||||
|
Iterator var21 = productList.iterator();
|
||||||
|
|
||||||
|
while(var21.hasNext()) {
|
||||||
|
String field = (String)var21.next();
|
||||||
|
// Class cls = param.getClass();
|
||||||
|
// Field f = cls.getDeclaredField(field);
|
||||||
|
// f.setAccessible(true);
|
||||||
|
// Object object = f.get(param);
|
||||||
|
value.put(field, param.get(field));
|
||||||
|
}
|
||||||
|
|
||||||
|
regulationMap.put("products", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> conditionFields = (List)regulationObj.get("conditionFields");
|
||||||
|
if (!conditionFields.isEmpty() && !"".equals(conditionFields.get(0))) {
|
||||||
|
value = new HashMap();
|
||||||
|
Iterator var24 = conditionFields.iterator();
|
||||||
|
|
||||||
|
while(var24.hasNext()) {
|
||||||
|
String field = (String)var24.next();
|
||||||
|
// Class cls = param.getClass();
|
||||||
|
// Field f = cls.getDeclaredField(field);
|
||||||
|
// f.setAccessible(true);
|
||||||
|
// Object object = f.get(param);
|
||||||
|
// value.put(field, object);
|
||||||
|
value.put(field, param.get(field));
|
||||||
|
}
|
||||||
|
|
||||||
|
regulationMap.put("conditionFields", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
regulationMap.put("orgOu", orgId);
|
||||||
|
Map<String, Object> params = new HashMap();
|
||||||
|
params.put("regulationId", map.get("regulationId"));
|
||||||
|
params.put("parameters", regulationMap);
|
||||||
|
params.put("uploadFiles", map.get("uploadFiles"));
|
||||||
|
parameterList.add(params);
|
||||||
|
}
|
||||||
|
groupOuterVo.setRegulations(parameterList);
|
||||||
|
}
|
||||||
|
return regulationParamsList;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
package com.chinaunicom.mall.ebtp.extend.riskmanage.controller;
|
||||||
|
|
||||||
|
import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
|
||||||
|
import com.chinaunicom.mall.ebtp.extend.feign.client.RiskManageRegulationService;
|
||||||
|
import com.chinaunicom.mall.ebtp.extend.feign.entity.risk.RiskManageRegulationGroupOuterVO;
|
||||||
|
import com.chinaunicom.mall.ebtp.extend.riskmanage.entity.RiskManageRegulation;
|
||||||
|
import com.chinaunicom.mall.ebtp.extend.riskmanage.entity.RiskManageRegulationGroupApply;
|
||||||
|
import com.chinaunicom.mall.ebtp.extend.riskmanage.entity.RiskManageRegulationVO;
|
||||||
|
import com.chinaunicom.mall.ebtp.extend.riskmanage.service.IRiskManageService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author daixc
|
||||||
|
* @date daixc
|
||||||
|
*/
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Api(tags = "风险管控")
|
||||||
|
@RequestMapping("/v1/risk")
|
||||||
|
public class RiskManageController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RiskManageRegulationService regulationService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IRiskManageService riskManageService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询规则模型列表接口
|
||||||
|
* @param riskManageRegulation 风险管控规则模型
|
||||||
|
* @return 返回结果
|
||||||
|
*/
|
||||||
|
@PostMapping({"/findRegulationParams"})
|
||||||
|
public BaseResponse<List<RiskManageRegulationGroupOuterVO>> findRegulationParams(@RequestBody RiskManageRegulation riskManageRegulation){
|
||||||
|
return regulationService.findRegulationParams(riskManageRegulation);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行风控规则
|
||||||
|
* @param regulationGroupApply 风控规则对象
|
||||||
|
* @return 返回结果
|
||||||
|
*/
|
||||||
|
@PostMapping({"/applyRegulation"})
|
||||||
|
public BaseResponse<Object> applyRegulation(@RequestBody RiskManageRegulationGroupApply regulationGroupApply){
|
||||||
|
return regulationService.applyRegulation(regulationGroupApply);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询规则模型列表接口
|
||||||
|
* @param riskManageRegulation 风险管控规则模型
|
||||||
|
* @return 返回结果
|
||||||
|
*/
|
||||||
|
@PostMapping({"/findApplyRegulation"})
|
||||||
|
public BaseResponse<Object> findApplyRegulation(@RequestBody RiskManageRegulationVO riskManageRegulation){
|
||||||
|
return BaseResponse.success(riskManageService.findApplyRegulation(riskManageRegulation));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package com.chinaunicom.mall.ebtp.extend.riskmanage.entity;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 风险管控规则模型
|
||||||
|
* @author daixc
|
||||||
|
* @date 2021/08/18
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel("RiskManageRegulation规则模型对象")
|
||||||
|
public class RiskManageRegulation implements Serializable {
|
||||||
|
|
||||||
|
@ApiModelProperty("主键")
|
||||||
|
private String regulationGroupModuleId;
|
||||||
|
|
||||||
|
@ApiModelProperty("规则集合主键")
|
||||||
|
private String regulationGroupId;
|
||||||
|
|
||||||
|
@ApiModelProperty("规则集合编号")
|
||||||
|
private String regulationGroupCode;
|
||||||
|
|
||||||
|
@ApiModelProperty("调用模块类别名称")
|
||||||
|
private String callCategoryName;
|
||||||
|
|
||||||
|
@ApiModelProperty("调用模块类别编号")
|
||||||
|
private String callCategory;
|
||||||
|
|
||||||
|
@ApiModelProperty("风险调用模块名称")
|
||||||
|
private String callModuleName;
|
||||||
|
|
||||||
|
@ApiModelProperty("风险调用模块")
|
||||||
|
private String callModuleCode;
|
||||||
|
|
||||||
|
@ApiModelProperty("调用节点(多个用英文逗号隔开)")
|
||||||
|
private String callPointName;
|
||||||
|
|
||||||
|
@ApiModelProperty("调用节点编号(多个用英文逗号隔开)")
|
||||||
|
private String callPointCode;
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package com.chinaunicom.mall.ebtp.extend.riskmanage.entity;
|
||||||
|
|
||||||
|
import com.chinaunicom.mall.ebtp.extend.feign.entity.risk.RiskManageRegulationGroupOuterVO;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 风控规则
|
||||||
|
* @author daixc
|
||||||
|
* @date 2021/08/18
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel("风控规则对象")
|
||||||
|
public class RiskManageRegulationGroupApply implements Serializable {
|
||||||
|
|
||||||
|
@ApiModelProperty("业务id")
|
||||||
|
private String businessId;
|
||||||
|
|
||||||
|
@ApiModelProperty("调用模块类别编号")
|
||||||
|
private String callCategoryCode;
|
||||||
|
|
||||||
|
@ApiModelProperty("调用模块类别名称")
|
||||||
|
private String callCategoryName;
|
||||||
|
|
||||||
|
@ApiModelProperty("风险调用模块编号")
|
||||||
|
private String callModuleCode;
|
||||||
|
|
||||||
|
@ApiModelProperty("风险调用模块名称")
|
||||||
|
private String callModuleName;
|
||||||
|
|
||||||
|
@ApiModelProperty("调用节点编号")
|
||||||
|
private String callPointCode;
|
||||||
|
|
||||||
|
@ApiModelProperty("调用节点名称")
|
||||||
|
private String callPointName;
|
||||||
|
|
||||||
|
@ApiModelProperty("应用规则所需的参数")
|
||||||
|
private List<RiskManageRegulationGroupOuterVO> outerVoList;
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package com.chinaunicom.mall.ebtp.extend.riskmanage.entity;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 风险管控规则模型
|
||||||
|
* @author daixc
|
||||||
|
* @date 2021/08/18
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel("执行接口请求对象")
|
||||||
|
public class RiskManageRegulationVO {
|
||||||
|
|
||||||
|
@ApiModelProperty("请求参数对象")
|
||||||
|
private Map<String,Object> params;
|
||||||
|
|
||||||
|
@ApiModelProperty("规则模型对象")
|
||||||
|
private RiskManageRegulation riskManageRegulation;
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.chinaunicom.mall.ebtp.extend.riskmanage.service;
|
||||||
|
|
||||||
|
import com.chinaunicom.mall.ebtp.extend.riskmanage.entity.RiskManageRegulationVO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 风控接口
|
||||||
|
* @author daixc
|
||||||
|
* @date 2021/08/19
|
||||||
|
*/
|
||||||
|
public interface IRiskManageService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分控中心校验是否通过
|
||||||
|
* @param riskManageRegulation 访问实体
|
||||||
|
* @return 返回结果
|
||||||
|
*/
|
||||||
|
Object findApplyRegulation(RiskManageRegulationVO riskManageRegulation);
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
package com.chinaunicom.mall.ebtp.extend.riskmanage.service.impl;
|
||||||
|
|
||||||
|
import com.chinaunicom.mall.ebtp.common.base.entity.BaseCacheUser;
|
||||||
|
import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
|
||||||
|
import com.chinaunicom.mall.ebtp.common.base.service.IBaseCacheUserService;
|
||||||
|
import com.chinaunicom.mall.ebtp.extend.feign.client.RiskManageRegulationService;
|
||||||
|
import com.chinaunicom.mall.ebtp.extend.feign.entity.risk.RiskManageRegulationGroupOuterVO;
|
||||||
|
import com.chinaunicom.mall.ebtp.extend.feign.utils.CallRegulationUtil;
|
||||||
|
import com.chinaunicom.mall.ebtp.extend.riskmanage.entity.RiskManageRegulation;
|
||||||
|
import com.chinaunicom.mall.ebtp.extend.riskmanage.entity.RiskManageRegulationGroupApply;
|
||||||
|
import com.chinaunicom.mall.ebtp.extend.riskmanage.entity.RiskManageRegulationVO;
|
||||||
|
import com.chinaunicom.mall.ebtp.extend.riskmanage.service.IRiskManageService;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 风险管控接口实现
|
||||||
|
* @author daixc
|
||||||
|
* @date 2021/08/19
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class RiskManageServiceImpl implements IRiskManageService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RiskManageRegulationService regulationService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IBaseCacheUserService cacheUserService;
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
@Override
|
||||||
|
public Object findApplyRegulation(RiskManageRegulationVO riskManageRegulation) {
|
||||||
|
|
||||||
|
Map<String,Object> params = riskManageRegulation.getParams();
|
||||||
|
RiskManageRegulation regulation = riskManageRegulation.getRiskManageRegulation();
|
||||||
|
|
||||||
|
//查询模型信息
|
||||||
|
BaseResponse<List<RiskManageRegulationGroupOuterVO>> regulationParams = regulationService.findRegulationParams(regulation);
|
||||||
|
|
||||||
|
RiskManageRegulationGroupApply regulationGroupApply = new RiskManageRegulationGroupApply();
|
||||||
|
regulationGroupApply.setBusinessId(params.get("id").toString());
|
||||||
|
//模块分类
|
||||||
|
regulationGroupApply.setCallCategoryCode(regulation.getCallCategory());
|
||||||
|
regulationGroupApply.setCallCategoryName(regulation.getCallCategoryName());
|
||||||
|
//调用模块
|
||||||
|
regulationGroupApply.setCallModuleCode(regulation.getCallModuleCode());
|
||||||
|
regulationGroupApply.setCallModuleName(regulation.getCallModuleName());
|
||||||
|
//调用节点
|
||||||
|
regulationGroupApply.setCallPointCode(regulation.getCallPointCode());
|
||||||
|
regulationGroupApply.setCallPointName(regulation.getCallPointName());
|
||||||
|
|
||||||
|
BaseCacheUser cacheUser = cacheUserService.getCacheUser();
|
||||||
|
regulationGroupApply.setOuterVoList(CallRegulationUtil.getCallRegulationMap(params,regulationParams,cacheUser.getOrganizationId()));
|
||||||
|
|
||||||
|
//校验信息
|
||||||
|
return regulationService.applyRegulation(regulationGroupApply);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user