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
a5c2aff4
Commit
a5c2aff4
authored
Nov 16, 2018
by
Junling Bu
Browse files
chore[后端服务]: 后端服务代码基于IDEA的reformat code工具格式化代码,但是mybatis generator生成的代码除外。
parent
556f269d
Changes
132
Hide whitespace changes
Inline
Side-by-side
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxFootprintController.java
View file @
a5c2aff4
...
...
@@ -2,12 +2,12 @@ package org.linlinjava.litemall.wx.web;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.core.util.JacksonUtil
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.db.domain.LitemallFootprint
;
import
org.linlinjava.litemall.db.domain.LitemallGoods
;
import
org.linlinjava.litemall.db.service.LitemallFootprintService
;
import
org.linlinjava.litemall.db.service.LitemallGoodsService
;
import
org.linlinjava.litemall.core.util.JacksonUtil
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.wx.annotation.LoginUser
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
...
...
@@ -33,30 +33,30 @@ public class WxFootprintController {
* 删除用户足迹
*
* @param userId 用户ID
* @param body 请求内容, { footprintId: xxx }
* @param body
请求内容, { footprintId: xxx }
* @return 删除操作结果
*
成功则 { errno: 0, errmsg: '成功' }
*
失败则 { errno: XXX, errmsg: XXX }
* 成功则 { errno: 0, errmsg: '成功' }
* 失败则 { errno: XXX, errmsg: XXX }
*/
@PostMapping
(
"delete"
)
public
Object
delete
(
@LoginUser
Integer
userId
,
@RequestBody
String
body
)
{
if
(
userId
==
null
){
if
(
userId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
if
(
body
==
null
){
if
(
body
==
null
)
{
return
ResponseUtil
.
badArgument
();
}
Integer
footprintId
=
JacksonUtil
.
parseInteger
(
body
,
"footprintId"
);
if
(
footprintId
==
null
){
if
(
footprintId
==
null
)
{
return
ResponseUtil
.
badArgument
();
}
LitemallFootprint
footprint
=
footprintService
.
findById
(
footprintId
);
if
(
footprint
==
null
){
if
(
footprint
==
null
)
{
return
ResponseUtil
.
badArgumentValue
();
}
if
(!
footprint
.
getUserId
().
equals
(
userId
)){
if
(!
footprint
.
getUserId
().
equals
(
userId
))
{
return
ResponseUtil
.
badArgumentValue
();
}
...
...
@@ -70,23 +70,23 @@ public class WxFootprintController {
* @param page 分页页数
* @param size 分页大小
* @return 用户足迹列表
*
成功则
*
{
*
errno: 0,
*
errmsg: '成功',
*
data:
*
{
*
footprintList: xxx,
*
totalPages: xxx
*
}
*
}
*
失败则 { errno: XXX, errmsg: XXX }
* 成功则
* {
* errno: 0,
* errmsg: '成功',
* data:
* {
* footprintList: xxx,
* totalPages: xxx
* }
* }
* 失败则 { errno: XXX, errmsg: XXX }
*/
@GetMapping
(
"list"
)
public
Object
list
(
@LoginUser
Integer
userId
,
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
defaultValue
=
"10"
)
Integer
size
)
{
if
(
userId
==
null
){
if
(
userId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
...
...
@@ -95,7 +95,7 @@ public class WxFootprintController {
int
totalPages
=
(
int
)
Math
.
ceil
((
double
)
count
/
size
);
List
<
Object
>
footprintVoList
=
new
ArrayList
<>(
footprintList
.
size
());
for
(
LitemallFootprint
footprint
:
footprintList
){
for
(
LitemallFootprint
footprint
:
footprintList
)
{
Map
<
String
,
Object
>
c
=
new
HashMap
<
String
,
Object
>();
c
.
put
(
"id"
,
footprint
.
getId
());
c
.
put
(
"goodsId"
,
footprint
.
getGoodsId
());
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxGoodsController.java
View file @
a5c2aff4
...
...
@@ -18,7 +18,6 @@ import org.springframework.web.bind.annotation.RequestParam;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.constraints.NotNull
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -106,10 +105,9 @@ public class WxGoodsController {
// 商品品牌商
Integer
brandId
=
info
.
getBrandId
();
LitemallBrand
brand
=
null
;
if
(
brandId
==
0
){
if
(
brandId
==
0
)
{
brand
=
new
LitemallBrand
();
}
else
{
}
else
{
brand
=
brandService
.
findById
(
info
.
getBrandId
());
}
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxGrouponController.java
View file @
a5c2aff4
package
org.linlinjava.litemall.wx.web
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.core.express.ExpressService
;
import
org.linlinjava.litemall.core.express.dao.ExpressInfo
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
...
...
@@ -15,8 +17,6 @@ import org.springframework.web.bind.annotation.GetMapping;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
javax.validation.constraints.NotNull
;
import
java.util.ArrayList
;
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxHomeController.java
View file @
a5c2aff4
...
...
@@ -2,10 +2,10 @@ package org.linlinjava.litemall.wx.web;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.core.system.SystemConfig
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.db.domain.*
;
import
org.linlinjava.litemall.db.service.*
;
import
org.linlinjava.litemall.core.system.SystemConfig
;
import
org.linlinjava.litemall.wx.service.HomeCacheManager
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxIndexController.java
View file @
a5c2aff4
...
...
@@ -12,7 +12,7 @@ public class WxIndexController {
private
final
Log
logger
=
LogFactory
.
getLog
(
WxIndexController
.
class
);
@RequestMapping
(
"/index"
)
public
Object
index
(){
public
Object
index
()
{
return
ResponseUtil
.
ok
(
"hello world, this is wx service"
);
}
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxOrderController.java
View file @
a5c2aff4
...
...
@@ -15,6 +15,7 @@ import org.linlinjava.litemall.core.express.dao.ExpressInfo;
import
org.linlinjava.litemall.core.notify.NotifyService
;
import
org.linlinjava.litemall.core.notify.NotifyType
;
import
org.linlinjava.litemall.core.qcode.QCodeService
;
import
org.linlinjava.litemall.core.system.SystemConfig
;
import
org.linlinjava.litemall.core.util.DateTimeUtil
;
import
org.linlinjava.litemall.core.util.JacksonUtil
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
...
...
@@ -23,7 +24,6 @@ import org.linlinjava.litemall.db.service.*;
import
org.linlinjava.litemall.db.util.OrderHandleOption
;
import
org.linlinjava.litemall.db.util.OrderUtil
;
import
org.linlinjava.litemall.wx.annotation.LoginUser
;
import
org.linlinjava.litemall.core.system.SystemConfig
;
import
org.linlinjava.litemall.wx.util.IpUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.transaction.PlatformTransactionManager
;
...
...
@@ -39,7 +39,6 @@ import javax.servlet.http.HttpServletResponse;
import
javax.validation.constraints.NotNull
;
import
java.io.IOException
;
import
java.math.BigDecimal
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
...
...
@@ -300,7 +299,7 @@ public class WxOrderController {
// 收货地址
LitemallAddress
checkedAddress
=
addressService
.
findById
(
addressId
);
if
(
checkedAddress
==
null
){
if
(
checkedAddress
==
null
)
{
return
ResponseUtil
.
badArgument
();
}
...
...
@@ -416,7 +415,7 @@ public class WxOrderController {
throw
new
RuntimeException
(
"下单的商品货品数量大于库存量"
);
}
product
.
setNumber
(
remainNumber
);
if
(
productService
.
updateById
(
product
)
==
0
){
if
(
productService
.
updateById
(
product
)
==
0
)
{
throw
new
Exception
(
"更新数据失败"
);
}
}
...
...
@@ -501,7 +500,7 @@ public class WxOrderController {
// 设置订单已取消状态
order
.
setOrderStatus
(
OrderUtil
.
STATUS_CANCEL
);
order
.
setEndTime
(
LocalDateTime
.
now
());
if
(
orderService
.
updateWithOptimisticLocker
(
order
)
==
0
){
if
(
orderService
.
updateWithOptimisticLocker
(
order
)
==
0
)
{
throw
new
Exception
(
"更新数据已失效"
);
}
...
...
@@ -512,7 +511,7 @@ public class WxOrderController {
LitemallGoodsProduct
product
=
productService
.
findById
(
productId
);
Integer
number
=
product
.
getNumber
()
+
orderGoods
.
getNumber
();
product
.
setNumber
(
number
);
if
(
productService
.
updateById
(
product
)
==
0
){
if
(
productService
.
updateById
(
product
)
==
0
)
{
throw
new
Exception
(
"更新数据失败"
);
}
}
...
...
@@ -599,7 +598,7 @@ public class WxOrderController {
return
ResponseUtil
.
fail
(
403
,
"订单不能支付"
);
}
if
(
orderService
.
updateWithOptimisticLocker
(
order
)
==
0
){
if
(
orderService
.
updateWithOptimisticLocker
(
order
)
==
0
)
{
return
ResponseUtil
.
updatedDateExpired
();
}
return
ResponseUtil
.
ok
(
result
);
...
...
@@ -670,7 +669,7 @@ public class WxOrderController {
// 因此,这里会重新读取数据库检查状态是否是订单自动取消,如果是则更新成支付状态。
order
=
orderService
.
findBySn
(
orderSn
);
int
updated
=
0
;
if
(
OrderUtil
.
isAutoCancelStatus
(
order
)){
if
(
OrderUtil
.
isAutoCancelStatus
(
order
))
{
order
.
setPayId
(
payId
);
order
.
setPayTime
(
LocalDateTime
.
now
());
order
.
setOrderStatus
(
OrderUtil
.
STATUS_PAY
);
...
...
@@ -678,7 +677,7 @@ public class WxOrderController {
}
// 如果updated是0,那么数据库更新失败
if
(
updated
==
0
)
{
if
(
updated
==
0
)
{
return
WxPayNotifyResponse
.
fail
(
"更新数据已失效"
);
}
}
...
...
@@ -756,7 +755,7 @@ public class WxOrderController {
// 设置订单申请退款状态
order
.
setOrderStatus
(
OrderUtil
.
STATUS_REFUND
);
if
(
orderService
.
updateWithOptimisticLocker
(
order
)
==
0
){
if
(
orderService
.
updateWithOptimisticLocker
(
order
)
==
0
)
{
return
ResponseUtil
.
updatedDateExpired
();
}
...
...
@@ -806,7 +805,7 @@ public class WxOrderController {
order
.
setOrderStatus
(
OrderUtil
.
STATUS_CONFIRM
);
order
.
setConfirmTime
(
LocalDateTime
.
now
());
if
(
orderService
.
updateWithOptimisticLocker
(
order
)
==
0
){
if
(
orderService
.
updateWithOptimisticLocker
(
order
)
==
0
)
{
return
ResponseUtil
.
updatedDateExpired
();
}
return
ResponseUtil
.
ok
();
...
...
@@ -865,8 +864,8 @@ public class WxOrderController {
*/
@GetMapping
(
"goods"
)
public
Object
goods
(
@LoginUser
Integer
userId
,
@NotNull
Integer
orderId
,
@NotNull
Integer
goodsId
)
{
@NotNull
Integer
orderId
,
@NotNull
Integer
goodsId
)
{
if
(
userId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
...
...
@@ -901,48 +900,48 @@ public class WxOrderController {
}
Integer
orderGoodsId
=
JacksonUtil
.
parseInteger
(
body
,
"orderGoodsId"
);
if
(
orderGoodsId
==
null
){
if
(
orderGoodsId
==
null
)
{
return
ResponseUtil
.
badArgument
();
}
LitemallOrderGoods
orderGoods
=
orderGoodsService
.
findById
(
orderGoodsId
);
if
(
orderGoods
==
null
){
if
(
orderGoods
==
null
)
{
return
ResponseUtil
.
badArgumentValue
();
}
Integer
orderId
=
orderGoods
.
getOrderId
();
Integer
orderId
=
orderGoods
.
getOrderId
();
LitemallOrder
order
=
orderService
.
findById
(
orderId
);
if
(
order
==
null
){
if
(
order
==
null
)
{
return
ResponseUtil
.
badArgumentValue
();
}
Short
orderStatus
=
order
.
getOrderStatus
();
if
(!
OrderUtil
.
isConfirmStatus
(
order
)
&&
!
OrderUtil
.
isAutoConfirmStatus
(
order
))
{
if
(!
OrderUtil
.
isConfirmStatus
(
order
)
&&
!
OrderUtil
.
isAutoConfirmStatus
(
order
))
{
return
ResponseUtil
.
fail
(
404
,
"当前商品不能评价"
);
}
if
(!
order
.
getUserId
().
equals
(
userId
)){
if
(!
order
.
getUserId
().
equals
(
userId
))
{
return
ResponseUtil
.
fail
(
404
,
"当前商品不属于用户"
);
}
Integer
commentId
=
orderGoods
.
getComment
();
if
(
commentId
==
-
1
){
if
(
commentId
==
-
1
)
{
return
ResponseUtil
.
fail
(
404
,
"当前商品评价时间已经过期"
);
}
if
(
commentId
!=
0
){
if
(
commentId
!=
0
)
{
return
ResponseUtil
.
fail
(
404
,
"订单商品已评价"
);
}
String
content
=
JacksonUtil
.
parseString
(
body
,
"content"
);
Integer
star
=
JacksonUtil
.
parseInteger
(
body
,
"star"
);
if
(
star
==
null
||
star
<
0
||
star
>
5
){
if
(
star
==
null
||
star
<
0
||
star
>
5
)
{
return
ResponseUtil
.
badArgumentValue
();
}
Boolean
hasPicture
=
JacksonUtil
.
parseBoolean
(
body
,
"hasPicture"
);
List
<
String
>
picUrls
=
JacksonUtil
.
parseStringList
(
body
,
"picUrls"
);
if
(
hasPicture
==
null
||
!
hasPicture
){
if
(
hasPicture
==
null
||
!
hasPicture
)
{
picUrls
=
new
ArrayList
<>(
0
);
}
// 1. 创建评价
LitemallComment
comment
=
new
LitemallComment
();
comment
.
setUserId
(
userId
);
comment
.
setType
((
byte
)
0
);
comment
.
setType
((
byte
)
0
);
comment
.
setValueId
(
orderGoods
.
getGoodsId
());
comment
.
setStar
(
star
.
shortValue
());
comment
.
setContent
(
content
);
...
...
@@ -956,7 +955,7 @@ public class WxOrderController {
// 3. 更新订单中未评价的订单商品可评价数量
Short
commentCount
=
order
.
getComments
();
if
(
commentCount
>
0
){
if
(
commentCount
>
0
)
{
commentCount
--;
}
order
.
setComments
(
commentCount
);
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxRegionController.java
View file @
a5c2aff4
...
...
@@ -2,9 +2,9 @@ package org.linlinjava.litemall.wx.web;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.db.domain.LitemallRegion
;
import
org.linlinjava.litemall.db.service.LitemallRegionService
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
...
@@ -25,19 +25,19 @@ public class WxRegionController {
/**
* 区域数据
*
*
<p>
* 根据父区域ID,返回子区域数据。
* 如果父区域ID是0,则返回省级区域数据;
*
* @param pid 父区域ID
* @return 区域数据
*
成功则
*
{
*
errno: 0,
*
errmsg: '成功',
*
data: xxx
*
}
*
失败则 { errno: XXX, errmsg: XXX }
* 成功则
* {
* errno: 0,
* errmsg: '成功',
* data: xxx
* }
* 失败则 { errno: XXX, errmsg: XXX }
*/
@GetMapping
(
"list"
)
public
Object
list
(
@NotNull
Integer
pid
)
{
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxSearchController.java
View file @
a5c2aff4
...
...
@@ -2,11 +2,11 @@ package org.linlinjava.litemall.wx.web;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.db.domain.LitemallKeyword
;
import
org.linlinjava.litemall.db.domain.LitemallSearchHistory
;
import
org.linlinjava.litemall.db.service.LitemallKeywordService
;
import
org.linlinjava.litemall.db.service.LitemallSearchHistoryService
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.wx.annotation.LoginUser
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxStorageController.java
View file @
a5c2aff4
...
...
@@ -63,7 +63,7 @@ public class WxStorageController {
if
(
key
==
null
)
{
return
ResponseEntity
.
notFound
().
build
();
}
if
(
key
.
contains
(
"../"
)){
if
(
key
.
contains
(
"../"
))
{
return
ResponseEntity
.
badRequest
().
build
();
}
String
type
=
litemallStorage
.
getType
();
...
...
@@ -82,7 +82,7 @@ public class WxStorageController {
if
(
key
==
null
)
{
return
ResponseEntity
.
notFound
().
build
();
}
if
(
key
.
contains
(
"../"
)){
if
(
key
.
contains
(
"../"
))
{
return
ResponseEntity
.
badRequest
().
build
();
}
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxTopicController.java
View file @
a5c2aff4
...
...
@@ -2,13 +2,13 @@ package org.linlinjava.litemall.wx.web;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.core.validator.Order
;
import
org.linlinjava.litemall.core.validator.Sort
;
import
org.linlinjava.litemall.db.domain.LitemallGoods
;
import
org.linlinjava.litemall.db.domain.LitemallTopic
;
import
org.linlinjava.litemall.db.service.LitemallGoodsService
;
import
org.linlinjava.litemall.db.service.LitemallTopicService
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxUserController.java
View file @
a5c2aff4
...
...
@@ -7,7 +7,10 @@ import org.linlinjava.litemall.db.service.LitemallOrderService;
import
org.linlinjava.litemall.wx.annotation.LoginUser
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -25,17 +28,17 @@ public class WxUserController {
*
* @param userId 用户ID
* @return 用户信息
*
成功则
*
{
*
errno: 0,
*
errmsg: '成功',
*
data: xxx
*
}
*
失败则 { errno: XXX, errmsg: XXX }
* 成功则
* {
* errno: 0,
* errmsg: '成功',
* data: xxx
* }
* 失败则 { errno: XXX, errmsg: XXX }
*/
@GetMapping
(
"index"
)
public
Object
list
(
@LoginUser
Integer
userId
)
{
if
(
userId
==
null
){
if
(
userId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
...
...
litemall-wx-api/src/test/java/org/linlinjava/litemall/wx/WxConfigTest.java
View file @
a5c2aff4
package
org.linlinjava.litemall.wx
;
import
com.github.binarywang.wxpay.config.WxPayConfig
;
import
com.github.binarywang.wxpay.service.WxPayService
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
Prev
1
…
3
4
5
6
7
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