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

整理方法

上级 8221d13f
...@@ -58,8 +58,9 @@ public class BootServiceImpl<T extends BaseData, F extends BaseFilter> extends D ...@@ -58,8 +58,9 @@ public class BootServiceImpl<T extends BaseData, F extends BaseFilter> extends D
private IBootSystemRuntime systemRuntime; private IBootSystemRuntime systemRuntime;
@Override @Override
public IBootSystemRuntime getSystemRuntime() { public IBootSystemRuntime getSystemRuntime() {
if(this.systemRuntime==null) if(this.systemRuntime==null) {
systemRuntime=BootSystemRuntime.getInstance(); systemRuntime = BootSystemRuntime.getInstance();
}
return this.systemRuntime; return this.systemRuntime;
} }
...@@ -129,13 +130,6 @@ public class BootServiceImpl<T extends BaseData, F extends BaseFilter> extends D ...@@ -129,13 +130,6 @@ public class BootServiceImpl<T extends BaseData, F extends BaseFilter> extends D
public Object executeAction(String strActionName, IPSDEAction iPSDEAction, Object[] args) throws Throwable { public Object executeAction(String strActionName, IPSDEAction iPSDEAction, Object[] args) throws Throwable {
if(getBaseService()!=null) { if(getBaseService()!=null) {
if(args.length>0&&args[0]!=null) { if(args.length>0&&args[0]!=null) {
// if(args[0] instanceof BaseData)
// {
// Method beforeMethod = getBaseService().getServiceMethod("before"+StringAdvUtils.pascalcase(strActionName), args[0].getClass());
// if (beforeMethod != null)
// beforeMethod.invoke(this.getBaseService(), args[0]);
// }
Method method = getBaseService().getServiceMethod(StringAdvUtils.camelcase(strActionName), args[0].getClass()); Method method = getBaseService().getServiceMethod(StringAdvUtils.camelcase(strActionName), args[0].getClass());
if (method != null) { if (method != null) {
Object rt = null; Object rt = null;
...@@ -143,14 +137,6 @@ public class BootServiceImpl<T extends BaseData, F extends BaseFilter> extends D ...@@ -143,14 +137,6 @@ public class BootServiceImpl<T extends BaseData, F extends BaseFilter> extends D
method.invoke(this.getBaseService(), args[0]); method.invoke(this.getBaseService(), args[0]);
else else
rt = method.invoke(this.getBaseService(), args[0]); rt = method.invoke(this.getBaseService(), args[0]);
// if(args[0] instanceof BaseData)
// {
// Method afterMethod = getBaseService().getServiceMethod("after"+StringAdvUtils.pascalcase(strActionName), args[0].getClass());
// if (afterMethod != null)
// afterMethod.invoke(this.getBaseService(), args[0]);
// }
return rt; return rt;
} }
} }
...@@ -186,12 +172,6 @@ public class BootServiceImpl<T extends BaseData, F extends BaseFilter> extends D ...@@ -186,12 +172,6 @@ public class BootServiceImpl<T extends BaseData, F extends BaseFilter> extends D
if(getBaseService()!=null) { if(getBaseService()!=null) {
if(args.length>0&&args[0]!=null) { if(args.length>0&&args[0]!=null) {
((F) args[0]).setDataSet(iPSDEDataSet); ((F) args[0]).setDataSet(iPSDEDataSet);
// if(args[0] instanceof BaseFilter)
// {
// Method beforeMethod = getBaseService().getServiceMethod("beforeFetch"+StringAdvUtils.pascalcase(strDataSetName), args[0].getClass());
// if (beforeMethod != null)
// beforeMethod.invoke(this.getBaseService(), args[0]);
// }
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)
return method.invoke(this.getBaseService(), args[0]); return method.invoke(this.getBaseService(), args[0]);
......
...@@ -43,24 +43,38 @@ public interface IBaseService<T extends BaseData, F extends BaseFilter> { ...@@ -43,24 +43,38 @@ public interface IBaseService<T extends BaseData, F extends BaseFilter> {
return this.getRuntimeService().getDataEntityRuntime().executeAction(strActionName, iPSDEAction, args, true); return this.getRuntimeService().getDataEntityRuntime().executeAction(strActionName, iPSDEAction, args, true);
} }
default void callAction(String strActionName,Object arg) throws Throwable{
beforeAction(strActionName,arg);
forwardAction(strActionName,arg);
afterAction(strActionName,arg);
}
default Object fetchDataSet(String strDataSetName, IPSDEDataSet iPSDEDataSet, Object[] args) throws Throwable { default void beforeAction(String strActionName,Object arg) throws Throwable{
return this.getRuntimeService().getDataEntityRuntime().fetchDataSet(strDataSetName, iPSDEDataSet, args, true); Method beforeMethod = getServiceMethod("before"+ StringAdvUtils.pascalcase(strActionName), arg.getClass());
if (beforeMethod != null)
beforeMethod.invoke(this, arg);
} }
default Object forwardAction(String strActionName,Object arg) throws Throwable{
return this.getRuntimeService().getDataEntityRuntime().executeAction(strActionName, null, new Object[]{arg}, true);
}
default Object executeActionReal(IDataEntityRuntimeContext iDataEntityRuntimeContext, String strActionName, IPSDEAction iPSDEAction, Object[] args, Object actionData) throws Throwable{ default Object executeActionReal(IDataEntityRuntimeContext iDataEntityRuntimeContext, String strActionName, IPSDEAction iPSDEAction, Object[] args, Object actionData) throws Throwable{
return iDataEntityRuntimeContext.executeActionReal(strActionName, iPSDEAction, args, actionData); return iDataEntityRuntimeContext.executeActionReal(strActionName, iPSDEAction, args, actionData);
} }
default Object fetchDataSetReal(IDataEntityRuntimeContext iDataEntityRuntimeContext, String strDataSetName, IPSDEDataSet iPSDEDataSet, Object[] args, Object actionData) throws Throwable{ default Object onRealAction(String strActionName,Object arg) throws Throwable{
return iDataEntityRuntimeContext.fetchDataSetReal(strDataSetName, iPSDEDataSet, args, actionData); return this.getDataEntityRuntimeContext().executeActionReal(strActionName, null, new Object[]{arg}, null);
} }
default void beforeAction(String strActionName,Object arg) throws Throwable{ default void afterAction(String strActionName,Object arg) throws Throwable{
Method beforeMethod = getServiceMethod("before"+ StringAdvUtils.pascalcase(strActionName), arg.getClass()); Method afterMethod = getServiceMethod("after"+ StringAdvUtils.pascalcase(strActionName), arg.getClass());
if (beforeMethod != null) if (afterMethod != null)
beforeMethod.invoke(this, arg); afterMethod.invoke(this, arg);
}
default Object fetchDataSet(String strDataSetName, IPSDEDataSet iPSDEDataSet, Object[] args) throws Throwable {
return this.getRuntimeService().getDataEntityRuntime().fetchDataSet(strDataSetName, iPSDEDataSet, args, true);
} }
default void beforeFetch(String strActionName,Object arg) throws Throwable{ default void beforeFetch(String strActionName,Object arg) throws Throwable{
...@@ -69,45 +83,45 @@ public interface IBaseService<T extends BaseData, F extends BaseFilter> { ...@@ -69,45 +83,45 @@ public interface IBaseService<T extends BaseData, F extends BaseFilter> {
beforeMethod.invoke(this, arg); beforeMethod.invoke(this, arg);
} }
default void afterAction(String strActionName,Object arg) throws Throwable{ default Object forwardFetch(String dsName,F arg) throws Throwable{
Method afterMethod = getServiceMethod("after"+ StringAdvUtils.pascalcase(strActionName), arg.getClass()); return this.getRuntimeService().getDataEntityRuntime().fetchDataSet(dsName, arg.getDataSet(), new Object[]{arg}, true);
if (afterMethod != null) }
afterMethod.invoke(this, arg);
default Object fetchDataSetReal(IDataEntityRuntimeContext iDataEntityRuntimeContext, String strDataSetName, IPSDEDataSet iPSDEDataSet, Object[] args, Object actionData) throws Throwable{
return iDataEntityRuntimeContext.fetchDataSetReal(strDataSetName, iPSDEDataSet, args, actionData);
}
default Object onRealFetch(String dsName,F arg) throws Throwable{
return this.getDataEntityRuntimeContext().fetchDataSetReal("DEFAULT", arg.getDataSet(), new Object[]{arg}, null);
} }
default boolean create(T dto) throws Throwable { default boolean create(T dto) throws Throwable {
beforeAction("Create",dto); callAction("Create",dto);
this.getRuntimeService().getDataEntityRuntime().executeAction("Create", null, new Object[]{dto}, true);
afterAction("Create",dto);
return true; return true;
} }
default boolean onCreate(T dto) throws Throwable { default boolean onCreate(T dto) throws Throwable {
this.getDataEntityRuntimeContext().executeActionReal("Create", null, new Object[]{dto}, null); onRealAction("Create",dto);
return true; return true;
} }
default boolean update(T dto) throws Throwable { default boolean update(T dto) throws Throwable {
beforeAction("Update",dto); callAction("Update",dto);
this.getRuntimeService().getDataEntityRuntime().executeAction("Update", null, new Object[]{dto}, true);
afterAction("Update",dto);
return true; return true;
} }
default boolean onUpdate(T dto) throws Throwable { default boolean onUpdate(T dto) throws Throwable {
this.getDataEntityRuntimeContext().executeActionReal("Update", null, new Object[]{dto}, null); onRealAction("Update",dto);
return true; return true;
} }
default boolean save(T dto) throws Throwable { default boolean save(T dto) throws Throwable {
beforeAction("Save",dto); callAction("Save",dto);
this.getRuntimeService().getDataEntityRuntime().executeAction("Save", null, new Object[]{dto}, true);
afterAction("Save",dto);
return true; return true;
} }
default boolean onSave(T dto) throws Throwable { default boolean onSave(T dto) throws Throwable {
this.getDataEntityRuntimeContext().executeActionReal("Save", null, new Object[]{dto}, null); onRealAction("Save",dto);
return true; return true;
} }
...@@ -122,58 +136,56 @@ public interface IBaseService<T extends BaseData, F extends BaseFilter> { ...@@ -122,58 +136,56 @@ public interface IBaseService<T extends BaseData, F extends BaseFilter> {
} }
default boolean remove(List keys) throws Throwable { default boolean remove(List keys) throws Throwable {
beforeAction("Remove",keys); callAction("Remove",keys);
this.getRuntimeService().getDataEntityRuntime().executeAction("Remove", null, new Object[]{keys}, true);
afterAction("Remove",keys);
return true; return true;
} }
default boolean onRemove(List keys) throws Throwable { default boolean onRemove(List keys) throws Throwable {
this.getDataEntityRuntimeContext().executeActionReal("Remove", null, new Object[]{keys}, null); onRealAction("Remove",keys);
return true; return true;
} }
default <K extends Serializable> T get(K key) throws Throwable { default <K extends Serializable> T get(K key) throws Throwable {
T dto = (T)this.getRuntimeService().getDataEntityRuntime().executeAction("Get", null, new Object[]{key}, true); T dto = (T)forwardAction("Get",key);
if(dto!=null) if(dto!=null)
afterAction("Get",dto); afterAction("Get",dto);
return dto; return dto;
} }
default <K extends Serializable> T onGet(K key) throws Throwable { default <K extends Serializable> T onGet(K key) throws Throwable {
return (T)this.getDataEntityRuntimeContext().executeActionReal("Get", null, new Object[]{key}, null); return (T)onRealAction("Get",key);
} }
default T getDraft(T dto) throws Throwable { default T getDraft(T dto) throws Throwable {
beforeAction("GetDraft",dto); beforeAction("GetDraft",dto);
T rtdto = (T)this.getRuntimeService().getDataEntityRuntime().executeAction("GetDraft", null, new Object[]{dto}, true); T rtdto = (T)forwardAction("GetDraft",dto);
if(dto!=null) if(dto!=null)
afterAction("GetDraft",rtdto); afterAction("GetDraft",rtdto);
return rtdto; return rtdto;
} }
default T onGetDraft(T dto) throws Throwable { default T onGetDraft(T dto) throws Throwable {
return (T)this.getDataEntityRuntimeContext().executeActionReal("GetDraft", null, new Object[]{dto}, null); return (T)onRealAction("GetDraft",dto);
} }
default Integer checkKey(T dto) throws Throwable { default Integer checkKey(T dto) throws Throwable {
beforeAction("CheckKey",dto); beforeAction("CheckKey",dto);
return (Integer) this.getRuntimeService().getDataEntityRuntime().executeAction("CheckKey", null, new Object[]{dto}, true); return (Integer) forwardAction("CheckKey",dto);
} }
default Integer onCheckKey(T dto) throws Throwable { default Integer onCheckKey(T dto) throws Throwable {
return (Integer) this.getDataEntityRuntimeContext().executeActionReal("CheckKey", null, new Object[]{dto}, null); return (Integer) onRealAction("CheckKey",dto);
} }
default Page<T> fetchDefault(F dto) throws Throwable { default Page<T> fetchDefault(F dto) throws Throwable {
beforeFetch("Default",dto); beforeFetch("Default",dto);
return (Page) this.getRuntimeService().getDataEntityRuntime().fetchDataSet("DEFAULT", dto.getDataSet(), new Object[]{dto}, true); return (Page) forwardFetch("DEFAULT",dto);
} }
default Page<T> onFetchDefault(F dto) throws Throwable { default Page<T> onFetchDefault(F dto) throws Throwable {
return (Page) this.getDataEntityRuntimeContext().fetchDataSetReal("DEFAULT", dto.getDataSet(), new Object[]{dto}, null); return (Page) onRealFetch("DEFAULT",dto);
} }
default List<T> selectDefault(F dto) throws Throwable { default List<T> selectDefault(F dto) throws Throwable {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册