为什么这两段代码分别在/shop/list和/match/list这两个网址下显示的内容是一样的?
正常的应该一个显示数据库内category='match'的记录,另一个显示category='test'的内容。本来以为是缓存名字的问题,但是修改了之后仍然没有用,求助大神!
shopController.java
private shopModel gradingModel = new shopModel();
// 比赛列表
public void list() {
Map<String, Object> para = new HashMap<String, Object>();
para.put("pageNum", getParaToInt("page", 1));
para.put("pageSize", getParaToInt("rows", 10));
String url = "http://" + DOMAIN + "/shop/list";
JSONObject jsConfigJson = WeiXinJsUtil.getWXConfigMap(url);
setAttr("jsConfig", jsConfigJson.toJSONString());
Page<Record> page = gradingModel.getList(para);
setAttrs(buildPagination(page.getList(), page.getTotalRow()));
render(new VelocityLayoutRender("list.html"));
}MatchController.java
private MatchModel matchModel = new MatchModel();
// 比赛列表
public void list() {
Map<String, Object> para = new HashMap<String, Object>();
para.put("pageNum", getParaToInt("page", 1));
para.put("pageSize", getParaToInt("rows", 10));
Page<Record> page = matchModel.getList(para);
String url = "http://" + DOMAIN + "/match/list";
JSONObject jsConfigJson = WeiXinJsUtil.getWXConfigMap(url);
setAttr("jsConfig", jsConfigJson.toJSONString());
setAttrs(buildPagination(page.getList(), page.getTotalRow()));
render(new VelocityLayoutRender("list.html"));
}
shopModel.java
private final static String CACHE_MATCH_LIST = "shopList";
private final static String CACHE_MATCH_DETAIL = "shopDetail";
/**
* 考级列表
*
* @param para
* @return
*/
public Page<Record> getList(Map<String, Object> para) {
Integer pageNum = (Integer) para.get("pageNum");
Integer pageSize = (Integer) para.get("pageSize");
Integer is_index = (Integer) para.get("is_index");
pageNum = pageNum > 0 ? pageNum : 1;
String cacheKey = "shop_" + Util.implode(",", para);
Page<Record> page = CacheKit.get(CACHE_MATCH_LIST, cacheKey);
if (page != null) {
return page;
}
String whereSql = " category='test' ";
if (is_index != null && is_index > 0) {
whereSql += " and index_show > 0 ";
}
page = Db.paginate(pageNum, pageSize, "select *",
"from tbl_match where status >=0 and " + whereSql
+ " ORDER BY index_show DESC,id DESC");
for (Record record : page.getList()) {
record.set("intro_content", StringUtil.getTextFromHtml(
record.getStr("intro_content"), 50));
record.set("main_image", ImageUtil.getThumbImageUrl(
record.getStr("main_image"),
BaseController.IMAGE_SIZE_MAP.get("match_list")));
}
CacheKit.put(CACHE_MATCH_LIST, cacheKey, page);
return page;
}MatchModel
private final static String CACHE_MATCH_LIST = "matchList";
private final static String CACHE_MATCH_DETAIL = "matchDetail";
/**
* 比赛列表
*
* @param para
* @return
*/
public Page<Record> getList(Map<String, Object> para) {
Integer pageNum = (Integer) para.get("pageNum");
Integer pageSize = (Integer) para.get("pageSize");
Integer is_index = (Integer) para.get("is_index");
pageNum = pageNum > 0 ? pageNum : 1;
String cacheKey = Util.implode(",", para);
Page<Record> page = CacheKit.get(CACHE_MATCH_LIST, cacheKey);
if (page != null) {
return page;
}
String whereSql = " category='match' ";
if (is_index != null && is_index > 0) {
whereSql += " and index_show > 0 ";
}
page = Db.paginate(pageNum, pageSize, "select *",
"from tbl_match where status >=0 and " + whereSql
+ " ORDER BY index_show DESC,id DESC");
for (Record record : page.getList()) {
record.set("intro_content", StringUtil.getTextFromHtml(
record.getStr("intro_content"), 50));
record.set("main_image", ImageUtil.getThumbImageUrl(
record.getStr("main_image"),
BaseController.IMAGE_SIZE_MAP.get("match_list")));
}
CacheKit.put(CACHE_MATCH_LIST, cacheKey, page);
return page;
}
项目:JFinal