工具类修改
parent
d161236561
commit
df192939ce
|
@ -9,6 +9,7 @@
|
||||||
<sourceRoots>
|
<sourceRoots>
|
||||||
<root url="file://$MODULE_DIR$/src/main/java" />
|
<root url="file://$MODULE_DIR$/src/main/java" />
|
||||||
<root url="file://$MODULE_DIR$/src/main/resources" />
|
<root url="file://$MODULE_DIR$/src/main/resources" />
|
||||||
|
<root url="file://$MODULE_DIR$/target/generated-sources/annotations" />
|
||||||
</sourceRoots>
|
</sourceRoots>
|
||||||
</configuration>
|
</configuration>
|
||||||
</facet>
|
</facet>
|
||||||
|
@ -20,16 +21,20 @@
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/target/generated-sources/annotations" isTestSource="false" generated="true" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/log" />
|
<excludeFolder url="file://$MODULE_DIR$/log" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="library" name="classbean" level="project" />
|
<orderEntry type="library" exported="" name="classbean" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.18.22" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.18.22" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.mapstruct:mapstruct-jdk8:1.4.2.Final" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.mapstruct:mapstruct:1.4.2.Final" level="project" />
|
||||||
<orderEntry type="library" name="Maven: cn.hutool:hutool-all:5.7.12" level="project" />
|
<orderEntry type="library" name="Maven: cn.hutool:hutool-all:5.7.12" level="project" />
|
||||||
<orderEntry type="library" name="Maven: com.drewnoakes:metadata-extractor:2.16.0" level="project" />
|
<orderEntry type="library" name="Maven: com.drewnoakes:metadata-extractor:2.16.0" level="project" />
|
||||||
<orderEntry type="library" name="Maven: com.adobe.xmp:xmpcore:6.1.11" level="project" />
|
<orderEntry type="library" name="Maven: com.adobe.xmp:xmpcore:6.1.11" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: junit:junit:4.12" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.apache.poi:poi-excelant:3.12" level="project" />
|
<orderEntry type="library" name="Maven: org.apache.poi:poi-excelant:3.12" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.apache.poi:poi:3.12" level="project" />
|
<orderEntry type="library" name="Maven: org.apache.poi:poi:3.12" level="project" />
|
||||||
|
|
|
@ -337,7 +337,13 @@ function bindEvent(configObj) {
|
||||||
let colorMapper = item.colorMapper
|
let colorMapper = item.colorMapper
|
||||||
for (let v in colorMapper) {
|
for (let v in colorMapper) {
|
||||||
WfForm.proxyFieldContentComp(convertField2Id(v, item.simpleTableName, false), changeColor(colorMapper[v]));
|
WfForm.proxyFieldContentComp(convertField2Id(v, item.simpleTableName, false), changeColor(colorMapper[v]));
|
||||||
WfForm.forceRenderField(convertField2Id(v, item.simpleTableName));
|
setTimeout(()=>{
|
||||||
|
let rowArr = (WfForm.getDetailAllRowIndexStr(item.simpleTableName) ?? '').split(",");
|
||||||
|
rowArr.forEach(value=>{
|
||||||
|
console.log(convertField2Id(v, item.simpleTableName)+"_"+value)
|
||||||
|
WfForm.forceRenderField(convertField2Id(v, item.simpleTableName)+"_"+value);
|
||||||
|
})
|
||||||
|
},100)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
35
pom.xml
35
pom.xml
|
@ -32,6 +32,7 @@
|
||||||
<lombok.version>1.18.22</lombok.version>
|
<lombok.version>1.18.22</lombok.version>
|
||||||
<hutool.version>5.7.12</hutool.version>
|
<hutool.version>5.7.12</hutool.version>
|
||||||
<metadata-extractor.version>2.16.0</metadata-extractor.version>
|
<metadata-extractor.version>2.16.0</metadata-extractor.version>
|
||||||
|
<org.mapstruct.version>1.4.2.Final</org.mapstruct.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,6 +44,17 @@
|
||||||
<version>${lombok.version}</version>
|
<version>${lombok.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- mapstruct -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mapstruct</groupId>
|
||||||
|
<artifactId>mapstruct-jdk8</artifactId>
|
||||||
|
<version>${org.mapstruct.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mapstruct</groupId>
|
||||||
|
<artifactId>mapstruct</artifactId>
|
||||||
|
<version>${org.mapstruct.version}</version>
|
||||||
|
</dependency>
|
||||||
<!-- 糊涂工具包,法大大验签指定版本-->
|
<!-- 糊涂工具包,法大大验签指定版本-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
|
@ -92,17 +104,24 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>2.3.2</version>
|
<version>3.8.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>8</source>
|
<source>8</source>
|
||||||
<target>8</target>
|
<target>8</target>
|
||||||
<!-- <annotationProcessors>-->
|
<annotationProcessorPaths>
|
||||||
<!-- <annotationProcessor>-->
|
<path>
|
||||||
<!-- <groupId>org.projectors</groupId>-->
|
<groupId>org.projectlombok</groupId>
|
||||||
<!-- <artifactId>lombok</artifactId>-->
|
<artifactId>lombok</artifactId>
|
||||||
<!-- <version>${lombok.version}</version>-->
|
<version>${lombok.version}</version>
|
||||||
<!-- </annotationProcessor>-->
|
</path>
|
||||||
<!-- </annotationProcessors>-->
|
<path>
|
||||||
|
<groupId>org.mapstruct</groupId>
|
||||||
|
<artifactId>mapstruct-processor</artifactId>
|
||||||
|
<version>${org.mapstruct.version}</version>
|
||||||
|
</path>
|
||||||
|
|
||||||
|
</annotationProcessorPaths>
|
||||||
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
|
|
@ -64,9 +64,9 @@ public class Util extends weaver.general.Util {
|
||||||
private static final RecordSet rs = new RecordSet();
|
private static final RecordSet rs = new RecordSet();
|
||||||
private static final String LOGGER_NAME = "cusAYH";
|
private static final String LOGGER_NAME = "cusAYH";
|
||||||
static ToolUtil toolUtil = new ToolUtil();
|
static ToolUtil toolUtil = new ToolUtil();
|
||||||
private static RecordsetUtil recordsetUtil = new RecordsetUtil();
|
private static final RecordsetUtil recordsetUtil = new RecordsetUtil();
|
||||||
private static final UtilMapper mapper = getMapper(UtilMapper.class);
|
private static final UtilMapper mapper = getMapper(UtilMapper.class);
|
||||||
private static LoggerUtil loggerUtil = new LoggerUtil();
|
private static final LoggerUtil loggerUtil = new LoggerUtil();
|
||||||
private static volatile Logger log = null;
|
private static volatile Logger log = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2145,6 +2145,9 @@ public class Util extends weaver.general.Util {
|
||||||
for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
|
for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
|
||||||
Method writeMethod = propertyDescriptor.getWriteMethod();
|
Method writeMethod = propertyDescriptor.getWriteMethod();
|
||||||
String name = propertyDescriptor.getName();
|
String name = propertyDescriptor.getName();
|
||||||
|
if (writeMethod == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
Field sourceClassField = sourceClass.getDeclaredField(name);
|
Field sourceClassField = sourceClass.getDeclaredField(name);
|
||||||
Class<?> propertyType = propertyDescriptor.getPropertyType();
|
Class<?> propertyType = propertyDescriptor.getPropertyType();
|
||||||
|
@ -2162,4 +2165,29 @@ public class Util extends weaver.general.Util {
|
||||||
// TODO 复制bean
|
// TODO 复制bean
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String randomNumber(int length) {
|
||||||
|
return creatRandom("0123456789", length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String randomString(int length) {
|
||||||
|
return creatRandom("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String randomLetter(int length) {
|
||||||
|
return creatRandom("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", length);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String creatRandom(String randomStr, int length) {
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
Random random = new Random();
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
int rand = random.nextInt(randomStr.length());
|
||||||
|
sb.append(randomStr.charAt(rand));
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package aiyh.utils.apirequest.core.typehandler;
|
package aiyh.utils.apirequest.core.typehandler;
|
||||||
|
|
||||||
|
import aiyh.utils.apirequest.entity.ApiRequestData;
|
||||||
import aiyh.utils.apirequest.entity.ParamConfigInfo;
|
import aiyh.utils.apirequest.entity.ParamConfigInfo;
|
||||||
import aiyh.utils.apirequest.pojo.ApiRequestMain;
|
import aiyh.utils.apirequest.pojo.ApiRequestMain;
|
||||||
|
|
||||||
|
@ -15,8 +16,8 @@ public interface IDataSourceHandler {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据来源处理方法
|
* 数据来源处理方法
|
||||||
* @param apiRequestMain 请求配置信息
|
* @param apiRequestData 请求配置信息
|
||||||
* @return 解析后
|
* @return 解析后
|
||||||
*/
|
*/
|
||||||
public ParamConfigInfo parseDataSource(ApiRequestMain apiRequestMain);
|
public ParamConfigInfo parseDataSource(ApiRequestData apiRequestData);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
package aiyh.utils.apirequest.core.typehandler;
|
package aiyh.utils.apirequest.core.typehandler;
|
||||||
|
|
||||||
|
import aiyh.utils.apirequest.entity.ApiRequestParamData;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>请求参数类型处理器接口</p>
|
* <p>请求参数类型处理器接口</p>
|
||||||
* <p>create 2022/1/22 0022 20:21</p>
|
* <p>create 2022/1/22 0022 20:21</p>
|
||||||
|
@ -11,8 +15,10 @@ package aiyh.utils.apirequest.core.typehandler;
|
||||||
public interface IParamTypeHandler {
|
public interface IParamTypeHandler {
|
||||||
/**
|
/**
|
||||||
* 参数值类型的转换
|
* 参数值类型的转换
|
||||||
* @param value 为转换前参数值
|
*
|
||||||
|
* @param paramData 为转换前参数信息
|
||||||
|
* @param paramValueRuleHandler 参数转换处理器
|
||||||
* @return 转换后的参数
|
* @return 转换后的参数
|
||||||
*/
|
*/
|
||||||
public Object getValue(Object value);
|
public Object getValue(ApiRequestParamData paramData, IParamValueRuleHandler paramValueRuleHandler, Map<String, Object> dataMap);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package aiyh.utils.apirequest.core.typehandler;
|
package aiyh.utils.apirequest.core.typehandler;
|
||||||
|
|
||||||
|
import aiyh.utils.apirequest.entity.ApiRequestParamData;
|
||||||
import aiyh.utils.apirequest.pojo.ApiRequestParamDetail;
|
import aiyh.utils.apirequest.pojo.ApiRequestParamDetail;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -19,5 +20,5 @@ public interface IParamValueRuleHandler {
|
||||||
* @param dataMap 流程数据或建模表数据
|
* @param dataMap 流程数据或建模表数据
|
||||||
* @return 参数对应 的值
|
* @return 参数对应 的值
|
||||||
*/
|
*/
|
||||||
public Object getValue(ApiRequestParamDetail paramInfo, Map<String,Object> dataMap);
|
public Object getValue(ApiRequestParamData paramInfo, Map<String,Object> dataMap);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package aiyh.utils.apirequest.core.typehandler.datasource;
|
package aiyh.utils.apirequest.core.typehandler.datasource;
|
||||||
|
|
||||||
import aiyh.utils.apirequest.core.typehandler.IDataSourceHandler;
|
import aiyh.utils.apirequest.core.typehandler.IDataSourceHandler;
|
||||||
|
import aiyh.utils.apirequest.entity.ApiRequestData;
|
||||||
import aiyh.utils.apirequest.entity.ParamConfigInfo;
|
import aiyh.utils.apirequest.entity.ParamConfigInfo;
|
||||||
import aiyh.utils.apirequest.pojo.ApiRequestMain;
|
import aiyh.utils.apirequest.pojo.ApiRequestMain;
|
||||||
|
|
||||||
|
@ -14,7 +15,7 @@ import aiyh.utils.apirequest.pojo.ApiRequestMain;
|
||||||
|
|
||||||
public class ModelDataHandler implements IDataSourceHandler {
|
public class ModelDataHandler implements IDataSourceHandler {
|
||||||
@Override
|
@Override
|
||||||
public ParamConfigInfo parseDataSource(ApiRequestMain apiRequestMain) {
|
public ParamConfigInfo parseDataSource(ApiRequestData apiRequestData) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,21 +3,22 @@ package aiyh.utils.apirequest.core.typehandler.datasource;
|
||||||
import aiyh.utils.Util;
|
import aiyh.utils.Util;
|
||||||
import aiyh.utils.apirequest.core.factory.AbstractFactory;
|
import aiyh.utils.apirequest.core.factory.AbstractFactory;
|
||||||
import aiyh.utils.apirequest.core.factory.AbstractFactoryImpl;
|
import aiyh.utils.apirequest.core.factory.AbstractFactoryImpl;
|
||||||
|
import aiyh.utils.apirequest.core.factory.ParamTypeHandlerFactory;
|
||||||
import aiyh.utils.apirequest.core.factory.ParamValueRuleHandlerFactory;
|
import aiyh.utils.apirequest.core.factory.ParamValueRuleHandlerFactory;
|
||||||
import aiyh.utils.apirequest.core.typehandler.IDataSourceHandler;
|
import aiyh.utils.apirequest.core.typehandler.IDataSourceHandler;
|
||||||
|
import aiyh.utils.apirequest.core.typehandler.IParamTypeHandler;
|
||||||
import aiyh.utils.apirequest.core.typehandler.IParamValueRuleHandler;
|
import aiyh.utils.apirequest.core.typehandler.IParamValueRuleHandler;
|
||||||
import aiyh.utils.apirequest.entity.ParamConfigInfo;
|
import aiyh.utils.apirequest.entity.*;
|
||||||
import aiyh.utils.apirequest.entity.ParamInfo;
|
import aiyh.utils.apirequest.enumtype.ParamTypeEnum;
|
||||||
import aiyh.utils.apirequest.enumtype.ParamValueRuleEnum;
|
import aiyh.utils.apirequest.enumtype.ParamValueRuleEnum;
|
||||||
import aiyh.utils.apirequest.mapper.DataSourceMapper;
|
import aiyh.utils.apirequest.mapper.DataSourceMapper;
|
||||||
import aiyh.utils.apirequest.pojo.ApiRequestMain;
|
import aiyh.utils.apirequest.mapsturct.BeanMapper;
|
||||||
import aiyh.utils.apirequest.pojo.ApiRequestParamDetail;
|
|
||||||
import weaver.workflow.workflow.WorkflowVersion;
|
import weaver.workflow.workflow.WorkflowVersion;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>数据来源为流程的处理方法实现</p>
|
* <p>数据来源为流程的处理方法实现</p>
|
||||||
|
@ -33,43 +34,62 @@ public class WorkflowDataHandler implements IDataSourceHandler {
|
||||||
private final AbstractFactory factory = new AbstractFactoryImpl();
|
private final AbstractFactory factory = new AbstractFactoryImpl();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ParamConfigInfo parseDataSource(ApiRequestMain apiRequestMain) {
|
public ParamConfigInfo parseDataSource(ApiRequestData apiRequestData) {
|
||||||
String workflowId = apiRequestMain.getWorkflowType();
|
String workflowId = apiRequestData.getWorkflowType();
|
||||||
String workflowVersionIds = WorkflowVersion.getVersionStringByWfid(workflowId);
|
String workflowVersionIds = WorkflowVersion.getVersionStringByWfid(workflowId);
|
||||||
String workflowTable = mapper.selectWorkflowTableById(workflowVersionIds.split(","));
|
String workflowTable = mapper.selectWorkflowTableById(workflowVersionIds.split(","));
|
||||||
if("".equals(apiRequestMain.getRequestId()) || Objects.isNull(apiRequestMain.getRequestId())){
|
ApiBaseInfo apiBaseInfo = apiRequestData.getApiBaseInfo();
|
||||||
throw new RuntimeException("数据来源为流程时,流程的requestId为必要参数!");
|
if (apiBaseInfo == null) {
|
||||||
|
throw new RuntimeException("The mandatory parameter is ApiBaseInfo empty");
|
||||||
}
|
}
|
||||||
Map<String, Object> mainData = mapper.selectMainData(workflowTable, apiRequestMain.getRequestId());
|
Map<String, Object> mainData = mapper.selectMainData(workflowTable, apiBaseInfo.getRequestId());
|
||||||
ParamConfigInfo paramConfigInfo = Util.copyBeanBaseField(apiRequestMain, new ParamConfigInfo());
|
|
||||||
List<ApiRequestParamDetail> paramDetailList = apiRequestMain.getParamDetailList();
|
|
||||||
// 明细请求模式,单挑明细 当做请求参数进行一次请求
|
// 明细请求模式,单挑明细 当做请求参数进行一次请求
|
||||||
if (apiRequestMain.getParamRequestType() == 1) {
|
if (apiRequestData.getParamRequestType() == 1) {
|
||||||
List<List<ParamInfo>> lists = parseValueForDetail(apiRequestMain, mainData);
|
List<List<ParamInfo>> lists = parseValueForDetail(apiRequestData, mainData);
|
||||||
} else {
|
} else {
|
||||||
// 默认模式
|
// 默认模式
|
||||||
|
|
||||||
}
|
}
|
||||||
return paramConfigInfo;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<List<ParamInfo>> parseValueForDetail(ApiRequestMain apiRequestMain, Map<String, Object> mainData) {
|
/**
|
||||||
String requestDetailTableName = apiRequestMain.getRequestDetailTableName();
|
* 查询流程明细表数据,并通过明细表数据解析请求参数
|
||||||
|
* @param apiRequestData api请求配置参数对象
|
||||||
|
* @param mainData 流程主表数据信息
|
||||||
|
* @return api请求参数信息
|
||||||
|
*/
|
||||||
|
public List<List<ParamInfo>> parseValueForDetail(ApiRequestData apiRequestData, Map<String, Object> mainData) {
|
||||||
|
String requestDetailTableName = apiRequestData.getRequestDetailTableName();
|
||||||
List<Map<String, Object>> detailList = mapper.selectDetailData(requestDetailTableName, String.valueOf(mainData.get("id")));
|
List<Map<String, Object>> detailList = mapper.selectDetailData(requestDetailTableName, String.valueOf(mainData.get("id")));
|
||||||
List<ApiRequestParamDetail> paramDetailList = apiRequestMain.getParamDetailList();
|
// 获取api请求配置明细表配置信息
|
||||||
|
List<ApiRequestParamData> paramDetailList = apiRequestData.getParamDetailList();
|
||||||
|
// 创建参数处理对象
|
||||||
ParamValueRuleHandlerFactory paramHandlerFactory = factory.createParamHandlerFactory(ParamValueRuleHandlerFactory.class);
|
ParamValueRuleHandlerFactory paramHandlerFactory = factory.createParamHandlerFactory(ParamValueRuleHandlerFactory.class);
|
||||||
for (Map<String, Object> detail : detailList) {
|
ParamTypeHandlerFactory paramTypeHandlerFactory = factory.createParamHandlerFactory(ParamTypeHandlerFactory.class);
|
||||||
|
List<List<ParamInfo>> result = new ArrayList<>();
|
||||||
Map<String, Object> dataMap = new HashMap<>(8);
|
Map<String, Object> dataMap = new HashMap<>(8);
|
||||||
dataMap.put("main", mainData);
|
dataMap.put("main", mainData);
|
||||||
|
dataMap.put("requestId", apiRequestData.getApiBaseInfo().getRequestId());
|
||||||
|
dataMap.put("workflowId", apiRequestData.getApiBaseInfo().getWorkflowId());
|
||||||
|
dataMap.put("user", apiRequestData.getApiBaseInfo().getUser());
|
||||||
|
for (Map<String, Object> detail : detailList) {
|
||||||
dataMap.put("detail", detail);
|
dataMap.put("detail", detail);
|
||||||
for (ApiRequestParamDetail paramDetail : paramDetailList) {
|
List<ParamInfo> paramInfoList = new ArrayList<>();
|
||||||
|
for (ApiRequestParamData paramDetail : paramDetailList) {
|
||||||
ParamValueRuleEnum paramValueRuleEnum = ParamValueRuleEnum.get(paramDetail.getValueRule());
|
ParamValueRuleEnum paramValueRuleEnum = ParamValueRuleEnum.get(paramDetail.getValueRule());
|
||||||
|
ParamTypeEnum paramTypeEnum = ParamTypeEnum.get(paramDetail.getParamType());
|
||||||
IParamValueRuleHandler paramHandler = paramHandlerFactory.createParamHandler(paramValueRuleEnum);
|
IParamValueRuleHandler paramHandler = paramHandlerFactory.createParamHandler(paramValueRuleEnum);
|
||||||
Object value = paramHandler.getValue(paramDetail, dataMap);
|
IParamTypeHandler paramTypeHandler = paramTypeHandlerFactory.createParamHandler(paramTypeEnum);
|
||||||
|
Object value = paramTypeHandler.getValue(paramDetail, paramHandler,dataMap);
|
||||||
|
ParamInfo paramInfo = BeanMapper.INSTANCE.apiRequestData2ParamInfo(paramDetail);
|
||||||
|
paramInfo.setParamValue(value);
|
||||||
|
paramInfoList.add(paramInfo);
|
||||||
}
|
}
|
||||||
|
result.add(paramInfoList);
|
||||||
}
|
}
|
||||||
return null;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ParamInfo> parseValueForDefault() {
|
public List<ParamInfo> parseValueForDefault() {
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package aiyh.utils.apirequest.core.typehandler.paramtype;
|
package aiyh.utils.apirequest.core.typehandler.paramtype;
|
||||||
|
|
||||||
import aiyh.utils.apirequest.core.typehandler.IParamTypeHandler;
|
import aiyh.utils.apirequest.core.typehandler.IParamTypeHandler;
|
||||||
|
import aiyh.utils.apirequest.core.typehandler.IParamValueRuleHandler;
|
||||||
|
import aiyh.utils.apirequest.entity.ApiRequestParamData;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>boolean参数类型处理器</p>
|
* <p>boolean参数类型处理器</p>
|
||||||
|
@ -11,8 +15,11 @@ import aiyh.utils.apirequest.core.typehandler.IParamTypeHandler;
|
||||||
|
|
||||||
|
|
||||||
public class BooleanTypeHandler implements IParamTypeHandler {
|
public class BooleanTypeHandler implements IParamTypeHandler {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean getValue(Object value) {
|
public Object getValue(ApiRequestParamData paramData, IParamValueRuleHandler paramValueRuleHandler, Map<String, Object> dataMap) {
|
||||||
|
Object value = paramValueRuleHandler.getValue(paramData, dataMap);
|
||||||
return Boolean.parseBoolean(String.valueOf(value));
|
return Boolean.parseBoolean(String.valueOf(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package aiyh.utils.apirequest.core.typehandler.paramtype;
|
package aiyh.utils.apirequest.core.typehandler.paramtype;
|
||||||
|
|
||||||
import aiyh.utils.apirequest.core.typehandler.IParamTypeHandler;
|
import aiyh.utils.apirequest.core.typehandler.IParamTypeHandler;
|
||||||
|
import aiyh.utils.apirequest.core.typehandler.IParamValueRuleHandler;
|
||||||
|
import aiyh.utils.apirequest.entity.ApiRequestParamData;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>浮点数类型处理器</p>
|
* <p>浮点数类型处理器</p>
|
||||||
|
@ -11,8 +15,11 @@ import aiyh.utils.apirequest.core.typehandler.IParamTypeHandler;
|
||||||
|
|
||||||
|
|
||||||
public class DoubleTypeHandler implements IParamTypeHandler {
|
public class DoubleTypeHandler implements IParamTypeHandler {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Double getValue(Object value) {
|
public Object getValue(ApiRequestParamData paramData, IParamValueRuleHandler paramValueRuleHandler, Map<String, Object> dataMap) {
|
||||||
|
Object value = paramValueRuleHandler.getValue(paramData, dataMap);
|
||||||
return Double.parseDouble(String.valueOf(value));
|
return Double.parseDouble(String.valueOf(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package aiyh.utils.apirequest.core.typehandler.paramtype;
|
package aiyh.utils.apirequest.core.typehandler.paramtype;
|
||||||
|
|
||||||
import aiyh.utils.apirequest.core.typehandler.IParamTypeHandler;
|
import aiyh.utils.apirequest.core.typehandler.IParamTypeHandler;
|
||||||
|
import aiyh.utils.apirequest.core.typehandler.IParamValueRuleHandler;
|
||||||
|
import aiyh.utils.apirequest.entity.ApiRequestParamData;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>数组参数类型处理器</p>
|
* <p>数组参数类型处理器</p>
|
||||||
|
@ -11,8 +15,9 @@ import aiyh.utils.apirequest.core.typehandler.IParamTypeHandler;
|
||||||
|
|
||||||
|
|
||||||
public class ListTypeHandler implements IParamTypeHandler {
|
public class ListTypeHandler implements IParamTypeHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValue(Object value) {
|
public Object getValue(ApiRequestParamData paramData, IParamValueRuleHandler paramValueRuleHandler, Map<String, Object> dataMap) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package aiyh.utils.apirequest.core.typehandler.paramtype;
|
package aiyh.utils.apirequest.core.typehandler.paramtype;
|
||||||
|
|
||||||
import aiyh.utils.apirequest.core.typehandler.IParamTypeHandler;
|
import aiyh.utils.apirequest.core.typehandler.IParamTypeHandler;
|
||||||
|
import aiyh.utils.apirequest.core.typehandler.IParamValueRuleHandler;
|
||||||
|
import aiyh.utils.apirequest.entity.ApiRequestParamData;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>长整型数据类型处理器</p>
|
* <p>长整型数据类型处理器</p>
|
||||||
|
@ -12,7 +16,8 @@ import aiyh.utils.apirequest.core.typehandler.IParamTypeHandler;
|
||||||
|
|
||||||
public class LongTypeHandler implements IParamTypeHandler {
|
public class LongTypeHandler implements IParamTypeHandler {
|
||||||
@Override
|
@Override
|
||||||
public Long getValue(Object value) {
|
public Object getValue(ApiRequestParamData paramData, IParamValueRuleHandler paramValueRuleHandler, Map<String, Object> dataMap) {
|
||||||
|
Object value = paramValueRuleHandler.getValue(paramData, dataMap);
|
||||||
return Long.parseLong(String.valueOf(value));
|
return Long.parseLong(String.valueOf(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package aiyh.utils.apirequest.core.typehandler.paramtype;
|
package aiyh.utils.apirequest.core.typehandler.paramtype;
|
||||||
|
|
||||||
import aiyh.utils.apirequest.core.typehandler.IParamTypeHandler;
|
import aiyh.utils.apirequest.core.typehandler.IParamTypeHandler;
|
||||||
|
import aiyh.utils.apirequest.core.typehandler.IParamValueRuleHandler;
|
||||||
|
import aiyh.utils.apirequest.entity.ApiRequestParamData;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Object参数类型处理器</p>
|
* <p>Object参数类型处理器</p>
|
||||||
|
@ -11,8 +15,9 @@ import aiyh.utils.apirequest.core.typehandler.IParamTypeHandler;
|
||||||
|
|
||||||
|
|
||||||
public class ObjectTypeHandler implements IParamTypeHandler {
|
public class ObjectTypeHandler implements IParamTypeHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValue(Object value) {
|
public Object getValue(ApiRequestParamData paramData, IParamValueRuleHandler paramValueRuleHandler, Map<String, Object> dataMap) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package aiyh.utils.apirequest.core.typehandler.paramtype;
|
package aiyh.utils.apirequest.core.typehandler.paramtype;
|
||||||
|
|
||||||
import aiyh.utils.apirequest.core.typehandler.IParamTypeHandler;
|
import aiyh.utils.apirequest.core.typehandler.IParamTypeHandler;
|
||||||
|
import aiyh.utils.apirequest.core.typehandler.IParamValueRuleHandler;
|
||||||
|
import aiyh.utils.apirequest.entity.ApiRequestParamData;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>字符串类型处理器</p>
|
* <p>字符串类型处理器</p>
|
||||||
|
@ -11,8 +15,11 @@ import aiyh.utils.apirequest.core.typehandler.IParamTypeHandler;
|
||||||
|
|
||||||
|
|
||||||
public class StringTypeHandler implements IParamTypeHandler {
|
public class StringTypeHandler implements IParamTypeHandler {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getValue(Object value) {
|
public Object getValue(ApiRequestParamData paramData, IParamValueRuleHandler paramValueRuleHandler, Map<String, Object> dataMap) {
|
||||||
|
Object value = paramValueRuleHandler.getValue(paramData, dataMap);
|
||||||
return String.valueOf(value);
|
return String.valueOf(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package aiyh.utils.apirequest.core.typehandler.paramvalue;
|
||||||
|
|
||||||
|
import aiyh.utils.apirequest.core.typehandler.IParamValueRuleHandler;
|
||||||
|
import aiyh.utils.apirequest.entity.ApiRequestParamData;
|
||||||
|
import aiyh.utils.apirequest.pojo.ApiRequestParamDetail;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>当前日期时间处理</p>
|
||||||
|
* <p>create 2022/1/27 0027 15:51</p>
|
||||||
|
*
|
||||||
|
* @author EBU7-dev1-ayh
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
public class CurrentDataTimeRuleHandler implements IParamValueRuleHandler {
|
||||||
|
@Override
|
||||||
|
public Object getValue(ApiRequestParamData paramInfo, Map<String, Object> dataMap) {
|
||||||
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(paramInfo.getCustomerValue());
|
||||||
|
return simpleDateFormat.format(new Date());
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,10 +2,15 @@ package aiyh.utils.apirequest.core.typehandler.paramvalue;
|
||||||
|
|
||||||
import aiyh.utils.Util;
|
import aiyh.utils.Util;
|
||||||
import aiyh.utils.apirequest.core.typehandler.IParamValueRuleHandler;
|
import aiyh.utils.apirequest.core.typehandler.IParamValueRuleHandler;
|
||||||
|
import aiyh.utils.apirequest.entity.ApiRequestParamData;
|
||||||
|
import aiyh.utils.apirequest.enumtype.ParamTypeEnum;
|
||||||
import aiyh.utils.apirequest.mapper.ParamValueParseMapper;
|
import aiyh.utils.apirequest.mapper.ParamValueParseMapper;
|
||||||
import aiyh.utils.apirequest.pojo.ApiRequestParamDetail;
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>自定义SQL处理器</p>
|
* <p>自定义SQL处理器</p>
|
||||||
|
@ -16,14 +21,40 @@ import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
public class CustomerSqlRuleHandler implements IParamValueRuleHandler {
|
public class CustomerSqlRuleHandler implements IParamValueRuleHandler {
|
||||||
|
public static final String SELECT = "select ";
|
||||||
private final ParamValueParseMapper mapper = Util.getMapper(ParamValueParseMapper.class);
|
private final ParamValueParseMapper mapper = Util.getMapper(ParamValueParseMapper.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValue(ApiRequestParamDetail paramInfo, Map<String, Object> dataMap) {
|
public Object getValue(ApiRequestParamData paramInfo, Map<String, Object> dataMap) {
|
||||||
String customerSql = paramInfo.getCustomerValue();
|
String customerSql = paramInfo.getCustomerValue();
|
||||||
if(customerSql.toLowerCase().trim().startsWith("select ".toLowerCase())){
|
String pattern = "^(\\$:)(?<name>\\w*)\\{(?<sql>[\\S\\s]+)}";
|
||||||
return mapper.selectCustomerSql(customerSql, dataMap);
|
Pattern compile = Pattern.compile(pattern);
|
||||||
|
Matcher matcher = compile.matcher(customerSql.trim());
|
||||||
|
if (matcher.find()) {
|
||||||
|
String sqlStr = matcher.group("sql");
|
||||||
|
String name = matcher.group("name");
|
||||||
|
if (sqlStr.toLowerCase().trim().startsWith(SELECT.toLowerCase())) {
|
||||||
|
if (Objects.isNull(name) || "".equals(name)) {
|
||||||
|
return mapper.selectCustomerSql(sqlStr, dataMap);
|
||||||
|
} else {
|
||||||
|
// 起名字的SQL需要做特殊处理
|
||||||
|
ParamTypeEnum paramTypeEnum = ParamTypeEnum.get(paramInfo.getParamType());
|
||||||
|
// 如果参数类型是List类型,则需要查询list类型出来,并且将list数据存储在dataMap中
|
||||||
|
if (paramTypeEnum == ParamTypeEnum.LIST_TYPE) {
|
||||||
|
List<Map<String, Object>> maps = mapper.selectListByCustomerSql(sqlStr, dataMap);
|
||||||
|
dataMap.put(name, maps);
|
||||||
|
}
|
||||||
|
// 如果是Object类型,则需要查询Map类型的数据,并将数据保存在dataMap中
|
||||||
|
if (paramTypeEnum == ParamTypeEnum.OBJECT_TYPE) {
|
||||||
|
Map<String, Object> dataResult = mapper.selectMapByCustomerSql(sqlStr, dataMap);
|
||||||
|
dataMap.put(name, dataResult);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("违规SQL,自定义SQL只支持查询SQL,不支持其他SQL操作!");
|
throw new RuntimeException("违规SQL,自定义SQL只支持查询SQL,不支持其他SQL操作!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package aiyh.utils.apirequest.core.typehandler.paramvalue;
|
package aiyh.utils.apirequest.core.typehandler.paramvalue;
|
||||||
|
|
||||||
import aiyh.utils.apirequest.core.typehandler.IParamValueRuleHandler;
|
import aiyh.utils.apirequest.core.typehandler.IParamValueRuleHandler;
|
||||||
|
import aiyh.utils.apirequest.entity.ApiRequestParamData;
|
||||||
import aiyh.utils.apirequest.pojo.ApiRequestParamDetail;
|
import aiyh.utils.apirequest.pojo.ApiRequestParamDetail;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -16,7 +17,7 @@ import java.util.Map;
|
||||||
public class FixedValueRuleHandle implements IParamValueRuleHandler {
|
public class FixedValueRuleHandle implements IParamValueRuleHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValue(ApiRequestParamDetail paramInfo, Map<String, Object> dataMap) {
|
public Object getValue(ApiRequestParamData paramInfo, Map<String, Object> dataMap) {
|
||||||
return paramInfo.getCustomerValue();
|
return paramInfo.getCustomerValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package aiyh.utils.apirequest.core.typehandler.paramvalue;
|
package aiyh.utils.apirequest.core.typehandler.paramvalue;
|
||||||
|
|
||||||
import aiyh.utils.apirequest.core.typehandler.IParamValueRuleHandler;
|
import aiyh.utils.apirequest.core.typehandler.IParamValueRuleHandler;
|
||||||
|
import aiyh.utils.apirequest.entity.ApiRequestParamData;
|
||||||
import aiyh.utils.apirequest.pojo.ApiRequestParamDetail;
|
import aiyh.utils.apirequest.pojo.ApiRequestParamDetail;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -16,7 +17,7 @@ import java.util.Map;
|
||||||
public class NullValueRuleHandler implements IParamValueRuleHandler {
|
public class NullValueRuleHandler implements IParamValueRuleHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValue(ApiRequestParamDetail paramInfo, Map<String, Object> dataMap) {
|
public Object getValue(ApiRequestParamData paramInfo, Map<String, Object> dataMap) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
package aiyh.utils.apirequest.core.typehandler.paramvalue;
|
||||||
|
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.apirequest.core.typehandler.IParamValueRuleHandler;
|
||||||
|
import aiyh.utils.apirequest.entity.ApiRequestParamData;
|
||||||
|
import aiyh.utils.apirequest.pojo.ApiRequestParamDetail;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>随机值处理器</p>
|
||||||
|
* <p>create 2022/1/27 0027 17:28</p>
|
||||||
|
*
|
||||||
|
* @author EBU7-dev1-ayh
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
public class RandomValueRuleHandle implements IParamValueRuleHandler {
|
||||||
|
@Override
|
||||||
|
public Object getValue(ApiRequestParamData paramInfo, Map<String, Object> dataMap) {
|
||||||
|
String customerValue = paramInfo.getCustomerValue();
|
||||||
|
String pattern = "\\$\\{number:(?<length>(\\d)+)}";
|
||||||
|
Pattern compile = Pattern.compile(pattern);
|
||||||
|
Matcher matcher = compile.matcher(customerValue.trim());
|
||||||
|
if (matcher.find()) {
|
||||||
|
int length = Integer.parseInt(matcher.group("length"));
|
||||||
|
return Util.randomNumber(length);
|
||||||
|
}
|
||||||
|
pattern = "\\$\\{string:(?<length>(\\\\d)+)}";
|
||||||
|
compile = Pattern.compile(pattern);
|
||||||
|
matcher = compile.matcher(customerValue.trim());
|
||||||
|
if (matcher.find()) {
|
||||||
|
int length = Integer.parseInt(matcher.group("length"));
|
||||||
|
return Util.randomString(length);
|
||||||
|
}
|
||||||
|
pattern = "\\$\\{letter:(?<length>(\\\\d)+)}";
|
||||||
|
compile = Pattern.compile(pattern);
|
||||||
|
matcher = compile.matcher(customerValue.trim());
|
||||||
|
if (matcher.find()) {
|
||||||
|
int length = Integer.parseInt(matcher.group("length"));
|
||||||
|
return Util.randomLetter(length);
|
||||||
|
}
|
||||||
|
return Util.randomNumber(6);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package aiyh.utils.apirequest.core.typehandler.paramvalue;
|
||||||
|
|
||||||
|
import aiyh.utils.apirequest.core.typehandler.IParamValueRuleHandler;
|
||||||
|
import aiyh.utils.apirequest.entity.ApiRequestParamData;
|
||||||
|
import aiyh.utils.apirequest.pojo.ApiRequestParamDetail;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>流程请求id值处理</p>
|
||||||
|
* <p>create 2022/1/27 0027 15:53</p>
|
||||||
|
*
|
||||||
|
* @author EBU7-dev1-ayh
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
public class RequestIdRuleHandler implements IParamValueRuleHandler {
|
||||||
|
@Override
|
||||||
|
public Object getValue(ApiRequestParamData paramInfo, Map<String, Object> dataMap) {
|
||||||
|
return dataMap.get("requestId");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package aiyh.utils.apirequest.core.typehandler.paramvalue;
|
||||||
|
|
||||||
|
import aiyh.utils.apirequest.core.typehandler.IParamValueRuleHandler;
|
||||||
|
import aiyh.utils.apirequest.entity.ApiRequestParamData;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>SQL字段值处理</p>
|
||||||
|
* <p>create 2022/2/8 0008 11:40</p>
|
||||||
|
*
|
||||||
|
* @author EBU7-dev1-ayh
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
public class SqlFieldRuleHandler implements IParamValueRuleHandler {
|
||||||
|
@Override
|
||||||
|
public Object getValue(ApiRequestParamData paramInfo, Map<String, Object> dataMap) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package aiyh.utils.apirequest.core.typehandler.paramvalue;
|
package aiyh.utils.apirequest.core.typehandler.paramvalue;
|
||||||
|
|
||||||
import aiyh.utils.apirequest.core.typehandler.IParamValueRuleHandler;
|
import aiyh.utils.apirequest.core.typehandler.IParamValueRuleHandler;
|
||||||
|
import aiyh.utils.apirequest.entity.ApiRequestParamData;
|
||||||
import aiyh.utils.apirequest.pojo.ApiRequestParamDetail;
|
import aiyh.utils.apirequest.pojo.ApiRequestParamDetail;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -14,9 +15,16 @@ import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
public class SystemFieldValueRuleHandle implements IParamValueRuleHandler {
|
public class SystemFieldValueRuleHandle implements IParamValueRuleHandler {
|
||||||
|
private String mainTableName = "workflow main table";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValue(ApiRequestParamDetail paramInfo, Map<String, Object> dataMap) {
|
public Object getValue(ApiRequestParamData paramInfo, Map<String, Object> dataMap) {
|
||||||
|
if (paramInfo.getFieldTableName() != null && mainTableName.equalsIgnoreCase(paramInfo.getFieldTableName())) {
|
||||||
Map<String, Object> main = (Map<String, Object>) dataMap.get("main");
|
Map<String, Object> main = (Map<String, Object>) dataMap.get("main");
|
||||||
return main.get(paramInfo.getSystemFieldName());
|
return main.get(paramInfo.getSystemFieldName());
|
||||||
|
} else {
|
||||||
|
Map<String, Object> detail = (Map<String, Object>) dataMap.get("detail");
|
||||||
|
return detail.get(paramInfo.getSystemFieldName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package aiyh.utils.apirequest.core.typehandler.paramvalue;
|
||||||
|
|
||||||
|
import aiyh.utils.apirequest.core.typehandler.IParamValueRuleHandler;
|
||||||
|
import aiyh.utils.apirequest.entity.ApiRequestParamData;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>当前时间戳处理</p>
|
||||||
|
* <p>create 2022/2/8 0008 11:38</p>
|
||||||
|
*
|
||||||
|
* @author EBU7-dev1-ayh
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
public class TimeStampRuleHandler implements IParamValueRuleHandler {
|
||||||
|
@Override
|
||||||
|
public Object getValue(ApiRequestParamData paramInfo, Map<String, Object> dataMap) {
|
||||||
|
return System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package aiyh.utils.apirequest.core.typehandler.paramvalue;
|
||||||
|
|
||||||
|
import aiyh.utils.apirequest.core.typehandler.IParamValueRuleHandler;
|
||||||
|
import aiyh.utils.apirequest.entity.ApiRequestParamData;
|
||||||
|
import aiyh.utils.apirequest.pojo.ApiRequestParamDetail;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>流程类型值处理规则类</p>
|
||||||
|
* <p>create 2022/1/27 0027 17:27</p>
|
||||||
|
*
|
||||||
|
* @author EBU7-dev1-ayh
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
public class WorkflowIdRuleHandle implements IParamValueRuleHandler {
|
||||||
|
@Override
|
||||||
|
public Object getValue(ApiRequestParamData paramInfo, Map<String, Object> dataMap) {
|
||||||
|
return dataMap.get("workflowId");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package aiyh.utils.apirequest.entity;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
import weaver.hrm.User;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>api请求参数所需的基本参数</p>
|
||||||
|
* <p>create 2022/1/28 0028 9:16</p>
|
||||||
|
*
|
||||||
|
* @author EBU7-dev1-ayh
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
@ToString
|
||||||
|
public class ApiBaseInfo {
|
||||||
|
/**
|
||||||
|
* 流程requestId
|
||||||
|
*/
|
||||||
|
private String requestId;
|
||||||
|
/**
|
||||||
|
* 流程id
|
||||||
|
*/
|
||||||
|
private String workflowId;
|
||||||
|
/**
|
||||||
|
* 当前请求用户
|
||||||
|
*/
|
||||||
|
private User user;
|
||||||
|
}
|
|
@ -0,0 +1,85 @@
|
||||||
|
package aiyh.utils.apirequest.entity;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>请求参数必要类</p>
|
||||||
|
* <p>create 2022/1/27 0027 16:07</p>
|
||||||
|
*
|
||||||
|
* @author EBU7-dev1-ayh
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString
|
||||||
|
public class ApiRequestData {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主表id
|
||||||
|
*/
|
||||||
|
private Integer id;
|
||||||
|
/**
|
||||||
|
* api地址
|
||||||
|
*/
|
||||||
|
private String apiUrl;
|
||||||
|
/**
|
||||||
|
* 测试环境api地址
|
||||||
|
*/
|
||||||
|
private String testApiUrl;
|
||||||
|
/**
|
||||||
|
* 请求方式
|
||||||
|
*/
|
||||||
|
private Integer requestType;
|
||||||
|
/**
|
||||||
|
* api启用类型
|
||||||
|
*/
|
||||||
|
private Integer apiType;
|
||||||
|
/**
|
||||||
|
* 数据来源
|
||||||
|
*/
|
||||||
|
private Integer dataSource;
|
||||||
|
/**
|
||||||
|
* api接口描述
|
||||||
|
*/
|
||||||
|
private String apiDesc;
|
||||||
|
/**
|
||||||
|
* 流程类型
|
||||||
|
*/
|
||||||
|
private String workflowType;
|
||||||
|
/**
|
||||||
|
* 建模表表名
|
||||||
|
*/
|
||||||
|
private String modelTableName;
|
||||||
|
/**
|
||||||
|
* 参数请求方式
|
||||||
|
*/
|
||||||
|
private Integer paramRequestType;
|
||||||
|
/**
|
||||||
|
* 请求参数的数据来源,适用于参数请求方式为明细表模式
|
||||||
|
*/
|
||||||
|
private String requestDetailTableName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 唯一标识
|
||||||
|
*/
|
||||||
|
private String onlyMark;
|
||||||
|
/**
|
||||||
|
* 请求参数信息
|
||||||
|
*/
|
||||||
|
private List<ApiRequestParamData> paramDetailList;
|
||||||
|
/**
|
||||||
|
* 请求头信息
|
||||||
|
*/
|
||||||
|
private List<ApiRequestHeardData> heardDetailList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* api请求基本信息
|
||||||
|
*/
|
||||||
|
private ApiBaseInfo apiBaseInfo;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package aiyh.utils.apirequest.entity;
|
||||||
|
|
||||||
|
import aiyh.utils.apirequest.pojo.ApiRequestHeardDetail;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>api 请求头参数业务处理对象</p>
|
||||||
|
* <p>create 2022/2/8 0008 11:15</p>
|
||||||
|
*
|
||||||
|
* @author EBU7-dev1-ayh
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
public class ApiRequestHeardData extends ApiRequestHeardDetail {
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package aiyh.utils.apirequest.entity;
|
||||||
|
|
||||||
|
import aiyh.utils.apirequest.pojo.ApiRequestParamDetail;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Api 请求参数配置业务对象</p>
|
||||||
|
* <p>create 2022/1/28 0028 12:09</p>
|
||||||
|
*
|
||||||
|
* @author EBU7-dev1-ayh
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
public class ApiRequestParamData extends ApiRequestParamDetail {
|
||||||
|
}
|
|
@ -13,8 +13,11 @@ import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class ParamConfigInfo {
|
public class ParamConfigInfo {
|
||||||
private String requestId;
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置主表id
|
||||||
|
*/
|
||||||
private Integer id;
|
private Integer id;
|
||||||
/**
|
/**
|
||||||
* api地址
|
* api地址
|
||||||
|
@ -28,10 +31,7 @@ public class ParamConfigInfo {
|
||||||
* 请求方式
|
* 请求方式
|
||||||
*/
|
*/
|
||||||
private Integer requestType;
|
private Integer requestType;
|
||||||
/**
|
|
||||||
* api启用类型
|
|
||||||
*/
|
|
||||||
private Integer apiType;
|
|
||||||
/**
|
/**
|
||||||
* 数据来源
|
* 数据来源
|
||||||
*/
|
*/
|
||||||
|
@ -57,10 +57,7 @@ public class ParamConfigInfo {
|
||||||
*/
|
*/
|
||||||
private String requestDetailTableName;
|
private String requestDetailTableName;
|
||||||
|
|
||||||
/**
|
|
||||||
* 唯一标识
|
|
||||||
*/
|
|
||||||
private String onlyMark;
|
|
||||||
/**
|
/**
|
||||||
* 参数信息
|
* 参数信息
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
package aiyh.utils.apirequest.enumtype;
|
package aiyh.utils.apirequest.enumtype;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>参数类型枚举</p>
|
* <p>参数类型枚举</p>
|
||||||
* <p>create 2022/1/25 0025 10:36</p>
|
* <p>create 2022/1/25 0025 10:36</p>
|
||||||
|
@ -9,4 +13,55 @@ package aiyh.utils.apirequest.enumtype;
|
||||||
|
|
||||||
|
|
||||||
public enum ParamTypeEnum {
|
public enum ParamTypeEnum {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* string 类型
|
||||||
|
*/
|
||||||
|
STRING_TYPE(0),
|
||||||
|
/**
|
||||||
|
* long 类型
|
||||||
|
*/
|
||||||
|
LONG_TYPE(1),
|
||||||
|
/**
|
||||||
|
* boolean类型
|
||||||
|
*/
|
||||||
|
BOOLEAN_TYPE(2),
|
||||||
|
/**
|
||||||
|
* object 类型
|
||||||
|
*/
|
||||||
|
OBJECT_TYPE(3),
|
||||||
|
/**
|
||||||
|
* list类型
|
||||||
|
*/
|
||||||
|
LIST_TYPE(4),
|
||||||
|
/**
|
||||||
|
* double 类型
|
||||||
|
*/
|
||||||
|
DOUBLE_TYPE(5);
|
||||||
|
|
||||||
|
|
||||||
|
private static final Map<Integer, ParamTypeEnum> LOOKUP;
|
||||||
|
|
||||||
|
static {
|
||||||
|
LOOKUP = new HashMap<>();
|
||||||
|
for (ParamTypeEnum enumType : EnumSet.allOf(ParamTypeEnum.class)) {
|
||||||
|
LOOKUP.put(enumType.getValue(), enumType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final int value;
|
||||||
|
|
||||||
|
ParamTypeEnum(int value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ParamTypeEnum get(int value) {
|
||||||
|
return LOOKUP.get(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValue() {
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import aiyh.utils.annotation.recordset.Select;
|
||||||
import aiyh.utils.annotation.recordset.SqlMapper;
|
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||||
import aiyh.utils.annotation.recordset.SqlString;
|
import aiyh.utils.annotation.recordset.SqlString;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,4 +27,26 @@ public interface ParamValueParseMapper {
|
||||||
@Select(custom = true)
|
@Select(custom = true)
|
||||||
@CaseConversion(false)
|
@CaseConversion(false)
|
||||||
public String selectCustomerSql(@SqlString String sql, Map<String,Object> map);
|
public String selectCustomerSql(@SqlString String sql, Map<String,Object> map);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义查询SQL对象
|
||||||
|
* @param sqlStr 自定义SQL字符串
|
||||||
|
* @param dataMap 参数
|
||||||
|
* @return 查询到的数据
|
||||||
|
*/
|
||||||
|
@Select(custom = true)
|
||||||
|
@CaseConversion(false)
|
||||||
|
public Map<String, Object> selectMapByCustomerSql(@SqlString String sqlStr, Map<String, Object> dataMap);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义查询SQL集合
|
||||||
|
* @param sql 自定义SQL字符串
|
||||||
|
* @param dataMap 参数
|
||||||
|
* @return 查询到的数据
|
||||||
|
*/
|
||||||
|
@Select(custom = true)
|
||||||
|
@CaseConversion(false)
|
||||||
|
public List<Map<String,Object>> selectListByCustomerSql(@SqlString String sql, Map<String,Object> dataMap);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,106 @@
|
||||||
|
package aiyh.utils.apirequest.mapsturct;
|
||||||
|
|
||||||
|
import aiyh.utils.apirequest.entity.ApiRequestData;
|
||||||
|
import aiyh.utils.apirequest.entity.ApiRequestHeardData;
|
||||||
|
import aiyh.utils.apirequest.entity.ApiRequestParamData;
|
||||||
|
import aiyh.utils.apirequest.entity.ParamInfo;
|
||||||
|
import aiyh.utils.apirequest.pojo.ApiRequestHeardDetail;
|
||||||
|
import aiyh.utils.apirequest.pojo.ApiRequestMain;
|
||||||
|
import aiyh.utils.apirequest.pojo.ApiRequestParamDetail;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.Mapping;
|
||||||
|
import org.mapstruct.Mappings;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>实体类映射</p>
|
||||||
|
* <p>create 2022/1/28 0028 9:34</p>
|
||||||
|
*
|
||||||
|
* @author EBU7-dev1-ayh
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
引入maven坐标
|
||||||
|
|
||||||
|
<org.mapstruct.version>1.4.2.Final</org.mapstruct.version>
|
||||||
|
<!-- mapstruct -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mapstruct</groupId>
|
||||||
|
<artifactId>mapstruct-jdk8</artifactId>
|
||||||
|
<version>${org.mapstruct.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mapstruct</groupId>
|
||||||
|
<artifactId>mapstruct</artifactId>
|
||||||
|
<version>${org.mapstruct.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface BeanMapper {
|
||||||
|
static final BeanMapper INSTANCE = Mappers.getMapper(BeanMapper.class);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将ApiRequestMain对象转化为APIRequestData对象
|
||||||
|
*
|
||||||
|
* @param requestMain 原对象
|
||||||
|
* @return 复制转化后的对象
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Mapping(target = "apiBaseInfo", ignore = true)
|
||||||
|
@Mapping(target = "paramDetailList", source = "paramDetailList")
|
||||||
|
@Mapping(target = "heardDetailList", source = "heardDetailList")
|
||||||
|
public ApiRequestData apiRequestMain2Data(ApiRequestMain requestMain);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将ApiRequestParamDetail 对象转换为ApiRequestParamData对象
|
||||||
|
*
|
||||||
|
* @param paramDetail 原对象
|
||||||
|
* @return 目标对象
|
||||||
|
*/
|
||||||
|
public ApiRequestParamData apiRequestDetail2Data(ApiRequestParamDetail paramDetail);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量转换
|
||||||
|
*
|
||||||
|
* @param list 批量原对象
|
||||||
|
* @return 目标对象集合
|
||||||
|
*/
|
||||||
|
public List<ApiRequestParamData> apiRequestDetailList2Data(List<ApiRequestParamDetail> list);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将ApiRequestHeardDetail对象转换为APIRequestHeardData对象
|
||||||
|
*
|
||||||
|
* @param heardDetail 原对象
|
||||||
|
* @return 目标对象
|
||||||
|
*/
|
||||||
|
public ApiRequestHeardData apiRequestHeard2Data(ApiRequestHeardDetail heardDetail);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量转换
|
||||||
|
*
|
||||||
|
* @param list 原对象集合
|
||||||
|
* @return 目标对象集合
|
||||||
|
*/
|
||||||
|
public List<ApiRequestHeardData> apiRequestHeardList2Data(List<ApiRequestHeardDetail> list);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* apiRequestParamData 对象转为paramInfo对象
|
||||||
|
*
|
||||||
|
* @param paramData 原对象
|
||||||
|
* @return 转换后的对象
|
||||||
|
*/
|
||||||
|
@Mappings({
|
||||||
|
@Mapping(target = "lineNum", source = "lineNum"),
|
||||||
|
@Mapping(target = "paramName", source = "paramName"),
|
||||||
|
@Mapping(target = "parentLine", source = "parentLine"),
|
||||||
|
@Mapping(target = "paramValue", ignore = true),
|
||||||
|
@Mapping(target = "childList", ignore = true)
|
||||||
|
})
|
||||||
|
public ParamInfo apiRequestData2ParamInfo(ApiRequestParamData paramData);
|
||||||
|
}
|
|
@ -14,10 +14,7 @@ import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class ApiRequestMain {
|
public class ApiRequestMain {
|
||||||
/**
|
|
||||||
* 流程请求id
|
|
||||||
*/
|
|
||||||
private String requestId;
|
|
||||||
/**
|
/**
|
||||||
* 主表id
|
* 主表id
|
||||||
*/
|
*/
|
||||||
|
@ -75,4 +72,5 @@ public class ApiRequestMain {
|
||||||
* 请求头信息
|
* 请求头信息
|
||||||
*/
|
*/
|
||||||
private List<ApiRequestHeardDetail> heardDetailList;
|
private List<ApiRequestHeardDetail> heardDetailList;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,6 @@ package aiyh.utils.apirequest.pojo;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p></p>
|
* <p></p>
|
||||||
* <p>create 2022/1/23 0023 18:04</p>
|
* <p>create 2022/1/23 0023 18:04</p>
|
||||||
|
@ -59,4 +57,9 @@ public class ApiRequestParamDetail {
|
||||||
private Integer enableParam;
|
private Integer enableParam;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字段所在表
|
||||||
|
*/
|
||||||
|
private String fieldTableName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,15 +5,16 @@ import aiyh.utils.apirequest.core.factory.AbstractFactory;
|
||||||
import aiyh.utils.apirequest.core.factory.AbstractFactoryImpl;
|
import aiyh.utils.apirequest.core.factory.AbstractFactoryImpl;
|
||||||
import aiyh.utils.apirequest.core.factory.DataSourceHandlerFactory;
|
import aiyh.utils.apirequest.core.factory.DataSourceHandlerFactory;
|
||||||
import aiyh.utils.apirequest.core.typehandler.IDataSourceHandler;
|
import aiyh.utils.apirequest.core.typehandler.IDataSourceHandler;
|
||||||
import aiyh.utils.apirequest.entity.ParamConfigInfo;
|
import aiyh.utils.apirequest.entity.*;
|
||||||
import aiyh.utils.apirequest.entity.ParamInfo;
|
|
||||||
import aiyh.utils.apirequest.entity.ParseAfterData;
|
|
||||||
import aiyh.utils.apirequest.enumtype.DataSourceRuleEnum;
|
import aiyh.utils.apirequest.enumtype.DataSourceRuleEnum;
|
||||||
import aiyh.utils.apirequest.interceptor.ApiRequestInterceptor;
|
import aiyh.utils.apirequest.interceptor.ApiRequestInterceptor;
|
||||||
import aiyh.utils.apirequest.mapper.ApiRequestMapper;
|
import aiyh.utils.apirequest.mapper.ApiRequestMapper;
|
||||||
|
import aiyh.utils.apirequest.mapsturct.BeanMapper;
|
||||||
import aiyh.utils.apirequest.pojo.ApiRequestHeardDetail;
|
import aiyh.utils.apirequest.pojo.ApiRequestHeardDetail;
|
||||||
import aiyh.utils.apirequest.pojo.ApiRequestMain;
|
import aiyh.utils.apirequest.pojo.ApiRequestMain;
|
||||||
import aiyh.utils.apirequest.pojo.ApiRequestParamDetail;
|
import aiyh.utils.apirequest.pojo.ApiRequestParamDetail;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
@ -27,7 +28,8 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||||
* @author EBU7-dev1-ayh
|
* @author EBU7-dev1-ayh
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
@Data
|
||||||
public class ApiRequestService {
|
public class ApiRequestService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,8 +41,8 @@ public class ApiRequestService {
|
||||||
* 查询数据库数据
|
* 查询数据库数据
|
||||||
*/
|
*/
|
||||||
private final ApiRequestMapper mapper;
|
private final ApiRequestMapper mapper;
|
||||||
|
private ApiBaseInfo apiBaseInfo;
|
||||||
|
|
||||||
private String requestId;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param interceptor 拦截器
|
* @param interceptor 拦截器
|
||||||
|
@ -86,8 +88,9 @@ public class ApiRequestService {
|
||||||
DataSourceHandlerFactory dataSourceHandlerFactory = abstractFactory.createParamHandlerFactory(DataSourceHandlerFactory.class);
|
DataSourceHandlerFactory dataSourceHandlerFactory = abstractFactory.createParamHandlerFactory(DataSourceHandlerFactory.class);
|
||||||
DataSourceRuleEnum dataSourceRuleEnum = DataSourceRuleEnum.get(apiRequestMain.getDataSource());
|
DataSourceRuleEnum dataSourceRuleEnum = DataSourceRuleEnum.get(apiRequestMain.getDataSource());
|
||||||
IDataSourceHandler paramHandler = dataSourceHandlerFactory.createParamHandler(dataSourceRuleEnum);
|
IDataSourceHandler paramHandler = dataSourceHandlerFactory.createParamHandler(dataSourceRuleEnum);
|
||||||
apiRequestMain.setRequestId(this.requestId);
|
ApiRequestData apiRequestData = BeanMapper.INSTANCE.apiRequestMain2Data(apiRequestMain);
|
||||||
AtomicReference<ParamConfigInfo> paramConfigInfo = new AtomicReference<>(paramHandler.parseDataSource(apiRequestMain));
|
apiRequestData.setApiBaseInfo(this.apiBaseInfo);
|
||||||
|
AtomicReference<ParamConfigInfo> paramConfigInfo = new AtomicReference<>(paramHandler.parseDataSource(apiRequestData));
|
||||||
// TODO 解析配置表中的参数
|
// TODO 解析配置表中的参数
|
||||||
Optional.ofNullable(interceptor).map(interceptor -> {
|
Optional.ofNullable(interceptor).map(interceptor -> {
|
||||||
Optional.ofNullable(interceptor.parseAfter(paramConfigInfo.get())).map(v -> {
|
Optional.ofNullable(interceptor.parseAfter(paramConfigInfo.get())).map(v -> {
|
||||||
|
@ -126,12 +129,4 @@ public class ApiRequestService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getRequestId() {
|
|
||||||
return requestId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRequestId(String requestId) {
|
|
||||||
this.requestId = requestId;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ public class ParseParamValue {
|
||||||
DataSourceHandlerFactory dataSourceHandlerFactory = abstractFactory.createParamHandlerFactory(DataSourceHandlerFactory.class);
|
DataSourceHandlerFactory dataSourceHandlerFactory = abstractFactory.createParamHandlerFactory(DataSourceHandlerFactory.class);
|
||||||
DataSourceRuleEnum dataSourceRuleEnum = DataSourceRuleEnum.get(apiRequestMain.getDataSource());
|
DataSourceRuleEnum dataSourceRuleEnum = DataSourceRuleEnum.get(apiRequestMain.getDataSource());
|
||||||
IDataSourceHandler paramHandler = dataSourceHandlerFactory.createParamHandler(dataSourceRuleEnum);
|
IDataSourceHandler paramHandler = dataSourceHandlerFactory.createParamHandler(dataSourceRuleEnum);
|
||||||
return paramHandler.parseDataSource(apiRequestMain);
|
// return paramHandler.parseDataSource(apiRequestMain);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.api.aiyh_pcn.async_organization;
|
package com.api.aiyh_pcn.async_organization;
|
||||||
|
|
||||||
import aiyh.utils.zwl.common.ToolUtil;
|
import aiyh.utils.zwl.common.ToolUtil;
|
||||||
import com.ibm.icu.text.SimpleDateFormat;
|
|
||||||
import km.org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
import km.org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
||||||
import km.org.apache.poi.hssf.util.HSSFColor;
|
import km.org.apache.poi.hssf.util.HSSFColor;
|
||||||
import org.apache.poi.ss.usermodel.*;
|
import org.apache.poi.ss.usermodel.*;
|
||||||
|
@ -22,6 +21,7 @@ import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
|
@ -16,12 +16,10 @@ import com.drew.metadata.Directory;
|
||||||
import com.drew.metadata.Metadata;
|
import com.drew.metadata.Metadata;
|
||||||
import com.drew.metadata.Tag;
|
import com.drew.metadata.Tag;
|
||||||
import com.engine.doc.cmd.secCategoryList.DocSecCategoryAddCmd;
|
import com.engine.doc.cmd.secCategoryList.DocSecCategoryAddCmd;
|
||||||
import com.weaver.general.GCONST;
|
|
||||||
import entity.ImageInfo;
|
import entity.ImageInfo;
|
||||||
import mybatisTest.mapper.IMapperTest;
|
import mybatisTest.mapper.IMapperTest;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.log4j.*;
|
import org.apache.log4j.*;
|
||||||
import org.apache.log4j.spi.Configurator;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import utilTest.entity.TestTreeEntity;
|
import utilTest.entity.TestTreeEntity;
|
||||||
|
@ -29,11 +27,17 @@ import weaver.conn.RecordSet;
|
||||||
import weaver.hrm.User;
|
import weaver.hrm.User;
|
||||||
import weaver.hrm.moduledetach.ManageDetachComInfo;
|
import weaver.hrm.moduledetach.ManageDetachComInfo;
|
||||||
|
|
||||||
|
import javax.xml.transform.Source;
|
||||||
|
import java.beans.BeanInfo;
|
||||||
|
import java.beans.IntrospectionException;
|
||||||
|
import java.beans.Introspector;
|
||||||
|
import java.beans.PropertyDescriptor;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.reflect.*;
|
import java.lang.reflect.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author EBU7-dev1-ayh
|
* @author EBU7-dev1-ayh
|
||||||
|
@ -509,4 +513,63 @@ public class UtilTest {
|
||||||
log.warn("我是警告-------------->");
|
log.warn("我是警告-------------->");
|
||||||
System.out.println(log.getEffectiveLevel());
|
System.out.println(log.getEffectiveLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testClass() throws IntrospectionException, NoSuchFieldException {
|
||||||
|
ApiRequestMain apiRequestMain = new ApiRequestMain();
|
||||||
|
|
||||||
|
BeanInfo beanInfo = Introspector.getBeanInfo(ApiRequestMain.class,Object.class);
|
||||||
|
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
|
||||||
|
for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
|
||||||
|
System.out.println(propertyDescriptor.getName());
|
||||||
|
System.out.println(apiRequestMain.getClass().getDeclaredField(propertyDescriptor.getName()));
|
||||||
|
;
|
||||||
|
System.out.println("=====================================");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testClassM() throws NoSuchFieldException {
|
||||||
|
Class<A> clazz = A.class;
|
||||||
|
Field field = clazz.getField("list");
|
||||||
|
ParameterizedType type = (ParameterizedType) field.getGenericType();
|
||||||
|
Stream.of(type.getActualTypeArguments()).forEach(System.out::println);
|
||||||
|
|
||||||
|
field = clazz.getField("list1");
|
||||||
|
type = (ParameterizedType) field.getGenericType();
|
||||||
|
Stream.of(type.getActualTypeArguments()).forEach(v->{
|
||||||
|
ParameterizedType v1 = (ParameterizedType)v;
|
||||||
|
for (Type actualTypeArgument : v1.getActualTypeArguments()) {
|
||||||
|
System.out.println(actualTypeArgument);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
class A {
|
||||||
|
public List<? extends String> list = new ArrayList<>();
|
||||||
|
|
||||||
|
public List<Map<String,ApiRequestMain>> list1 = new ArrayList<>();
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void testRandom(){
|
||||||
|
String pattern = "\\$\\{number:(?<length>(\\d)+)}";
|
||||||
|
Pattern compile = Pattern.compile(pattern);
|
||||||
|
Matcher matcher = compile.matcher(" ${number:10}".trim());
|
||||||
|
if(matcher.find()){
|
||||||
|
System.out.println(matcher.group("length"));
|
||||||
|
System.out.println(Util.randomNumber(Integer.parseInt(matcher.group("length"))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReg(){
|
||||||
|
String str = "$:{select * from #{alal} and ${sjls}}";
|
||||||
|
String pattern = "^(\\$:)(?<name>\\w*)\\{(?<sql>[\\S\\s]+)}";
|
||||||
|
Pattern compile = Pattern.compile(pattern);
|
||||||
|
Matcher matcher = compile.matcher(str.trim());
|
||||||
|
if(matcher.find()){
|
||||||
|
System.out.println(matcher.group("name"));
|
||||||
|
System.out.println(matcher.group("sql"));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue