Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
3883fa46
Commit
3883fa46
authored
Aug 13, 2018
by
Junling Bu
Browse files
fix: 小商城分类搜索无效果
parent
0271ab4f
Changes
4
Hide whitespace changes
Inline
Side-by-side
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGoodsService.java
View file @
3883fa46
...
...
@@ -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
)
{
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
){
criteria
.
andCategoryIdEqualTo
(
catId
);
criteria1
.
andCategoryIdEqualTo
(
catId
);
criteria2
.
andCategoryIdEqualTo
(
catId
);
}
if
(!
StringUtils
.
isEmpty
(
brandId
)){
criteria
.
andBrandIdEqualTo
(
brandId
);
criteria1
.
andBrandIdEqualTo
(
brandId
);
criteria2
.
andBrandIdEqualTo
(
brandId
);
}
if
(!
StringUtils
.
isEmpty
(
isNew
)){
criteria
.
andIsNewEqualTo
(
isNew
);
criteria1
.
andIsNewEqualTo
(
isNew
);
criteria2
.
andIsNewEqualTo
(
isNew
);
}
if
(!
StringUtils
.
isEmpty
(
isHot
)){
criteria
.
andIsHotEqualTo
(
isHot
);
criteria1
.
andIsHotEqualTo
(
isHot
);
criteria2
.
andIsHotEqualTo
(
isHot
);
}
if
(!
StringUtils
.
isEmpty
(
keyword
)){
criteria
.
andKeywordsLike
(
"%"
+
keyword
+
"%"
);
LitemallGoodsExample
.
Criteria
criteria2
=
example
.
createCriteria
();
criteria1
.
andKeywordsLike
(
"%"
+
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
))
{
example
.
setOrderByClause
(
sort
+
" "
+
order
);
...
...
@@ -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
)
{
LitemallGoodsExample
example
=
new
LitemallGoodsExample
();
LitemallGoodsExample
.
Criteria
criteria
=
example
.
createCriteria
();
LitemallGoodsExample
.
Criteria
criteria1
=
example
.
or
();
LitemallGoodsExample
.
Criteria
criteria2
=
example
.
or
();
if
(
catId
!=
null
){
criteria
.
andCategoryIdEqualTo
(
catId
);
if
(!
StringUtils
.
isEmpty
(
catId
)
&&
catId
!=
0
){
criteria1
.
andCategoryIdEqualTo
(
catId
);
criteria2
.
andCategoryIdEqualTo
(
catId
);
}
if
(
brandId
!=
null
){
criteria
.
andBrandIdEqualTo
(
brandId
);
if
(!
StringUtils
.
isEmpty
(
brandId
)){
criteria1
.
andBrandIdEqualTo
(
brandId
);
criteria2
.
andBrandIdEqualTo
(
brandId
);
}
if
(
isNew
!=
null
){
criteria
.
andIsNewEqualTo
(
isNew
);
if
(!
StringUtils
.
isEmpty
(
isNew
)){
criteria1
.
andIsNewEqualTo
(
isNew
);
criteria2
.
andIsNewEqualTo
(
isNew
);
}
if
(
isHot
!=
null
){
criteria
.
andIsHotEqualTo
(
isHot
);
if
(!
StringUtils
.
isEmpty
(
isHot
)){
criteria1
.
andIsHotEqualTo
(
isHot
);
criteria2
.
andIsHotEqualTo
(
isHot
);
}
if
(
keyword
!=
null
){
criteria
.
andKeywordsLike
(
"%"
+
keyword
+
"%"
);
if
(!
StringUtils
.
isEmpty
(
keyword
)){
criteria1
.
andKeywordsLike
(
"%"
+
keyword
+
"%"
);
criteria2
.
andNameLike
(
"%"
+
keyword
+
"%"
);
}
criteria
.
andDeletedEqualTo
(
false
);
return
(
int
)
goodsMapper
.
countByExample
(
example
);
}
...
...
@@ -194,21 +201,25 @@ public class LitemallGoodsService {
public
List
<
Integer
>
getCatIds
(
Integer
brandId
,
String
keyword
,
Boolean
isHot
,
Boolean
isNew
)
{
LitemallGoodsExample
example
=
new
LitemallGoodsExample
();
LitemallGoodsExample
.
Criteria
criteria
=
example
.
createCriteria
();
LitemallGoodsExample
.
Criteria
criteria1
=
example
.
or
();
LitemallGoodsExample
.
Criteria
criteria2
=
example
.
or
();
if
(
brandId
!=
null
){
criteria
.
andBrandIdEqualTo
(
brandId
);
if
(!
StringUtils
.
isEmpty
(
brandId
)){
criteria1
.
andBrandIdEqualTo
(
brandId
);
criteria2
.
andBrandIdEqualTo
(
brandId
);
}
if
(
isNew
!=
null
){
criteria
.
andIsNewEqualTo
(
isNew
);
if
(!
StringUtils
.
isEmpty
(
isNew
)){
criteria1
.
andIsNewEqualTo
(
isNew
);
criteria2
.
andIsNewEqualTo
(
isNew
);
}
if
(
isHot
!=
null
){
criteria
.
andIsHotEqualTo
(
isHot
);
if
(!
StringUtils
.
isEmpty
(
isHot
)){
criteria1
.
andIsHotEqualTo
(
isHot
);
criteria2
.
andIsHotEqualTo
(
isHot
);
}
if
(
keyword
!=
null
){
criteria
.
andKeywordsLike
(
"%"
+
keyword
+
"%"
);
if
(!
StringUtils
.
isEmpty
(
keyword
)){
criteria1
.
andKeywordsLike
(
"%"
+
keyword
+
"%"
);
criteria2
.
andNameLike
(
"%"
+
keyword
+
"%"
);
}
criteria
.
andDeletedEqualTo
(
false
);
List
<
LitemallGoods
>
goodsList
=
goodsMapper
.
selectByExampleSelective
(
example
,
Column
.
categoryId
);
List
<
Integer
>
cats
=
new
ArrayList
<
Integer
>();
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxGoodsController.java
View file @
3883fa46
...
...
@@ -259,6 +259,9 @@ public class WxGoodsController {
if
(
goodsCatIds
.
size
()
!=
0
)
{
categoryList
=
categoryService
.
queryL2ByIds
(
goodsCatIds
);
}
else
{
categoryList
=
new
ArrayList
<>(
0
);
}
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"goodsList"
,
goodsList
);
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxSearchController.java
View file @
3883fa46
...
...
@@ -11,6 +11,7 @@ import org.springframework.validation.annotation.Validated;
import
org.springframework.web.bind.annotation.*
;
import
javax.validation.constraints.NotEmpty
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -56,8 +57,11 @@ public class WxSearchController {
//取出用户历史关键字
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
(
"historyKeywordList"
,
historyList
);
data
.
put
(
"hotKeywordList"
,
hotKeywordList
);
...
...
litemall-wx/pages/search/search.wxml
View file @
3883fa46
...
...
@@ -39,7 +39,7 @@
<view class="item by-price {{currentSortType == 'price' ? 'active' : ''}} {{currentSortOrder == 'asc' ? 'asc' : 'desc'}}" bindtap="openSortFilter" id="priceSort">
<text class="txt">价格</text>
</view>
<view class="item {{currentSortType == 'category' ? 'active' : ''}}" id="categoryFilter">
<view class="item {{currentSortType == 'category' ? 'active' : ''}}"
bindtap="openSortFilter"
id="categoryFilter">
<text class="txt">分类</text>
</view>
</view>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment