"deploy/git@ustchcs.com:gujinli1118/litemall.git" did not exist on "83fbfca3d40db0f2aa323a1075bc33d05fa6f049"
Commit db969a15 authored by Junling Bu's avatar Junling Bu
Browse files

专题代码微调

parent b95e4ca7
...@@ -17,16 +17,10 @@ public class LitemallBrandService { ...@@ -17,16 +17,10 @@ public class LitemallBrandService {
private LitemallBrandMapper brandMapper; private LitemallBrandMapper brandMapper;
private Column[] columns = new Column[]{Column.id, Column.name, Column.desc, Column.picUrl, Column.floorPrice}; 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) { public List<LitemallBrand> queryVO(int offset, int limit) {
LitemallBrandExample example = new LitemallBrandExample(); LitemallBrandExample example = new LitemallBrandExample();
example.or().andDeletedEqualTo(false); example.or().andDeletedEqualTo(false);
example.setOrderByClause("add_time desc");
PageHelper.startPage(offset, limit); PageHelper.startPage(offset, limit);
return brandMapper.selectByExampleSelective(example, columns); return brandMapper.selectByExampleSelective(example, columns);
} }
......
...@@ -18,8 +18,13 @@ public class LitemallTopicService { ...@@ -18,8 +18,13 @@ public class LitemallTopicService {
private Column[] columns = new Column[]{Column.id, Column.title, Column.subtitle, Column.price, Column.picUrl, Column.readCount}; 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) { 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(); LitemallTopicExample example = new LitemallTopicExample();
example.or().andDeletedEqualTo(false); example.or().andDeletedEqualTo(false);
example.setOrderByClause(sort + " " + order);
PageHelper.startPage(offset, limit); PageHelper.startPage(offset, limit);
return topicMapper.selectByExampleSelective(example, columns); return topicMapper.selectByExampleSelective(example, columns);
} }
...@@ -41,7 +46,7 @@ public class LitemallTopicService { ...@@ -41,7 +46,7 @@ public class LitemallTopicService {
example.or().andIdEqualTo(id).andDeletedEqualTo(false); example.or().andIdEqualTo(id).andDeletedEqualTo(false);
List<LitemallTopic> topics = topicMapper.selectByExample(example); List<LitemallTopic> topics = topicMapper.selectByExample(example);
if (topics.size() == 0) { if (topics.size() == 0) {
return queryList(offset, limit); return queryList(offset, limit, "add_time", "desc");
} }
LitemallTopic topic = topics.get(0); LitemallTopic topic = topics.get(0);
...@@ -53,7 +58,7 @@ public class LitemallTopicService { ...@@ -53,7 +58,7 @@ public class LitemallTopicService {
return relateds; 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) { public List<LitemallTopic> querySelective(String title, String subtitle, Integer page, Integer limit, String sort, String order) {
...@@ -94,7 +99,7 @@ public class LitemallTopicService { ...@@ -94,7 +99,7 @@ public class LitemallTopicService {
public int updateById(LitemallTopic topic) { public int updateById(LitemallTopic topic) {
LitemallTopicExample example = new LitemallTopicExample(); LitemallTopicExample example = new LitemallTopicExample();
example.or().andIdEqualTo(topic.getId()); example.or().andIdEqualTo(topic.getId());
return topicMapper.updateByExampleWithBLOBs(topic, example); return topicMapper.updateByExampleSelective(topic, example);
} }
public void deleteById(Integer id) { public void deleteById(Integer id) {
......
package org.linlinjava.litemall.wx.web; 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.LitemallGoods;
import org.linlinjava.litemall.db.domain.LitemallTopic; import org.linlinjava.litemall.db.domain.LitemallTopic;
import org.linlinjava.litemall.db.service.LitemallGoodsService; import org.linlinjava.litemall.db.service.LitemallGoodsService;
...@@ -47,8 +49,10 @@ public class WxTopicController { ...@@ -47,8 +49,10 @@ public class WxTopicController {
*/ */
@GetMapping("list") @GetMapping("list")
public Object list(@RequestParam(defaultValue = "1") Integer page, public Object list(@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer size) { @RequestParam(defaultValue = "10") Integer size,
List<LitemallTopic> topicList = topicService.queryList(page, 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(); int total = topicService.queryTotal();
Map<String, Object> data = new HashMap<String, Object>(); Map<String, Object> data = new HashMap<String, Object>();
data.put("data", topicList); data.put("data", topicList);
......
...@@ -28,7 +28,7 @@ Page({ ...@@ -28,7 +28,7 @@ Page({
}, },
nextPage: function (event) { nextPage: function (event) {
var that = this; 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; return true;
} }
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
</navigator> </navigator>
<view class="page" wx:if="{{showPage}}"> <view class="page" wx:if="{{showPage}}">
<view class="prev {{ page <= 1 ? 'disabled' : ''}}" bindtap="prevPage">上一页</view> <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> </view>
</scroll-view> </scroll-view>
</view> </view>
\ No newline at end of file
...@@ -28,7 +28,7 @@ Page({ ...@@ -28,7 +28,7 @@ Page({
}, },
nextPage: function(event) { nextPage: function(event) {
var that = this; 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; return true;
} }
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
</navigator> </navigator>
<view class="page" wx:if="{{showPage}}"> <view class="page" wx:if="{{showPage}}">
<view class="prev {{ page <= 1 ? 'disabled' : ''}}" bindtap="prevPage">上一页</view> <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> </view>
</scroll-view> </scroll-view>
</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