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
149c7d20
Commit
149c7d20
authored
Aug 15, 2018
by
Menethil
Browse files
优化首页Json数据
parent
cd3ea740
Changes
6
Hide whitespace changes
Inline
Side-by-side
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallBrandService.java
View file @
149c7d20
...
@@ -3,6 +3,7 @@ package org.linlinjava.litemall.db.service;
...
@@ -3,6 +3,7 @@ package org.linlinjava.litemall.db.service;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageHelper
;
import
org.linlinjava.litemall.db.domain.LitemallBrandExample
;
import
org.linlinjava.litemall.db.domain.LitemallBrandExample
;
import
org.linlinjava.litemall.db.dao.LitemallBrandMapper
;
import
org.linlinjava.litemall.db.dao.LitemallBrandMapper
;
import
org.linlinjava.litemall.db.domain.LitemallBrand.Column
;
import
org.linlinjava.litemall.db.domain.LitemallBrand
;
import
org.linlinjava.litemall.db.domain.LitemallBrand
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
...
@@ -14,6 +15,7 @@ import java.util.List;
...
@@ -14,6 +15,7 @@ import java.util.List;
public
class
LitemallBrandService
{
public
class
LitemallBrandService
{
@Resource
@Resource
private
LitemallBrandMapper
brandMapper
;
private
LitemallBrandMapper
brandMapper
;
private
Column
[]
columns
=
new
Column
[]{
Column
.
id
,
Column
.
name
,
Column
.
desc
,
Column
.
picUrl
,
Column
.
floorPrice
};
public
List
<
LitemallBrand
>
query
(
int
offset
,
int
limit
)
{
public
List
<
LitemallBrand
>
query
(
int
offset
,
int
limit
)
{
LitemallBrandExample
example
=
new
LitemallBrandExample
();
LitemallBrandExample
example
=
new
LitemallBrandExample
();
...
@@ -22,10 +24,17 @@ public class LitemallBrandService {
...
@@ -22,10 +24,17 @@ public class LitemallBrandService {
return
brandMapper
.
selectByExample
(
example
);
return
brandMapper
.
selectByExample
(
example
);
}
}
public
List
<
LitemallBrand
>
queryVO
(
int
offset
,
int
limit
)
{
LitemallBrandExample
example
=
new
LitemallBrandExample
();
example
.
or
().
andDeletedEqualTo
(
false
);
PageHelper
.
startPage
(
offset
,
limit
);
return
brandMapper
.
selectByExampleSelective
(
example
,
columns
);
}
public
int
queryTotalCount
()
{
public
int
queryTotalCount
()
{
LitemallBrandExample
example
=
new
LitemallBrandExample
();
LitemallBrandExample
example
=
new
LitemallBrandExample
();
example
.
or
().
andDeletedEqualTo
(
false
);
example
.
or
().
andDeletedEqualTo
(
false
);
return
(
int
)
brandMapper
.
countByExample
(
example
);
return
(
int
)
brandMapper
.
countByExample
(
example
);
}
}
public
LitemallBrand
findById
(
Integer
id
)
{
public
LitemallBrand
findById
(
Integer
id
)
{
...
@@ -36,10 +45,10 @@ public class LitemallBrandService {
...
@@ -36,10 +45,10 @@ public class LitemallBrandService {
LitemallBrandExample
example
=
new
LitemallBrandExample
();
LitemallBrandExample
example
=
new
LitemallBrandExample
();
LitemallBrandExample
.
Criteria
criteria
=
example
.
createCriteria
();
LitemallBrandExample
.
Criteria
criteria
=
example
.
createCriteria
();
if
(!
StringUtils
.
isEmpty
(
id
)){
if
(!
StringUtils
.
isEmpty
(
id
))
{
criteria
.
andIdEqualTo
(
Integer
.
valueOf
(
id
));
criteria
.
andIdEqualTo
(
Integer
.
valueOf
(
id
));
}
}
if
(!
StringUtils
.
isEmpty
(
name
)){
if
(!
StringUtils
.
isEmpty
(
name
))
{
criteria
.
andNameLike
(
"%"
+
name
+
"%"
);
criteria
.
andNameLike
(
"%"
+
name
+
"%"
);
}
}
criteria
.
andDeletedEqualTo
(
false
);
criteria
.
andDeletedEqualTo
(
false
);
...
@@ -56,15 +65,15 @@ public class LitemallBrandService {
...
@@ -56,15 +65,15 @@ public class LitemallBrandService {
LitemallBrandExample
example
=
new
LitemallBrandExample
();
LitemallBrandExample
example
=
new
LitemallBrandExample
();
LitemallBrandExample
.
Criteria
criteria
=
example
.
createCriteria
();
LitemallBrandExample
.
Criteria
criteria
=
example
.
createCriteria
();
if
(!
StringUtils
.
isEmpty
(
id
)){
if
(!
StringUtils
.
isEmpty
(
id
))
{
criteria
.
andIdEqualTo
(
Integer
.
valueOf
(
id
));
criteria
.
andIdEqualTo
(
Integer
.
valueOf
(
id
));
}
}
if
(!
StringUtils
.
isEmpty
(
name
)){
if
(!
StringUtils
.
isEmpty
(
name
))
{
criteria
.
andNameLike
(
"%"
+
name
+
"%"
);
criteria
.
andNameLike
(
"%"
+
name
+
"%"
);
}
}
criteria
.
andDeletedEqualTo
(
false
);
criteria
.
andDeletedEqualTo
(
false
);
return
(
int
)
brandMapper
.
countByExample
(
example
);
return
(
int
)
brandMapper
.
countByExample
(
example
);
}
}
public
void
updateById
(
LitemallBrand
brand
)
{
public
void
updateById
(
LitemallBrand
brand
)
{
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGoodsService.java
View file @
149c7d20
...
@@ -11,14 +11,13 @@ import org.springframework.util.StringUtils;
...
@@ -11,14 +11,13 @@ import org.springframework.util.StringUtils;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Random
;
@Service
@Service
public
class
LitemallGoodsService
{
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
};
Column
[]
columns
=
new
Column
[]{
Column
.
id
,
Column
.
name
,
Column
.
brief
,
Column
.
picUrl
,
Column
.
counterPrice
,
Column
.
retailPrice
};
/**
/**
* 获取热卖商品
* 获取热卖商品
...
@@ -187,12 +186,30 @@ public class LitemallGoodsService {
...
@@ -187,12 +186,30 @@ public class LitemallGoodsService {
return
(
int
)
goodsMapper
.
countByExample
(
example
);
return
(
int
)
goodsMapper
.
countByExample
(
example
);
}
}
/**
* 获取某个商品信息,包含完整信息
*
* @param id
* @return
*/
public
LitemallGoods
findById
(
Integer
id
)
{
public
LitemallGoods
findById
(
Integer
id
)
{
LitemallGoodsExample
example
=
new
LitemallGoodsExample
();
LitemallGoodsExample
example
=
new
LitemallGoodsExample
();
example
.
or
().
andIdEqualTo
(
id
).
andDeletedEqualTo
(
false
);
example
.
or
().
andIdEqualTo
(
id
).
andDeletedEqualTo
(
false
);
return
goodsMapper
.
selectOneByExampleWithBLOBs
(
example
);
return
goodsMapper
.
selectOneByExampleWithBLOBs
(
example
);
}
}
/**
* 获取某个商品信息,仅展示相关内容
*
* @param id
* @return
*/
public
LitemallGoods
findByIdVO
(
Integer
id
)
{
LitemallGoodsExample
example
=
new
LitemallGoodsExample
();
example
.
or
().
andIdEqualTo
(
id
).
andDeletedEqualTo
(
false
);
return
goodsMapper
.
selectOneByExampleSelective
(
example
,
columns
);
}
/**
/**
* 获取所有在售物品总数
* 获取所有在售物品总数
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallTopicService.java
View file @
149c7d20
...
@@ -3,6 +3,7 @@ package org.linlinjava.litemall.db.service;
...
@@ -3,6 +3,7 @@ package org.linlinjava.litemall.db.service;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageHelper
;
import
org.linlinjava.litemall.db.dao.LitemallTopicMapper
;
import
org.linlinjava.litemall.db.dao.LitemallTopicMapper
;
import
org.linlinjava.litemall.db.domain.LitemallTopic
;
import
org.linlinjava.litemall.db.domain.LitemallTopic
;
import
org.linlinjava.litemall.db.domain.LitemallTopic.Column
;
import
org.linlinjava.litemall.db.domain.LitemallTopicExample
;
import
org.linlinjava.litemall.db.domain.LitemallTopicExample
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
...
@@ -14,18 +15,19 @@ import java.util.List;
...
@@ -14,18 +15,19 @@ import java.util.List;
public
class
LitemallTopicService
{
public
class
LitemallTopicService
{
@Resource
@Resource
private
LitemallTopicMapper
topicMapper
;
private
LitemallTopicMapper
topicMapper
;
private
Column
[]
columns
=
new
Column
[]{
Column
.
id
,
Column
.
title
,
Column
.
subtitle
,
Column
.
picUrl
,
Column
.
readCount
};
public
List
<
LitemallTopic
>
queryList
(
int
offset
,
int
limit
)
{
public
List
<
LitemallTopic
>
queryList
(
int
offset
,
int
limit
)
{
LitemallTopicExample
example
=
new
LitemallTopicExample
();
LitemallTopicExample
example
=
new
LitemallTopicExample
();
example
.
or
().
andDeletedEqualTo
(
false
);
example
.
or
().
andDeletedEqualTo
(
false
);
PageHelper
.
startPage
(
offset
,
limit
);
PageHelper
.
startPage
(
offset
,
limit
);
return
topicMapper
.
selectByExample
WithBLOBs
(
example
);
return
topicMapper
.
selectByExample
Selective
(
example
,
columns
);
}
}
public
int
queryTotal
()
{
public
int
queryTotal
()
{
LitemallTopicExample
example
=
new
LitemallTopicExample
();
LitemallTopicExample
example
=
new
LitemallTopicExample
();
example
.
or
().
andDeletedEqualTo
(
false
);
example
.
or
().
andDeletedEqualTo
(
false
);
return
(
int
)
topicMapper
.
countByExample
(
example
);
return
(
int
)
topicMapper
.
countByExample
(
example
);
}
}
public
LitemallTopic
findById
(
Integer
id
)
{
public
LitemallTopic
findById
(
Integer
id
)
{
...
@@ -38,7 +40,7 @@ public class LitemallTopicService {
...
@@ -38,7 +40,7 @@ public class LitemallTopicService {
LitemallTopicExample
example
=
new
LitemallTopicExample
();
LitemallTopicExample
example
=
new
LitemallTopicExample
();
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
);
}
}
LitemallTopic
topic
=
topics
.
get
(
0
);
LitemallTopic
topic
=
topics
.
get
(
0
);
...
@@ -47,7 +49,7 @@ public class LitemallTopicService {
...
@@ -47,7 +49,7 @@ public class LitemallTopicService {
example
.
or
().
andIdNotEqualTo
(
topic
.
getId
()).
andDeletedEqualTo
(
false
);
example
.
or
().
andIdNotEqualTo
(
topic
.
getId
()).
andDeletedEqualTo
(
false
);
PageHelper
.
startPage
(
offset
,
limit
);
PageHelper
.
startPage
(
offset
,
limit
);
List
<
LitemallTopic
>
relateds
=
topicMapper
.
selectByExampleWithBLOBs
(
example
);
List
<
LitemallTopic
>
relateds
=
topicMapper
.
selectByExampleWithBLOBs
(
example
);
if
(
relateds
.
size
()
!=
0
){
if
(
relateds
.
size
()
!=
0
)
{
return
relateds
;
return
relateds
;
}
}
...
@@ -58,10 +60,10 @@ public class LitemallTopicService {
...
@@ -58,10 +60,10 @@ public class LitemallTopicService {
LitemallTopicExample
example
=
new
LitemallTopicExample
();
LitemallTopicExample
example
=
new
LitemallTopicExample
();
LitemallTopicExample
.
Criteria
criteria
=
example
.
createCriteria
();
LitemallTopicExample
.
Criteria
criteria
=
example
.
createCriteria
();
if
(!
StringUtils
.
isEmpty
(
title
)){
if
(!
StringUtils
.
isEmpty
(
title
))
{
criteria
.
andTitleLike
(
"%"
+
title
+
"%"
);
criteria
.
andTitleLike
(
"%"
+
title
+
"%"
);
}
}
if
(!
StringUtils
.
isEmpty
(
subtitle
)){
if
(!
StringUtils
.
isEmpty
(
subtitle
))
{
criteria
.
andSubtitleLike
(
"%"
+
subtitle
+
"%"
);
criteria
.
andSubtitleLike
(
"%"
+
subtitle
+
"%"
);
}
}
criteria
.
andDeletedEqualTo
(
false
);
criteria
.
andDeletedEqualTo
(
false
);
...
@@ -78,15 +80,15 @@ public class LitemallTopicService {
...
@@ -78,15 +80,15 @@ public class LitemallTopicService {
LitemallTopicExample
example
=
new
LitemallTopicExample
();
LitemallTopicExample
example
=
new
LitemallTopicExample
();
LitemallTopicExample
.
Criteria
criteria
=
example
.
createCriteria
();
LitemallTopicExample
.
Criteria
criteria
=
example
.
createCriteria
();
if
(!
StringUtils
.
isEmpty
(
title
)){
if
(!
StringUtils
.
isEmpty
(
title
))
{
criteria
.
andTitleLike
(
"%"
+
title
+
"%"
);
criteria
.
andTitleLike
(
"%"
+
title
+
"%"
);
}
}
if
(!
StringUtils
.
isEmpty
(
subtitle
)){
if
(!
StringUtils
.
isEmpty
(
subtitle
))
{
criteria
.
andSubtitleLike
(
"%"
+
subtitle
+
"%"
);
criteria
.
andSubtitleLike
(
"%"
+
subtitle
+
"%"
);
}
}
criteria
.
andDeletedEqualTo
(
false
);
criteria
.
andDeletedEqualTo
(
false
);
return
(
int
)
topicMapper
.
countByExample
(
example
);
return
(
int
)
topicMapper
.
countByExample
(
example
);
}
}
public
void
updateById
(
LitemallTopic
topic
)
{
public
void
updateById
(
LitemallTopic
topic
)
{
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxBrandController.java
View file @
149c7d20
...
@@ -32,23 +32,23 @@ public class WxBrandController {
...
@@ -32,23 +32,23 @@ public class WxBrandController {
* @param page 分页页数
* @param page 分页页数
* @param size 分页大小
* @param size 分页大小
* @return 品牌列表
* @return 品牌列表
*
成功则
* 成功则
*
{
* {
*
errno: 0,
* errno: 0,
*
errmsg: '成功',
* errmsg: '成功',
*
data:
* data:
*
{
* {
*
brandList: xxx,
* brandList: xxx,
*
totalPages: xxx
* totalPages: xxx
*
}
* }
*
}
* }
*
失败则 { errno: XXX, errmsg: XXX }
* 失败则 { errno: XXX, errmsg: XXX }
*/
*/
@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
<
LitemallBrand
>
brandList
=
brandService
.
query
(
page
,
size
);
List
<
LitemallBrand
>
brandList
=
brandService
.
query
VO
(
page
,
size
);
int
total
=
brandService
.
queryTotalCount
();
int
total
=
brandService
.
queryTotalCount
();
int
totalPages
=
(
int
)
Math
.
ceil
((
double
)
total
/
size
);
int
totalPages
=
(
int
)
Math
.
ceil
((
double
)
total
/
size
);
...
@@ -63,26 +63,26 @@ public class WxBrandController {
...
@@ -63,26 +63,26 @@ public class WxBrandController {
*
*
* @param id 品牌ID
* @param id 品牌ID
* @return 品牌详情
* @return 品牌详情
*
成功则
* 成功则
*
{
* {
*
errno: 0,
* errno: 0,
*
errmsg: '成功',
* errmsg: '成功',
*
data:
* data:
*
{
* {
*
brand: xxx
* brand: xxx
*
}
* }
*
}
* }
*
失败则 { errno: XXX, errmsg: XXX }
* 失败则 { errno: XXX, errmsg: XXX }
*/
*/
@GetMapping
(
"detail"
)
@GetMapping
(
"detail"
)
public
Object
detail
(
@NotNull
Integer
id
)
{
public
Object
detail
(
@NotNull
Integer
id
)
{
LitemallBrand
entity
=
brandService
.
findById
(
id
);
LitemallBrand
entity
=
brandService
.
findById
(
id
);
if
(
entity
==
null
){
if
(
entity
==
null
)
{
return
ResponseUtil
.
badArgumentValue
();
return
ResponseUtil
.
badArgumentValue
();
}
}
Map
<
String
,
Object
>
data
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
data
=
new
HashMap
<
String
,
Object
>();
data
.
put
(
"brand"
,
entity
);
data
.
put
(
"brand"
,
entity
);
return
ResponseUtil
.
ok
(
data
);
return
ResponseUtil
.
ok
(
data
);
}
}
}
}
\ No newline at end of file
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxGrouponController.java
View file @
149c7d20
package
org.linlinjava.litemall.wx.web
;
package
org.linlinjava.litemall.wx.web
;
import
org.linlinjava.litemall.core.express.ExpressService
;
import
org.linlinjava.litemall.core.express.dao.ExpressInfo
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.db.domain.*
;
import
org.linlinjava.litemall.db.domain.*
;
import
org.linlinjava.litemall.db.service.*
;
import
org.linlinjava.litemall.db.service.*
;
...
@@ -36,6 +38,8 @@ public class WxGrouponController {
...
@@ -36,6 +38,8 @@ public class WxGrouponController {
private
LitemallOrderGoodsService
orderGoodsService
;
private
LitemallOrderGoodsService
orderGoodsService
;
@Autowired
@Autowired
private
LitemallUserService
userService
;
private
LitemallUserService
userService
;
@Autowired
private
ExpressService
expressService
;
@GetMapping
(
"detail"
)
@GetMapping
(
"detail"
)
public
Object
detail
(
@LoginUser
Integer
userId
,
@NotNull
Integer
grouponId
)
{
public
Object
detail
(
@LoginUser
Integer
userId
,
@NotNull
Integer
grouponId
)
{
...
@@ -95,6 +99,13 @@ public class WxGrouponController {
...
@@ -95,6 +99,13 @@ public class WxGrouponController {
result
.
put
(
"orderInfo"
,
orderVo
);
result
.
put
(
"orderInfo"
,
orderVo
);
result
.
put
(
"orderGoods"
,
orderGoodsVoList
);
result
.
put
(
"orderGoods"
,
orderGoodsVoList
);
// 订单状态为已发货且物流信息不为空
//"YTO", "800669400640887922"
if
(
order
.
getOrderStatus
().
equals
(
OrderUtil
.
STATUS_SHIP
))
{
ExpressInfo
ei
=
expressService
.
getExpressInfo
(
order
.
getShipChannel
(),
order
.
getShipSn
());
result
.
put
(
"expressInfo"
,
ei
);
}
UserVo
creator
=
userService
.
findUserVoById
(
groupon
.
getCreatorUserId
());
UserVo
creator
=
userService
.
findUserVoById
(
groupon
.
getCreatorUserId
());
List
<
UserVo
>
joiners
=
new
ArrayList
<>();
List
<
UserVo
>
joiners
=
new
ArrayList
<>();
joiners
.
add
(
creator
);
joiners
.
add
(
creator
);
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxHomeController.java
View file @
149c7d20
...
@@ -89,7 +89,7 @@ public class WxHomeController {
...
@@ -89,7 +89,7 @@ public class WxHomeController {
List
<
LitemallGoods
>
hotGoods
=
goodsService
.
queryByHot
(
0
,
SystemConfig
.
getHotLimit
());
List
<
LitemallGoods
>
hotGoods
=
goodsService
.
queryByHot
(
0
,
SystemConfig
.
getHotLimit
());
data
.
put
(
"hotGoodsList"
,
hotGoods
);
data
.
put
(
"hotGoodsList"
,
hotGoods
);
List
<
LitemallBrand
>
brandList
=
brandService
.
query
(
0
,
SystemConfig
.
getBrandLimit
());
List
<
LitemallBrand
>
brandList
=
brandService
.
query
VO
(
0
,
SystemConfig
.
getBrandLimit
());
data
.
put
(
"brandList"
,
brandList
);
data
.
put
(
"brandList"
,
brandList
);
List
<
LitemallTopic
>
topicList
=
topicService
.
queryList
(
0
,
SystemConfig
.
getTopicLimit
());
List
<
LitemallTopic
>
topicList
=
topicService
.
queryList
(
0
,
SystemConfig
.
getTopicLimit
());
...
@@ -100,7 +100,7 @@ public class WxHomeController {
...
@@ -100,7 +100,7 @@ public class WxHomeController {
List
<
LitemallGoods
>
grouponGoods
=
new
ArrayList
<>();
List
<
LitemallGoods
>
grouponGoods
=
new
ArrayList
<>();
List
<
Map
<
String
,
Object
>>
grouponList
=
new
ArrayList
<>();
List
<
Map
<
String
,
Object
>>
grouponList
=
new
ArrayList
<>();
for
(
LitemallGrouponRules
rule
:
grouponRules
)
{
for
(
LitemallGrouponRules
rule
:
grouponRules
)
{
LitemallGoods
goods
=
goodsService
.
findById
(
rule
.
getGoodsId
());
LitemallGoods
goods
=
goodsService
.
findById
VO
(
rule
.
getGoodsId
());
if
(
goods
==
null
)
if
(
goods
==
null
)
continue
;
continue
;
...
...
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