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));
} }
......
...@@ -24,423 +24,433 @@ import java.text.SimpleDateFormat; ...@@ -24,423 +24,433 @@ import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
public class NoUiPresentationUtil { public class NoUiPresentationUtil {
protected static final Log log = LogFactory.getLog(NoUiPresentationUtil.class); protected static final Log log = LogFactory.getLog(NoUiPresentationUtil.class);
public static void hanleInput(NoUiContext context, NoUiRequest request, Alias alias) { public static void hanleInput(NoUiContext context, NoUiRequest request, Alias alias) {
Map<String, ?> dataMap = request.getDataMap(); Map<String, ?> dataMap = request.getDataMap();
for (String aliasKey : dataMap.keySet()) { for (String aliasKey : dataMap.keySet()) {
if (aliasKey.startsWith(Constants.MAPPING_PRE)) { if (aliasKey.startsWith(Constants.MAPPING_PRE)) {
continue; continue;
} }
String url = alias.getRelPath(aliasKey); String url = alias.getRelPath(aliasKey);
if (StringUtils.isEmpty(url)) { if (StringUtils.isEmpty(url)) {
continue; continue;
} }
IBaseObject baseObject = null; IBaseObject baseObject = null;
try { try {
baseObject = context.getSession().getBaseObject(context.getRoot(), url); baseObject = context.getSession().getBaseObject(context.getRoot(), url);
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);
} else { } else {
Object value = dataMap.get(aliasKey); Object value = dataMap.get(aliasKey);
if (null != value) { if (null != value) {
if (baseObject instanceof IDatafield<?>) { if (baseObject instanceof IDatafield<?>) {
IDatafield<Object> dataField = (IDatafield<Object>) baseObject; IDatafield<Object> dataField = (IDatafield<Object>) baseObject;
handleDatafield(context, dataField, value); handleDatafield(context, dataField, value);
// dataField.invokeDefaultRules(context); // dataField.invokeDefaultRules(context);
// dataField.invokeCheckRules(context); // dataField.invokeCheckRules(context);
// dataField.invokeEventRules(context, // dataField.invokeEventRules(context,
// EventType.ON_CHANGE, null, 0); // EventType.ON_CHANGE, null, 0);
} }
if (baseObject instanceof IModuleList<?> && value instanceof List<?>) { if (baseObject instanceof IModuleList<?> && value instanceof List<?>) {
IModuleList<IModule> moduleList = (IModuleList<IModule>) baseObject; IModuleList<IModule> moduleList = (IModuleList<IModule>) baseObject;
moduleList.clear(); moduleList.clear();
List<Map<String, Object>> valueList = (List<Map<String, Object>>) value; List<Map<String, Object>> valueList = (List<Map<String, Object>>) value;
for (Map<String, Object> m : valueList) { for (Map<String, Object> m : valueList) {
IModule module = moduleList.add(); IModule module = moduleList.add();
for (Map.Entry<String, Object> entry : m.entrySet()) for (Map.Entry<String, Object> entry : m.entrySet())
handleDatafield(context, (IDatafield<Object>) module.get(obfuscationPath(entry.getKey())), entry.getValue()); handleDatafield(context, (IDatafield<Object>) module.get(obfuscationPath(entry.getKey())), entry.getValue());
} }
} }
} }
} }
} catch (Exception e) { } catch (Exception e) {
log.error("Input command error", e); log.error("Input command error", e);
throw new NoUiException("Input command error", e); throw new NoUiException("Input command error", e);
} }
} }
//处理分页信息 //处理分页信息
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)) {
url = aliasKey; url = aliasKey;
} }
IBaseObject baseObject = null; IBaseObject baseObject = null;
try { try {
baseObject = context.getSession().getBaseObject(context.getRoot(), url); baseObject = context.getSession().getBaseObject(context.getRoot(), url);
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);
} }
} }
} }
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<>();
{ AbstractCache.paginationMap.set(paginationCache);
paginationCache = new HashMap<>(); }
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) {
if (null == value || dataField == null)
private static void handleDatafield(IContext context, IDatafield<Object> dataField, Object value) { return;
if (null == value || dataField == null) Class<?> dataType = dataField.getDataType();
return; if (dataType.equals(String.class)) {
Class<?> dataType = dataField.getDataType(); String valStr = value.toString();
if (dataType.equals(String.class)) {
String valStr = value.toString();
// if ("true".equalsIgnoreCase(valStr.trim())) // if ("true".equalsIgnoreCase(valStr.trim()))
// dataField.setValue("X"); // dataField.setValue("X");
// else if ("false".equalsIgnoreCase(valStr.trim())) // else if ("false".equalsIgnoreCase(valStr.trim()))
// dataField.setValue(""); // dataField.setValue("");
// else // else
dataField.setValue(valStr); dataField.setValue(valStr);
return; return;
} }
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
} dataField.setValue(Double.valueOf(data.replaceAll(",", "")).intValue());
else return;
dataField.setValue(Double.valueOf(data.replaceAll(",", "")).intValue()); }
return; if (dataType.equals(BigDecimal.class)) {
} String data = value.toString().trim();
if (dataType.equals(BigDecimal.class)) { if (StringUtils.isEmpty(data))
String data = value.toString().trim(); dataField.setValue(new BigDecimal(0));
if (StringUtils.isEmpty(data)) else
dataField.setValue(new BigDecimal(0)); dataField.setValue(new BigDecimal(data.replaceAll(",", "")));
else return;
dataField.setValue(new BigDecimal(data.replaceAll(",", ""))); }
return; if (dataType.equals(Date.class)) {
} String data = value.toString().trim();
if (dataType.equals(Date.class)) { dataField.setValue(dealDateFormat(data));
String data = value.toString().trim(); return;
dataField.setValue(dealDateFormat(data)); }
return; if (dataType.equals(Long.TYPE) || dataType.equals(Long.class)) {
} String data = value.toString().trim();
if (dataType.equals(Long.TYPE) || dataType.equals(Long.class)) { if (StringUtils.isEmpty(data))
String data = value.toString().trim(); dataField.setValue(0L);
if (StringUtils.isEmpty(data)) else
dataField.setValue(0L); dataField.setValue(Double.valueOf(data.replaceAll(",", "")).longValue());
else return;
dataField.setValue(Double.valueOf(data.replaceAll(",", "")).longValue()); }
return; throw new NoUiException("Unsupported data type", ErrorCodes.UNSUPPORTED_DATA_TYPE);
} }
throw new NoUiException("Unsupported data type", ErrorCodes.UNSUPPORTED_DATA_TYPE);
} private static Date dealDateFormat(String s) {
if (StringUtils.isEmpty(s))
private static Date dealDateFormat(String s) { return null;
if (StringUtils.isEmpty(s))
return null; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return sdf.parse(s);
try { } catch (ParseException e) {
return sdf.parse(s); }
} catch (ParseException e) { sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
} try {
sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); return sdf.parse(s);
try { } catch (ParseException e) {
return sdf.parse(s); }
} catch (ParseException e) { sdf = new SimpleDateFormat("yyyy/MM/dd");
} try {
sdf = new SimpleDateFormat("yyyy/MM/dd"); return sdf.parse(s);
try { } catch (ParseException e) {
return sdf.parse(s); }
} catch (ParseException e) { sdf = new SimpleDateFormat("yyyy-MM-dd");
} try {
sdf = new SimpleDateFormat("yyyy-MM-dd"); return sdf.parse(s);
try { } catch (ParseException e) {
return sdf.parse(s); }
} catch (ParseException e) {
} try {
return new Date(Long.valueOf(s));
try { } catch (Exception e) {
return new Date(Long.valueOf(s)); throw new NoUiException("Uncorrect data format", ErrorCodes.UNCORRECT_DATA_FORMAT);
} catch (Exception e) { }
throw new NoUiException("Uncorrect data format", ErrorCodes.UNCORRECT_DATA_FORMAT); }
}
} public static String retMsg(NoUiContext context) {
NoUiPresentation gui = (NoUiPresentation) context.getGui();
public static String retMsg(NoUiContext context) { return StringUtil.isEmpty(gui.getMessage()) ? ErrorCodes.SUCCESS_INFO : gui.getMessage();
NoUiPresentation gui = (NoUiPresentation) context.getGui(); }
return StringUtil.isEmpty(gui.getMessage()) ? ErrorCodes.SUCCESS_INFO : gui.getMessage();
} public static String retCode(NoUiContext context) {
NoUiPresentation gui = (NoUiPresentation) context.getGui();
public static String retCode(NoUiContext context) { return gui.getMessageCode();
NoUiPresentation gui = (NoUiPresentation) context.getGui(); }
return gui.getMessageCode();
} public static Map<String, Object> handleEventReturnData(EventType eventType, NoUiContext context, NoUiRequest request, Alias alias) {
public static Map<String, Object> handleEventReturnData(EventType eventType, NoUiContext context, NoUiRequest request, Alias alias) { Map<String, Object> data = new HashMap<String, Object>();
// 初始化事件
Map<String, Object> data = new HashMap<String, Object>(); if (eventType == null) {
// 初始化事件 for (String aliasKey : alias.getRel().keySet()) {
if (eventType == null) { if (aliasKey.startsWith("_")) {
for (String aliasKey : alias.getRel().keySet()) { continue;
if (aliasKey.startsWith("_")) { }
continue; String realPath = alias.getRelPath(aliasKey);
} IBaseObject baseObject = context.getSession().getBaseObject(context.getRoot(), realPath);
String realPath = alias.getRelPath(aliasKey); data.put(aliasKey, handIBaseObject(context, baseObject, realPath));
IBaseObject baseObject = context.getSession().getBaseObject(context.getRoot(), realPath); }
data.put(aliasKey, handIBaseObject(context, baseObject, realPath)); return data;
} }
return data;
} NoUiPresentation gui = (NoUiPresentation) context.getGui();
Map<String, Object> modifyMap = gui.getModifyMap();
NoUiPresentation gui = (NoUiPresentation) context.getGui(); for (Map.Entry<String, Object> modifyEntry : modifyMap.entrySet()) {
Map<String, Object> modifyMap = gui.getModifyMap(); for (Map.Entry<String, String> aliasEntry : alias.getRel().entrySet()) {
for (Map.Entry<String, Object> modifyEntry : modifyMap.entrySet()) { String aliasKey = aliasEntry.getKey();
for (Map.Entry<String, String> aliasEntry : alias.getRel().entrySet()) { String aliasPath = aliasEntry.getValue();
String aliasKey = aliasEntry.getKey(); if (aliasPath.startsWith(modifyEntry.getKey())) {
String aliasPath = aliasEntry.getValue(); Object val = modifyEntry.getValue();
if (aliasPath.startsWith(modifyEntry.getKey())) { data.put(aliasKey, handIBaseObject(context, val, aliasEntry.getValue()));
Object val = modifyEntry.getValue(); }
data.put(aliasKey, handIBaseObject(context, val, aliasEntry.getValue()));
} }
}
} return data;
} }
return data;
} private static String handle(Object value, IDatafield<Object> dataField) {
if (null == value)
private static String handle(Object value, IDatafield<Object> dataField) { return null;
if (null == value) Class<?> dataType = dataField.getDataType();
return null; if (dataType.equals(String.class)) {
Class<?> dataType = dataField.getDataType(); String valStr = value.toString();
if (dataType.equals(String.class)) { return valStr;
String valStr = value.toString(); }
return valStr; if (dataType.equals(Integer.TYPE) || dataType.equals(Integer.class)) {
} String data = value.toString().trim();
if (dataType.equals(Integer.TYPE) || dataType.equals(Integer.class)) { return data;
String data = value.toString().trim(); }
return data;
} if (dataType.equals(Double.TYPE) || dataType.equals(Double.class)) {
java.text.NumberFormat nf = java.text.NumberFormat.getInstance();
if (dataType.equals(Double.TYPE) || dataType.equals(Double.class)) { nf.setGroupingUsed(false);
java.text.NumberFormat nf = java.text.NumberFormat.getInstance(); // 设置数的小数部分所允许的最小位数
nf.setGroupingUsed(false); nf.setMinimumFractionDigits(0);
// 设置数的小数部分所允许的最小位数 // 设置数的小数部分所允许的最大位数
nf.setMinimumFractionDigits(0); nf.setMaximumFractionDigits(2);
// 设置数的小数部分所允许的最大位数 return nf.format(value);
nf.setMaximumFractionDigits(2); }
return nf.format(value); if (dataType.equals(BigDecimal.class)) {
} String data = value.toString().trim();
if (dataType.equals(BigDecimal.class)) { return data;
String data = value.toString().trim(); }
return data; if (dataType.equals(Date.class)) {
} Date date = (Date) value;
if (dataType.equals(Date.class)) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = (Date) value; return sdf.format(date);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); }
return sdf.format(date); if (dataType.equals(Long.TYPE) || dataType.equals(Long.class)) {
} String data = value.toString().trim();
if (dataType.equals(Long.TYPE) || dataType.equals(Long.class)) { return data;
String data = value.toString().trim(); }
return data; return null;
} }
return null;
} public static Object handIBaseObject(IContext context, Object val, String path) {
if (val == null)
public static Object handIBaseObject(IContext context, Object val, String path) { return null;
if (val == null) if ((val instanceof IModuleList)) {
return null; List list = new ArrayList();
if ((val instanceof IModuleList)) { IModuleList moduleList = (IModuleList) val;
List list = new ArrayList(); boolean isAll = true;
IModuleList moduleList = (IModuleList)val; if (!StringUtil.isEmpty(path)) {
for (int index = 0; index < moduleList.size(); index++) { isAll = false;
Map map = new HashMap(); }
IModule module = (IModule)moduleList.get(index); for (int index = 0; index < moduleList.size(); index++) {
Collection<IDatafield> datafields = module.getDatafields(); Map map = new HashMap();
for (IDatafield datafield : datafields) { IModule module = (IModule) moduleList.get(index);
map.put(obfuscationPath(datafield.getName()), handle(datafield.getValue(), datafield)); if (isAll) {
} Collection<IDatafield> datafields = module.getDatafields();
list.add(map); for (IDatafield datafield : datafields) {
} String dataFieldName = obfuscationPath(datafield.getName());
return list;
}if ((val instanceof IModule)) { map.put(dataFieldName, handle(datafield.getValue(), datafield));
val = context.getSession().getBaseObject(context.getRoot(), path); }
return handIBaseObject(context, val, path); } else {
}if ((val instanceof IDatafield)) { String[] pths = path.split(",");
IDatafield datafield = (IDatafield)val; for (String pth : pths) {
return handle(datafield.getValue(), datafield); IDatafield datafieldtmp = (IDatafield) context.getSession().getBaseObject(module, pth);
} String dataFieldName = obfuscationPath(datafieldtmp.getName());
return null; map.put(dataFieldName, handle(datafieldtmp.getValue(), datafieldtmp));
} }
}
public static Map<String, Object> getWholeAliasData(IContext context,String mappingUrl) list.add(map);
{ }
Map<String, Object> data = new HashMap<String, Object>(); return list;
Alias alias = new Alias(mappingUrl); }
for (String aliasKey : alias.getRel().keySet()) { if ((val instanceof IModule)) {
if (aliasKey.startsWith(Constants.MAPPING_PRE)) { val = context.getSession().getBaseObject(context.getRoot(), path);
continue; return handIBaseObject(context, val, path);
} }
String realPath = alias.getRelPath(aliasKey); if ((val instanceof IDatafield)) {
IBaseObject baseObject = context.getSession().getBaseObject(context.getRoot(), realPath); IDatafield datafield = (IDatafield) val;
data.put(aliasKey, NoUiPresentationUtil.handIBaseObject(context, baseObject, realPath)); return handle(datafield.getValue(), datafield);
} }
return data; return null;
} }
public static Map<String, Object> handleErrorReturnData(NoUiContext context, Alias alias) { public static Map<String, Object> getWholeAliasData(IContext context, String mappingUrl) {
NoUiPresentation gui = (NoUiPresentation) context.getGui(); Map<String, Object> data = new HashMap<String, Object>();
Map<String, Object> errorMap = gui.getError(); Alias alias = new Alias(mappingUrl);
Map<String, Object> n_errorMap = new HashMap<String,Object>(); for (String aliasKey : alias.getRel().keySet()) {
for (Map.Entry<String, Object> errorEntity : errorMap.entrySet()) { if (aliasKey.startsWith(Constants.MAPPING_PRE)) {
String key = errorEntity.getKey(); continue;
String realKey = alias.getRevertRel().get(key); }
if (!StringUtils.isEmpty(realKey)) String realPath = alias.getRelPath(aliasKey);
n_errorMap.put(realKey, errorEntity.getValue()); IBaseObject baseObject = context.getSession().getBaseObject(context.getRoot(), realPath);
else data.put(aliasKey, NoUiPresentationUtil.handIBaseObject(context, baseObject, realPath));
n_errorMap.put(key, errorEntity.getValue()); }
} return data;
return n_errorMap; }
}
public static Map<String, Object> handleErrorReturnData(NoUiContext context, Alias alias) {
public static Map<String, Object> handleCodeTableReturnData(NoUiContext context, Alias alias) { NoUiPresentation gui = (NoUiPresentation) context.getGui();
NoUiPresentation gui = (NoUiPresentation) context.getGui(); Map<String, Object> errorMap = gui.getError();
Map<String, Object> codeTableMap = gui.getCodetable(); Map<String, Object> n_errorMap = new HashMap<String, Object>();
Map<String, Object> retCodeTableMap = new HashMap<>(); for (Map.Entry<String, Object> errorEntity : errorMap.entrySet()) {
for (Map.Entry<String, Object> codeTableEntity : codeTableMap.entrySet()) { String key = errorEntity.getKey();
String key = codeTableEntity.getKey(); String realKey = alias.getRevertRel().get(key);
String realKey = alias.getRevertRel().get(key); if (!StringUtils.isEmpty(realKey))
if (!StringUtils.isEmpty(realKey)) n_errorMap.put(realKey, errorEntity.getValue());
retCodeTableMap.put(realKey, codeTableEntity.getValue()); else
else n_errorMap.put(key, errorEntity.getValue());
retCodeTableMap.put(key, codeTableEntity.getValue()); }
} return n_errorMap;
return retCodeTableMap; }
}
public static Map<String, Object> handleCodeTableReturnData(NoUiContext context, Alias alias) {
public static void setSysmod(NoUiContext context, byte[] oldSysmod) { NoUiPresentation gui = (NoUiPresentation) context.getGui();
AbstractPOJOModuleSession session = (AbstractPOJOModuleSession) context.getSession(); Map<String, Object> codeTableMap = gui.getCodetable();
Field sysmod = null; Map<String, Object> retCodeTableMap = new HashMap<>();
try { for (Map.Entry<String, Object> codeTableEntity : codeTableMap.entrySet()) {
sysmod = AbstractPOJOModuleSession.class.getDeclaredField("sysmod"); String key = codeTableEntity.getKey();
sysmod.setAccessible(true); String realKey = alias.getRevertRel().get(key);
// sysmod.set(session, oldSysmod); if (!StringUtils.isEmpty(realKey))
StreamImpl simp = new StreamImpl(); retCodeTableMap.put(realKey, codeTableEntity.getValue());
IOUtils.write(oldSysmod, simp.getOutputStream()); else
context.getSession().loadData((IParent) sysmod.get(session), simp); retCodeTableMap.put(key, codeTableEntity.getValue());
}
} catch (Exception e) { return retCodeTableMap;
log.error("setSysmod exception",e); }
}
} public static void setSysmod(NoUiContext context, byte[] oldSysmod) {
AbstractPOJOModuleSession session = (AbstractPOJOModuleSession) context.getSession();
public static byte[] sysmodToBytes(NoUiContext context) { Field sysmod = null;
try {
IParent sysmod = (IParent) context.getSession().getBaseObject(context.getRoot(), "sysmod"); sysmod = AbstractPOJOModuleSession.class.getDeclaredField("sysmod");
StreamImpl stream = new StreamImpl(); sysmod.setAccessible(true);
context.getSession().saveData(sysmod, stream); // sysmod.set(session, oldSysmod);
byte[] sysmodBytes = null; StreamImpl simp = new StreamImpl();
try { IOUtils.write(oldSysmod, simp.getOutputStream());
sysmodBytes = IOUtils.toByteArray(stream.getInputStream()); context.getSession().loadData((IParent) sysmod.get(session), simp);
} catch (IOException e) {
log.error("sysmodToBytes exception",e); } catch (Exception e) {
} log.error("setSysmod exception", e);
return sysmodBytes; }
} }
//混淆路径,算法:偏移 头4 尾7 public static byte[] sysmodToBytes(NoUiContext context) {
public static String obfuscationPath(String str){
if(NoUiUtils.fieldencode){ IParent sysmod = (IParent) context.getSession().getBaseObject(context.getRoot(), "sysmod");
StreamImpl stream = new StreamImpl();
context.getSession().saveData(sysmod, stream);
byte[] sysmodBytes = null;
try {
sysmodBytes = IOUtils.toByteArray(stream.getInputStream());
} catch (IOException e) {
log.error("sysmodToBytes exception", e);
}
return sysmodBytes;
}
//混淆路径,算法:偏移 头4 尾7
public static String obfuscationPath(String str) {
/*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(',');
sb.append(str); }
sb.append(','); if (sb.charAt(sb.length() - 1) == ',')
} sb.deleteCharAt(sb.length() - 1);
if(sb.charAt(sb.length() - 1) == ',') return sb.toString();
sb.deleteCharAt(sb.length() - 1); }
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++) {
{ if (paramsKey[i].equals(key)) {
for (int i = 0; i < paramsKey.length; i++) { params[i] = value;
if (paramsKey[i].equals(key)) { break;
params[i] = value; }
break; }
} }
}
}
} }
...@@ -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