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
3abfeea8
Commit
3abfeea8
authored
Jul 08, 2018
by
Junling Bu
Browse files
修复商品排序问题
parent
d2a561f3
Changes
45
Show whitespace changes
Inline
Side-by-side
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallBrandService.java
View file @
3abfeea8
...
...
@@ -44,6 +44,10 @@ public class LitemallBrandService {
}
criteria
.
andDeletedEqualTo
(
false
);
if
(!
StringUtils
.
isEmpty
(
sort
)
&&
!
StringUtils
.
isEmpty
(
order
))
{
example
.
setOrderByClause
(
sort
+
" "
+
order
);
}
PageHelper
.
startPage
(
page
,
size
);
return
brandMapper
.
selectByExample
(
example
);
}
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCartService.java
View file @
3abfeea8
...
...
@@ -5,6 +5,7 @@ import org.linlinjava.litemall.db.dao.LitemallCartMapper;
import
org.linlinjava.litemall.db.domain.LitemallCart
;
import
org.linlinjava.litemall.db.domain.LitemallCartExample
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
javax.annotation.Resource
;
import
java.util.List
;
...
...
@@ -77,14 +78,18 @@ public class LitemallCartService {
LitemallCartExample
example
=
new
LitemallCartExample
();
LitemallCartExample
.
Criteria
criteria
=
example
.
createCriteria
();
if
(
userId
!=
null
){
if
(
!
StringUtils
.
isEmpty
(
userId
)
){
criteria
.
andUserIdEqualTo
(
userId
);
}
if
(
goodsId
!=
null
){
if
(
!
StringUtils
.
isEmpty
(
goodsId
)
){
criteria
.
andGoodsIdEqualTo
(
goodsId
);
}
criteria
.
andDeletedEqualTo
(
false
);
if
(!
StringUtils
.
isEmpty
(
sort
)
&&
!
StringUtils
.
isEmpty
(
order
))
{
example
.
setOrderByClause
(
sort
+
" "
+
order
);
}
PageHelper
.
startPage
(
page
,
limit
);
return
cartMapper
.
selectByExample
(
example
);
}
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCategoryService.java
View file @
3abfeea8
...
...
@@ -63,6 +63,10 @@ public class LitemallCategoryService {
}
criteria
.
andDeletedEqualTo
(
false
);
if
(!
StringUtils
.
isEmpty
(
sort
)
&&
!
StringUtils
.
isEmpty
(
order
))
{
example
.
setOrderByClause
(
sort
+
" "
+
order
);
}
PageHelper
.
startPage
(
page
,
size
);
return
categoryMapper
.
selectByExample
(
example
);
}
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCollectService.java
View file @
3abfeea8
...
...
@@ -61,6 +61,10 @@ public class LitemallCollectService {
}
criteria
.
andDeletedEqualTo
(
false
);
if
(!
StringUtils
.
isEmpty
(
sort
)
&&
!
StringUtils
.
isEmpty
(
order
))
{
example
.
setOrderByClause
(
sort
+
" "
+
order
);
}
PageHelper
.
startPage
(
page
,
size
);
return
collectMapper
.
selectByExample
(
example
);
}
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCommentService.java
View file @
3abfeea8
...
...
@@ -83,6 +83,10 @@ public class LitemallCommentService {
}
criteria
.
andDeletedEqualTo
(
false
);
if
(!
StringUtils
.
isEmpty
(
sort
)
&&
!
StringUtils
.
isEmpty
(
order
))
{
example
.
setOrderByClause
(
sort
+
" "
+
order
);
}
PageHelper
.
startPage
(
page
,
size
);
return
commentMapper
.
selectByExample
(
example
);
}
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCouponService.java
deleted
100644 → 0
View file @
d2a561f3
package
org.linlinjava.litemall.db.service
;
import
org.springframework.stereotype.Service
;
@Service
public
class
LitemallCouponService
{
}
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallFootprintService.java
View file @
3abfeea8
...
...
@@ -53,6 +53,10 @@ public class LitemallFootprintService {
}
criteria
.
andDeletedEqualTo
(
false
);
if
(!
StringUtils
.
isEmpty
(
sort
)
&&
!
StringUtils
.
isEmpty
(
order
))
{
example
.
setOrderByClause
(
sort
+
" "
+
order
);
}
PageHelper
.
startPage
(
page
,
size
);
return
footprintMapper
.
selectByExample
(
example
);
}
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGoodsAttributeService.java
View file @
3abfeea8
...
...
@@ -20,31 +20,6 @@ public class LitemallGoodsAttributeService {
return
goodsAttributeMapper
.
selectByExample
(
example
);
}
public
List
<
LitemallGoodsAttribute
>
querySelective
(
Integer
goodsId
,
Integer
page
,
Integer
size
,
String
sort
,
String
order
)
{
LitemallGoodsAttributeExample
example
=
new
LitemallGoodsAttributeExample
();
LitemallGoodsAttributeExample
.
Criteria
criteria
=
example
.
createCriteria
();
if
(
goodsId
!=
null
){
criteria
.
andGoodsIdEqualTo
(
goodsId
);
}
criteria
.
andDeletedEqualTo
(
false
);
PageHelper
.
startPage
(
page
,
size
);
return
goodsAttributeMapper
.
selectByExample
(
example
);
}
public
int
countSelective
(
Integer
goodsId
,
Integer
page
,
Integer
size
,
String
sort
,
String
order
)
{
LitemallGoodsAttributeExample
example
=
new
LitemallGoodsAttributeExample
();
LitemallGoodsAttributeExample
.
Criteria
criteria
=
example
.
createCriteria
();
if
(
goodsId
!=
null
){
criteria
.
andGoodsIdEqualTo
(
goodsId
);
}
criteria
.
andDeletedEqualTo
(
false
);
return
(
int
)
goodsAttributeMapper
.
countByExample
(
example
);
}
public
void
updateById
(
LitemallGoodsAttribute
goodsAttribute
)
{
goodsAttributeMapper
.
updateByPrimaryKeySelective
(
goodsAttribute
);
}
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGoodsService.java
View file @
3abfeea8
...
...
@@ -58,31 +58,32 @@ public class LitemallGoodsService {
return
(
int
)
goodsMapper
.
countByExample
(
example
);
}
public
List
<
LitemallGoods
>
querySelective
(
Integer
catId
,
Integer
brandId
,
String
keyword
,
Integer
isHot
,
Integer
isNew
,
Integer
offset
,
Integer
limit
,
String
sort
)
{
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
();
if
(
catId
!=
null
&&
catId
!=
0
){
if
(
!
StringUtils
.
isEmpty
(
catId
)
&&
catId
!=
0
){
criteria
.
andCategoryIdEqualTo
(
catId
);
}
if
(
brandId
!=
null
){
if
(
!
StringUtils
.
isEmpty
(
brandId
)
){
criteria
.
andBrandIdEqualTo
(
brandId
);
}
if
(
isNew
!=
null
){
criteria
.
andIsNewEqualTo
(
isNew
.
intValue
()
==
1
);
if
(
!
StringUtils
.
isEmpty
(
isNew
)
){
criteria
.
andIsNewEqualTo
(
isNew
);
}
if
(
isHot
!=
null
){
criteria
.
andIsHotEqualTo
(
isHot
.
intValue
()
==
1
);
if
(
!
StringUtils
.
isEmpty
(
isHot
)
){
criteria
.
andIsHotEqualTo
(
isHot
);
}
if
(
keyword
!=
null
){
if
(
!
StringUtils
.
isEmpty
(
keyword
)
){
criteria
.
andKeywordsLike
(
"%"
+
keyword
+
"%"
);
}
criteria
.
andDeletedEqualTo
(
false
);
if
(
sort
!=
null
)
{
example
.
setOrderByClause
(
sort
);
if
(!
StringUtils
.
isEmpty
(
sort
)
&&
!
StringUtils
.
isEmpty
(
order
))
{
example
.
setOrderByClause
(
sort
+
" "
+
order
);
}
if
(
limit
!=
null
&&
offset
!=
null
)
{
if
(!
StringUtils
.
isEmpty
(
limit
)
&&
!
StringUtils
.
isEmpty
(
offset
))
{
PageHelper
.
startPage
(
offset
,
limit
);
}
...
...
@@ -90,7 +91,7 @@ public class LitemallGoodsService {
return
goodsMapper
.
selectByExampleSelective
(
example
,
columns
);
}
public
int
countSelective
(
Integer
catId
,
Integer
brandId
,
String
keyword
,
Integer
isHot
,
Integer
isNew
,
Integer
offset
,
Integer
limit
,
String
sort
)
{
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
();
...
...
@@ -101,10 +102,10 @@ public class LitemallGoodsService {
criteria
.
andBrandIdEqualTo
(
brandId
);
}
if
(
isNew
!=
null
){
criteria
.
andIsNewEqualTo
(
isNew
.
intValue
()
==
1
);
criteria
.
andIsNewEqualTo
(
isNew
);
}
if
(
isHot
!=
null
){
criteria
.
andIsHotEqualTo
(
isHot
.
intValue
()
==
1
);
criteria
.
andIsHotEqualTo
(
isHot
);
}
if
(
keyword
!=
null
){
criteria
.
andKeywordsLike
(
"%"
+
keyword
+
"%"
);
...
...
@@ -182,7 +183,7 @@ public class LitemallGoodsService {
return
(
int
)
goodsMapper
.
countByExample
(
example
);
}
public
List
<
Integer
>
getCatIds
(
Integer
brandId
,
String
keyword
,
Integer
isHot
,
Integer
isNew
)
{
public
List
<
Integer
>
getCatIds
(
Integer
brandId
,
String
keyword
,
Boolean
isHot
,
Boolean
isNew
)
{
LitemallGoodsExample
example
=
new
LitemallGoodsExample
();
LitemallGoodsExample
.
Criteria
criteria
=
example
.
createCriteria
();
...
...
@@ -190,10 +191,10 @@ public class LitemallGoodsService {
criteria
.
andBrandIdEqualTo
(
brandId
);
}
if
(
isNew
!=
null
){
criteria
.
andIsNewEqualTo
(
isNew
.
intValue
()
==
1
);
criteria
.
andIsNewEqualTo
(
isNew
);
}
if
(
isHot
!=
null
){
criteria
.
andIsHotEqualTo
(
isHot
.
intValue
()
==
1
);
criteria
.
andIsHotEqualTo
(
isHot
);
}
if
(
keyword
!=
null
){
criteria
.
andKeywordsLike
(
"%"
+
keyword
+
"%"
);
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGoodsSpecificationService.java
View file @
3abfeea8
...
...
@@ -27,31 +27,6 @@ public class LitemallGoodsSpecificationService {
return
goodsSpecificationMapper
.
selectByPrimaryKey
(
id
);
}
public
List
<
LitemallGoodsSpecification
>
querySelective
(
Integer
goodsId
,
Integer
page
,
Integer
size
,
String
sort
,
String
order
)
{
LitemallGoodsSpecificationExample
example
=
new
LitemallGoodsSpecificationExample
();
LitemallGoodsSpecificationExample
.
Criteria
criteria
=
example
.
createCriteria
();
if
(
goodsId
!=
null
){
criteria
.
andGoodsIdEqualTo
(
goodsId
);
}
criteria
.
andDeletedEqualTo
(
false
);
PageHelper
.
startPage
(
page
,
size
);
return
goodsSpecificationMapper
.
selectByExample
(
example
);
}
public
int
countSelective
(
Integer
goodsId
,
Integer
page
,
Integer
size
,
String
sort
,
String
order
)
{
LitemallGoodsSpecificationExample
example
=
new
LitemallGoodsSpecificationExample
();
LitemallGoodsSpecificationExample
.
Criteria
criteria
=
example
.
createCriteria
();
if
(
goodsId
!=
null
){
criteria
.
andGoodsIdEqualTo
(
goodsId
);
}
criteria
.
andDeletedEqualTo
(
false
);
return
(
int
)
goodsSpecificationMapper
.
countByExample
(
example
);
}
public
void
updateById
(
LitemallGoodsSpecification
goodsSpecification
)
{
goodsSpecificationMapper
.
updateByPrimaryKeySelective
(
goodsSpecification
);
}
...
...
@@ -70,15 +45,6 @@ public class LitemallGoodsSpecificationService {
goodsSpecificationMapper
.
insertSelective
(
goodsSpecification
);
}
public
Integer
[]
queryIdsByGid
(
Integer
goodsId
)
{
List
<
LitemallGoodsSpecification
>
goodsSpecificationList
=
queryByGid
(
goodsId
);
Integer
[]
ids
=
new
Integer
[
goodsSpecificationList
.
size
()];
for
(
int
i
=
0
;
i
<
ids
.
length
;
i
++){
ids
[
i
]
=
goodsSpecificationList
.
get
(
i
).
getId
();
}
return
ids
;
}
private
class
VO
{
private
String
name
;
private
List
<
LitemallGoodsSpecification
>
valueList
;
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallIssueService.java
View file @
3abfeea8
...
...
@@ -38,6 +38,10 @@ public class LitemallIssueService {
}
criteria
.
andDeletedEqualTo
(
false
);
if
(!
StringUtils
.
isEmpty
(
sort
)
&&
!
StringUtils
.
isEmpty
(
order
))
{
example
.
setOrderByClause
(
sort
+
" "
+
order
);
}
PageHelper
.
startPage
(
page
,
size
);
return
issueMapper
.
selectByExample
(
example
);
}
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallKeywordService.java
View file @
3abfeea8
...
...
@@ -53,6 +53,10 @@ public class LitemallKeywordService {
}
criteria
.
andDeletedEqualTo
(
false
);
if
(!
StringUtils
.
isEmpty
(
sort
)
&&
!
StringUtils
.
isEmpty
(
order
))
{
example
.
setOrderByClause
(
sort
+
" "
+
order
);
}
PageHelper
.
startPage
(
page
,
limit
);
return
keywordsMapper
.
selectByExample
(
example
);
}
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallOrderService.java
View file @
3abfeea8
...
...
@@ -75,7 +75,7 @@ public class LitemallOrderService {
public
List
<
LitemallOrder
>
queryByOrderStatus
(
Integer
userId
,
List
<
Short
>
orderStatus
)
{
LitemallOrderExample
example
=
new
LitemallOrderExample
();
example
.
o
rderBy
(
LitemallOrder
.
Column
.
addTime
.
desc
());
example
.
setO
rderBy
Clause
(
LitemallOrder
.
Column
.
addTime
.
desc
());
LitemallOrderExample
.
Criteria
criteria
=
example
.
or
();
criteria
.
andUserIdEqualTo
(
userId
);
if
(
orderStatus
!=
null
)
{
...
...
@@ -112,6 +112,10 @@ public class LitemallOrderService {
}
criteria
.
andDeletedEqualTo
(
false
);
if
(!
StringUtils
.
isEmpty
(
sort
)
&&
!
StringUtils
.
isEmpty
(
order
))
{
example
.
setOrderByClause
(
sort
+
" "
+
order
);
}
PageHelper
.
startPage
(
page
,
size
);
return
orderMapper
.
selectByExample
(
example
);
}
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallProductService.java
View file @
3abfeea8
...
...
@@ -24,31 +24,6 @@ public class LitemallProductService {
return
productMapper
.
selectByPrimaryKey
(
id
);
}
public
List
<
LitemallProduct
>
querySelective
(
Integer
goodsId
,
Integer
page
,
Integer
size
,
String
sort
,
String
order
)
{
LitemallProductExample
example
=
new
LitemallProductExample
();
LitemallProductExample
.
Criteria
criteria
=
example
.
createCriteria
();
if
(
goodsId
!=
null
){
criteria
.
andGoodsIdEqualTo
(
goodsId
);
}
criteria
.
andDeletedEqualTo
(
false
);
PageHelper
.
startPage
(
page
,
size
);
return
productMapper
.
selectByExample
(
example
);
}
public
int
countSelective
(
Integer
goodsId
,
Integer
page
,
Integer
size
,
String
sort
,
String
order
)
{
LitemallProductExample
example
=
new
LitemallProductExample
();
LitemallProductExample
.
Criteria
criteria
=
example
.
createCriteria
();
if
(
goodsId
!=
null
){
criteria
.
andGoodsIdEqualTo
(
goodsId
);
}
criteria
.
andDeletedEqualTo
(
false
);
return
(
int
)
productMapper
.
countByExample
(
example
);
}
public
void
updateById
(
LitemallProduct
product
)
{
productMapper
.
updateByPrimaryKeySelective
(
product
);
}
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallRegionService.java
View file @
3abfeea8
...
...
@@ -32,9 +32,14 @@ public class LitemallRegionService {
if
(!
StringUtils
.
isEmpty
(
name
)){
criteria
.
andNameLike
(
"%"
+
name
+
"%"
);
}
if
(
code
!=
null
){
if
(
!
StringUtils
.
isEmpty
(
code
)
){
criteria
.
andCodeEqualTo
(
code
);
}
if
(!
StringUtils
.
isEmpty
(
sort
)
&&
!
StringUtils
.
isEmpty
(
order
))
{
example
.
setOrderByClause
(
sort
+
" "
+
order
);
}
PageHelper
.
startPage
(
page
,
size
);
return
regionMapper
.
selectByExample
(
example
);
}
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallSearchHistoryService.java
View file @
3abfeea8
...
...
@@ -57,6 +57,10 @@ public class LitemallSearchHistoryService {
}
criteria
.
andDeletedEqualTo
(
false
);
if
(!
StringUtils
.
isEmpty
(
sort
)
&&
!
StringUtils
.
isEmpty
(
order
))
{
example
.
setOrderByClause
(
sort
+
" "
+
order
);
}
PageHelper
.
startPage
(
page
,
size
);
return
searchHistoryMapper
.
selectByExample
(
example
);
}
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallStorageService.java
View file @
3abfeea8
...
...
@@ -58,6 +58,10 @@ public class LitemallStorageService {
}
criteria
.
andDeletedEqualTo
(
false
);
if
(!
StringUtils
.
isEmpty
(
sort
)
&&
!
StringUtils
.
isEmpty
(
order
))
{
example
.
setOrderByClause
(
sort
+
" "
+
order
);
}
PageHelper
.
startPage
(
page
,
limit
);
return
storageMapper
.
selectByExample
(
example
);
}
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallTopicService.java
View file @
3abfeea8
...
...
@@ -66,6 +66,10 @@ public class LitemallTopicService {
}
criteria
.
andDeletedEqualTo
(
false
);
if
(!
StringUtils
.
isEmpty
(
sort
)
&&
!
StringUtils
.
isEmpty
(
order
))
{
example
.
setOrderByClause
(
sort
+
" "
+
order
);
}
PageHelper
.
startPage
(
page
,
limit
);
return
topicMapper
.
selectByExampleWithBLOBs
(
example
);
}
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallUserService.java
View file @
3abfeea8
...
...
@@ -44,6 +44,10 @@ public class LitemallUserService {
}
criteria
.
andDeletedEqualTo
(
false
);
if
(!
StringUtils
.
isEmpty
(
sort
)
&&
!
StringUtils
.
isEmpty
(
order
))
{
example
.
setOrderByClause
(
sort
+
" "
+
order
);
}
PageHelper
.
startPage
(
page
,
size
);
return
userMapper
.
selectByExample
(
example
);
}
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/util/SortUtil.java
deleted
100644 → 0
View file @
d2a561f3
package
org.linlinjava.litemall.db.util
;
public
class
SortUtil
{
public
static
final
String
goodsSort
(
String
sort
,
String
order
){
if
(
sort
==
null
){
return
null
;
}
String
sortWithOrder
=
""
;
if
(
sort
.
equalsIgnoreCase
(
"price"
)){
sortWithOrder
=
"retail_price"
;
}
else
if
(
sort
.
equalsIgnoreCase
(
"default"
)
||
sort
.
equalsIgnoreCase
(
"category"
)){
return
null
;
}
else
{
return
null
;
}
if
(
order
==
null
)
{
return
sortWithOrder
;
}
if
(
order
.
equalsIgnoreCase
(
"asc"
)){
sortWithOrder
+=
" ASC"
;
}
else
if
(
order
.
equalsIgnoreCase
(
"DESC"
)){
sortWithOrder
+=
" DESC"
;
}
return
sortWithOrder
;
}
}
Prev
1
2
3
Next
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