mirror of
https://gitee.com/jeelowcode/JeeLowCode.git
synced 2026-06-04 01:32:26 +08:00
[fix]:JAVA增强返回类型错误修复
This commit is contained in:
@@ -184,7 +184,7 @@ public class JeeLowCodeAnnoaionAspectjSQL {
|
||||
}
|
||||
EnhanceContext context = new EnhanceContext();
|
||||
Map<String, Object> params = JeeLowCodeUtils.getMap2Map(paramMap, "params");
|
||||
context.setParam(dbFormId, params, dataList, dataId, page);
|
||||
context.setParamMore(dbFormId, params, dataList, dataId, page);
|
||||
context.setResult(new EnhanceResult());
|
||||
return new BuildSqlEnhanceContext(context, allPlugins, setOperation);
|
||||
}
|
||||
@@ -294,7 +294,7 @@ public class JeeLowCodeAnnoaionAspectjSQL {
|
||||
|
||||
String executeSql = sqlEntity.getExecuteSql();
|
||||
List<Map<String, Object>> dataMapList = this.executeSelectListSql(executeSql, params, autoWhereSql);
|
||||
context.setResult(ResultDataModel.fomatList(dataMapList));
|
||||
context.setResultModel(ResultDataModel.fomatList(dataMapList));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,4 @@
|
||||
/*
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
|
||||
|
||||
开源协议中文释意如下:
|
||||
1.JeeLowCode开源版本无任何限制,在遵循本开源协议(Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
|
||||
2.允许基于本平台软件开展业务系统开发。
|
||||
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
|
||||
|
||||
最终解释权归:http://www.jeelowcode.com
|
||||
*/
|
||||
package com.jeelowcode.core.framework.config.aspect.enhance;
|
||||
|
||||
|
||||
@@ -19,7 +7,6 @@ import com.jeelowcode.core.framework.config.aspect.enhance.model.*;
|
||||
import com.jeelowcode.core.framework.config.aspect.enhance.plugin.*;
|
||||
import com.jeelowcode.core.framework.config.listener.JeeLowCodeListener;
|
||||
import com.jeelowcode.core.framework.entity.EnhanceJavaEntity;
|
||||
import com.jeelowcode.core.framework.params.SaveImportDataParam;
|
||||
import com.jeelowcode.core.framework.utils.Func;
|
||||
import com.jeelowcode.framework.exception.JeeLowCodeException;
|
||||
import com.jeelowcode.framework.utils.model.ExecuteEnhanceModel;
|
||||
@@ -40,7 +27,8 @@ import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.jeelowcode.framework.utils.constant.EnhanceConstant.*;
|
||||
import static com.jeelowcode.framework.utils.constant.EnhanceConstant.ENHANCE_EXPORT;
|
||||
import static com.jeelowcode.framework.utils.constant.EnhanceConstant.ENHANCE_LIST;
|
||||
|
||||
/**
|
||||
* @author JX
|
||||
@@ -138,9 +126,10 @@ public class JeeLowCodeAnnotationAspectjJAVA {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
Class<?> returnType = signature.getMethod().getReturnType();
|
||||
//返回结果
|
||||
Object result = getResult(context);
|
||||
Object result = getResult(returnType,context);
|
||||
if (resultFlag) {
|
||||
ResultDataModel returnValData = (ResultDataModel) returnVal;
|
||||
ResultDataModel resultDataModel = (ResultDataModel) result;
|
||||
@@ -178,8 +167,11 @@ public class JeeLowCodeAnnotationAspectjJAVA {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 获取目标方法返回类型
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
Class<?> returnType = signature.getMethod().getReturnType();
|
||||
|
||||
return getResult(context);
|
||||
return getResult(returnType,context);
|
||||
}
|
||||
|
||||
@AfterThrowing(value = EXPRESSION, throwing = "ex")
|
||||
@@ -302,7 +294,6 @@ public class JeeLowCodeAnnotationAspectjJAVA {
|
||||
param.setList((ArrayList) paramMap.getOrDefault("dataList", null));
|
||||
param.setParams((Map<String, Object>) paramMap.getOrDefault("params", null));
|
||||
|
||||
|
||||
//把参数放入到上下文
|
||||
EnhanceContext context = new EnhanceContext();
|
||||
context.setParam(param);
|
||||
@@ -616,24 +607,34 @@ public class JeeLowCodeAnnotationAspectjJAVA {
|
||||
|
||||
|
||||
|
||||
public Object getResult(EnhanceContext context) {
|
||||
if (Func.isEmpty(context.getResult().getRecords()) && FuncBase.isEmpty(context.getResult().getId())) {
|
||||
return ResultDataModel.fomat(0L, new ArrayList<>());
|
||||
}
|
||||
if (FuncBase.isEmpty(context.getResult().getRecords())) {
|
||||
ExecuteEnhanceModel enhanceModel = new ExecuteEnhanceModel();
|
||||
enhanceModel.setId(context.getResult().getId());
|
||||
enhanceModel.setExitFlag(context.getResult().isExitFlag());
|
||||
|
||||
return enhanceModel;
|
||||
} else {
|
||||
|
||||
public Object getResult(Class<?> returnType,EnhanceContext context) {
|
||||
if (returnType.equals(ResultDataModel.class)) {//查询相关
|
||||
EnhanceResult result = context.getResult();
|
||||
if(Func.isEmpty(result.getRecords())){
|
||||
return ResultDataModel.fomat(0L, new ArrayList<>());
|
||||
}
|
||||
List<Map<String, Object>> records = result.getRecords();
|
||||
String id = result.getId();
|
||||
if(FuncBase.isEmpty(id) && Func.isEmpty(records)){
|
||||
return ResultDataModel.fomat(0L, new ArrayList<>());
|
||||
}
|
||||
ResultDataModel resultDataModel = new ResultDataModel();
|
||||
resultDataModel.setRecords(context.getResult().getRecords());
|
||||
resultDataModel.setTotal(context.getResult().getTotal());
|
||||
resultDataModel.setExitFlag(context.getResult().isExitFlag());
|
||||
return resultDataModel;
|
||||
|
||||
}
|
||||
//不是查询类型
|
||||
if (returnType.equals(ExecuteEnhanceModel.class)) {
|
||||
ExecuteEnhanceModel enhanceModel = new ExecuteEnhanceModel();
|
||||
enhanceModel.setId(context.getResult().getId());
|
||||
enhanceModel.setExitFlag(context.getResult().isExitFlag());
|
||||
|
||||
return enhanceModel;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
//判断左边是否为空
|
||||
|
||||
@@ -1,16 +1,4 @@
|
||||
/*
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
|
||||
|
||||
开源协议中文释意如下:
|
||||
1.JeeLowCode开源版本无任何限制,在遵循本开源协议(Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
|
||||
2.允许基于本平台软件开展业务系统开发。
|
||||
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
|
||||
|
||||
最终解释权归:http://www.jeelowcode.com
|
||||
*/
|
||||
package com.jeelowcode.core.framework.config.aspect.enhance.model;
|
||||
|
||||
import com.jeelowcode.framework.utils.model.ResultDataModel;
|
||||
@@ -48,7 +36,7 @@ public class EnhanceContext extends BaseEnhanceContext implements Serializable{
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public void setResult(ResultDataModel resultDataModel){
|
||||
public void setResultModel(ResultDataModel resultDataModel){
|
||||
this.result.setExitFlag(resultDataModel.isExitFlag());
|
||||
this.result.setRecords(resultDataModel.getRecords());
|
||||
this.result.setTotal(resultDataModel.getTotal());
|
||||
@@ -70,15 +58,8 @@ public class EnhanceContext extends BaseEnhanceContext implements Serializable{
|
||||
}
|
||||
}
|
||||
|
||||
public void setParam(Long dbFormId,Map<String,Object> params,List<Map<String,Object>> list){
|
||||
this.param = new EnhanceParam(dbFormId,params,list);
|
||||
}
|
||||
|
||||
public void setResult(boolean exitFlag,String id,Long total,List<Map<String,Object>> records){
|
||||
this.result = new EnhanceResult(exitFlag,id,total,records);
|
||||
}
|
||||
|
||||
public void setParam(Long dbFormId, Map<String, Object> params, List<Map<String, Object>> list, Long dataId, Page page){
|
||||
public void setParamMore(Long dbFormId, Map<String, Object> params, List<Map<String, Object>> list, Long dataId, Page page){
|
||||
this.param = new EnhanceParam(dbFormId,params,list,dataId,page);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,4 @@
|
||||
/*
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
|
||||
|
||||
开源协议中文释意如下:
|
||||
1.JeeLowCode开源版本无任何限制,在遵循本开源协议(Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
|
||||
2.允许基于本平台软件开展业务系统开发。
|
||||
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
|
||||
|
||||
最终解释权归:http://www.jeelowcode.com
|
||||
*/
|
||||
package com.jeelowcode.core.framework.config.aspect.enhancereport;
|
||||
|
||||
|
||||
@@ -93,8 +81,10 @@ public class JeeLowCodeAnnotationAspectjReport {
|
||||
|
||||
|
||||
//返回结果
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
Class<?> returnType = signature.getMethod().getReturnType();
|
||||
ResultDataModel returnValData = (ResultDataModel) returnVal;
|
||||
resultDataModel = (ResultDataModel) getResult(context);
|
||||
resultDataModel = (ResultDataModel) getResult(returnType,context);
|
||||
returnValData.setRecords(resultDataModel.getRecords());
|
||||
returnValData.setTotal(resultDataModel.getTotal());
|
||||
return returnValData;
|
||||
@@ -148,16 +138,25 @@ public class JeeLowCodeAnnotationAspectjReport {
|
||||
ReportPluginManager.executePlugin(javaClassUrl, context);
|
||||
}
|
||||
|
||||
public Object getResult(EnhanceReportContext context) {
|
||||
if (Func.isEmpty(context.getResult().getRecords()) && FuncBase.isEmpty(context.getResult().getId())) {
|
||||
return ResultDataModel.fomat(0L, new ArrayList<>());
|
||||
}
|
||||
public Object getResult(Class<?> returnType,EnhanceReportContext context) {
|
||||
if (returnType.equals(ResultDataModel.class)) {//查询相关
|
||||
EnhanceResult result = context.getResult();
|
||||
if(Func.isEmpty(result.getRecords())){
|
||||
return ResultDataModel.fomat(0L, new ArrayList<>());
|
||||
}
|
||||
List<Map<String, Object>> records = result.getRecords();
|
||||
String id = result.getId();
|
||||
if(FuncBase.isEmpty(id) && Func.isEmpty(records)){
|
||||
return ResultDataModel.fomat(0L, new ArrayList<>());
|
||||
}
|
||||
ResultDataModel resultDataModel = new ResultDataModel();
|
||||
resultDataModel.setRecords(context.getResult().getRecords());
|
||||
resultDataModel.setTotal(context.getResult().getTotal());
|
||||
resultDataModel.setExitFlag(context.getResult().isExitFlag());
|
||||
return resultDataModel;
|
||||
|
||||
ResultDataModel resultDataModel = new ResultDataModel();
|
||||
resultDataModel.setRecords(context.getResult().getRecords());
|
||||
resultDataModel.setTotal(context.getResult().getTotal());
|
||||
resultDataModel.setExitFlag(context.getResult().isExitFlag());
|
||||
return resultDataModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//刷新插件
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
/*
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
|
||||
|
||||
开源协议中文释意如下:
|
||||
1.JeeLowCode开源版本无任何限制,在遵循本开源协议(Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
|
||||
2.允许基于本平台软件开展业务系统开发。
|
||||
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
|
||||
|
||||
最终解释权归:http://www.jeelowcode.com
|
||||
*/
|
||||
package com.jeelowcode.module.biz.demo.test;
|
||||
|
||||
import com.jeelowcode.core.framework.config.aspect.enhance.criteria.DifferenceCriteriaFilterAdvicePlugin;
|
||||
import com.jeelowcode.core.framework.config.aspect.enhance.criteria.IntersectionCriteriaFilterAdvicePlugin;
|
||||
import com.jeelowcode.core.framework.config.aspect.enhance.criteria.OrCriteriaFilterAdvicePlugin;
|
||||
import com.jeelowcode.core.framework.config.aspect.enhance.criteria.UnionCriteriaFilterAdvicePlugin;
|
||||
import com.jeelowcode.core.framework.config.aspect.enhance.model.EnhanceContext;
|
||||
import com.jeelowcode.framework.utils.utils.FuncBase;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author JX
|
||||
* @create 2024-08-19 15:03
|
||||
* @dedescription:
|
||||
*/
|
||||
public class TestCriterFilter {
|
||||
|
||||
|
||||
|
||||
|
||||
//合集
|
||||
@Test
|
||||
public void testCriterFilter(){
|
||||
EnhanceContext context = new EnhanceContext();
|
||||
context.setParam(01L,new HashMap<>(),new ArrayList<>());
|
||||
context.setResult(false, "01",10L,initRecords());
|
||||
TestAfterAdvicePlugin01 plugin01 = new TestAfterAdvicePlugin01();
|
||||
TestAfterAdvicePlugin02 plugin02 = new TestAfterAdvicePlugin02();
|
||||
//合集
|
||||
OrCriteriaFilterAdvicePlugin orPlugin = new OrCriteriaFilterAdvicePlugin(plugin01, plugin02);
|
||||
orPlugin.execute(context);
|
||||
System.out.println("合集:"+FuncBase.json2Str(context.getResult().getRecords()));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//差集
|
||||
@Test
|
||||
public void testCriterFilter02(){
|
||||
EnhanceContext context = new EnhanceContext();
|
||||
context.setParam(01L,new HashMap<>(),new ArrayList<>());
|
||||
context.setResult(false, "01",10L,initRecords());
|
||||
TestAfterAdvicePlugin01 plugin01 = new TestAfterAdvicePlugin01();
|
||||
TestAfterAdvicePlugin02 plugin02 = new TestAfterAdvicePlugin02();
|
||||
//差集
|
||||
DifferenceCriteriaFilterAdvicePlugin differPlugin = new DifferenceCriteriaFilterAdvicePlugin(plugin01, plugin02);
|
||||
differPlugin.execute(context);
|
||||
System.out.println("差集:"+FuncBase.json2Str(context.getResult().getRecords()));
|
||||
}
|
||||
|
||||
//并集
|
||||
@Test
|
||||
public void testCriterFilter03(){
|
||||
EnhanceContext context = new EnhanceContext();
|
||||
context.setParam(01L,new HashMap<>(),new ArrayList<>());
|
||||
context.setResult(false, "01",10L,initRecords());
|
||||
TestAfterAdvicePlugin01 plugin01 = new TestAfterAdvicePlugin01();
|
||||
TestAfterAdvicePlugin02 plugin02 = new TestAfterAdvicePlugin02();
|
||||
//并集
|
||||
UnionCriteriaFilterAdvicePlugin unionPlugin = new UnionCriteriaFilterAdvicePlugin(plugin01, plugin02);
|
||||
unionPlugin.execute(context);
|
||||
System.out.println("并集:"+FuncBase.json2Str(context.getResult().getRecords()));
|
||||
}
|
||||
|
||||
//交集
|
||||
@Test
|
||||
public void testCriterFilter04(){
|
||||
EnhanceContext context = new EnhanceContext();
|
||||
context.setParam(01L,new HashMap<>(),new ArrayList<>());
|
||||
context.setResult(false, "01",10L,initRecords());
|
||||
TestAfterAdvicePlugin01 plugin01 = new TestAfterAdvicePlugin01();
|
||||
TestAfterAdvicePlugin02 plugin02 = new TestAfterAdvicePlugin02();
|
||||
//交集
|
||||
IntersectionCriteriaFilterAdvicePlugin intersection = new IntersectionCriteriaFilterAdvicePlugin(plugin01, plugin02);
|
||||
intersection.execute(context);
|
||||
System.out.println("交集:"+FuncBase.json2Str(context.getResult().getRecords()));
|
||||
}
|
||||
|
||||
|
||||
public static List<Map<String,Object>> initRecords(){
|
||||
List<Map<String,Object>> records = new ArrayList<>();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Map<String,Object> record = new HashMap<>();
|
||||
record.put("id",i);
|
||||
record.put("name","name--"+i);
|
||||
records.add(record);
|
||||
}
|
||||
return records;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user