From 7e7db2fa55a9a3af46d4fd8ede0dee147f101d64 Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期六, 09 五月 2020 21:41:27 +0800 Subject: [PATCH] 2.1需求 --- fanli/src/main/java/com/yeshi/fanli/controller/admin/PushRecordAdminController.java | 57 ++++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 46 insertions(+), 11 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/PushRecordAdminController.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/PushRecordAdminController.java index dafb478..d40dce9 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/PushRecordAdminController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/PushRecordAdminController.java @@ -7,13 +7,12 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.yeshi.utils.JsonUtil; import com.yeshi.fanli.entity.xinge.PushRecord; import com.yeshi.fanli.service.inter.push.PushRecordService; import com.yeshi.fanli.tag.PageEntity; import com.yeshi.fanli.util.Constant; -import org.yeshi.utils.JsonUtil; import net.sf.json.JSONObject; @@ -25,15 +24,51 @@ @Resource private PushRecordService pushRecordService; - @RequestMapping(value = "getPushRecordList", method = RequestMethod.POST) - public void getAll(String title,int type,int page,PrintWriter out){ - List<PushRecord> list = pushRecordService.getPushRecordList(title,type,page); - int count = pushRecordService.getCount(title,type,page); - PageEntity pe = new PageEntity(page, Constant.PAGE_SIZE, count); - JSONObject data = new JSONObject(); - data.put("pe", pe); - data.put("list", list); - out.print(JsonUtil.loadTrueResult(data)); + + /** + * 鎺ㄨ崘璁板綍 -(鏂板悗鍙�) + * @param callback + * @param key + * @param type + * @param pageIndex + * @param out + */ + @RequestMapping(value = "getNewPushRecordList") + public void getNewPushRecordList(String callback, String key, Integer type, Integer pageIndex, PrintWriter out){ + try { + + if (pageIndex == null || pageIndex < 0){ + pageIndex = 1; + } + + if (type == null) { + type = 0; + } + + int pageSize = Constant.PAGE_SIZE; + + List<PushRecord> list = pushRecordService.getPushRecordList((pageIndex-1) * pageSize, pageSize, key, type); + if (list == null || list.size() == 0) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏇村鏁版嵁")); + return; + } + + long count = pushRecordService.getCount(key, type); + + int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); + PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage); + + JSONObject data = new JSONObject(); + data.put("pe", pe); + data.put("result_list", list); + + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); + } catch (Exception e) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏌ヨ澶辫触")); + e.printStackTrace(); + } + } + } -- Gitblit v1.8.0