Commit e294df89 by WeiCong

Merge remote-tracking branch 'origin/master'

parents 97e08c89 9c63b41f
...@@ -16,8 +16,10 @@ public class NoUiRequest { ...@@ -16,8 +16,10 @@ public class NoUiRequest {
private String mappingUrl; private String mappingUrl;
private boolean openSource; private boolean openSource;
private Map<String, ?> paramsMap = new HashMap<String, Object>(); private Map<String, ?> paramsMap = new HashMap<String, Object>();
private Map<String, ?> paginationMap = new HashMap<String, Object>();
private Map<String, ?> dataMap = new HashMap<String, Object>(); private Map<String, ?> dataMap = new HashMap<String, Object>();
private Map<String, ?> saveDisplayMap = new HashMap<String, Object>(); private Map<String, ?> saveDisplayMap = new HashMap<String, Object>();
private boolean isSecurity=false; private boolean isSecurity=false;
private String reqUrl; private String reqUrl;
private String trnName; private String trnName;
...@@ -56,12 +58,15 @@ public class NoUiRequest { ...@@ -56,12 +58,15 @@ public class NoUiRequest {
this.paramsMap = (Map<String, ?>) requestData.get(Constants.PARAMS); this.paramsMap = (Map<String, ?>) requestData.get(Constants.PARAMS);
this.dataMap = (Map<String, ?>) requestData.get(Constants.DATA); this.dataMap = (Map<String, ?>) requestData.get(Constants.DATA);
this.saveDisplayMap = (Map<String, ?>) requestData.get(Constants.DISPLAY); this.saveDisplayMap = (Map<String, ?>) requestData.get(Constants.DISPLAY);
this.paginationMap = (Map<String, ?>) requestData.get(Constants.PAGINATION);
if (this.paramsMap == null) if (this.paramsMap == null)
this.paramsMap = new HashMap<String, Object>(); this.paramsMap = new HashMap<String, Object>();
if (this.dataMap == null) if (this.dataMap == null)
this.dataMap = new HashMap<String, Object>(); this.dataMap = new HashMap<String, Object>();
if (this.saveDisplayMap == null) if (this.saveDisplayMap == null)
this.saveDisplayMap = new HashMap<String, Object>(); this.saveDisplayMap = new HashMap<String, Object>();
if (this.paginationMap == null)
this.paginationMap = new HashMap<>();
} }
} }
...@@ -144,4 +149,12 @@ public class NoUiRequest { ...@@ -144,4 +149,12 @@ public class NoUiRequest {
public String getTrnName() { public String getTrnName() {
return trnName; return trnName;
} }
public Map<String, ?> getPaginationMap() {
return paginationMap;
}
public void setPaginationMap(Map<String, ?> paginationMap) {
this.paginationMap = paginationMap;
}
} }
...@@ -8,6 +8,7 @@ public class Result { ...@@ -8,6 +8,7 @@ public class Result {
private String retmsg; private String retmsg;
private Map<String, Object> error;// 错误信息 private Map<String, Object> error;// 错误信息
private Map<String, Object> codetable; private Map<String, Object> codetable;
private Object pagination;
private Object data; private Object data;
private String verison; private String verison;
private static final String EMPTY=""; private static final String EMPTY="";
...@@ -79,4 +80,12 @@ public class Result { ...@@ -79,4 +80,12 @@ public class Result {
public void setCodetable(Map<String, Object> codetable) { public void setCodetable(Map<String, Object> codetable) {
this.codetable = codetable; this.codetable = codetable;
} }
public Object getPagination() {
return pagination;
}
public void setPagination(Object pagination) {
this.pagination = pagination;
}
} }
...@@ -12,6 +12,13 @@ public class ResultUtil { ...@@ -12,6 +12,13 @@ public class ResultUtil {
return new Result(retcod, retmsg, error, codetable, data,version); return new Result(retcod, retmsg, error, codetable, data,version);
} }
public static Result result(String retcod, String retmsg, Map<String, Object> data,Map<String, Object> paginationData, Map<String, Object> error, Map<String, Object> codetable,String version) {
Result result = new Result(retcod, retmsg, error, codetable, data,version);
if(!paginationData.isEmpty())
result.setPagination(paginationData);
return result;
}
public static Result result(String retcod, String retmsg, Object data) { public static Result result(String retcod, String retmsg, Object data) {
return new Result(retcod, retmsg, data,DEFAULT_VERSION); return new Result(retcod, retmsg, data,DEFAULT_VERSION);
} }
......
...@@ -19,4 +19,8 @@ public class Constants { ...@@ -19,4 +19,8 @@ public class Constants {
public final static String SESSION = "session"; public final static String SESSION = "session";
public final static String BACKGROUND_FLAG = "BackGroundRequest-"; public final static String BACKGROUND_FLAG = "BackGroundRequest-";
public static final String PAGINATION = "pagination";
public static final String PAGINATION_INDEX = "index";
public static final String PAGINATION_PAGESIZE = "pageSize";
public static final String PAGINATION_TOTAL = "total";
} }
...@@ -163,9 +163,8 @@ public abstract class AbstractCommonController { ...@@ -163,9 +163,8 @@ public abstract class AbstractCommonController {
redisLoginInfo.setSysmod(sysmodBytes); redisLoginInfo.setSysmod(sysmodBytes);
RedisUtil.set(StringUtil.userUniqueId(noUiRequest), redisLoginInfo); RedisUtil.set(StringUtil.userUniqueId(noUiRequest), redisLoginInfo);
} }
Map<String, Object> paginationData = new HashMap<>();
Map<String, Object> afterReturnData = handleReturnData(eventType, context, noUiRequest, alias); 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())) {
...@@ -176,7 +175,7 @@ public abstract class AbstractCommonController { ...@@ -176,7 +175,7 @@ public abstract class AbstractCommonController {
} }
} }
ret = ResultUtil.result(NoUiPresentationUtil.retCode(context), NoUiPresentationUtil.retMsg(context), afterReturnData, 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 (Exception e) { } catch (Exception e) {
log.error("OnClick command error", e); log.error("OnClick command error", e);
...@@ -200,7 +199,19 @@ public abstract class AbstractCommonController { ...@@ -200,7 +199,19 @@ public abstract class AbstractCommonController {
return baseObject; return baseObject;
} }
private Map<String, Object> handleReturnData(String eventType, NoUiContext context, NoUiRequest noUiRequest, Alias alias) { private void putModuleListPagination(String aliasKey,Map<String,Object> paginationMap,IModuleList moduleList)
{
//没有做分页
if(moduleList.getPageSize() == 0)
return;
int total = moduleList.fullSize();
int index = moduleList.getPage();
Map<String,Integer> map = new HashMap<>();
map.put("total",total);
map.put("index",index);
paginationMap.put(aliasKey,map);
}
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>();
// 初始化事件 // 初始化事件
...@@ -211,7 +222,10 @@ public abstract class AbstractCommonController { ...@@ -211,7 +222,10 @@ 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)
{
putModuleListPagination( aliasKey,paginationMap,(IModuleList)baseObject);
}
data.put(aliasKey, NoUiPresentationUtil.handIBaseObject(context, baseObject, realPath)); data.put(aliasKey, NoUiPresentationUtil.handIBaseObject(context, baseObject, realPath));
} }
return data; return data;
...@@ -240,6 +254,10 @@ public abstract class AbstractCommonController { ...@@ -240,6 +254,10 @@ public abstract class AbstractCommonController {
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())); data.put(aliasKey, NoUiPresentationUtil.handIBaseObject(context, val, aliasEntry.getValue()));
containsKeys.add(modifyEntry.getKey()); containsKeys.add(modifyEntry.getKey());
} }
...@@ -256,7 +274,12 @@ public abstract class AbstractCommonController { ...@@ -256,7 +274,12 @@ public abstract class AbstractCommonController {
System.out.println("modify moduleList:" + (modifyMap.get(key) instanceof IModuleList)); System.out.println("modify moduleList:" + (modifyMap.get(key) instanceof IModuleList));
if (key == null) if (key == null)
continue; continue;
data.put(key, NoUiPresentationUtil.handIBaseObject(context, modifyMap.get(key), key)); Object baseObject = modifyMap.get(key);
if( baseObject instanceof IModuleList)
{
putModuleListPagination(key,paginationMap,(IModuleList)baseObject);
}
data.put(key, NoUiPresentationUtil.handIBaseObject(context, baseObject, key));
} }
} }
......
...@@ -73,6 +73,34 @@ public class NoUiPresentationUtil { ...@@ -73,6 +73,34 @@ public class NoUiPresentationUtil {
} }
//处理分页信息
Map<String,?> paginationMap = request.getPaginationMap();
for (String aliasKey : paginationMap.keySet()) {
String url = alias.getRelPath(aliasKey);
if (StringUtils.isEmpty(url)) {
url = aliasKey;
}
IBaseObject baseObject = null;
try {
System.out.println("url=" + url);
baseObject = context.getSession().getBaseObject(context.getRoot(), url);
if (null == baseObject) {
throw new NoUiException("not found url :" + url + " ,alias name is:" + aliasKey);
}
if(!(baseObject instanceof IModuleList))
throw new NoUiException( url + " is not a moduleList");
//处理分页信息
IModuleList moduleList = (IModuleList) baseObject;
Map<String,Integer> paginationItem = (Map<String,Integer>)paginationMap.get(aliasKey);
moduleList.setPageSize(paginationItem.get(Constants.PAGINATION_PAGESIZE));
moduleList.setPage(paginationItem.get(Constants.PAGINATION_INDEX));
} catch (Exception e) {
log.error("Pagination command error", e);
throw new NoUiException("Pagination command error", e);
}
}
} }
private static void handleDatafield(IContext context, IDatafield<Object> dataField, Object value) { private static void handleDatafield(IContext context, IDatafield<Object> dataField, Object value) {
...@@ -236,42 +264,24 @@ public class NoUiPresentationUtil { ...@@ -236,42 +264,24 @@ public class NoUiPresentationUtil {
public static Object handIBaseObject(IContext context, Object val, String path) { public static Object handIBaseObject(IContext context, Object val, String path) {
if (val == null) if (val == null)
return null; return null;
if (val instanceof IModuleList<?>) { if ((val instanceof IModuleList)) {
List<Map<String, Object>> list = new ArrayList<>(); List list = new ArrayList();
IModuleList<?> moduleList = (IModuleList<?>) val; IModuleList moduleList = (IModuleList)val;
List<String> cacheRecord = new ArrayList<>();
String paramsKey[] = BizKeySetManager.getParamKeys(moduleList);
String params[] = new String[paramsKey.length];
//是否需要缓存
boolean needCache = BizKeySetManager.isModueListNeedCache(context.getSession().getTransName(),path);
for (int index = 0; index < moduleList.size(); index++) { for (int index = 0; index < moduleList.size(); index++) {
Map<String, Object> map = new HashMap<>(); Map map = new HashMap();
IModule module = moduleList.get(index); IModule module = (IModule)moduleList.get(index);
Collection<IDatafield> datafields = module.getDatafields(); Collection<IDatafield> datafields = module.getDatafields();
for (IDatafield datafield : datafields) {
for (IDatafield<Object> datafield : datafields) { map.put(changeForELCS(datafield.getName()), handle(datafield.getValue(), datafield));
String value = handle(datafield.getValue(), datafield);
String colName = datafield.getName();
map.put(changeForELCS(colName), value);
if(needCache) { //拷贝值进入params
copyValueToParamsArr(paramsKey,params,colName,value);
}
}
if(needCache)
{
cacheRecord.add(transParamsToString(params));
} }
list.add(map); list.add(map);
} }
if(needCache) //进入redis缓存
BizKeySetManager.cacheDataKeys(cacheRecord.toArray(new String[0]));
return list; return list;
} else 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);
} else if (val instanceof IDatafield) { }if ((val instanceof IDatafield)) {
IDatafield datafield = (IDatafield) val; IDatafield datafield = (IDatafield)val;
return handle(datafield.getValue(), datafield); return handle(datafield.getValue(), datafield);
} }
return null; return null;
......
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