Commit be81bc61 by WeiCong

Merge remote-tracking branch 'origin/master'

parents e294df89 8122ae89
...@@ -3,12 +3,16 @@ package org.sss.presentation.noui.cache; ...@@ -3,12 +3,16 @@ package org.sss.presentation.noui.cache;
import org.hibernate.Criteria; import org.hibernate.Criteria;
import org.hibernate.Query; import org.hibernate.Query;
import org.sss.common.model.CacheController; import org.sss.common.model.CacheController;
import org.sss.common.model.IModuleList;
import org.sss.presentation.noui.common.Constants;
import java.util.List; import java.util.List;
import java.util.Map;
public abstract class AbstractCache implements CacheController { public abstract class AbstractCache implements CacheController {
protected final String cacheName; protected final String cacheName;
final String SPLIT = "__"; final String SPLIT = "__";
public static final ThreadLocal paginationMap = new ThreadLocal();
public AbstractCache(String redis_cache) { public AbstractCache(String redis_cache) {
this.cacheName = redis_cache; this.cacheName = redis_cache;
...@@ -59,6 +63,20 @@ public abstract class AbstractCache implements CacheController { ...@@ -59,6 +63,20 @@ public abstract class AbstractCache implements CacheController {
return sb.toString(); return sb.toString();
} }
@Override
public void prepareReadset(IModuleList moduleList) {
Map<String, Map<String,Integer>> paginationCache = (Map<String, Map<String,Integer>>)paginationMap.get();
if(paginationCache == null)
return;
Map<String,Integer> paginationItem = paginationCache.remove(moduleList.getUrl());
if(paginationCache.size() ==0)
paginationMap.remove();
if(paginationItem == null)
return;
moduleList.setPageSize(paginationItem.get(Constants.PAGINATION_PAGESIZE));
moduleList.setPage(paginationItem.get(Constants.PAGINATION_INDEX));
}
protected abstract List doCacheRead(String key); protected abstract List doCacheRead(String key);
protected abstract void doCacheWrite(String key, List lst, long keepAlive); protected abstract void doCacheWrite(String key, List lst, long keepAlive);
......
...@@ -11,6 +11,7 @@ import org.sss.presentation.noui.api.exception.NoUiException; ...@@ -11,6 +11,7 @@ import org.sss.presentation.noui.api.exception.NoUiException;
import org.sss.presentation.noui.api.model.Alias; import org.sss.presentation.noui.api.model.Alias;
import org.sss.presentation.noui.api.request.NoUiRequest; import org.sss.presentation.noui.api.request.NoUiRequest;
import org.sss.presentation.noui.api.response.ErrorCodes; import org.sss.presentation.noui.api.response.ErrorCodes;
import org.sss.presentation.noui.cache.AbstractCache;
import org.sss.presentation.noui.common.Constants; import org.sss.presentation.noui.common.Constants;
import org.sss.presentation.noui.context.NoUiContext; import org.sss.presentation.noui.context.NoUiContext;
import org.sss.presentation.noui.context.NoUiPresentation; import org.sss.presentation.noui.context.NoUiPresentation;
...@@ -93,8 +94,7 @@ public class NoUiPresentationUtil { ...@@ -93,8 +94,7 @@ public class NoUiPresentationUtil {
//处理分页信息 //处理分页信息
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);
moduleList.setPageSize(paginationItem.get(Constants.PAGINATION_PAGESIZE)); putPaginationCache(paginationItem,moduleList);
moduleList.setPage(paginationItem.get(Constants.PAGINATION_INDEX));
} 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);
...@@ -103,6 +103,17 @@ public class NoUiPresentationUtil { ...@@ -103,6 +103,17 @@ public class NoUiPresentationUtil {
} }
private static void putPaginationCache(Map<String,Integer> paginationItem,IModuleList moduleList)
{
Map<String,Map<String,Integer>> paginationCache = (Map<String,Map<String,Integer>>)AbstractCache.paginationMap.get();
if(paginationCache == null)
{
paginationCache = new HashMap<>();
AbstractCache.paginationMap.set(paginationCache);
}
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) {
if (null == value || dataField == null) if (null == value || dataField == null)
return; return;
......
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