Commit db969a15 authored by Junling Bu's avatar Junling Bu
Browse files

专题代码微调

parent b95e4ca7
......@@ -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<LitemallBrand> query(int offset, int limit) {
LitemallBrandExample example = new LitemallBrandExample();
example.or().andDeletedEqualTo(false);
PageHelper.startPage(offset, limit);
return brandMapper.selectByExample(example);
}
public List<LitemallBrand> 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);
}
......
......@@ -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<LitemallTopic> queryList(int offset, int limit) {
return queryList(offset, limit, "add_time", "desc");
}
public List<LitemallTopic> 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<LitemallTopic> 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<LitemallTopic> 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) {
......
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<LitemallTopic> topicList = topicService.queryList(page, size);
@RequestParam(defaultValue = "10") Integer size,
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
List<LitemallTopic> topicList = topicService.queryList(page, size, sort, order);
int total = topicService.queryTotal();
Map<String, Object> data = new HashMap<String, Object>();
data.put("data", topicList);
......
......@@ -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;
}
......
......@@ -10,7 +10,7 @@
</navigator>
<view class="page" wx:if="{{showPage}}">
<view class="prev {{ page <= 1 ? 'disabled' : ''}}" bindtap="prevPage">上一页</view>
<view class="next {{ (count / size) < page +1 ? 'disabled' : ''}}" bindtap="nextPage">下一页</view>
<view class="next {{ (count / size) < page ? 'disabled' : ''}}" bindtap="nextPage">下一页</view>
</view>
</scroll-view>
</view>
\ No newline at end of file
......@@ -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;
}
......
......@@ -10,7 +10,7 @@
</navigator>
<view class="page" wx:if="{{showPage}}">
<view class="prev {{ page <= 1 ? 'disabled' : ''}}" bindtap="prevPage">上一页</view>
<view class="next {{ (count / size) < page +1 ? 'disabled' : ''}}" bindtap="nextPage">下一页</view>
<view class="next {{ (count / size) < page ? 'disabled' : ''}}" bindtap="nextPage">下一页</view>
</view>
</scroll-view>
</view>
\ No newline at end of file
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