diff --git a/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallBrandService.java b/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallBrandService.java index e51a0b28..84ee17d3 100644 --- a/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallBrandService.java +++ b/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallBrandService.java @@ -17,16 +17,10 @@ public class LitemallBrandService { private LitemallBrandMapper brandMapper; private Column[] columns = new Column[]{Column.id, Column.name, Column.desc, Column.picUrl, Column.floorPrice}; - public List query(int offset, int limit) { - LitemallBrandExample example = new LitemallBrandExample(); - example.or().andDeletedEqualTo(false); - PageHelper.startPage(offset, limit); - return brandMapper.selectByExample(example); - } - public List queryVO(int offset, int limit) { LitemallBrandExample example = new LitemallBrandExample(); example.or().andDeletedEqualTo(false); + example.setOrderByClause("add_time desc"); PageHelper.startPage(offset, limit); return brandMapper.selectByExampleSelective(example, columns); } diff --git a/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallTopicService.java b/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallTopicService.java index 3c2802db..a70103f5 100644 --- a/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallTopicService.java +++ b/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallTopicService.java @@ -18,8 +18,13 @@ public class LitemallTopicService { private Column[] columns = new Column[]{Column.id, Column.title, Column.subtitle, Column.price, Column.picUrl, Column.readCount}; public List queryList(int offset, int limit) { + return queryList(offset, limit, "add_time", "desc"); + } + + public List queryList(int offset, int limit, String sort, String order) { LitemallTopicExample example = new LitemallTopicExample(); example.or().andDeletedEqualTo(false); + example.setOrderByClause(sort + " " + order); PageHelper.startPage(offset, limit); return topicMapper.selectByExampleSelective(example, columns); } @@ -41,7 +46,7 @@ public class LitemallTopicService { example.or().andIdEqualTo(id).andDeletedEqualTo(false); List topics = topicMapper.selectByExample(example); if (topics.size() == 0) { - return queryList(offset, limit); + return queryList(offset, limit, "add_time", "desc"); } LitemallTopic topic = topics.get(0); @@ -53,7 +58,7 @@ public class LitemallTopicService { return relateds; } - return queryList(offset, limit); + return queryList(offset, limit, "add_time", "desc"); } public List querySelective(String title, String subtitle, Integer page, Integer limit, String sort, String order) { @@ -94,7 +99,7 @@ public class LitemallTopicService { public int updateById(LitemallTopic topic) { LitemallTopicExample example = new LitemallTopicExample(); example.or().andIdEqualTo(topic.getId()); - return topicMapper.updateByExampleWithBLOBs(topic, example); + return topicMapper.updateByExampleSelective(topic, example); } public void deleteById(Integer id) { diff --git a/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxTopicController.java b/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxTopicController.java index 0449c475..8a08399d 100644 --- a/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxTopicController.java +++ b/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxTopicController.java @@ -1,5 +1,7 @@ package org.linlinjava.litemall.wx.web; +import org.linlinjava.litemall.core.validator.Order; +import org.linlinjava.litemall.core.validator.Sort; import org.linlinjava.litemall.db.domain.LitemallGoods; import org.linlinjava.litemall.db.domain.LitemallTopic; import org.linlinjava.litemall.db.service.LitemallGoodsService; @@ -47,8 +49,10 @@ public class WxTopicController { */ @GetMapping("list") public Object list(@RequestParam(defaultValue = "1") Integer page, - @RequestParam(defaultValue = "10") Integer size) { - List topicList = topicService.queryList(page, size); + @RequestParam(defaultValue = "10") Integer size, + @Sort @RequestParam(defaultValue = "add_time") String sort, + @Order @RequestParam(defaultValue = "desc") String order) { + List topicList = topicService.queryList(page, size, sort, order); int total = topicService.queryTotal(); Map data = new HashMap(); data.put("data", topicList); diff --git a/litemall-wx/pages/topic/topic.js b/litemall-wx/pages/topic/topic.js index 379b9f09..0237c73c 100644 --- a/litemall-wx/pages/topic/topic.js +++ b/litemall-wx/pages/topic/topic.js @@ -28,7 +28,7 @@ Page({ }, nextPage: function (event) { var that = this; - if (this.data.page+1 > that.data.count / that.data.size) { + if (this.data.page > that.data.count / that.data.size) { return true; } diff --git a/litemall-wx/pages/topic/topic.wxml b/litemall-wx/pages/topic/topic.wxml index 423e4f7e..d9da3fd6 100644 --- a/litemall-wx/pages/topic/topic.wxml +++ b/litemall-wx/pages/topic/topic.wxml @@ -10,7 +10,7 @@ 上一页 - 下一页 + 下一页 \ No newline at end of file diff --git a/renard-wx/pages/topic/topic.js b/renard-wx/pages/topic/topic.js index 8f2c3b7b..f5efcc7b 100644 --- a/renard-wx/pages/topic/topic.js +++ b/renard-wx/pages/topic/topic.js @@ -28,7 +28,7 @@ Page({ }, nextPage: function(event) { var that = this; - if (this.data.page + 1 > that.data.count / that.data.size) { + if (this.data.page > that.data.count / that.data.size) { return true; } diff --git a/renard-wx/pages/topic/topic.wxml b/renard-wx/pages/topic/topic.wxml index ff101b5d..0921b4f9 100644 --- a/renard-wx/pages/topic/topic.wxml +++ b/renard-wx/pages/topic/topic.wxml @@ -10,7 +10,7 @@ 上一页 - 下一页 + 下一页 \ No newline at end of file