提交 e9a0b07f 编写于 作者: sq3536's avatar sq3536

反射

上级 bca585b2
package net.ibizsys.central.plugin.boot.core.domain; package net.ibizsys.central.plugin.boot.core.domain;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.util.TypeUtils; import com.alibaba.fastjson.util.TypeUtils;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
...@@ -183,15 +185,7 @@ public class BaseData implements IEntityDTO { ...@@ -183,15 +185,7 @@ public class BaseData implements IEntityDTO {
if(_allParamMap==null) if(_allParamMap==null)
_allParamMap = new HashMap<>(); _allParamMap = new HashMap<>();
_allParamMap.clear(); _allParamMap.clear();
_allParamMap.putAll(this.paramMap); _allParamMap.putAll(toMap());
getMap().keySet().forEach(key->{
Object obj=getMap().get(key);
if(obj==null)
return;
if((!key.equals("map"))&&(!key.equals("_allParamMap"))&&(!key.equals("paramMap")))
_allParamMap.put(key.toString(),obj);
});
focusNull.forEach(item->_allParamMap.put(item,null));
return _allParamMap; return _allParamMap;
} }
...@@ -776,8 +770,7 @@ public class BaseData implements IEntityDTO { ...@@ -776,8 +770,7 @@ public class BaseData implements IEntityDTO {
public Map<String, Object> toMap() public Map<String, Object> toMap()
{ {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.putAll(this.paramMap); map.putAll((JSONObject)JSON.toJSON(this));
map.putAll(this.getMap());
focusNull.forEach(item->map.put(item,null)); focusNull.forEach(item->map.put(item,null));
return map; return map;
......
...@@ -19,6 +19,7 @@ import net.ibizsys.runtime.dataentity.service.DEMethodReturnTypes; ...@@ -19,6 +19,7 @@ import net.ibizsys.runtime.dataentity.service.DEMethodReturnTypes;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType; import java.lang.reflect.ParameterizedType;
import java.util.HashMap; import java.util.HashMap;
...@@ -134,9 +135,19 @@ public class BootServiceImpl<T extends BaseData, F extends BaseFilter> extends D ...@@ -134,9 +135,19 @@ public class BootServiceImpl<T extends BaseData, F extends BaseFilter> extends D
if (method != null) { if (method != null) {
Object rt = null; Object rt = null;
if (iPSDEAction != null && iPSDEAction.getPSDEActionReturn() != null && DEMethodReturnTypes.VOID.equals(iPSDEAction.getPSDEActionReturn().getType())) if (iPSDEAction != null && iPSDEAction.getPSDEActionReturn() != null && DEMethodReturnTypes.VOID.equals(iPSDEAction.getPSDEActionReturn().getType()))
try{
method.invoke(this.getBaseService(), args[0]); method.invoke(this.getBaseService(), args[0]);
else } catch (InvocationTargetException ex){
throw ex.getTargetException();
}
else {
try {
rt = method.invoke(this.getBaseService(), args[0]); rt = method.invoke(this.getBaseService(), args[0]);
} catch (InvocationTargetException ex){
throw ex.getTargetException();
}
}
return rt; return rt;
} }
} }
...@@ -154,9 +165,20 @@ public class BootServiceImpl<T extends BaseData, F extends BaseFilter> extends D ...@@ -154,9 +165,20 @@ public class BootServiceImpl<T extends BaseData, F extends BaseFilter> extends D
if (method != null) { if (method != null) {
Object rt = null; Object rt = null;
if (iPSDEAction != null && iPSDEAction.getPSDEActionReturn() != null && DEMethodReturnTypes.VOID.equals(iPSDEAction.getPSDEActionReturn().getType())) if (iPSDEAction != null && iPSDEAction.getPSDEActionReturn() != null && DEMethodReturnTypes.VOID.equals(iPSDEAction.getPSDEActionReturn().getType()))
{
try {
method.invoke(this.getBaseService(), args[0]); method.invoke(this.getBaseService(), args[0]);
else } catch (InvocationTargetException ex){
throw ex.getTargetException();
}
}
else {
try {
rt = method.invoke(this.getBaseService(), args[0]); rt = method.invoke(this.getBaseService(), args[0]);
}catch (InvocationTargetException ex){
throw ex.getTargetException();
}
}
return rt; return rt;
} }
...@@ -173,8 +195,13 @@ public class BootServiceImpl<T extends BaseData, F extends BaseFilter> extends D ...@@ -173,8 +195,13 @@ public class BootServiceImpl<T extends BaseData, F extends BaseFilter> extends D
if(args.length>0&&args[0]!=null) { if(args.length>0&&args[0]!=null) {
((F) args[0]).setDataSet(iPSDEDataSet); ((F) args[0]).setDataSet(iPSDEDataSet);
Method method = getBaseService().getServiceMethod("fetch" + StringAdvUtils.pascalcase(strDataSetName), args[0].getClass()); Method method = getBaseService().getServiceMethod("fetch" + StringAdvUtils.pascalcase(strDataSetName), args[0].getClass());
if (method != null) if (method != null) {
try {
return method.invoke(this.getBaseService(), args[0]); return method.invoke(this.getBaseService(), args[0]);
}catch (InvocationTargetException ex){
throw ex.getTargetException();
}
}
} }
return getBaseService().fetchDataSet(strDataSetName,iPSDEDataSet,args); return getBaseService().fetchDataSet(strDataSetName,iPSDEDataSet,args);
} }
...@@ -188,8 +215,13 @@ public class BootServiceImpl<T extends BaseData, F extends BaseFilter> extends D ...@@ -188,8 +215,13 @@ public class BootServiceImpl<T extends BaseData, F extends BaseFilter> extends D
if(args.length>0&&args[0]!=null) { if(args.length>0&&args[0]!=null) {
((F) args[0]).setDataSet(iPSDEDataSet); ((F) args[0]).setDataSet(iPSDEDataSet);
Method method = getBaseService().getServiceMethod("onFetch" + StringAdvUtils.pascalcase(strDataSetName), args[0].getClass()); Method method = getBaseService().getServiceMethod("onFetch" + StringAdvUtils.pascalcase(strDataSetName), args[0].getClass());
if (method != null) if (method != null) {
try {
return method.invoke(this.getBaseService(), args[0]); return method.invoke(this.getBaseService(), args[0]);
}catch (InvocationTargetException ex){
throw ex.getTargetException();
}
}
} }
return getBaseService().fetchDataSetReal(iDataEntityRuntimeContext, strDataSetName, iPSDEDataSet, args, actionData); return getBaseService().fetchDataSetReal(iDataEntityRuntimeContext, strDataSetName, iPSDEDataSet, args, actionData);
} }
......
...@@ -11,6 +11,7 @@ import net.ibizsys.model.dataentity.action.IPSDEAction; ...@@ -11,6 +11,7 @@ import net.ibizsys.model.dataentity.action.IPSDEAction;
import net.ibizsys.model.dataentity.ds.IPSDEDataSet; import net.ibizsys.model.dataentity.ds.IPSDEDataSet;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -50,9 +51,13 @@ public interface IBaseService<T extends BaseData, F extends BaseFilter> { ...@@ -50,9 +51,13 @@ public interface IBaseService<T extends BaseData, F extends BaseFilter> {
} }
default void beforeAction(String strActionName,Object arg) throws Throwable{ default void beforeAction(String strActionName,Object arg) throws Throwable{
Method beforeMethod = getServiceMethod("before"+ StringAdvUtils.pascalcase(strActionName), arg.getClass()); try {
Method beforeMethod = getServiceMethod("before" + StringAdvUtils.pascalcase(strActionName), arg.getClass());
if (beforeMethod != null) if (beforeMethod != null)
beforeMethod.invoke(this, arg); beforeMethod.invoke(this, arg);
}catch (InvocationTargetException ex){
throw ex.getTargetException();
}
} }
default Object forwardAction(String strActionName,Object arg) throws Throwable{ default Object forwardAction(String strActionName,Object arg) throws Throwable{
...@@ -68,9 +73,13 @@ public interface IBaseService<T extends BaseData, F extends BaseFilter> { ...@@ -68,9 +73,13 @@ public interface IBaseService<T extends BaseData, F extends BaseFilter> {
} }
default void afterAction(String strActionName,Object arg) throws Throwable{ default void afterAction(String strActionName,Object arg) throws Throwable{
Method afterMethod = getServiceMethod("after"+ StringAdvUtils.pascalcase(strActionName), arg.getClass()); try {
Method afterMethod = getServiceMethod("after" + StringAdvUtils.pascalcase(strActionName), arg.getClass());
if (afterMethod != null) if (afterMethod != null)
afterMethod.invoke(this, arg); afterMethod.invoke(this, arg);
} catch (InvocationTargetException ex){
throw ex.getTargetException();
}
} }
default Object fetchDataSet(String strDataSetName, IPSDEDataSet iPSDEDataSet, Object[] args) throws Throwable { default Object fetchDataSet(String strDataSetName, IPSDEDataSet iPSDEDataSet, Object[] args) throws Throwable {
...@@ -78,9 +87,13 @@ public interface IBaseService<T extends BaseData, F extends BaseFilter> { ...@@ -78,9 +87,13 @@ public interface IBaseService<T extends BaseData, F extends BaseFilter> {
} }
default void beforeFetch(String strActionName,Object arg) throws Throwable{ default void beforeFetch(String strActionName,Object arg) throws Throwable{
Method beforeMethod = getServiceMethod("beforeFetch"+ StringAdvUtils.pascalcase(strActionName), arg.getClass()); try {
Method beforeMethod = getServiceMethod("beforeFetch" + StringAdvUtils.pascalcase(strActionName), arg.getClass());
if (beforeMethod != null) if (beforeMethod != null)
beforeMethod.invoke(this, arg); beforeMethod.invoke(this, arg);
} catch (InvocationTargetException ex){
throw ex.getTargetException();
}
} }
default Object forwardFetch(String dsName,F arg) throws Throwable{ default Object forwardFetch(String dsName,F arg) throws Throwable{
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册