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
cd3ea740
Commit
cd3ea740
authored
Aug 15, 2018
by
Menethil
Browse files
修复类别商品查询BUG
parent
78127aed
Changes
1
Hide whitespace changes
Inline
Side-by-side
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGoodsService.java
View file @
cd3ea740
...
@@ -18,50 +18,76 @@ public class LitemallGoodsService {
...
@@ -18,50 +18,76 @@ public class LitemallGoodsService {
@Resource
@Resource
private
LitemallGoodsMapper
goodsMapper
;
private
LitemallGoodsMapper
goodsMapper
;
Column
[]
columns
=
new
Column
[]{
Column
.
id
,
Column
.
name
,
Column
.
picUrl
,
Column
.
counterPrice
,
Column
.
retailPrice
};
/**
* 获取热卖商品
*
* @param offset
* @param limit
* @return
*/
public
List
<
LitemallGoods
>
queryByHot
(
int
offset
,
int
limit
)
{
public
List
<
LitemallGoods
>
queryByHot
(
int
offset
,
int
limit
)
{
LitemallGoodsExample
example
=
new
LitemallGoodsExample
();
LitemallGoodsExample
example
=
new
LitemallGoodsExample
();
example
.
or
().
andIsHotEqualTo
(
true
).
andDeletedEqualTo
(
false
);
example
.
or
().
andIsHotEqualTo
(
true
).
andDeletedEqualTo
(
false
);
example
.
setOrderByClause
(
"add_time desc"
);
example
.
setOrderByClause
(
"add_time desc"
);
PageHelper
.
startPage
(
offset
,
limit
);
PageHelper
.
startPage
(
offset
,
limit
);
return
goodsMapper
.
selectByExample
(
example
);
return
goodsMapper
.
selectByExampleSelective
(
example
,
columns
);
}
}
/**
* 获取新品上市
*
* @param offset
* @param limit
* @return
*/
public
List
<
LitemallGoods
>
queryByNew
(
int
offset
,
int
limit
)
{
public
List
<
LitemallGoods
>
queryByNew
(
int
offset
,
int
limit
)
{
LitemallGoodsExample
example
=
new
LitemallGoodsExample
();
LitemallGoodsExample
example
=
new
LitemallGoodsExample
();
example
.
or
().
andIsNewEqualTo
(
true
).
andDeletedEqualTo
(
false
);
example
.
or
().
andIsNewEqualTo
(
true
).
andDeletedEqualTo
(
false
);
example
.
setOrderByClause
(
"add_time desc"
);
example
.
setOrderByClause
(
"add_time desc"
);
PageHelper
.
startPage
(
offset
,
limit
);
PageHelper
.
startPage
(
offset
,
limit
);
return
goodsMapper
.
selectByExample
(
example
);
return
goodsMapper
.
selectByExampleSelective
(
example
,
columns
);
}
}
/**
* 获取分类下的商品
*
* @param catList
* @param offset
* @param limit
* @return
*/
public
List
<
LitemallGoods
>
queryByCategory
(
List
<
Integer
>
catList
,
int
offset
,
int
limit
)
{
public
List
<
LitemallGoods
>
queryByCategory
(
List
<
Integer
>
catList
,
int
offset
,
int
limit
)
{
LitemallGoodsExample
example
=
new
LitemallGoodsExample
();
LitemallGoodsExample
example
=
new
LitemallGoodsExample
();
example
.
or
().
andCategoryIdIn
(
catList
).
andDeletedEqualTo
(
false
);
example
.
or
().
andCategoryIdIn
(
catList
).
andDeletedEqualTo
(
false
);
example
.
setOrderByClause
(
"add_time desc"
);
example
.
setOrderByClause
(
"add_time desc"
);
PageHelper
.
startPage
(
offset
,
limit
);
PageHelper
.
startPage
(
offset
,
limit
);
return
goodsMapper
.
selectByExample
(
example
);
}
public
int
countByCategory
(
List
<
Integer
>
catList
,
int
offset
,
int
limit
)
{
return
goodsMapper
.
selectByExampleSelective
(
example
,
columns
);
LitemallGoodsExample
example
=
new
LitemallGoodsExample
();
example
.
or
().
andCategoryIdIn
(
catList
).
andDeletedEqualTo
(
false
);
return
(
int
)
goodsMapper
.
countByExample
(
example
);
}
}
/**
* 获取分类下的商品
*
* @param catId
* @param offset
* @param limit
* @return
*/
public
List
<
LitemallGoods
>
queryByCategory
(
Integer
catId
,
int
offset
,
int
limit
)
{
public
List
<
LitemallGoods
>
queryByCategory
(
Integer
catId
,
int
offset
,
int
limit
)
{
LitemallGoodsExample
example
=
new
LitemallGoodsExample
();
LitemallGoodsExample
example
=
new
LitemallGoodsExample
();
example
.
or
().
andCategoryIdEqualTo
(
catId
).
andDeletedEqualTo
(
false
);
example
.
or
().
andCategoryIdEqualTo
(
catId
).
andDeletedEqualTo
(
false
);
example
.
setOrderByClause
(
"add_time desc"
);
example
.
setOrderByClause
(
"add_time desc"
);
PageHelper
.
startPage
(
offset
,
limit
);
PageHelper
.
startPage
(
offset
,
limit
);
return
goodsMapper
.
selectByExample
(
example
);
}
public
int
countByCategory
(
Integer
catId
,
Integer
page
,
Integer
size
)
{
return
goodsMapper
.
selectByExampleSelective
(
example
,
columns
);
LitemallGoodsExample
example
=
new
LitemallGoodsExample
();
example
.
or
().
andCategoryIdEqualTo
(
catId
).
andDeletedEqualTo
(
false
);
return
(
int
)
goodsMapper
.
countByExample
(
example
);
}
}
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
criteria1
=
example
.
or
();
LitemallGoodsExample
.
Criteria
criteria1
=
example
.
or
();
...
@@ -98,7 +124,6 @@ public class LitemallGoodsService {
...
@@ -98,7 +124,6 @@ public class LitemallGoodsService {
PageHelper
.
startPage
(
offset
,
limit
);
PageHelper
.
startPage
(
offset
,
limit
);
}
}
Column
[]
columns
=
new
Column
[]{
Column
.
id
,
Column
.
name
,
Column
.
picUrl
,
Column
.
counterPrice
,
Column
.
retailPrice
};
return
goodsMapper
.
selectByExampleSelective
(
example
,
columns
);
return
goodsMapper
.
selectByExampleSelective
(
example
,
columns
);
}
}
...
@@ -131,25 +156,6 @@ public class LitemallGoodsService {
...
@@ -131,25 +156,6 @@ public class LitemallGoodsService {
return
(
int
)
goodsMapper
.
countByExample
(
example
);
return
(
int
)
goodsMapper
.
countByExample
(
example
);
}
}
public
LitemallGoods
findById
(
Integer
id
)
{
LitemallGoodsExample
example
=
new
LitemallGoodsExample
();
example
.
or
().
andIdEqualTo
(
id
).
andDeletedEqualTo
(
false
);
return
goodsMapper
.
selectOneByExampleWithBLOBs
(
example
);
}
public
List
<
LitemallGoods
>
queryByIds
(
List
<
Integer
>
relatedGoodsIds
)
{
LitemallGoodsExample
example
=
new
LitemallGoodsExample
();
example
.
or
().
andIdIn
(
relatedGoodsIds
).
andDeletedEqualTo
(
false
);
return
goodsMapper
.
selectByExampleWithBLOBs
(
example
);
}
public
Integer
queryOnSale
()
{
LitemallGoodsExample
example
=
new
LitemallGoodsExample
();
example
.
or
().
andIsOnSaleEqualTo
(
true
).
andDeletedEqualTo
(
false
);
return
(
int
)
goodsMapper
.
countByExample
(
example
);
}
public
List
<
LitemallGoods
>
querySelective
(
String
goodsSn
,
String
name
,
Integer
page
,
Integer
size
,
String
sort
,
String
order
)
{
public
List
<
LitemallGoods
>
querySelective
(
String
goodsSn
,
String
name
,
Integer
page
,
Integer
size
,
String
sort
,
String
order
)
{
LitemallGoodsExample
example
=
new
LitemallGoodsExample
();
LitemallGoodsExample
example
=
new
LitemallGoodsExample
();
LitemallGoodsExample
.
Criteria
criteria
=
example
.
createCriteria
();
LitemallGoodsExample
.
Criteria
criteria
=
example
.
createCriteria
();
...
@@ -181,6 +187,24 @@ public class LitemallGoodsService {
...
@@ -181,6 +187,24 @@ public class LitemallGoodsService {
return
(
int
)
goodsMapper
.
countByExample
(
example
);
return
(
int
)
goodsMapper
.
countByExample
(
example
);
}
}
public
LitemallGoods
findById
(
Integer
id
)
{
LitemallGoodsExample
example
=
new
LitemallGoodsExample
();
example
.
or
().
andIdEqualTo
(
id
).
andDeletedEqualTo
(
false
);
return
goodsMapper
.
selectOneByExampleWithBLOBs
(
example
);
}
/**
* 获取所有在售物品总数
*
* @return
*/
public
Integer
queryOnSale
()
{
LitemallGoodsExample
example
=
new
LitemallGoodsExample
();
example
.
or
().
andIsOnSaleEqualTo
(
true
).
andDeletedEqualTo
(
false
);
return
(
int
)
goodsMapper
.
countByExample
(
example
);
}
public
void
updateById
(
LitemallGoods
goods
)
{
public
void
updateById
(
LitemallGoods
goods
)
{
goodsMapper
.
updateByPrimaryKeySelective
(
goods
);
goodsMapper
.
updateByPrimaryKeySelective
(
goods
);
}
}
...
@@ -204,6 +228,9 @@ public class LitemallGoodsService {
...
@@ -204,6 +228,9 @@ public class LitemallGoodsService {
LitemallGoodsExample
.
Criteria
criteria1
=
example
.
or
();
LitemallGoodsExample
.
Criteria
criteria1
=
example
.
or
();
LitemallGoodsExample
.
Criteria
criteria2
=
example
.
or
();
LitemallGoodsExample
.
Criteria
criteria2
=
example
.
or
();
criteria1
.
andDeletedEqualTo
(
false
);
criteria2
.
andDeletedEqualTo
(
false
);
if
(!
StringUtils
.
isEmpty
(
brandId
))
{
if
(!
StringUtils
.
isEmpty
(
brandId
))
{
criteria1
.
andBrandIdEqualTo
(
brandId
);
criteria1
.
andBrandIdEqualTo
(
brandId
);
criteria2
.
andBrandIdEqualTo
(
brandId
);
criteria2
.
andBrandIdEqualTo
(
brandId
);
...
...
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