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
324c8da3
Unverified
Commit
324c8da3
authored
Dec 29, 2019
by
linlinjava
Committed by
GitHub
Dec 29, 2019
Browse files
Merge branch 'master' into dev
parents
693cf5cd
4c46da9b
Changes
399
Show whitespace changes
Inline
Side-by-side
Too many changes to show.
To preserve performance only
20 of 399+
files are displayed.
Plain diff
Email patch
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/job/OrderJob.java
View file @
324c8da3
...
...
@@ -3,12 +3,8 @@ package org.linlinjava.litemall.admin.job;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.core.system.SystemConfig
;
import
org.linlinjava.litemall.db.domain.LitemallGoodsProduct
;
import
org.linlinjava.litemall.db.domain.LitemallOrder
;
import
org.linlinjava.litemall.db.domain.LitemallOrderGoods
;
import
org.linlinjava.litemall.db.service.LitemallGoodsProductService
;
import
org.linlinjava.litemall.db.service.LitemallOrderGoodsService
;
import
org.linlinjava.litemall.db.service.LitemallOrderService
;
import
org.linlinjava.litemall.db.domain.*
;
import
org.linlinjava.litemall.db.service.*
;
import
org.linlinjava.litemall.db.util.OrderUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Scheduled
;
...
...
@@ -31,43 +27,10 @@ public class OrderJob {
private
LitemallOrderService
orderService
;
@Autowired
private
LitemallGoodsProductService
productService
;
/**
* 自动取消订单
* <p>
* 定时检查订单未付款情况,如果超时 LITEMALL_ORDER_UNPAID 分钟则自动取消订单
* 定时时间是每次相隔半个小时。
* <p>
* TODO
* 注意,因为是相隔半小时检查,因此导致订单真正超时时间是 [LITEMALL_ORDER_UNPAID, 30 + LITEMALL_ORDER_UNPAID]
*/
@Scheduled
(
fixedDelay
=
30
*
60
*
1000
)
@Transactional
public
void
checkOrderUnpaid
()
{
logger
.
info
(
"系统开启任务检查订单是否已经超期自动取消订单"
);
List
<
LitemallOrder
>
orderList
=
orderService
.
queryUnpaid
(
SystemConfig
.
getOrderUnpaid
());
for
(
LitemallOrder
order
:
orderList
)
{
// 设置订单已取消状态
order
.
setOrderStatus
(
OrderUtil
.
STATUS_AUTO_CANCEL
);
order
.
setEndTime
(
LocalDateTime
.
now
());
if
(
orderService
.
updateWithOptimisticLocker
(
order
)
==
0
)
{
throw
new
RuntimeException
(
"更新数据已失效"
);
}
// 商品货品数量增加
Integer
orderId
=
order
.
getId
();
List
<
LitemallOrderGoods
>
orderGoodsList
=
orderGoodsService
.
queryByOid
(
orderId
);
for
(
LitemallOrderGoods
orderGoods
:
orderGoodsList
)
{
Integer
productId
=
orderGoods
.
getProductId
();
Short
number
=
orderGoods
.
getNumber
();
if
(
productService
.
addStock
(
productId
,
number
)
==
0
)
{
throw
new
RuntimeException
(
"商品货品库存增加失败"
);
}
}
logger
.
info
(
"订单 ID="
+
order
.
getId
()
+
" 已经超期自动取消订单"
);
}
}
@Autowired
private
LitemallGrouponService
grouponService
;
@Autowired
private
LitemallGrouponRulesService
rulesService
;
/**
* 自动确认订单
...
...
@@ -80,7 +43,7 @@ public class OrderJob {
*/
@Scheduled
(
cron
=
"0 0 3 * * ?"
)
public
void
checkOrderUnconfirm
()
{
logger
.
info
(
"系统开启任务检查订单是否已经超期自动确认收货"
);
logger
.
info
(
"系统开启
定时
任务检查订单是否已经超期自动确认收货"
);
List
<
LitemallOrder
>
orderList
=
orderService
.
queryUnconfirm
(
SystemConfig
.
getOrderUnconfirm
());
for
(
LitemallOrder
order
:
orderList
)
{
...
...
@@ -109,7 +72,6 @@ public class OrderJob {
public
void
checkOrderComment
()
{
logger
.
info
(
"系统开启任务检查订单是否已经超期未评价"
);
LocalDateTime
now
=
LocalDateTime
.
now
();
List
<
LitemallOrder
>
orderList
=
orderService
.
queryComment
(
SystemConfig
.
getOrderComment
());
for
(
LitemallOrder
order
:
orderList
)
{
order
.
setComments
((
short
)
0
);
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/service/AdminGoodsService.java
View file @
324c8da3
package
org.linlinjava.litemall.admin.service
;
import
com.github.pagehelper.PageInfo
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.admin.dto.GoodsAllinone
;
...
...
@@ -40,21 +39,13 @@ public class AdminGoodsService {
private
LitemallBrandService
brandService
;
@Autowired
private
LitemallCartService
cartService
;
@Autowired
private
LitemallOrderGoodsService
orderGoodsService
;
@Autowired
private
QCodeService
qCodeService
;
public
Object
list
(
String
goodsSn
,
String
name
,
public
Object
list
(
Integer
goodsId
,
String
goodsSn
,
String
name
,
Integer
page
,
Integer
limit
,
String
sort
,
String
order
)
{
List
<
LitemallGoods
>
goodsList
=
goodsService
.
querySelective
(
goodsSn
,
name
,
page
,
limit
,
sort
,
order
);
long
total
=
PageInfo
.
of
(
goodsList
).
getTotal
();
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
goodsList
);
return
ResponseUtil
.
ok
(
data
);
List
<
LitemallGoods
>
goodsList
=
goodsService
.
querySelective
(
goodsId
,
goodsSn
,
name
,
page
,
limit
,
sort
,
order
);
return
ResponseUtil
.
okList
(
goodsList
);
}
private
Object
validate
(
GoodsAllinone
goodsAllinone
)
{
...
...
@@ -129,19 +120,25 @@ public class AdminGoodsService {
/**
* 编辑商品
* <p>
* TODO
* 目前商品修改的逻辑是
* 1. 更新litemall_goods表
* 2. 逻辑删除litemall_goods_specification、litemall_goods_attribute、litemall_goods_product
* 3. 添加litemall_goods_specification、litemall_goods_attribute、litemall_goods_product
* <p>
* 这里商品三个表的数据采用删除再添加的策略是因为
* 商品编辑页面,支持管理员添加删除商品规格、添加删除商品属性,因此这里仅仅更新是不可能的,
* 只能删除三个表旧的数据,然后添加新的数据。
* 但是这里又会引入新的问题,就是存在订单商品货品ID指向了失效的商品货品表。
* 因此这里会拒绝管理员编辑商品,如果订单或购物车中存在商品。
* 所以这里可能需要重新设计。
*
* NOTE:
* 由于商品涉及到四个表,特别是litemall_goods_product表依赖litemall_goods_specification表,
* 这导致允许所有字段都是可编辑会带来一些问题,因此这里商品编辑功能是受限制:
* (1)litemall_goods表可以编辑字段;
* (2)litemall_goods_specification表只能编辑pic_url字段,其他操作不支持;
* (3)litemall_goods_product表只能编辑price, number和url字段,其他操作不支持;
* (4)litemall_goods_attribute表支持编辑、添加和删除操作。
*
* NOTE2:
* 前后端这里使用了一个小技巧:
* 如果前端传来的update_time字段是空,则说明前端已经更新了某个记录,则这个记录会更新;
* 否则说明这个记录没有编辑过,无需更新该记录。
*
* NOTE3:
* (1)购物车缓存了一些商品信息,因此需要及时更新。
* 目前这些字段是goods_sn, goods_name, price, pic_url。
* (2)但是订单里面的商品信息则是不会更新。
* 如果订单是未支付订单,此时仍然以旧的价格支付。
*/
@Transactional
public
Object
update
(
GoodsAllinone
goodsAllinone
)
{
...
...
@@ -155,38 +152,62 @@ public class AdminGoodsService {
LitemallGoodsSpecification
[]
specifications
=
goodsAllinone
.
getSpecifications
();
LitemallGoodsProduct
[]
products
=
goodsAllinone
.
getProducts
();
Integer
id
=
goods
.
getId
();
//将生成的分享图片地址写入数据库
String
url
=
qCodeService
.
createGoodShareImage
(
goods
.
getId
().
toString
(),
goods
.
getPicUrl
(),
goods
.
getName
());
goods
.
setShareUrl
(
url
);
// 商品表里面有一个字段retailPrice记录当前商品的最低价
BigDecimal
retailPrice
=
new
BigDecimal
(
Integer
.
MAX_VALUE
);
for
(
LitemallGoodsProduct
product
:
products
)
{
BigDecimal
productPrice
=
product
.
getPrice
();
if
(
retailPrice
.
compareTo
(
productPrice
)
==
1
){
retailPrice
=
productPrice
;
}
}
goods
.
setRetailPrice
(
retailPrice
);
// 商品基本信息表litemall_goods
if
(
goodsService
.
updateById
(
goods
)
==
0
)
{
throw
new
RuntimeException
(
"更新数据失败"
);
}
Integer
gid
=
goods
.
getId
();
specificationService
.
deleteByGid
(
gid
);
attributeService
.
deleteByGid
(
gid
);
productService
.
deleteByGid
(
gid
);
// 商品规格表litemall_goods_specification
for
(
LitemallGoodsSpecification
specification
:
specifications
)
{
specification
.
setGoodsId
(
goods
.
getId
());
specificationService
.
add
(
specification
);
// 目前只支持更新规格表的图片字段
if
(
specification
.
getUpdateTime
()
==
null
){
specification
.
setSpecification
(
null
);
specification
.
setValue
(
null
);
specificationService
.
updateById
(
specification
);
}
}
// 商品货品表litemall_product
for
(
LitemallGoodsProduct
product
:
products
)
{
if
(
product
.
getUpdateTime
()
==
null
)
{
productService
.
updateById
(
product
);
}
}
// 商品参数表litemall_goods_attribute
for
(
LitemallGoodsAttribute
attribute
:
attributes
)
{
if
(
attribute
.
getId
()
==
null
||
attribute
.
getId
().
equals
(
0
)){
attribute
.
setGoodsId
(
goods
.
getId
());
attributeService
.
add
(
attribute
);
}
else
if
(
attribute
.
getDeleted
()){
attributeService
.
deleteById
(
attribute
.
getId
());
}
else
if
(
attribute
.
getUpdateTime
()
==
null
){
attributeService
.
updateById
(
attribute
);
}
}
// 商品货品表litemall_product
// 这里需要注意的是购物车litemall_cart有些字段是拷贝商品的一些字段,因此需要及时更新
// 目前这些字段是goods_sn, goods_name, price, pic_url
for
(
LitemallGoodsProduct
product
:
products
)
{
product
.
setGoodsId
(
goods
.
getId
());
productService
.
add
(
product
);
cartService
.
updateProduct
(
product
.
getId
(),
goods
.
getGoodsSn
(),
goods
.
getName
(),
product
.
getPrice
(),
product
.
getUrl
());
}
return
ResponseUtil
.
ok
();
...
...
@@ -224,6 +245,16 @@ public class AdminGoodsService {
return
ResponseUtil
.
fail
(
GOODS_NAME_EXIST
,
"商品名已经存在"
);
}
// 商品表里面有一个字段retailPrice记录当前商品的最低价
BigDecimal
retailPrice
=
new
BigDecimal
(
Integer
.
MAX_VALUE
);
for
(
LitemallGoodsProduct
product
:
products
)
{
BigDecimal
productPrice
=
product
.
getPrice
();
if
(
retailPrice
.
compareTo
(
productPrice
)
==
1
){
retailPrice
=
productPrice
;
}
}
goods
.
setRetailPrice
(
retailPrice
);
// 商品基本信息表litemall_goods
goodsService
.
add
(
goods
);
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/service/AdminOrderService.java
View file @
324c8da3
...
...
@@ -4,7 +4,6 @@ import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
import
com.github.binarywang.wxpay.bean.result.WxPayRefundResult
;
import
com.github.binarywang.wxpay.exception.WxPayException
;
import
com.github.binarywang.wxpay.service.WxPayService
;
import
com.github.pagehelper.PageInfo
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.core.notify.NotifyService
;
...
...
@@ -54,14 +53,9 @@ public class AdminOrderService {
public
Object
list
(
Integer
userId
,
String
orderSn
,
List
<
Short
>
orderStatusArray
,
Integer
page
,
Integer
limit
,
String
sort
,
String
order
)
{
List
<
LitemallOrder
>
orderList
=
orderService
.
querySelective
(
userId
,
orderSn
,
orderStatusArray
,
page
,
limit
,
sort
,
order
);
long
total
=
PageInfo
.
of
(
orderList
).
getTotal
();
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
orderList
);
return
ResponseUtil
.
ok
(
data
);
List
<
LitemallOrder
>
orderList
=
orderService
.
querySelective
(
userId
,
orderSn
,
orderStatusArray
,
page
,
limit
,
sort
,
order
);
return
ResponseUtil
.
okList
(
orderList
);
}
public
Object
detail
(
Integer
id
)
{
...
...
@@ -126,11 +120,11 @@ public class AdminOrderService {
wxPayRefundRequest
.
setTotalFee
(
totalFee
);
wxPayRefundRequest
.
setRefundFee
(
totalFee
);
WxPayRefundResult
wxPayRefundResult
=
null
;
WxPayRefundResult
wxPayRefundResult
;
try
{
wxPayRefundResult
=
wxPayService
.
refund
(
wxPayRefundRequest
);
}
catch
(
WxPayException
e
)
{
e
.
printStackTrace
(
);
logger
.
error
(
e
.
getMessage
(),
e
);
return
ResponseUtil
.
fail
(
ORDER_REFUND_FAILED
,
"订单退款失败"
);
}
if
(!
wxPayRefundResult
.
getReturnCode
().
equals
(
"SUCCESS"
))
{
...
...
@@ -142,8 +136,15 @@ public class AdminOrderService {
return
ResponseUtil
.
fail
(
ORDER_REFUND_FAILED
,
"订单退款失败"
);
}
LocalDateTime
now
=
LocalDateTime
.
now
();
// 设置订单取消状态
order
.
setOrderStatus
(
OrderUtil
.
STATUS_REFUND_CONFIRM
);
order
.
setEndTime
(
now
);
// 记录订单退款相关信息
order
.
setRefundAmount
(
order
.
getActualPrice
());
order
.
setRefundType
(
"微信退款接口"
);
order
.
setRefundContent
(
wxPayRefundResult
.
getRefundId
());
order
.
setRefundTime
(
now
);
if
(
orderService
.
updateWithOptimisticLocker
(
order
)
==
0
)
{
throw
new
RuntimeException
(
"更新数据已失效"
);
}
...
...
@@ -161,7 +162,8 @@ public class AdminOrderService {
//TODO 发送邮件和短信通知,这里采用异步发送
// 退款成功通知用户, 例如“您申请的订单退款 [ 单号:{1} ] 已成功,请耐心等待到账。”
// 注意订单号只发后6位
notifyService
.
notifySmsTemplate
(
order
.
getMobile
(),
NotifyType
.
REFUND
,
new
String
[]{
order
.
getOrderSn
().
substring
(
8
,
14
)});
notifyService
.
notifySmsTemplate
(
order
.
getMobile
(),
NotifyType
.
REFUND
,
new
String
[]{
order
.
getOrderSn
().
substring
(
8
,
14
)});
logHelper
.
logOrderSucceed
(
"退款"
,
"订单编号 "
+
orderId
);
return
ResponseUtil
.
ok
();
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/service/LogHelper.java
View file @
324c8da3
...
...
@@ -19,87 +19,86 @@ import javax.servlet.http.HttpServletRequest;
* 安全日志:用户安全相关的操作日志,例如登录、删除管理员
* 订单日志:用户交易相关的操作日志,例如订单发货、退款
* 其他日志:如果以上三种不合适,可以选择其他日志,建议是优先级最低的日志级别
*
*
<p>
* 当然可能很多操作是不需要记录到数据库的,例如编辑商品、编辑广告品之类。
*/
@Component
public
class
LogHelper
{
public
final
static
Integer
LOG_TYPE_GENERAL
=
0
;
public
final
static
Integer
LOG_TYPE_AUTH
=
1
;
public
final
static
Integer
LOG_TYPE_ORDER
=
2
;
public
final
static
Integer
LOG_TYPE_OTHER
=
3
;
public
static
final
Integer
LOG_TYPE_GENERAL
=
0
;
public
static
final
Integer
LOG_TYPE_AUTH
=
1
;
public
static
final
Integer
LOG_TYPE_ORDER
=
2
;
public
static
final
Integer
LOG_TYPE_OTHER
=
3
;
@Autowired
private
LitemallLogService
logService
;
public
void
logGeneralSucceed
(
String
action
){
public
void
logGeneralSucceed
(
String
action
)
{
logAdmin
(
LOG_TYPE_GENERAL
,
action
,
true
,
""
,
""
);
}
public
void
logGeneralSucceed
(
String
action
,
String
result
){
public
void
logGeneralSucceed
(
String
action
,
String
result
)
{
logAdmin
(
LOG_TYPE_GENERAL
,
action
,
true
,
result
,
""
);
}
public
void
logGeneralFail
(
String
action
,
String
error
){
public
void
logGeneralFail
(
String
action
,
String
error
)
{
logAdmin
(
LOG_TYPE_GENERAL
,
action
,
false
,
error
,
""
);
}
public
void
logAuthSucceed
(
String
action
){
public
void
logAuthSucceed
(
String
action
)
{
logAdmin
(
LOG_TYPE_AUTH
,
action
,
true
,
""
,
""
);
}
public
void
logAuthSucceed
(
String
action
,
String
result
){
public
void
logAuthSucceed
(
String
action
,
String
result
)
{
logAdmin
(
LOG_TYPE_AUTH
,
action
,
true
,
result
,
""
);
}
public
void
logAuthFail
(
String
action
,
String
error
){
public
void
logAuthFail
(
String
action
,
String
error
)
{
logAdmin
(
LOG_TYPE_AUTH
,
action
,
false
,
error
,
""
);
}
public
void
logOrderSucceed
(
String
action
){
public
void
logOrderSucceed
(
String
action
)
{
logAdmin
(
LOG_TYPE_ORDER
,
action
,
true
,
""
,
""
);
}
public
void
logOrderSucceed
(
String
action
,
String
result
){
public
void
logOrderSucceed
(
String
action
,
String
result
)
{
logAdmin
(
LOG_TYPE_ORDER
,
action
,
true
,
result
,
""
);
}
public
void
logOrderFail
(
String
action
,
String
error
){
public
void
logOrderFail
(
String
action
,
String
error
)
{
logAdmin
(
LOG_TYPE_ORDER
,
action
,
false
,
error
,
""
);
}
public
void
logOtherSucceed
(
String
action
){
public
void
logOtherSucceed
(
String
action
)
{
logAdmin
(
LOG_TYPE_OTHER
,
action
,
true
,
""
,
""
);
}
public
void
logOtherSucceed
(
String
action
,
String
result
){
public
void
logOtherSucceed
(
String
action
,
String
result
)
{
logAdmin
(
LOG_TYPE_OTHER
,
action
,
true
,
result
,
""
);
}
public
void
logOtherFail
(
String
action
,
String
error
){
public
void
logOtherFail
(
String
action
,
String
error
)
{
logAdmin
(
LOG_TYPE_OTHER
,
action
,
false
,
error
,
""
);
}
public
void
logAdmin
(
Integer
type
,
String
action
,
Boolean
succeed
,
String
result
,
String
comment
){
public
void
logAdmin
(
Integer
type
,
String
action
,
Boolean
succeed
,
String
result
,
String
comment
)
{
LitemallLog
log
=
new
LitemallLog
();
Subject
currentUser
=
SecurityUtils
.
getSubject
();
if
(
currentUser
!=
null
)
{
if
(
currentUser
!=
null
)
{
LitemallAdmin
admin
=
(
LitemallAdmin
)
currentUser
.
getPrincipal
();
if
(
admin
!=
null
)
{
if
(
admin
!=
null
)
{
log
.
setAdmin
(
admin
.
getUsername
());
}
else
{
}
else
{
log
.
setAdmin
(
"匿名用户"
);
}
}
else
{
}
else
{
log
.
setAdmin
(
"匿名用户"
);
}
HttpServletRequest
request
=
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
();
if
(
request
!=
null
)
{
HttpServletRequest
request
=
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
();
if
(
request
!=
null
)
{
log
.
setIp
(
IpUtil
.
getIpAddr
(
request
));
}
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/shiro/AdminAuthorizingRealm.java
View file @
324c8da3
...
...
@@ -12,8 +12,6 @@ import org.linlinjava.litemall.db.domain.LitemallAdmin;
import
org.linlinjava.litemall.db.service.LitemallAdminService
;
import
org.linlinjava.litemall.db.service.LitemallPermissionService
;
import
org.linlinjava.litemall.db.service.LitemallRoleService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.Assert
;
import
org.springframework.util.StringUtils
;
...
...
@@ -23,7 +21,6 @@ import java.util.Set;
public
class
AdminAuthorizingRealm
extends
AuthorizingRealm
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
AdminAuthorizingRealm
.
class
);
@Autowired
private
LitemallAdminService
adminService
;
@Autowired
...
...
@@ -52,7 +49,7 @@ public class AdminAuthorizingRealm extends AuthorizingRealm {
UsernamePasswordToken
upToken
=
(
UsernamePasswordToken
)
token
;
String
username
=
upToken
.
getUsername
();
String
password
=
new
String
(
upToken
.
getPassword
());
String
password
=
new
String
(
upToken
.
getPassword
());
if
(
StringUtils
.
isEmpty
(
username
))
{
throw
new
AccountException
(
"用户名不能为空"
);
...
...
@@ -64,16 +61,16 @@ public class AdminAuthorizingRealm extends AuthorizingRealm {
List
<
LitemallAdmin
>
adminList
=
adminService
.
findAdmin
(
username
);
Assert
.
state
(
adminList
.
size
()
<
2
,
"同一个用户名存在两个账户"
);
if
(
adminList
.
size
()
==
0
)
{
throw
new
UnknownAccountException
(
"找不到用户("
+
username
+
")的帐号信息"
);
throw
new
UnknownAccountException
(
"找不到用户("
+
username
+
")的帐号信息"
);
}
LitemallAdmin
admin
=
adminList
.
get
(
0
);
BCryptPasswordEncoder
encoder
=
new
BCryptPasswordEncoder
();
if
(!
encoder
.
matches
(
password
,
admin
.
getPassword
()))
{
throw
new
UnknownAccountException
(
"找不到用户("
+
username
+
")的帐号信息"
);
throw
new
UnknownAccountException
(
"找不到用户("
+
username
+
")的帐号信息"
);
}
return
new
SimpleAuthenticationInfo
(
admin
,
password
,
getName
());
return
new
SimpleAuthenticationInfo
(
admin
,
password
,
getName
());
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/shiro/AdminWebSessionManager.java
View file @
324c8da3
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/task/AdminTaskStartupRunner.java
0 → 100644
View file @
324c8da3
package
org.linlinjava.litemall.admin.task
;
import
org.linlinjava.litemall.core.task.TaskService
;
import
org.linlinjava.litemall.db.domain.LitemallGrouponRules
;
import
org.linlinjava.litemall.db.service.LitemallGrouponRulesService
;
import
org.linlinjava.litemall.db.util.GrouponConstant
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.ApplicationArguments
;
import
org.springframework.boot.ApplicationRunner
;
import
org.springframework.stereotype.Component
;
import
java.time.LocalDateTime
;
import
java.time.temporal.ChronoUnit
;
import
java.util.List
;
@Component
public
class
AdminTaskStartupRunner
implements
ApplicationRunner
{
@Autowired
private
LitemallGrouponRulesService
rulesService
;
@Autowired
private
TaskService
taskService
;
@Override
public
void
run
(
ApplicationArguments
args
)
throws
Exception
{
List
<
LitemallGrouponRules
>
grouponRulesList
=
rulesService
.
queryByStatus
(
GrouponConstant
.
RULE_STATUS_ON
);
for
(
LitemallGrouponRules
grouponRules
:
grouponRulesList
){
LocalDateTime
now
=
LocalDateTime
.
now
();
LocalDateTime
expire
=
grouponRules
.
getExpireTime
();
if
(
expire
.
isBefore
(
now
))
{
// 已经过期,则加入延迟队列
taskService
.
addTask
(
new
GrouponRuleExpiredTask
(
grouponRules
.
getId
(),
0
));
}
else
{
// 还没过期,则加入延迟队列
long
delay
=
ChronoUnit
.
MILLIS
.
between
(
now
,
expire
);
taskService
.
addTask
(
new
GrouponRuleExpiredTask
(
grouponRules
.
getId
(),
delay
));
}
}
}
}
\ No newline at end of file
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/task/GrouponRuleExpiredTask.java
0 → 100644
View file @
324c8da3
package
org.linlinjava.litemall.admin.task
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.core.task.Task
;
import
org.linlinjava.litemall.core.util.BeanUtil
;
import
org.linlinjava.litemall.db.domain.LitemallGroupon
;
import
org.linlinjava.litemall.db.domain.LitemallGrouponRules
;
import
org.linlinjava.litemall.db.domain.LitemallOrder
;
import
org.linlinjava.litemall.db.service.*
;
import
org.linlinjava.litemall.db.util.GrouponConstant
;
import
org.linlinjava.litemall.db.util.OrderUtil
;
import
java.util.List
;
public
class
GrouponRuleExpiredTask
extends
Task
{
private
final
Log
logger
=
LogFactory
.
getLog
(
GrouponRuleExpiredTask
.
class
);
private
int
grouponRuleId
=
-
1
;
public
GrouponRuleExpiredTask
(
Integer
grouponRuleId
,
long
delayInMilliseconds
){
super
(
"GrouponRuleExpiredTask-"
+
grouponRuleId
,
delayInMilliseconds
);
this
.
grouponRuleId
=
grouponRuleId
;
}
@Override
public
void
run
()
{
logger
.
info
(
"系统开始处理延时任务---团购规则过期---"
+
this
.
grouponRuleId
);
LitemallOrderService
orderService
=
BeanUtil
.
getBean
(
LitemallOrderService
.
class
);
LitemallGrouponService
grouponService
=
BeanUtil
.
getBean
(
LitemallGrouponService
.
class
);
LitemallGrouponRulesService
grouponRulesService
=
BeanUtil
.
getBean
(
LitemallGrouponRulesService
.
class
);
LitemallGrouponRules
grouponRules
=
grouponRulesService
.
findById
(
grouponRuleId
);
if
(
grouponRules
==
null
){
return
;
}
if
(!
grouponRules
.
getStatus
().
equals
(
GrouponConstant
.
RULE_STATUS_ON
)){
return
;
}
// 团购活动取消
grouponRules
.
setStatus
(
GrouponConstant
.
RULE_STATUS_DOWN_EXPIRE
);
grouponRulesService
.
updateById
(
grouponRules
);
List
<
LitemallGroupon
>
grouponList
=
grouponService
.
queryByRuleId
(
grouponRuleId
);
// 用户团购处理
for
(
LitemallGroupon
groupon
:
grouponList
){
Short
status
=
groupon
.
getStatus
();
LitemallOrder
order
=
orderService
.
findById
(
groupon
.
getOrderId
());
if
(
status
.
equals
(
GrouponConstant
.
STATUS_NONE
)){
groupon
.
setStatus
(
GrouponConstant
.
STATUS_FAIL
);
grouponService
.
updateById
(
groupon
);
}
else
if
(
status
.
equals
(
GrouponConstant
.
STATUS_ON
)){
// 如果团购进行中
// (1) 团购设置团购失败等待退款状态
groupon
.
setStatus
(
GrouponConstant
.
STATUS_FAIL
);
grouponService
.
updateById
(
groupon
);
// (2) 团购订单申请退款
if
(
OrderUtil
.
isPayStatus
(
order
))
{
order
.
setOrderStatus
(
OrderUtil
.
STATUS_REFUND
);
orderService
.
updateWithOptimisticLocker
(
order
);
}
}
}
logger
.
info
(
"系统结束处理延时任务---团购规则过期---"
+
this
.
grouponRuleId
);
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/util/AdminResponseCode.java
View file @
324c8da3
...
...
@@ -20,5 +20,8 @@ public class AdminResponseCode {
public
static
final
Integer
ROLE_NAME_EXIST
=
640
;
public
static
final
Integer
ROLE_SUPER_SUPERMISSION
=
641
;
public
static
final
Integer
ROLE_USER_EXIST
=
642
;
public
static
final
Integer
GROUPON_GOODS_UNKNOWN
=
650
;
public
static
final
Integer
GROUPON_GOODS_EXISTED
=
651
;
public
static
final
Integer
GROUPON_GOODS_OFFLINE
=
652
;
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/util/Permission.java
View file @
324c8da3
...
...
@@ -2,7 +2,6 @@ package org.linlinjava.litemall.admin.util;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.linlinjava.litemall.admin.annotation.RequiresPermissionsDesc
;
import
org.springframework.web.bind.annotation.RequestMapping
;
public
class
Permission
{
private
RequiresPermissions
requiresPermissions
;
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/util/PermissionUtil.java
View file @
324c8da3
...
...
@@ -74,8 +74,7 @@ public class PermissionUtil {
leftPerm
.
setLabel
(
requiresPermissionsDesc
.
button
());
leftPerm
.
setApi
(
api
);
perm2
.
getChildren
().
add
(
leftPerm
);
}
else
{
}
else
{
// TODO
// 目前限制Controller里面每个方法的RequiresPermissionsDesc注解是唯一的
// 如果允许相同,可能会造成内部权限不一致。
...
...
@@ -100,8 +99,10 @@ public class PermissionUtil {
RequestMapping
clazzRequestMapping
=
AnnotationUtils
.
findAnnotation
(
controllerClz
,
RequestMapping
.
class
);
List
<
Method
>
methods
=
MethodUtils
.
getMethodsListWithAnnotation
(
controllerClz
,
RequiresPermissions
.
class
);
for
(
Method
method
:
methods
)
{
RequiresPermissions
requiresPermissions
=
AnnotationUtils
.
getAnnotation
(
method
,
RequiresPermissions
.
class
);
RequiresPermissionsDesc
requiresPermissionsDesc
=
AnnotationUtils
.
getAnnotation
(
method
,
RequiresPermissionsDesc
.
class
);
RequiresPermissions
requiresPermissions
=
AnnotationUtils
.
getAnnotation
(
method
,
RequiresPermissions
.
class
);
RequiresPermissionsDesc
requiresPermissionsDesc
=
AnnotationUtils
.
getAnnotation
(
method
,
RequiresPermissionsDesc
.
class
);
if
(
requiresPermissions
==
null
||
requiresPermissionsDesc
==
null
)
{
continue
;
...
...
@@ -143,7 +144,7 @@ public class PermissionUtil {
public
static
Set
<
String
>
listPermissionString
(
List
<
Permission
>
permissions
)
{
Set
<
String
>
permissionsString
=
new
HashSet
<>();
for
(
Permission
permission
:
permissions
){
for
(
Permission
permission
:
permissions
)
{
permissionsString
.
add
(
permission
.
getRequiresPermissions
().
value
()[
0
]);
}
return
permissionsString
;
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminAdController.java
View file @
324c8da3
package
org.linlinjava.litemall.admin.web
;
import
com.github.pagehelper.PageInfo
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
...
...
@@ -16,9 +15,7 @@ import org.springframework.validation.annotation.Validated;
import
org.springframework.web.bind.annotation.*
;
import
javax.validation.constraints.NotNull
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/admin/ad"
)
...
...
@@ -30,7 +27,7 @@ public class AdminAdController {
private
LitemallAdService
adService
;
@RequiresPermissions
(
"admin:ad:list"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"广告管理"
},
button
=
"查询"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"广告管理"
},
button
=
"查询"
)
@GetMapping
(
"/list"
)
public
Object
list
(
String
name
,
String
content
,
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
...
...
@@ -38,12 +35,7 @@ public class AdminAdController {
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
List
<
LitemallAd
>
adList
=
adService
.
querySelective
(
name
,
content
,
page
,
limit
,
sort
,
order
);
long
total
=
PageInfo
.
of
(
adList
).
getTotal
();
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
adList
);
return
ResponseUtil
.
ok
(
data
);
return
ResponseUtil
.
okList
(
adList
);
}
private
Object
validate
(
LitemallAd
ad
)
{
...
...
@@ -59,7 +51,7 @@ public class AdminAdController {
}
@RequiresPermissions
(
"admin:ad:create"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"广告管理"
},
button
=
"添加"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"广告管理"
},
button
=
"添加"
)
@PostMapping
(
"/create"
)
public
Object
create
(
@RequestBody
LitemallAd
ad
)
{
Object
error
=
validate
(
ad
);
...
...
@@ -71,15 +63,15 @@ public class AdminAdController {
}
@RequiresPermissions
(
"admin:ad:read"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"广告管理"
},
button
=
"详情"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"广告管理"
},
button
=
"详情"
)
@GetMapping
(
"/read"
)
public
Object
read
(
@NotNull
Integer
id
)
{
LitemallAd
bran
d
=
adService
.
findById
(
id
);
return
ResponseUtil
.
ok
(
bran
d
);
LitemallAd
a
d
=
adService
.
findById
(
id
);
return
ResponseUtil
.
ok
(
a
d
);
}
@RequiresPermissions
(
"admin:ad:update"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"广告管理"
},
button
=
"编辑"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"广告管理"
},
button
=
"编辑"
)
@PostMapping
(
"/update"
)
public
Object
update
(
@RequestBody
LitemallAd
ad
)
{
Object
error
=
validate
(
ad
);
...
...
@@ -94,7 +86,7 @@ public class AdminAdController {
}
@RequiresPermissions
(
"admin:ad:delete"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"广告管理"
},
button
=
"删除"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"广告管理"
},
button
=
"删除"
)
@PostMapping
(
"/delete"
)
public
Object
delete
(
@RequestBody
LitemallAd
ad
)
{
Integer
id
=
ad
.
getId
();
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminAddressController.java
View file @
324c8da3
package
org.linlinjava.litemall.admin.web
;
import
com.github.pagehelper.PageInfo
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
...
...
@@ -18,10 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/admin/address"
)
...
...
@@ -35,7 +31,7 @@ public class AdminAddressController {
private
LitemallRegionService
regionService
;
@RequiresPermissions
(
"admin:address:list"
)
@RequiresPermissionsDesc
(
menu
=
{
"用户管理"
,
"收货地址"
},
button
=
"查询"
)
@RequiresPermissionsDesc
(
menu
=
{
"用户管理"
,
"收货地址"
},
button
=
"查询"
)
@GetMapping
(
"/list"
)
public
Object
list
(
Integer
userId
,
String
name
,
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
...
...
@@ -44,13 +40,6 @@ public class AdminAddressController {
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
List
<
LitemallAddress
>
addressList
=
addressService
.
querySelective
(
userId
,
name
,
page
,
limit
,
sort
,
order
);
long
total
=
PageInfo
.
of
(
addressList
).
getTotal
();
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
addressList
);
return
ResponseUtil
.
ok
(
data
);
return
ResponseUtil
.
okList
(
addressList
);
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminAdminController.java
View file @
324c8da3
package
org.linlinjava.litemall.admin.web
;
import
com.github.pagehelper.PageInfo
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.apache.shiro.SecurityUtils
;
...
...
@@ -21,9 +20,7 @@ import org.springframework.validation.annotation.Validated;
import
org.springframework.web.bind.annotation.*
;
import
javax.validation.constraints.NotNull
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
static
org
.
linlinjava
.
litemall
.
admin
.
util
.
AdminResponseCode
.*;
...
...
@@ -39,7 +36,7 @@ public class AdminAdminController {
private
LogHelper
logHelper
;
@RequiresPermissions
(
"admin:admin:list"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"管理员管理"
},
button
=
"查询"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"管理员管理"
},
button
=
"查询"
)
@GetMapping
(
"/list"
)
public
Object
list
(
String
username
,
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
...
...
@@ -47,12 +44,7 @@ public class AdminAdminController {
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
List
<
LitemallAdmin
>
adminList
=
adminService
.
querySelective
(
username
,
page
,
limit
,
sort
,
order
);
long
total
=
PageInfo
.
of
(
adminList
).
getTotal
();
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
adminList
);
return
ResponseUtil
.
ok
(
data
);
return
ResponseUtil
.
okList
(
adminList
);
}
private
Object
validate
(
LitemallAdmin
admin
)
{
...
...
@@ -71,7 +63,7 @@ public class AdminAdminController {
}
@RequiresPermissions
(
"admin:admin:create"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"管理员管理"
},
button
=
"添加"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"管理员管理"
},
button
=
"添加"
)
@PostMapping
(
"/create"
)
public
Object
create
(
@RequestBody
LitemallAdmin
admin
)
{
Object
error
=
validate
(
admin
);
...
...
@@ -95,7 +87,7 @@ public class AdminAdminController {
}
@RequiresPermissions
(
"admin:admin:read"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"管理员管理"
},
button
=
"详情"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"管理员管理"
},
button
=
"详情"
)
@GetMapping
(
"/read"
)
public
Object
read
(
@NotNull
Integer
id
)
{
LitemallAdmin
admin
=
adminService
.
findById
(
id
);
...
...
@@ -103,7 +95,7 @@ public class AdminAdminController {
}
@RequiresPermissions
(
"admin:admin:update"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"管理员管理"
},
button
=
"编辑"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"管理员管理"
},
button
=
"编辑"
)
@PostMapping
(
"/update"
)
public
Object
update
(
@RequestBody
LitemallAdmin
admin
)
{
Object
error
=
validate
(
admin
);
...
...
@@ -128,7 +120,7 @@ public class AdminAdminController {
}
@RequiresPermissions
(
"admin:admin:delete"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"管理员管理"
},
button
=
"删除"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"管理员管理"
},
button
=
"删除"
)
@PostMapping
(
"/delete"
)
public
Object
delete
(
@RequestBody
LitemallAdmin
admin
)
{
Integer
anotherAdminId
=
admin
.
getId
();
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminAuthController.java
View file @
324c8da3
...
...
@@ -16,9 +16,7 @@ import org.linlinjava.litemall.core.util.IpUtil;
import
org.linlinjava.litemall.core.util.JacksonUtil
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.db.domain.LitemallAdmin
;
import
org.linlinjava.litemall.db.domain.LitemallLog
;
import
org.linlinjava.litemall.db.service.LitemallAdminService
;
import
org.linlinjava.litemall.db.service.LitemallLogService
;
import
org.linlinjava.litemall.db.service.LitemallPermissionService
;
import
org.linlinjava.litemall.db.service.LitemallRoleService
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -82,7 +80,16 @@ public class AdminAuthController {
adminService
.
updateById
(
admin
);
logHelper
.
logAuthSucceed
(
"登录"
);
return
ResponseUtil
.
ok
(
currentUser
.
getSession
().
getId
());
// userInfo
Map
<
String
,
Object
>
adminInfo
=
new
HashMap
<
String
,
Object
>();
adminInfo
.
put
(
"nickName"
,
admin
.
getUsername
());
adminInfo
.
put
(
"avatar"
,
admin
.
getAvatar
());
Map
<
Object
,
Object
>
result
=
new
HashMap
<
Object
,
Object
>();
result
.
put
(
"token"
,
currentUser
.
getSession
().
getId
());
result
.
put
(
"adminInfo"
,
adminInfo
);
return
ResponseUtil
.
ok
(
result
);
}
/*
...
...
@@ -115,7 +122,7 @@ public class AdminAuthController {
data
.
put
(
"roles"
,
roles
);
// NOTE
// 这里需要转换perms结构,因为对于前端而已API形式的权限更容易理解
data
.
put
(
"perms"
,
toA
PI
(
permissions
));
data
.
put
(
"perms"
,
toA
pi
(
permissions
));
return
ResponseUtil
.
ok
(
data
);
}
...
...
@@ -123,7 +130,7 @@ public class AdminAuthController {
private
ApplicationContext
context
;
private
HashMap
<
String
,
String
>
systemPermissionsMap
=
null
;
private
Collection
<
String
>
toA
PI
(
Set
<
String
>
permissions
)
{
private
Collection
<
String
>
toA
pi
(
Set
<
String
>
permissions
)
{
if
(
systemPermissionsMap
==
null
)
{
systemPermissionsMap
=
new
HashMap
<>();
final
String
basicPackage
=
"org.linlinjava.litemall.admin"
;
...
...
@@ -144,7 +151,7 @@ public class AdminAuthController {
apis
.
clear
();
apis
.
add
(
"*"
);
return
apis
;
// return systemPermissionsMap.values();
// return systemPermissionsMap.values();
}
}
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminBrandController.java
View file @
324c8da3
package
org.linlinjava.litemall.admin.web
;
import
com.github.pagehelper.PageInfo
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
...
...
@@ -17,9 +16,7 @@ import org.springframework.web.bind.annotation.*;
import
javax.validation.constraints.NotNull
;
import
java.math.BigDecimal
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/admin/brand"
)
...
...
@@ -31,7 +28,7 @@ public class AdminBrandController {
private
LitemallBrandService
brandService
;
@RequiresPermissions
(
"admin:brand:list"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"品牌管理"
},
button
=
"查询"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"品牌管理"
},
button
=
"查询"
)
@GetMapping
(
"/list"
)
public
Object
list
(
String
id
,
String
name
,
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
...
...
@@ -39,12 +36,7 @@ public class AdminBrandController {
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
List
<
LitemallBrand
>
brandList
=
brandService
.
querySelective
(
id
,
name
,
page
,
limit
,
sort
,
order
);
long
total
=
PageInfo
.
of
(
brandList
).
getTotal
();
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
brandList
);
return
ResponseUtil
.
ok
(
data
);
return
ResponseUtil
.
okList
(
brandList
);
}
private
Object
validate
(
LitemallBrand
brand
)
{
...
...
@@ -66,7 +58,7 @@ public class AdminBrandController {
}
@RequiresPermissions
(
"admin:brand:create"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"品牌管理"
},
button
=
"添加"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"品牌管理"
},
button
=
"添加"
)
@PostMapping
(
"/create"
)
public
Object
create
(
@RequestBody
LitemallBrand
brand
)
{
Object
error
=
validate
(
brand
);
...
...
@@ -78,7 +70,7 @@ public class AdminBrandController {
}
@RequiresPermissions
(
"admin:brand:read"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"品牌管理"
},
button
=
"详情"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"品牌管理"
},
button
=
"详情"
)
@GetMapping
(
"/read"
)
public
Object
read
(
@NotNull
Integer
id
)
{
LitemallBrand
brand
=
brandService
.
findById
(
id
);
...
...
@@ -86,7 +78,7 @@ public class AdminBrandController {
}
@RequiresPermissions
(
"admin:brand:update"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"品牌管理"
},
button
=
"编辑"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"品牌管理"
},
button
=
"编辑"
)
@PostMapping
(
"/update"
)
public
Object
update
(
@RequestBody
LitemallBrand
brand
)
{
Object
error
=
validate
(
brand
);
...
...
@@ -100,7 +92,7 @@ public class AdminBrandController {
}
@RequiresPermissions
(
"admin:brand:delete"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"品牌管理"
},
button
=
"删除"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"品牌管理"
},
button
=
"删除"
)
@PostMapping
(
"/delete"
)
public
Object
delete
(
@RequestBody
LitemallBrand
brand
)
{
Integer
id
=
brand
.
getId
();
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminCategoryController.java
View file @
324c8da3
...
...
@@ -29,13 +29,13 @@ public class AdminCategoryController {
private
LitemallCategoryService
categoryService
;
@RequiresPermissions
(
"admin:category:list"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"类目管理"
},
button
=
"查询"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"类目管理"
},
button
=
"查询"
)
@GetMapping
(
"/list"
)
public
Object
list
()
{
List
<
CategoryVo
>
categoryVoList
=
new
ArrayList
<>();
List
<
LitemallCategory
>
categoryList
=
categoryService
.
queryByPid
(
0
);
for
(
LitemallCategory
category
:
categoryList
){
for
(
LitemallCategory
category
:
categoryList
)
{
CategoryVo
categoryVO
=
new
CategoryVo
();
categoryVO
.
setId
(
category
.
getId
());
categoryVO
.
setDesc
(
category
.
getDesc
());
...
...
@@ -47,7 +47,7 @@ public class AdminCategoryController {
List
<
CategoryVo
>
children
=
new
ArrayList
<>();
List
<
LitemallCategory
>
subCategoryList
=
categoryService
.
queryByPid
(
category
.
getId
());
for
(
LitemallCategory
subCategory
:
subCategoryList
){
for
(
LitemallCategory
subCategory
:
subCategoryList
)
{
CategoryVo
subCategoryVo
=
new
CategoryVo
();
subCategoryVo
.
setId
(
subCategory
.
getId
());
subCategoryVo
.
setDesc
(
subCategory
.
getDesc
());
...
...
@@ -64,7 +64,7 @@ public class AdminCategoryController {
categoryVoList
.
add
(
categoryVO
);
}
return
ResponseUtil
.
ok
(
categoryVoList
);
return
ResponseUtil
.
ok
List
(
categoryVoList
);
}
private
Object
validate
(
LitemallCategory
category
)
{
...
...
@@ -90,7 +90,7 @@ public class AdminCategoryController {
}
@RequiresPermissions
(
"admin:category:create"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"类目管理"
},
button
=
"添加"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"类目管理"
},
button
=
"添加"
)
@PostMapping
(
"/create"
)
public
Object
create
(
@RequestBody
LitemallCategory
category
)
{
Object
error
=
validate
(
category
);
...
...
@@ -102,7 +102,7 @@ public class AdminCategoryController {
}
@RequiresPermissions
(
"admin:category:read"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"类目管理"
},
button
=
"详情"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"类目管理"
},
button
=
"详情"
)
@GetMapping
(
"/read"
)
public
Object
read
(
@NotNull
Integer
id
)
{
LitemallCategory
category
=
categoryService
.
findById
(
id
);
...
...
@@ -110,7 +110,7 @@ public class AdminCategoryController {
}
@RequiresPermissions
(
"admin:category:update"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"类目管理"
},
button
=
"编辑"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"类目管理"
},
button
=
"编辑"
)
@PostMapping
(
"/update"
)
public
Object
update
(
@RequestBody
LitemallCategory
category
)
{
Object
error
=
validate
(
category
);
...
...
@@ -125,7 +125,7 @@ public class AdminCategoryController {
}
@RequiresPermissions
(
"admin:category:delete"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"类目管理"
},
button
=
"删除"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"类目管理"
},
button
=
"删除"
)
@PostMapping
(
"/delete"
)
public
Object
delete
(
@RequestBody
LitemallCategory
category
)
{
Integer
id
=
category
.
getId
();
...
...
@@ -148,6 +148,6 @@ public class AdminCategoryController {
d
.
put
(
"label"
,
category
.
getName
());
data
.
add
(
d
);
}
return
ResponseUtil
.
ok
(
data
);
return
ResponseUtil
.
ok
List
(
data
);
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminCollectController.java
View file @
324c8da3
package
org.linlinjava.litemall.admin.web
;
import
com.github.pagehelper.PageInfo
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
...
...
@@ -17,9 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/admin/collect"
)
...
...
@@ -32,7 +29,7 @@ public class AdminCollectController {
@RequiresPermissions
(
"admin:collect:list"
)
@RequiresPermissionsDesc
(
menu
=
{
"用户管理"
,
"用户收藏"
},
button
=
"查询"
)
@RequiresPermissionsDesc
(
menu
=
{
"用户管理"
,
"用户收藏"
},
button
=
"查询"
)
@GetMapping
(
"/list"
)
public
Object
list
(
String
userId
,
String
valueId
,
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
...
...
@@ -40,11 +37,6 @@ public class AdminCollectController {
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
List
<
LitemallCollect
>
collectList
=
collectService
.
querySelective
(
userId
,
valueId
,
page
,
limit
,
sort
,
order
);
long
total
=
PageInfo
.
of
(
collectList
).
getTotal
();
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
collectList
);
return
ResponseUtil
.
ok
(
data
);
return
ResponseUtil
.
okList
(
collectList
);
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminCommentController.java
View file @
324c8da3
package
org.linlinjava.litemall.admin.web
;
import
com.github.pagehelper.PageInfo
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
...
...
@@ -14,9 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/admin/comment"
)
...
...
@@ -28,24 +25,19 @@ public class AdminCommentController {
private
LitemallCommentService
commentService
;
@RequiresPermissions
(
"admin:comment:list"
)
@RequiresPermissionsDesc
(
menu
=
{
"商品管理"
,
"评论管理"
},
button
=
"查询"
)
@RequiresPermissionsDesc
(
menu
=
{
"商品管理"
,
"评论管理"
},
button
=
"查询"
)
@GetMapping
(
"/list"
)
public
Object
list
(
String
userId
,
String
valueId
,
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
defaultValue
=
"10"
)
Integer
limit
,
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
List
<
LitemallComment
>
brandList
=
commentService
.
querySelective
(
userId
,
valueId
,
page
,
limit
,
sort
,
order
);
long
total
=
PageInfo
.
of
(
brandList
).
getTotal
();
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
brandList
);
return
ResponseUtil
.
ok
(
data
);
List
<
LitemallComment
>
commentList
=
commentService
.
querySelective
(
userId
,
valueId
,
page
,
limit
,
sort
,
order
);
return
ResponseUtil
.
okList
(
commentList
);
}
@RequiresPermissions
(
"admin:comment:delete"
)
@RequiresPermissionsDesc
(
menu
=
{
"商品管理"
,
"评论管理"
},
button
=
"删除"
)
@RequiresPermissionsDesc
(
menu
=
{
"商品管理"
,
"评论管理"
},
button
=
"删除"
)
@PostMapping
(
"/delete"
)
public
Object
delete
(
@RequestBody
LitemallComment
comment
)
{
Integer
id
=
comment
.
getId
();
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminConfigController.java
View file @
324c8da3
...
...
@@ -24,7 +24,7 @@ public class AdminConfigController {
private
LitemallSystemConfigService
systemConfigService
;
@RequiresPermissions
(
"admin:config:mall:list"
)
@RequiresPermissionsDesc
(
menu
=
{
"配置管理"
,
"商场配置"
},
button
=
"详情"
)
@RequiresPermissionsDesc
(
menu
=
{
"配置管理"
,
"商场配置"
},
button
=
"详情"
)
@GetMapping
(
"/mall"
)
public
Object
listMall
()
{
Map
<
String
,
String
>
data
=
systemConfigService
.
listMail
();
...
...
@@ -32,9 +32,9 @@ public class AdminConfigController {
}
@RequiresPermissions
(
"admin:config:mall:updateConfigs"
)
@RequiresPermissionsDesc
(
menu
=
{
"配置管理"
,
"商场配置"
},
button
=
"编辑"
)
@RequiresPermissionsDesc
(
menu
=
{
"配置管理"
,
"商场配置"
},
button
=
"编辑"
)
@PostMapping
(
"/mall"
)
public
Object
updateMall
(
@RequestBody
String
body
)
{
public
Object
updateMall
(
@RequestBody
String
body
)
{
Map
<
String
,
String
>
data
=
JacksonUtil
.
toMap
(
body
);
systemConfigService
.
updateConfig
(
data
);
SystemConfig
.
updateConfigs
(
data
);
...
...
@@ -42,7 +42,7 @@ public class AdminConfigController {
}
@RequiresPermissions
(
"admin:config:express:list"
)
@RequiresPermissionsDesc
(
menu
=
{
"配置管理"
,
"运费配置"
},
button
=
"详情"
)
@RequiresPermissionsDesc
(
menu
=
{
"配置管理"
,
"运费配置"
},
button
=
"详情"
)
@GetMapping
(
"/express"
)
public
Object
listExpress
()
{
Map
<
String
,
String
>
data
=
systemConfigService
.
listExpress
();
...
...
@@ -50,7 +50,7 @@ public class AdminConfigController {
}
@RequiresPermissions
(
"admin:config:express:updateConfigs"
)
@RequiresPermissionsDesc
(
menu
=
{
"配置管理"
,
"运费配置"
},
button
=
"编辑"
)
@RequiresPermissionsDesc
(
menu
=
{
"配置管理"
,
"运费配置"
},
button
=
"编辑"
)
@PostMapping
(
"/express"
)
public
Object
updateExpress
(
@RequestBody
String
body
)
{
Map
<
String
,
String
>
data
=
JacksonUtil
.
toMap
(
body
);
...
...
@@ -60,7 +60,7 @@ public class AdminConfigController {
}
@RequiresPermissions
(
"admin:config:order:list"
)
@RequiresPermissionsDesc
(
menu
=
{
"配置管理"
,
"订单配置"
},
button
=
"详情"
)
@RequiresPermissionsDesc
(
menu
=
{
"配置管理"
,
"订单配置"
},
button
=
"详情"
)
@GetMapping
(
"/order"
)
public
Object
lisOrder
()
{
Map
<
String
,
String
>
data
=
systemConfigService
.
listOrder
();
...
...
@@ -68,7 +68,7 @@ public class AdminConfigController {
}
@RequiresPermissions
(
"admin:config:order:updateConfigs"
)
@RequiresPermissionsDesc
(
menu
=
{
"配置管理"
,
"订单配置"
},
button
=
"编辑"
)
@RequiresPermissionsDesc
(
menu
=
{
"配置管理"
,
"订单配置"
},
button
=
"编辑"
)
@PostMapping
(
"/order"
)
public
Object
updateOrder
(
@RequestBody
String
body
)
{
Map
<
String
,
String
>
data
=
JacksonUtil
.
toMap
(
body
);
...
...
@@ -77,7 +77,7 @@ public class AdminConfigController {
}
@RequiresPermissions
(
"admin:config:wx:list"
)
@RequiresPermissionsDesc
(
menu
=
{
"配置管理"
,
"小程序配置"
},
button
=
"详情"
)
@RequiresPermissionsDesc
(
menu
=
{
"配置管理"
,
"小程序配置"
},
button
=
"详情"
)
@GetMapping
(
"/wx"
)
public
Object
listWx
()
{
Map
<
String
,
String
>
data
=
systemConfigService
.
listWx
();
...
...
@@ -85,7 +85,7 @@ public class AdminConfigController {
}
@RequiresPermissions
(
"admin:config:wx:updateConfigs"
)
@RequiresPermissionsDesc
(
menu
=
{
"配置管理"
,
"小程序配置"
},
button
=
"编辑"
)
@RequiresPermissionsDesc
(
menu
=
{
"配置管理"
,
"小程序配置"
},
button
=
"编辑"
)
@PostMapping
(
"/wx"
)
public
Object
updateWx
(
@RequestBody
String
body
)
{
Map
<
String
,
String
>
data
=
JacksonUtil
.
toMap
(
body
);
...
...
Prev
1
2
3
4
5
6
7
…
20
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