Commit 01c18313 authored by Junling Bu's avatar Junling Bu
Browse files

chore: 利用PageHelper的PageInfo简化代码。

parent d40b9146
package org.linlinjava.litemall.admin.service;
import com.github.pagehelper.PageInfo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.linlinjava.litemall.admin.dao.GoodsAllinone;
......@@ -49,7 +50,7 @@ public class AdminGoodsService {
public Object list(String goodsSn, String name,
Integer page, Integer limit, String sort, String order) {
List<LitemallGoods> goodsList = goodsService.querySelective(goodsSn, name, page, limit, sort, order);
int total = goodsService.countSelective(goodsSn, name, page, limit, sort, order);
long total = PageInfo.of(goodsList).getTotal();
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", goodsList);
......
......@@ -4,6 +4,7 @@ import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
import com.github.binarywang.wxpay.bean.result.WxPayRefundResult;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.pagehelper.PageInfo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.linlinjava.litemall.core.notify.NotifyService;
......@@ -52,7 +53,7 @@ public class AdminOrderService {
public Object list(Integer userId, String orderSn, List<Short> orderStatusArray,
Integer page, Integer limit, String sort, String order) {
List<LitemallOrder> orderList = orderService.querySelective(userId, orderSn, orderStatusArray, page, limit, sort, order);
int total = orderService.countSelective(userId, orderSn, orderStatusArray, page, limit, sort, order);
long total = PageInfo.of(orderList).getTotal();
Map<String, Object> data = new HashMap<>();
data.put("total", total);
......
package org.linlinjava.litemall.admin.web;
import com.github.pagehelper.PageInfo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;
......@@ -37,7 +38,7 @@ public class AdminAdController {
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
List<LitemallAd> adList = adService.querySelective(name, content, page, limit, sort, order);
int total = adService.countSelective(name, content, page, limit, sort, order);
long total = PageInfo.of(adList).getTotal();
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", adList);
......
package org.linlinjava.litemall.admin.web;
import com.github.pagehelper.PageInfo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;
......@@ -63,7 +64,7 @@ public class AdminAddressController {
@Order @RequestParam(defaultValue = "desc") String order) {
List<LitemallAddress> addressList = addressService.querySelective(userId, name, page, limit, sort, order);
int total = addressService.countSelective(userId, name, page, limit, sort, order);
long total = PageInfo.of(addressList).getTotal();
List<Map<String, Object>> addressVoList = new ArrayList<>(addressList.size());
for (LitemallAddress address : addressList) {
......
package org.linlinjava.litemall.admin.web;
import com.github.pagehelper.PageInfo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;
......@@ -41,7 +42,7 @@ public class AdminAdminController {
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
List<LitemallAdmin> adminList = adminService.querySelective(username, page, limit, sort, order);
int total = adminService.countSelective(username, page, limit, sort, order);
long total = PageInfo.of(adminList).getTotal();
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", adminList);
......
package org.linlinjava.litemall.admin.web;
import com.github.pagehelper.PageInfo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;
......@@ -38,7 +39,7 @@ public class AdminBrandController {
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
List<LitemallBrand> brandList = brandService.querySelective(id, name, page, limit, sort, order);
int total = brandService.countSelective(id, name, page, limit, sort, order);
long total = PageInfo.of(brandList).getTotal();
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", brandList);
......
package org.linlinjava.litemall.admin.web;
import com.github.pagehelper.PageInfo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;
......@@ -38,7 +39,7 @@ public class AdminCategoryController {
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
List<LitemallCategory> collectList = categoryService.querySelective(id, name, page, limit, sort, order);
int total = categoryService.countSelective(id, name, page, limit, sort, order);
long total = PageInfo.of(collectList).getTotal();
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", collectList);
......
package org.linlinjava.litemall.admin.web;
import com.github.pagehelper.PageInfo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;
......@@ -39,7 +40,7 @@ public class AdminCollectController {
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
List<LitemallCollect> collectList = collectService.querySelective(userId, valueId, page, limit, sort, order);
int total = collectService.countSelective(userId, valueId, page, limit, sort, order);
long total = PageInfo.of(collectList).getTotal();
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", collectList);
......
package org.linlinjava.litemall.admin.web;
import com.github.pagehelper.PageInfo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;
......@@ -35,7 +36,7 @@ public class AdminCommentController {
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
List<LitemallComment> brandList = commentService.querySelective(userId, valueId, page, limit, sort, order);
int total = commentService.countSelective(userId, valueId, page, limit, sort, order);
long total = PageInfo.of(brandList).getTotal();
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", brandList);
......
package org.linlinjava.litemall.admin.web;
import com.github.pagehelper.PageInfo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;
......@@ -42,7 +43,7 @@ public class AdminCouponController {
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
List<LitemallCoupon> couponList = couponService.querySelective(name, type, status, page, limit, sort, order);
int total = couponService.countSelective(name, type, status, page, limit, sort, order);
long total = PageInfo.of(couponList).getTotal();
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", couponList);
......@@ -59,7 +60,7 @@ public class AdminCouponController {
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
List<LitemallCouponUser> couponList = couponUserService.queryList(userId, couponId, status, page, limit, sort, order);
int total = couponUserService.countList(userId, couponId, status, page, limit, sort, order);
long total = PageInfo.of(couponList).getTotal();
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", couponList);
......
package org.linlinjava.litemall.admin.web;
import com.github.pagehelper.PageInfo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;
......@@ -42,7 +43,7 @@ public class AdminFeedbackController {
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
List<LitemallFeedback> feedbackList = feedbackService.querySelective(userId, username, page, limit, sort, order);
int total = feedbackService.countSelective(userId, username, page, limit, sort, order);
long total = PageInfo.of(feedbackList).getTotal();
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", feedbackList);
......
package org.linlinjava.litemall.admin.web;
import com.github.pagehelper.PageInfo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;
......@@ -38,7 +39,7 @@ public class AdminFootprintController {
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
List<LitemallFootprint> footprintList = footprintService.querySelective(userId, goodsId, page, limit, sort, order);
int total = footprintService.countSelective(userId, goodsId, page, limit, sort, order);
long total = PageInfo.of(footprintList).getTotal();
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", footprintList);
......
package org.linlinjava.litemall.admin.web;
import com.github.pagehelper.PageInfo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;
......@@ -46,7 +47,7 @@ public class AdminGrouponController {
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
List<LitemallGroupon> grouponList = grouponService.querySelective(grouponId, page, limit, sort, order);
int total = grouponService.countSelective(grouponId, page, limit, sort, order);
long total = PageInfo.of(grouponList).getTotal();
List<Map<String, Object>> records = new ArrayList<>();
for (LitemallGroupon groupon : grouponList) {
......@@ -83,7 +84,7 @@ public class AdminGrouponController {
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
List<LitemallGrouponRules> rulesList = rulesService.querySelective(goodsId, page, limit, sort, order);
int total = rulesService.countSelective(goodsId, page, limit, sort, order);
long total = PageInfo.of(rulesList).getTotal();
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", rulesList);
......
package org.linlinjava.litemall.admin.web;
import com.github.pagehelper.PageInfo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;
......@@ -36,7 +37,7 @@ public class AdminHistoryController {
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
List<LitemallSearchHistory> footprintList = searchHistoryService.querySelective(userId, keyword, page, limit, sort, order);
int total = searchHistoryService.countSelective(userId, keyword, page, limit, sort, order);
long total = PageInfo.of(footprintList).getTotal();
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", footprintList);
......
package org.linlinjava.litemall.admin.web;
import com.github.pagehelper.PageInfo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;
......@@ -37,7 +38,7 @@ public class AdminIssueController {
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
List<LitemallIssue> issueList = issueService.querySelective(question, page, limit, sort, order);
int total = issueService.countSelective(question, page, limit, sort, order);
long total = PageInfo.of(issueList).getTotal();
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", issueList);
......
package org.linlinjava.litemall.admin.web;
import com.github.pagehelper.PageInfo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;
......@@ -37,7 +38,7 @@ public class AdminKeywordController {
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
List<LitemallKeyword> brandList = keywordService.querySelective(keyword, url, page, limit, sort, order);
int total = keywordService.countSelective(keyword, url, page, limit, sort, order);
long total = PageInfo.of(brandList).getTotal();
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", brandList);
......
package org.linlinjava.litemall.admin.web;
import com.github.pagehelper.PageInfo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.linlinjava.litemall.core.util.ResponseUtil;
......@@ -41,7 +42,7 @@ public class AdminRegionController {
@Sort(accepts = {"id"}) @RequestParam(defaultValue = "id") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
List<LitemallRegion> regionList = regionService.querySelective(name, code, page, limit, sort, order);
int total = regionService.countSelective(name, code, page, limit, sort, order);
long total = PageInfo.of(regionList).getTotal();
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", regionList);
......
package org.linlinjava.litemall.admin.web;
import com.github.pagehelper.PageInfo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.SecurityUtils;
......@@ -51,7 +52,7 @@ public class AdminRoleController {
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
List<LitemallRole> roleList = roleService.querySelective(name, page, limit, sort, order);
int total = roleService.countSelective(name, page, limit, sort, order);
long total = PageInfo.of(roleList).getTotal();
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", roleList);
......
package org.linlinjava.litemall.admin.web;
import com.github.pagehelper.PageInfo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;
......@@ -42,7 +43,7 @@ public class AdminStorageController {
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
List<LitemallStorage> storageList = litemallStorageService.querySelective(key, name, page, limit, sort, order);
int total = litemallStorageService.countSelective(key, name, page, limit, sort, order);
long total = PageInfo.of(storageList).getTotal();
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", storageList);
......
package org.linlinjava.litemall.admin.web;
import com.github.pagehelper.PageInfo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;
......@@ -38,7 +39,7 @@ public class AdminTopicController {
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
List<LitemallTopic> topicList = topicService.querySelective(title, subtitle, page, limit, sort, order);
int total = topicService.countSelective(title, subtitle, page, limit, sort, order);
long total = PageInfo.of(topicList).getTotal();
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", topicList);
......
Supports Markdown
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