Commit bdde6363 authored by Menethil's avatar Menethil
Browse files

Merge remote-tracking branch 'origin/master'

parents 92b3446a 3883fa46
...@@ -64,29 +64,31 @@ public class LitemallGoodsService { ...@@ -64,29 +64,31 @@ public class LitemallGoodsService {
public List<LitemallGoods> querySelective(Integer catId, Integer brandId, String keyword, Boolean isHot, Boolean isNew, Integer offset, Integer limit, String sort, String order) { public List<LitemallGoods> querySelective(Integer catId, Integer brandId, String keyword, Boolean isHot, Boolean isNew, Integer offset, Integer limit, String sort, String order) {
LitemallGoodsExample example = new LitemallGoodsExample(); LitemallGoodsExample example = new LitemallGoodsExample();
LitemallGoodsExample.Criteria criteria = example.createCriteria(); LitemallGoodsExample.Criteria criteria1 = example.or();
LitemallGoodsExample.Criteria criteria2 = example.or();
if(!StringUtils.isEmpty(catId) && catId != 0){ if(!StringUtils.isEmpty(catId) && catId != 0){
criteria.andCategoryIdEqualTo(catId); criteria1.andCategoryIdEqualTo(catId);
criteria2.andCategoryIdEqualTo(catId);
} }
if(!StringUtils.isEmpty(brandId)){ if(!StringUtils.isEmpty(brandId)){
criteria.andBrandIdEqualTo(brandId); criteria1.andBrandIdEqualTo(brandId);
criteria2.andBrandIdEqualTo(brandId);
} }
if(!StringUtils.isEmpty(isNew)){ if(!StringUtils.isEmpty(isNew)){
criteria.andIsNewEqualTo(isNew); criteria1.andIsNewEqualTo(isNew);
criteria2.andIsNewEqualTo(isNew);
} }
if(!StringUtils.isEmpty(isHot)){ if(!StringUtils.isEmpty(isHot)){
criteria.andIsHotEqualTo(isHot); criteria1.andIsHotEqualTo(isHot);
criteria2.andIsHotEqualTo(isHot);
} }
if(!StringUtils.isEmpty(keyword)){ if(!StringUtils.isEmpty(keyword)){
criteria.andKeywordsLike("%" + keyword + "%"); criteria1.andKeywordsLike("%" + keyword + "%");
LitemallGoodsExample.Criteria criteria2 = example.createCriteria();
criteria2.andNameLike("%" + keyword + "%"); criteria2.andNameLike("%" + keyword + "%");
criteria2.andDeletedEqualTo(false);
example.or(criteria2);
} }
criteria.andDeletedEqualTo(false); criteria1.andDeletedEqualTo(false);
criteria2.andDeletedEqualTo(false);
if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) { if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
example.setOrderByClause(sort + " " + order); example.setOrderByClause(sort + " " + order);
...@@ -102,24 +104,29 @@ public class LitemallGoodsService { ...@@ -102,24 +104,29 @@ public class LitemallGoodsService {
public int countSelective(Integer catId, Integer brandId, String keyword, Boolean isHot, Boolean isNew, Integer offset, Integer limit, String sort, String order) { public int countSelective(Integer catId, Integer brandId, String keyword, Boolean isHot, Boolean isNew, Integer offset, Integer limit, String sort, String order) {
LitemallGoodsExample example = new LitemallGoodsExample(); LitemallGoodsExample example = new LitemallGoodsExample();
LitemallGoodsExample.Criteria criteria = example.createCriteria(); LitemallGoodsExample.Criteria criteria1 = example.or();
LitemallGoodsExample.Criteria criteria2 = example.or();
if(catId != null){ if(!StringUtils.isEmpty(catId) && catId != 0){
criteria.andCategoryIdEqualTo(catId); criteria1.andCategoryIdEqualTo(catId);
criteria2.andCategoryIdEqualTo(catId);
} }
if(brandId != null){ if(!StringUtils.isEmpty(brandId)){
criteria.andBrandIdEqualTo(brandId); criteria1.andBrandIdEqualTo(brandId);
criteria2.andBrandIdEqualTo(brandId);
} }
if(isNew != null){ if(!StringUtils.isEmpty(isNew)){
criteria.andIsNewEqualTo(isNew); criteria1.andIsNewEqualTo(isNew);
criteria2.andIsNewEqualTo(isNew);
} }
if(isHot != null){ if(!StringUtils.isEmpty(isHot)){
criteria.andIsHotEqualTo(isHot); criteria1.andIsHotEqualTo(isHot);
criteria2.andIsHotEqualTo(isHot);
} }
if(keyword != null){ if(!StringUtils.isEmpty(keyword)){
criteria.andKeywordsLike("%" + keyword + "%"); criteria1.andKeywordsLike("%" + keyword + "%");
criteria2.andNameLike("%" + keyword + "%");
} }
criteria.andDeletedEqualTo(false);
return (int)goodsMapper.countByExample(example); return (int)goodsMapper.countByExample(example);
} }
...@@ -194,21 +201,25 @@ public class LitemallGoodsService { ...@@ -194,21 +201,25 @@ public class LitemallGoodsService {
public List<Integer> getCatIds(Integer brandId, String keyword, Boolean isHot, Boolean isNew) { public List<Integer> getCatIds(Integer brandId, String keyword, Boolean isHot, Boolean isNew) {
LitemallGoodsExample example = new LitemallGoodsExample(); LitemallGoodsExample example = new LitemallGoodsExample();
LitemallGoodsExample.Criteria criteria = example.createCriteria(); LitemallGoodsExample.Criteria criteria1 = example.or();
LitemallGoodsExample.Criteria criteria2 = example.or();
if(brandId != null){ if(!StringUtils.isEmpty(brandId)){
criteria.andBrandIdEqualTo(brandId); criteria1.andBrandIdEqualTo(brandId);
criteria2.andBrandIdEqualTo(brandId);
} }
if(isNew != null){ if(!StringUtils.isEmpty(isNew)){
criteria.andIsNewEqualTo(isNew); criteria1.andIsNewEqualTo(isNew);
criteria2.andIsNewEqualTo(isNew);
} }
if(isHot != null){ if(!StringUtils.isEmpty(isHot)){
criteria.andIsHotEqualTo(isHot); criteria1.andIsHotEqualTo(isHot);
criteria2.andIsHotEqualTo(isHot);
} }
if(keyword != null){ if(!StringUtils.isEmpty(keyword)){
criteria.andKeywordsLike("%" + keyword + "%"); criteria1.andKeywordsLike("%" + keyword + "%");
criteria2.andNameLike("%" + keyword + "%");
} }
criteria.andDeletedEqualTo(false);
List<LitemallGoods> goodsList = goodsMapper.selectByExampleSelective(example, Column.categoryId); List<LitemallGoods> goodsList = goodsMapper.selectByExampleSelective(example, Column.categoryId);
List<Integer> cats = new ArrayList<Integer>(); List<Integer> cats = new ArrayList<Integer>();
......
...@@ -259,6 +259,9 @@ public class WxGoodsController { ...@@ -259,6 +259,9 @@ public class WxGoodsController {
if (goodsCatIds.size() != 0) { if (goodsCatIds.size() != 0) {
categoryList = categoryService.queryL2ByIds(goodsCatIds); categoryList = categoryService.queryL2ByIds(goodsCatIds);
} }
else {
categoryList = new ArrayList<>(0);
}
Map<String, Object> data = new HashMap<>(); Map<String, Object> data = new HashMap<>();
data.put("goodsList", goodsList); data.put("goodsList", goodsList);
......
...@@ -11,6 +11,7 @@ import org.springframework.validation.annotation.Validated; ...@@ -11,6 +11,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -56,8 +57,11 @@ public class WxSearchController { ...@@ -56,8 +57,11 @@ public class WxSearchController {
//取出用户历史关键字 //取出用户历史关键字
historyList = searchHistoryService.queryByUid(userId); historyList = searchHistoryService.queryByUid(userId);
} }
else {
historyList = new ArrayList<>(0);
}
Map<String, Object> data = new HashMap(); Map<String, Object> data = new HashMap<String, Object>();
data.put("defaultKeyword", defaultKeyword); data.put("defaultKeyword", defaultKeyword);
data.put("historyKeywordList", historyList); data.put("historyKeywordList", historyList);
data.put("hotKeywordList", hotKeywordList); data.put("hotKeywordList", hotKeywordList);
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
<view class="item by-price {{currentSortType == 'price' ? 'active' : ''}} {{currentSortOrder == 'asc' ? 'asc' : 'desc'}}" bindtap="openSortFilter" id="priceSort"> <view class="item by-price {{currentSortType == 'price' ? 'active' : ''}} {{currentSortOrder == 'asc' ? 'asc' : 'desc'}}" bindtap="openSortFilter" id="priceSort">
<text class="txt">价格</text> <text class="txt">价格</text>
</view> </view>
<view class="item {{currentSortType == 'category' ? 'active' : ''}}" id="categoryFilter"> <view class="item {{currentSortType == 'category' ? 'active' : ''}}" bindtap="openSortFilter" id="categoryFilter">
<text class="txt">分类</text> <text class="txt">分类</text>
</view> </view>
</view> </view>
......
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