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
b95e4ca7
Commit
b95e4ca7
authored
Oct 26, 2018
by
Junling Bu
Browse files
重大调整:除了订单更新采用乐观锁更新,其他表是普通更新
parent
e4007338
Changes
30
Hide whitespace changes
Inline
Side-by-side
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminAdController.java
View file @
b95e4ca7
...
...
@@ -94,7 +94,7 @@ public class AdminAdController {
return
error
;
}
if
(
adService
.
updateById
(
ad
)
==
0
){
return
ResponseUtil
.
updatedDat
eExpir
ed
();
return
ResponseUtil
.
updatedDat
aFail
ed
();
}
return
ResponseUtil
.
ok
(
ad
);
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminAdminController.java
View file @
b95e4ca7
...
...
@@ -149,7 +149,7 @@ public class AdminAdminController {
admin
.
setPassword
(
encodedPassword
);
if
(
adminService
.
updateById
(
admin
)
==
0
){
return
ResponseUtil
.
updatedDat
eExpir
ed
();
return
ResponseUtil
.
updatedDat
aFail
ed
();
}
return
ResponseUtil
.
ok
(
admin
);
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminBrandController.java
View file @
b95e4ca7
...
...
@@ -102,7 +102,7 @@ public class AdminBrandController {
return
error
;
}
if
(
brandService
.
updateById
(
brand
)
==
0
){
return
ResponseUtil
.
updatedDat
eExpir
ed
();
return
ResponseUtil
.
updatedDat
aFail
ed
();
}
return
ResponseUtil
.
ok
(
brand
);
}
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminCategoryController.java
View file @
b95e4ca7
...
...
@@ -107,7 +107,7 @@ public class AdminCategoryController {
}
if
(
categoryService
.
updateById
(
category
)
==
0
){
return
ResponseUtil
.
updatedDat
eExpir
ed
();
return
ResponseUtil
.
updatedDat
aFail
ed
();
}
return
ResponseUtil
.
ok
();
}
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminGrouponController.java
View file @
b95e4ca7
...
...
@@ -136,7 +136,7 @@ public class AdminGrouponController {
grouponRules
.
setPicUrl
(
goods
.
getPicUrl
());
if
(
rulesService
.
updateById
(
grouponRules
)
==
0
){
return
ResponseUtil
.
updatedDat
eExpir
ed
();
return
ResponseUtil
.
updatedDat
aFail
ed
();
}
return
ResponseUtil
.
ok
();
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminIssueController.java
View file @
b95e4ca7
...
...
@@ -94,7 +94,7 @@ public class AdminIssueController {
return
error
;
}
if
(
issueService
.
updateById
(
issue
)
==
0
){
return
ResponseUtil
.
updatedDat
eExpir
ed
();
return
ResponseUtil
.
updatedDat
aFail
ed
();
}
return
ResponseUtil
.
ok
(
issue
);
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminKeywordController.java
View file @
b95e4ca7
...
...
@@ -94,7 +94,7 @@ public class AdminKeywordController {
return
error
;
}
if
(
keywordService
.
updateById
(
keywords
)
==
0
){
return
ResponseUtil
.
updatedDat
eExpir
ed
();
return
ResponseUtil
.
updatedDat
aFail
ed
();
}
return
ResponseUtil
.
ok
(
keywords
);
}
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminOrderController.java
View file @
b95e4ca7
...
...
@@ -127,6 +127,8 @@ public class AdminOrderController {
return
ResponseUtil
.
fail
(
403
,
"订单不能确认收货"
);
}
Integer
version
=
order
.
getVersion
();
// 开启事务管理
DefaultTransactionDefinition
def
=
new
DefaultTransactionDefinition
();
def
.
setPropagationBehavior
(
TransactionDefinition
.
PROPAGATION_REQUIRED
);
...
...
@@ -134,7 +136,7 @@ public class AdminOrderController {
try
{
// 设置订单取消状态
order
.
setOrderStatus
(
OrderUtil
.
STATUS_REFUND_CONFIRM
);
if
(
orderService
.
updateById
(
order
)
==
0
)
{
if
(
orderService
.
updateById
WithVersion
(
version
,
order
)
==
0
)
{
throw
new
Exception
(
"跟新数据已失效"
);
}
...
...
@@ -199,6 +201,8 @@ public class AdminOrderController {
return
ResponseUtil
.
badArgument
();
}
Integer
version
=
order
.
getVersion
();
// 如果订单不是已付款状态,则不能发货
if
(!
order
.
getOrderStatus
().
equals
(
OrderUtil
.
STATUS_PAY
))
{
return
ResponseUtil
.
fail
(
403
,
"订单不能确认收货"
);
...
...
@@ -208,7 +212,7 @@ public class AdminOrderController {
order
.
setShipSn
(
shipSn
);
order
.
setShipChannel
(
shipChannel
);
order
.
setShipTime
(
LocalDateTime
.
now
());
if
(
orderService
.
updateById
(
order
)
==
0
){
if
(
orderService
.
updateById
WithVersion
(
version
,
order
)
==
0
){
return
ResponseUtil
.
updatedDateExpired
();
}
...
...
@@ -243,6 +247,8 @@ public class AdminOrderController {
continue
;
}
Integer
version
=
order
.
getVersion
();
// 开启事务管理
DefaultTransactionDefinition
def
=
new
DefaultTransactionDefinition
();
def
.
setPropagationBehavior
(
TransactionDefinition
.
PROPAGATION_REQUIRED
);
...
...
@@ -251,7 +257,7 @@ public class AdminOrderController {
// 设置订单已取消状态
order
.
setOrderStatus
(
OrderUtil
.
STATUS_AUTO_CANCEL
);
order
.
setEndTime
(
LocalDateTime
.
now
());
if
(
orderService
.
updateById
(
order
)
==
0
){
if
(
orderService
.
updateById
WithVersion
(
version
,
order
)
==
0
){
throw
new
Exception
(
"跟新数据已失效"
);
}
...
...
@@ -264,12 +270,12 @@ public class AdminOrderController {
Integer
number
=
product
.
getNumber
()
+
orderGoods
.
getNumber
();
product
.
setNumber
(
number
);
if
(
productService
.
updateById
(
product
)
==
0
){
throw
new
Exception
(
"跟新数据
已失效
"
);
throw
new
Exception
(
"跟新数据
失败
"
);
}
}
}
catch
(
Exception
ex
)
{
txManager
.
rollback
(
status
);
logger
.
info
(
"订单 ID="
+
order
.
getId
()
+
" 数据
已经
更新,放弃自动确认收货"
);
logger
.
info
(
"订单 ID="
+
order
.
getId
()
+
" 数据更新
失败
,放弃自动确认收货"
);
return
;
}
txManager
.
commit
(
status
);
...
...
@@ -306,10 +312,13 @@ public class AdminOrderController {
if
(
expired
.
isAfter
(
now
))
{
continue
;
}
Integer
version
=
order
.
getVersion
();
// 设置订单已取消状态
order
.
setOrderStatus
(
OrderUtil
.
STATUS_AUTO_CONFIRM
);
order
.
setConfirmTime
(
now
);
if
(
orderService
.
updateById
(
order
)
==
0
){
if
(
orderService
.
updateById
WithVersion
(
version
,
order
)
==
0
){
logger
.
info
(
"订单 ID="
+
order
.
getId
()
+
" 数据已经更新,放弃自动确认收货"
);
}
else
{
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminStorageController.java
View file @
b95e4ca7
...
...
@@ -75,7 +75,7 @@ public class AdminStorageController {
return
ResponseUtil
.
unlogin
();
}
if
(
litemallStorageService
.
update
(
litemallStorage
)
==
0
){
return
ResponseUtil
.
updatedDat
eExpir
ed
();
return
ResponseUtil
.
updatedDat
aFail
ed
();
}
return
ResponseUtil
.
ok
(
litemallStorage
);
}
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminTopicController.java
View file @
b95e4ca7
...
...
@@ -99,7 +99,7 @@ public class AdminTopicController {
return
error
;
}
if
(
topicService
.
updateById
(
topic
)
==
0
){
return
ResponseUtil
.
updatedDat
eExpir
ed
();
return
ResponseUtil
.
updatedDat
aFail
ed
();
}
return
ResponseUtil
.
ok
(
topic
);
}
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminUserController.java
View file @
b95e4ca7
...
...
@@ -134,7 +134,7 @@ public class AdminUserController {
user
.
setPassword
(
encodedPassword
);
if
(
userService
.
updateById
(
user
)
==
0
){
return
ResponseUtil
.
updatedDat
eExpir
ed
();
return
ResponseUtil
.
updatedDat
aFail
ed
();
}
return
ResponseUtil
.
ok
(
user
);
}
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallAdService.java
View file @
b95e4ca7
...
...
@@ -57,7 +57,7 @@ public class LitemallAdService {
}
public
int
updateById
(
LitemallAd
ad
)
{
return
adMapper
.
update
WithVersion
ByPrimaryKeySelective
(
ad
.
getVersion
(),
ad
);
return
adMapper
.
updateByPrimaryKeySelective
(
ad
);
}
public
void
deleteById
(
Integer
id
)
{
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallAdminService.java
View file @
b95e4ca7
...
...
@@ -53,7 +53,7 @@ public class LitemallAdminService {
}
public
int
updateById
(
LitemallAdmin
admin
)
{
return
adminMapper
.
update
WithVersion
ByPrimaryKeySelective
(
admin
.
getVersion
(),
admin
);
return
adminMapper
.
updateByPrimaryKeySelective
(
admin
);
}
public
void
deleteById
(
Integer
id
)
{
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallBrandService.java
View file @
b95e4ca7
...
...
@@ -77,7 +77,7 @@ public class LitemallBrandService {
}
public
int
updateById
(
LitemallBrand
brand
)
{
return
brandMapper
.
update
WithVersion
ByPrimaryKeySelective
(
brand
.
getVersion
(),
brand
);
return
brandMapper
.
updateByPrimaryKeySelective
(
brand
);
}
public
void
deleteById
(
Integer
id
)
{
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCartService.java
View file @
b95e4ca7
...
...
@@ -26,7 +26,7 @@ public class LitemallCartService {
}
public
int
updateById
(
LitemallCart
cart
)
{
return
cartMapper
.
update
WithVersion
ByPrimaryKeySelective
(
cart
.
getVersion
(),
cart
);
return
cartMapper
.
updateByPrimaryKeySelective
(
cart
);
}
public
List
<
LitemallCart
>
queryByUid
(
int
userId
)
{
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCategoryService.java
View file @
b95e4ca7
...
...
@@ -87,7 +87,7 @@ public class LitemallCategoryService {
}
public
int
updateById
(
LitemallCategory
category
)
{
return
categoryMapper
.
update
WithVersion
ByPrimaryKeySelective
(
category
.
getVersion
(),
category
);
return
categoryMapper
.
updateByPrimaryKeySelective
(
category
);
}
public
void
deleteById
(
Integer
id
)
{
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGoodsService.java
View file @
b95e4ca7
...
...
@@ -223,7 +223,7 @@ public class LitemallGoodsService {
}
public
int
updateById
(
LitemallGoods
goods
)
{
return
goodsMapper
.
update
WithVersion
ByPrimaryKeySelective
(
goods
.
getVersion
(),
goods
);
return
goodsMapper
.
updateByPrimaryKeySelective
(
goods
);
}
public
void
deleteById
(
Integer
id
)
{
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGrouponRulesService.java
View file @
b95e4ca7
...
...
@@ -108,6 +108,6 @@ public class LitemallGrouponRulesService {
}
public
int
updateById
(
LitemallGrouponRules
grouponRules
)
{
return
mapper
.
update
WithVersion
ByPrimaryKeySelective
(
grouponRules
.
getVersion
(),
grouponRules
);
return
mapper
.
updateByPrimaryKeySelective
(
grouponRules
);
}
}
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGrouponService.java
View file @
b95e4ca7
...
...
@@ -91,7 +91,7 @@ public class LitemallGrouponService {
}
public
int
updateById
(
LitemallGroupon
groupon
)
{
return
mapper
.
update
WithVersion
ByPrimaryKeySelective
(
groupon
.
getVersion
(),
groupon
);
return
mapper
.
updateByPrimaryKeySelective
(
groupon
);
}
/**
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallIssueService.java
View file @
b95e4ca7
...
...
@@ -59,7 +59,7 @@ public class LitemallIssueService {
}
public
int
updateById
(
LitemallIssue
issue
)
{
return
issueMapper
.
update
WithVersion
ByPrimaryKeySelective
(
issue
.
getVersion
(),
issue
);
return
issueMapper
.
updateByPrimaryKeySelective
(
issue
);
}
public
LitemallIssue
findById
(
Integer
id
)
{
...
...
Prev
1
2
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