Commit 49da27e1 by WeiCong

第三版完成

1.支持restoreData模型
2.支持渠道类型判断方式
3.支持sysmod下的spt模型加载
4.支持精确控制lst返回列
5.支持分页查询
parent edc9a29a
...@@ -52,9 +52,9 @@ ...@@ -52,9 +52,9 @@
</orderEntry> </orderEntry>
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" /> <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.30" level="project" /> <orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.30" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-core:2.12.1" level="project" /> <orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-core:2.18.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.12.1" level="project" /> <orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.18.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-slf4j-impl:2.12.1" level="project" /> <orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-slf4j-impl:2.18.0" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.7" level="project" /> <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.7" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.7" level="project" /> <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.7" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.7" level="project" /> <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.7" level="project" />
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<spring.version>5.1.3.RELEASE</spring.version> <spring.version>5.1.3.RELEASE</spring.version>
<slf4j-api_version>1.7.25</slf4j-api_version> <slf4j-api_version>1.7.25</slf4j-api_version>
<jul-to-slf4j_version>1.7.30</jul-to-slf4j_version> <jul-to-slf4j_version>1.7.30</jul-to-slf4j_version>
<log4j2.version>2.12.1</log4j2.version> <log4j2.version>2.18.0</log4j2.version>
<ehcache.version>2.10.4</ehcache.version> <ehcache.version>2.10.4</ehcache.version>
<jackson.version>2.9.7</jackson.version> <jackson.version>2.9.7</jackson.version>
<hibernate.version>5.6.9.Final</hibernate.version> <hibernate.version>5.6.9.Final</hibernate.version>
......
...@@ -10,12 +10,13 @@ import org.hibernate.transform.Transformers; ...@@ -10,12 +10,13 @@ import org.hibernate.transform.Transformers;
import org.sss.common.model.Argument; import org.sss.common.model.Argument;
import org.sss.common.model.IModule; import org.sss.common.model.IModule;
import org.sss.common.model.IModuleRoot; import org.sss.common.model.IModuleRoot;
import org.sss.common.model.IParent;
import org.sss.module.hibernate.HibernateUtils; import org.sss.module.hibernate.HibernateUtils;
import org.sss.presentation.noui.context.NoUiContext; import org.sss.presentation.noui.context.NoUiContext;
import org.sss.presentation.noui.util.PropertyUtil; import org.sss.presentation.noui.util.PropertyUtil;
import org.sss.presentation.noui.util.StringUtil; import org.sss.presentation.noui.util.StringUtil;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Field;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -55,12 +56,21 @@ public class PreHandle { ...@@ -55,12 +56,21 @@ public class PreHandle {
} }
public static boolean needPreHandle(String mappingUrl) { public static boolean needPreHandle(String trnName, Map<String, ?> paramsMap) {
return config.containsKey(mappingUrl); return config.containsKey(trnName) || paramsMap.containsKey("__sptinr");
} }
public static void preHandle(String trnName, Map<String, ?> paramsMap, NoUiContext context) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { public static void preHandle(String trnName, Map<String, ?> paramsMap, NoUiContext context) throws Exception {
//区别app还是zk版本
String terminalType = StringUtil.isEmpty(context.getNoUiRequest().getTerminalType()) ? "APP" : context.getNoUiRequest().getTerminalType();
context.getSession().storeData("__terminalType", terminalType);
if (paramsMap.containsKey("__sptinr")) {
loadSpt(context, paramsMap);
}
String[] handles = config.get(trnName); String[] handles = config.get(trnName);
if (handles == null) {
return;
}
for (String handle : handles) { for (String handle : handles) {
if (StringUtil.isEmpty(handle)) { if (StringUtil.isEmpty(handle)) {
continue; continue;
...@@ -77,16 +87,17 @@ public class PreHandle { ...@@ -77,16 +87,17 @@ public class PreHandle {
} }
MethodUtils.invokeStaticMethod(PreHandle.class, method, new Object[]{context, paramsMap, args}); MethodUtils.invokeStaticMethod(PreHandle.class, method, new Object[]{context, paramsMap, args});
} }
} }
public static void sureBtn(NoUiContext ctx, Map<String, ?> paramsMap, Object... otherParams) throws Exception { public static void sureBtn(NoUiContext ctx, Map<String, ?> paramsMap, Object... otherParams) throws Exception {
if (otherParams.length != 2) { if (otherParams.length != 2) {
log.warn("执行sureBtn预处理方法,需要两个参数:'Module名称'和'待跳转的交易名称'"); log.error("执行sureBtn预处理方法,需要两个参数:'Module名称'和'待跳转的交易名称'");
return; throw new RuntimeException("执行sureBtn预处理方法,需要两个参数:'Module名称'和'待跳转的交易名称'");
} }
if (paramsMap.get("__inr") == null) { if (paramsMap.get("__modelinr") == null) {
log.warn("执行sureBtn预处理方法,params中需要__inr关键字对应的模型inr"); log.error("执行sureBtn预处理方法,params中需要'__modelinr'关键字对应的模型inr");
return; throw new RuntimeException("执行sureBtn预处理方法,params参数中需要'__modelinr'映射的模型inr");
} }
String grpNam = (String) otherParams[0]; String grpNam = (String) otherParams[0];
String toTrs = (String) otherParams[1]; String toTrs = (String) otherParams[1];
...@@ -97,11 +108,24 @@ public class PreHandle { ...@@ -97,11 +108,24 @@ public class PreHandle {
new Object[]{toTrs, (IModule) ConstructorUtils.invokeConstructor(clazz, new Object[0])} new Object[]{toTrs, (IModule) ConstructorUtils.invokeConstructor(clazz, new Object[0])}
, new Class[]{String.class, IModule.class}); , new Class[]{String.class, IModule.class});
IModule grp = (IModule) ctx.getSession().getBaseObject(root, grpNam + "\\rec"); IModule grp = (IModule) ctx.getSession().getBaseObject(root, grpNam + "\\rec");
ctx.getSupport().get(grp, new Argument[]{new Argument("inr", paramsMap.get("__inr"))}); ctx.getSupport().get(grp, new Argument[]{new Argument("inr", paramsMap.get("__modelinr"))});
ctx.getError(); ctx.getError();
ctx.getSession().storeData("com.brilliance." + toTrs + ".ref", grp); ctx.getSession().storeData("com.brilliance." + toTrs + ".ref", grp);
} }
public static void loadSpt(NoUiContext ctx, Map<String, ?> paramsMap) throws Exception {
if (paramsMap.get("__sptinr") == null) {
log.error("执行loadSpt预处理方法,params中需要'__sptinr'关键字对应的模型inr");
throw new RuntimeException("执行sureBtn预处理方法,params参数中需要'__sptinr'映射的模型inr");
}
Field sysmodClaz = AbstractPOJOModuleSession.class.getDeclaredField("sysmod");
sysmodClaz.setAccessible(true);
IParent sysmod = (IParent) sysmodClaz.get(ctx.getSession());
IModule spt = (IModule) ctx.getSession().getBaseObject(sysmod, "spt");
ctx.getSupport().get(spt, new Argument[]{new Argument("inr", paramsMap.get("__sptinr"))});
ctx.getError();
}
public static boolean initUserInr(String cid, String oid) { public static boolean initUserInr(String cid, String oid) {
Session session = HibernateUtils.openSession(null); Session session = HibernateUtils.openSession(null);
String ptySql = "select inr,ptytyp from pty where (ptytyp='2' or PTYTYP='1') and cid=?"; String ptySql = "select inr,ptytyp from pty where (ptytyp='2' or PTYTYP='1') and cid=?";
......
...@@ -57,31 +57,33 @@ public abstract class AbstractCommonController { ...@@ -57,31 +57,33 @@ public abstract class AbstractCommonController {
NoUiContext context = null; NoUiContext context = null;
Result ret = null; Result ret = null;
String serverEnc = null; String serverEnc = null;
NoUiRequest noUiRequest=null; NoUiRequest noUiRequest = null;
try { try {
noUiRequest= new NoUiRequest(request, mappingUrl, dataMap); noUiRequest = new NoUiRequest(request, mappingUrl, dataMap);
Alias alias = new Alias(mappingUrl); Alias alias = new Alias(mappingUrl);
String trnName = alias.getTrnName(); String trnName = alias.getTrnName();
putTxInfo(alias,mappingUrl);//记录交易信息 putTxInfo(alias, mappingUrl);//记录交易信息
Map<String, ?> paramsMap = noUiRequest.getParamsMap(); Map<String, ?> paramsMap = noUiRequest.getParamsMap();
context = NoUiContextManager.createNoUiContext(noUiRequest); context = NoUiContextManager.createNoUiContext(noUiRequest);
// 交易参数赋值
if(PreHandle.needPreHandle(trnName)){
PreHandle.preHandle(trnName,paramsMap,context); if (PreHandle.needPreHandle(trnName, paramsMap)) {
PreHandle.preHandle(trnName, paramsMap, context);
} }
for (String key : paramsMap.keySet()) { for (String key : paramsMap.keySet()) {
context.getSession().storeData(key, paramsMap.get(key)); context.getSession().storeData(key, paramsMap.get(key));
} }
// 设置old sysmod // 设置old sysmod
LoginInfo loginInfo = null; LoginInfo loginInfo = null;
if (!StringUtils.isEmpty(noUiRequest.getUserId())){ if (!StringUtils.isEmpty(noUiRequest.getUserId())) {
loginInfo = (LoginInfo) EhcacheUtils.get(StringUtil.userUniqueId(noUiRequest)); loginInfo = (LoginInfo) EhcacheUtils.get(StringUtil.userUniqueId(noUiRequest));
if (loginInfo != null) { if (loginInfo != null) {
if(loginInfo.getSysmod()!=null){ if (loginInfo.getSysmod() != null) {
NoUiPresentationUtil.setSysmod(context, (byte[]) loginInfo.getSysmod()); NoUiPresentationUtil.setSysmod(context, (byte[]) loginInfo.getSysmod());
} }
context.setLoginInfo(loginInfo); context.setLoginInfo(loginInfo);
...@@ -102,9 +104,9 @@ public abstract class AbstractCommonController { ...@@ -102,9 +104,9 @@ public abstract class AbstractCommonController {
//数据安全性拦截-篡改数据拦截 //数据安全性拦截-篡改数据拦截
if (DataSecurityUtil.isSafeMode() && noUiRequest.isSecurity()) { if (DataSecurityUtil.isSafeMode() && noUiRequest.isSecurity()) {
if (DataSecurityUtil.needDecrypt(noUiRequest.getReqUrl())) { if (DataSecurityUtil.needDecrypt(noUiRequest.getReqUrl())) {
String[] clientpars = DataSecurityUtil.getSafeConfigByReqUrl(context,noUiRequest, noUiRequest.getReqUrl() + DataSecurityUtil.DECRYPT_FIX); String[] clientpars = DataSecurityUtil.getSafeConfigByReqUrl(context, noUiRequest, noUiRequest.getReqUrl() + DataSecurityUtil.DECRYPT_FIX);
if(!ArrayUtils.isEmpty(clientpars)){ if (!ArrayUtils.isEmpty(clientpars)) {
if(!DataSecurityUtil.isIgnoreCheck(paramsMap)){ if (!DataSecurityUtil.isIgnoreCheck(paramsMap)) {
if (paramsMap.containsKey(DataSecurityUtil.BACKGROUND_ID)) { if (paramsMap.containsKey(DataSecurityUtil.BACKGROUND_ID)) {
//合法性校验操作(场景:用户做修改、删除时调用) //合法性校验操作(场景:用户做修改、删除时调用)
serverEnc = (String) paramsMap.get(DataSecurityUtil.BACKGROUND_ID); serverEnc = (String) paramsMap.get(DataSecurityUtil.BACKGROUND_ID);
...@@ -119,15 +121,15 @@ public abstract class AbstractCommonController { ...@@ -119,15 +121,15 @@ public abstract class AbstractCommonController {
} }
} }
} }
}else if("infsmh".equals(trnName) && "_recpan_show".equals(alias.getAliasActionUrl())){ } else if ("infsmh".equals(trnName) && "_recpan_show".equals(alias.getAliasActionUrl())) {
String res = request.getHeader("res"); String res = request.getHeader("res");
String docpth = (String) paramsMap.get("docpth"); String docpth = (String) paramsMap.get("docpth");
String errmsg="Access Forbidden, Unauthorized!!!"; String errmsg = "Access Forbidden, Unauthorized!!!";
if(res==null || docpth ==null){ if (res == null || docpth == null) {
Result rt = new Result(ErrorCodes.ERROR, errmsg, null, noUiVersion.getVersion()); Result rt = new Result(ErrorCodes.ERROR, errmsg, null, noUiVersion.getVersion());
return rt; return rt;
} }
if(!res.equals(docpth)){ if (!res.equals(docpth)) {
Result rt = new Result(ErrorCodes.ERROR, errmsg, null, noUiVersion.getVersion()); Result rt = new Result(ErrorCodes.ERROR, errmsg, null, noUiVersion.getVersion());
return rt; return rt;
} }
...@@ -177,29 +179,28 @@ public abstract class AbstractCommonController { ...@@ -177,29 +179,28 @@ public abstract class AbstractCommonController {
EhcacheUtils.set(StringUtil.userUniqueId(noUiRequest), loginInfo); EhcacheUtils.set(StringUtil.userUniqueId(noUiRequest), loginInfo);
} }
Map<String, Object> paginationData = new HashMap<>(); Map<String, Object> paginationData = new HashMap<>();
Map<String, Object> afterReturnData = handleReturnData(eventType, context, noUiRequest, alias,paginationData); Map<String, Object> afterReturnData = handleReturnData(eventType, context, noUiRequest, alias, paginationData);
//数据安全性拦截-篡改数据加密 //数据安全性拦截-篡改数据加密
if (DataSecurityUtil.isSafeMode() && noUiRequest.isSecurity()) { if (DataSecurityUtil.isSafeMode() && noUiRequest.isSecurity()) {
if (DataSecurityUtil.needEncrypt(noUiRequest.getReqUrl())) { if (DataSecurityUtil.needEncrypt(noUiRequest.getReqUrl())) {
//加密操作(场景:用户查询指定信息时调用,后续会做修改,删除等操作) //加密操作(场景:用户查询指定信息时调用,后续会做修改,删除等操作)
String[] pars = DataSecurityUtil.getSafeConfigByReqUrl(context, noUiRequest,noUiRequest.getReqUrl() + DataSecurityUtil.ENCRYPT_FIX); String[] pars = DataSecurityUtil.getSafeConfigByReqUrl(context, noUiRequest, noUiRequest.getReqUrl() + DataSecurityUtil.ENCRYPT_FIX);
serverEnc = DataSecurityUtil.encrypt(pars, noUiRequest.getUserId()); serverEnc = DataSecurityUtil.encrypt(pars, noUiRequest.getUserId());
afterReturnData.put(DataSecurityUtil.BACKGROUND_ID, serverEnc); afterReturnData.put(DataSecurityUtil.BACKGROUND_ID, serverEnc);
}else if(!ErrorCodes.SUCCESS.equals(NoUiPresentationUtil.retCode(context)) && DataSecurityUtil.needDecrypt(noUiRequest.getReqUrl())){ } else if (!ErrorCodes.SUCCESS.equals(NoUiPresentationUtil.retCode(context)) && DataSecurityUtil.needDecrypt(noUiRequest.getReqUrl())) {
String[] pars = DataSecurityUtil.getSafeConfigByReqUrl(context, noUiRequest,noUiRequest.getReqUrl() + DataSecurityUtil.DECRYPT_FIX); String[] pars = DataSecurityUtil.getSafeConfigByReqUrl(context, noUiRequest, noUiRequest.getReqUrl() + DataSecurityUtil.DECRYPT_FIX);
serverEnc = DataSecurityUtil.encrypt(pars, noUiRequest.getUserId()); serverEnc = DataSecurityUtil.encrypt(pars, noUiRequest.getUserId());
afterReturnData.put(DataSecurityUtil.BACKGROUND_ID, serverEnc); afterReturnData.put(DataSecurityUtil.BACKGROUND_ID, serverEnc);
} }
} }
ret = ResultUtil.result(NoUiPresentationUtil.retCode(context), NoUiPresentationUtil.retMsg(context), afterReturnData,paginationData, ret = ResultUtil.result(NoUiPresentationUtil.retCode(context), NoUiPresentationUtil.retMsg(context), afterReturnData, paginationData,
NoUiPresentationUtil.handleErrorReturnData(context, alias), NoUiPresentationUtil.handleCodeTableReturnData(context, alias), noUiVersion.getVersion()); NoUiPresentationUtil.handleErrorReturnData(context, alias), NoUiPresentationUtil.handleCodeTableReturnData(context, alias), noUiVersion.getVersion());
} } catch (Throwable e) {
catch (Throwable e) { if (e.getCause() instanceof ExitTransactionException) {
if(e.getCause() instanceof ExitTransactionException){ ExitTransactionException exitTrans = ExitTransactionException.class.cast(e.getCause());
ExitTransactionException exitTrans=ExitTransactionException.class.cast(e.getCause());
ret = ResultUtil.result(exitTrans.getErrorCode(), exitTrans.getMessage(), exitTrans.getMessage(), noUiVersion.getVersion()); ret = ResultUtil.result(exitTrans.getErrorCode(), exitTrans.getMessage(), exitTrans.getMessage(), noUiVersion.getVersion());
}else{ } else {
log.error("OnClick command error", e); log.error("OnClick command error", e);
ret = ResultUtil.result(ErrorCodes.ERROR, "hander error", "service error", noUiVersion.getVersion()); ret = ResultUtil.result(ErrorCodes.ERROR, "hander error", "service error", noUiVersion.getVersion());
TxInfo.recordException(e); TxInfo.recordException(e);
...@@ -216,12 +217,11 @@ public abstract class AbstractCommonController { ...@@ -216,12 +217,11 @@ public abstract class AbstractCommonController {
} }
private void putTxInfo(Alias alias,String mappingUrl) private void putTxInfo(Alias alias, String mappingUrl) {
{
String trnName = alias.getTrnName(); String trnName = alias.getTrnName();
String aliasActionUrl = alias.getAliasActionUrl(); String aliasActionUrl = alias.getAliasActionUrl();
String actionUrl = alias.getRel().get(aliasActionUrl); String actionUrl = alias.getRel().get(aliasActionUrl);
TxInfo.putTxInfo(trnName,mappingUrl,actionUrl); TxInfo.putTxInfo(trnName, mappingUrl, actionUrl);
} }
private IBaseObject baseObject(NoUiContext context, NoUiRequest noUiRequest, Alias alias) { private IBaseObject baseObject(NoUiContext context, NoUiRequest noUiRequest, Alias alias) {
...@@ -233,19 +233,19 @@ public abstract class AbstractCommonController { ...@@ -233,19 +233,19 @@ public abstract class AbstractCommonController {
return baseObject; return baseObject;
} }
private void putModuleListPagination(String aliasKey,Map<String,Object> paginationMap,IModuleList moduleList) private void putModuleListPagination(String aliasKey, Map<String, Object> paginationMap, IModuleList moduleList) {
{
//没有做分页 //没有做分页
if(moduleList.getPageSize() == 0) if (moduleList.getPageSize() == 0)
return; return;
int total = moduleList.fullSize(); int total = moduleList.fullSize();
int index = moduleList.getPage(); int index = moduleList.getPage();
Map<String,Integer> map = new HashMap<>(); Map<String, Integer> map = new HashMap<>();
map.put("total",total); map.put("total", total);
map.put("index",index); map.put("index", index);
paginationMap.put(aliasKey,map); paginationMap.put(aliasKey, map);
} }
private Map<String, Object> handleReturnData(String eventType, NoUiContext context, NoUiRequest noUiRequest, Alias alias, Map<String,Object> paginationMap) {
private Map<String, Object> handleReturnData(String eventType, NoUiContext context, NoUiRequest noUiRequest, Alias alias, Map<String, Object> paginationMap) {
Map<String, Object> data = new HashMap<String, Object>(); Map<String, Object> data = new HashMap<String, Object>();
// 初始化事件 // 初始化事件
...@@ -256,9 +256,8 @@ public abstract class AbstractCommonController { ...@@ -256,9 +256,8 @@ public abstract class AbstractCommonController {
} }
String realPath = alias.getRelPath(aliasKey); String realPath = alias.getRelPath(aliasKey);
IBaseObject baseObject = context.getSession().getBaseObject(context.getRoot(), realPath); IBaseObject baseObject = context.getSession().getBaseObject(context.getRoot(), realPath);
if( baseObject instanceof IModuleList) if (baseObject instanceof IModuleList) {
{ putModuleListPagination(aliasKey, paginationMap, (IModuleList) baseObject);
putModuleListPagination( aliasKey,paginationMap,(IModuleList)baseObject);
} }
data.put(aliasKey, NoUiPresentationUtil.handIBaseObject(context, baseObject, realPath)); data.put(aliasKey, NoUiPresentationUtil.handIBaseObject(context, baseObject, realPath));
} }
...@@ -282,17 +281,18 @@ public abstract class AbstractCommonController { ...@@ -282,17 +281,18 @@ public abstract class AbstractCommonController {
} }
if (aliasPath.startsWith(modifyEntry.getKey())) { if (aliasPath.startsWith(modifyEntry.getKey())) {
int modifyKeyLen = modifyEntry.getKey().length(); int modifyKeyLen = modifyEntry.getKey().length();
//要么字符串相等,要么后续字符应该为 \\ 才可以 if (!(aliasPath.length() == modifyKeyLen || aliasPath.charAt(modifyKeyLen) == '\\')) {
if(!(aliasPath.length() == modifyKeyLen || aliasPath.charAt(modifyKeyLen) == '\\'))
continue; continue;
}
Object val = modifyEntry.getValue(); Object val = modifyEntry.getValue();
if (aliasKey == null) if (aliasKey == null) {
continue; continue;
if( val instanceof IModuleList)
{
putModuleListPagination(aliasKey,paginationMap,(IModuleList)val);
} }
data.put(aliasKey, NoUiPresentationUtil.handIBaseObject(context, val, aliasEntry.getValue())); if (val instanceof IModuleList) {
putModuleListPagination(aliasKey, paginationMap, (IModuleList) val);
aliasPath = alias.getRel().get(aliasPath);
}
data.put(aliasKey, NoUiPresentationUtil.handIBaseObject(context, val, aliasPath));
containsKeys.add(modifyEntry.getKey()); containsKeys.add(modifyEntry.getKey());
} }
...@@ -302,13 +302,12 @@ public abstract class AbstractCommonController { ...@@ -302,13 +302,12 @@ public abstract class AbstractCommonController {
// 不能修改 // 不能修改
for (String key : modifyMap.keySet()) { for (String key : modifyMap.keySet()) {
if (!containsKeys.contains(key)) { if (!containsKeys.contains(key)) {
if (key == null){ if (key == null) {
continue; continue;
} }
Object baseObject = modifyMap.get(key); Object baseObject = modifyMap.get(key);
if( baseObject instanceof IModuleList) if (baseObject instanceof IModuleList) {
{ putModuleListPagination(key, paginationMap, (IModuleList) baseObject);
putModuleListPagination(key,paginationMap,(IModuleList)baseObject);
} }
data.put(key, NoUiPresentationUtil.handIBaseObject(context, baseObject, key)); data.put(key, NoUiPresentationUtil.handIBaseObject(context, baseObject, key));
} }
......
...@@ -74,7 +74,7 @@ public class NoUiPresentationUtil { ...@@ -74,7 +74,7 @@ public class NoUiPresentationUtil {
} }
//处理分页信息 //处理分页信息
Map<String,?> paginationMap = request.getPaginationMap(); Map<String, ?> paginationMap = request.getPaginationMap();
for (String aliasKey : paginationMap.keySet()) { for (String aliasKey : paginationMap.keySet()) {
String url = alias.getRelPath(aliasKey); String url = alias.getRelPath(aliasKey);
if (StringUtils.isEmpty(url)) { if (StringUtils.isEmpty(url)) {
...@@ -87,12 +87,12 @@ public class NoUiPresentationUtil { ...@@ -87,12 +87,12 @@ public class NoUiPresentationUtil {
if (null == baseObject) { if (null == baseObject) {
throw new NoUiException("not found url :" + url + " ,alias name is:" + aliasKey); throw new NoUiException("not found url :" + url + " ,alias name is:" + aliasKey);
} }
if(!(baseObject instanceof IModuleList)) if (!(baseObject instanceof IModuleList))
throw new NoUiException( url + " is not a moduleList"); throw new NoUiException(url + " is not a moduleList");
//处理分页信息 //处理分页信息
IModuleList moduleList = (IModuleList) baseObject; IModuleList moduleList = (IModuleList) baseObject;
Map<String,Integer> paginationItem = (Map<String,Integer>)paginationMap.get(aliasKey); Map<String, Integer> paginationItem = (Map<String, Integer>) paginationMap.get(aliasKey);
putPaginationCache(paginationItem,moduleList); putPaginationCache(paginationItem, moduleList);
} catch (Exception e) { } catch (Exception e) {
log.error("Pagination command error", e); log.error("Pagination command error", e);
throw new NoUiException("Pagination command error", e); throw new NoUiException("Pagination command error", e);
...@@ -101,15 +101,13 @@ public class NoUiPresentationUtil { ...@@ -101,15 +101,13 @@ public class NoUiPresentationUtil {
} }
private static void putPaginationCache(Map<String,Integer> paginationItem,IModuleList moduleList) private static void putPaginationCache(Map<String, Integer> paginationItem, IModuleList moduleList) {
{ Map<String, Map<String, Integer>> paginationCache = (Map<String, Map<String, Integer>>) AbstractCache.paginationMap.get();
Map<String,Map<String,Integer>> paginationCache = (Map<String,Map<String,Integer>>)AbstractCache.paginationMap.get(); if (paginationCache == null) {
if(paginationCache == null)
{
paginationCache = new HashMap<>(); paginationCache = new HashMap<>();
AbstractCache.paginationMap.set(paginationCache); AbstractCache.paginationMap.set(paginationCache);
} }
paginationCache.put(moduleList.getUrl(),paginationItem); paginationCache.put(moduleList.getUrl(), paginationItem);
} }
private static void handleDatafield(IContext context, IDatafield<Object> dataField, Object value) { private static void handleDatafield(IContext context, IDatafield<Object> dataField, Object value) {
...@@ -128,14 +126,12 @@ public class NoUiPresentationUtil { ...@@ -128,14 +126,12 @@ public class NoUiPresentationUtil {
} }
if (dataType.equals(Integer.TYPE) || dataType.equals(Integer.class)) { if (dataType.equals(Integer.TYPE) || dataType.equals(Integer.class)) {
String data = value.toString().trim(); String data = value.toString().trim();
if (StringUtils.isEmpty(data)) if (StringUtils.isEmpty(data)) {
{ if (dataField.isNullable())
if(dataField.isNullable())
dataField.setValue(null); dataField.setValue(null);
else else
dataField.setValue(0); dataField.setValue(0);
} } else
else
dataField.setValue(Double.valueOf(data.replaceAll(",", "")).intValue()); dataField.setValue(Double.valueOf(data.replaceAll(",", "")).intValue());
return; return;
} }
...@@ -280,29 +276,45 @@ public class NoUiPresentationUtil { ...@@ -280,29 +276,45 @@ public class NoUiPresentationUtil {
return null; return null;
if ((val instanceof IModuleList)) { if ((val instanceof IModuleList)) {
List list = new ArrayList(); List list = new ArrayList();
IModuleList moduleList = (IModuleList)val; IModuleList moduleList = (IModuleList) val;
boolean isAll = true;
if (!StringUtil.isEmpty(path)) {
isAll = false;
}
for (int index = 0; index < moduleList.size(); index++) { for (int index = 0; index < moduleList.size(); index++) {
Map map = new HashMap(); Map map = new HashMap();
IModule module = (IModule)moduleList.get(index); IModule module = (IModule) moduleList.get(index);
if (isAll) {
Collection<IDatafield> datafields = module.getDatafields(); Collection<IDatafield> datafields = module.getDatafields();
for (IDatafield datafield : datafields) { for (IDatafield datafield : datafields) {
map.put(obfuscationPath(datafield.getName()), handle(datafield.getValue(), datafield)); String dataFieldName = obfuscationPath(datafield.getName());
map.put(dataFieldName, handle(datafield.getValue(), datafield));
}
} else {
String[] pths = path.split(",");
for (String pth : pths) {
IDatafield datafieldtmp = (IDatafield) context.getSession().getBaseObject(module, pth);
String dataFieldName = obfuscationPath(datafieldtmp.getName());
map.put(dataFieldName, handle(datafieldtmp.getValue(), datafieldtmp));
}
} }
list.add(map); list.add(map);
} }
return list; return list;
}if ((val instanceof IModule)) { }
if ((val instanceof IModule)) {
val = context.getSession().getBaseObject(context.getRoot(), path); val = context.getSession().getBaseObject(context.getRoot(), path);
return handIBaseObject(context, val, path); return handIBaseObject(context, val, path);
}if ((val instanceof IDatafield)) { }
IDatafield datafield = (IDatafield)val; if ((val instanceof IDatafield)) {
IDatafield datafield = (IDatafield) val;
return handle(datafield.getValue(), datafield); return handle(datafield.getValue(), datafield);
} }
return null; return null;
} }
public static Map<String, Object> getWholeAliasData(IContext context,String mappingUrl) public static Map<String, Object> getWholeAliasData(IContext context, String mappingUrl) {
{
Map<String, Object> data = new HashMap<String, Object>(); Map<String, Object> data = new HashMap<String, Object>();
Alias alias = new Alias(mappingUrl); Alias alias = new Alias(mappingUrl);
for (String aliasKey : alias.getRel().keySet()) { for (String aliasKey : alias.getRel().keySet()) {
...@@ -319,7 +331,7 @@ public class NoUiPresentationUtil { ...@@ -319,7 +331,7 @@ public class NoUiPresentationUtil {
public static Map<String, Object> handleErrorReturnData(NoUiContext context, Alias alias) { public static Map<String, Object> handleErrorReturnData(NoUiContext context, Alias alias) {
NoUiPresentation gui = (NoUiPresentation) context.getGui(); NoUiPresentation gui = (NoUiPresentation) context.getGui();
Map<String, Object> errorMap = gui.getError(); Map<String, Object> errorMap = gui.getError();
Map<String, Object> n_errorMap = new HashMap<String,Object>(); Map<String, Object> n_errorMap = new HashMap<String, Object>();
for (Map.Entry<String, Object> errorEntity : errorMap.entrySet()) { for (Map.Entry<String, Object> errorEntity : errorMap.entrySet()) {
String key = errorEntity.getKey(); String key = errorEntity.getKey();
String realKey = alias.getRevertRel().get(key); String realKey = alias.getRevertRel().get(key);
...@@ -358,7 +370,7 @@ public class NoUiPresentationUtil { ...@@ -358,7 +370,7 @@ public class NoUiPresentationUtil {
context.getSession().loadData((IParent) sysmod.get(session), simp); context.getSession().loadData((IParent) sysmod.get(session), simp);
} catch (Exception e) { } catch (Exception e) {
log.error("setSysmod exception",e); log.error("setSysmod exception", e);
} }
} }
...@@ -371,70 +383,68 @@ public class NoUiPresentationUtil { ...@@ -371,70 +383,68 @@ public class NoUiPresentationUtil {
try { try {
sysmodBytes = IOUtils.toByteArray(stream.getInputStream()); sysmodBytes = IOUtils.toByteArray(stream.getInputStream());
} catch (IOException e) { } catch (IOException e) {
log.error("sysmodToBytes exception",e); log.error("sysmodToBytes exception", e);
} }
return sysmodBytes; return sysmodBytes;
} }
//混淆路径,算法:偏移 头4 尾7 //混淆路径,算法:偏移 头4 尾7
public static String obfuscationPath(String str){ public static String obfuscationPath(String str) {
if(NoUiUtils.fieldencode){ /*if(NoUiUtils.fieldencode){
String btw_str = str.substring(1,str.length()-1); String btw_str = str.substring(1,str.length()-1);
String head = change(str.charAt(0),4); String head = change(str.charAt(0),4);
String tail = change(str.charAt(str.length()-1),7); String tail = change(str.charAt(str.length()-1),7);
return head + btw_str + tail; return head + btw_str + tail;
} }*/
return str; return str;
} }
//根据偏移量转换字符 //根据偏移量转换字符
public static String change(char ch,int offset){ public static String change(char ch, int offset) {
int before = ch; int before = ch;
int after; int after;
//a-z //a-z
if(ch >=97 && ch <= 122){ if (ch >= 97 && ch <= 122) {
if(before+offset <= 122){ if (before + offset <= 122) {
after = before+offset; after = before + offset;
}else{ } else {
after = (before+offset)%122+96; after = (before + offset) % 122 + 96;
} }
return String.valueOf((char)after); return String.valueOf((char) after);
} }
//A-Z //A-Z
else if(ch >=65 && ch <= 90){ else if (ch >= 65 && ch <= 90) {
if(before+offset <= 90){ if (before + offset <= 90) {
after = before+offset; after = before + offset;
}else{ } else {
after = (before+offset)%90+64; after = (before + offset) % 90 + 64;
} }
return String.valueOf((char)after); return String.valueOf((char) after);
} }
//0-9 //0-9
else if(ch >=48 && ch <= 57){ else if (ch >= 48 && ch <= 57) {
if(before+offset <= 57){ if (before + offset <= 57) {
after = before+offset; after = before + offset;
}else{ } else {
after = (before+offset)%57+47; after = (before + offset) % 57 + 47;
} }
return String.valueOf((char)after); return String.valueOf((char) after);
} }
return String.valueOf(ch); return String.valueOf(ch);
} }
public static String transParamsToString(String[] params) public static String transParamsToString(String[] params) {
{
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for(String str:params) for (String str : params) {
{
sb.append(str); sb.append(str);
sb.append(','); sb.append(',');
} }
if(sb.charAt(sb.length() - 1) == ',') if (sb.charAt(sb.length() - 1) == ',')
sb.deleteCharAt(sb.length() - 1); sb.deleteCharAt(sb.length() - 1);
return sb.toString(); return sb.toString();
} }
public static void copyValueToParamsArr(String[] paramsKey,String[] params,String key,String value)
{ public static void copyValueToParamsArr(String[] paramsKey, String[] params, String key, String value) {
for (int i = 0; i < paramsKey.length; i++) { for (int i = 0; i < paramsKey.length; i++) {
if (paramsKey[i].equals(key)) { if (paramsKey[i].equals(key)) {
params[i] = value; params[i] = value;
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
</service> </service>
<service class="org.sss.util.ContainerUtils"> <service class="org.sss.util.ContainerUtils">
<!-- <property name="cacheClassName" value="org.sss.presentation.noui.cache.Ehcache.EhcacheCache" class="java.lang.String" /> --> <property name="cacheClassName" value="org.sss.presentation.noui.cache.Ehcache.EhcacheCache" class="java.lang.String" />
<!-- 交易DAT文件是否采用压缩 --> <!-- 交易DAT文件是否采用压缩 -->
<property name="isCompressed" value="false" class="boolean"/> <property name="isCompressed" value="false" class="boolean"/>
</service> </service>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment