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
393
Hide whitespace changes
Inline
Side-by-side
Too many changes to show.
To preserve performance only
20 of 393+
files are displayed.
Plain diff
Email patch
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminCouponController.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
;
...
...
@@ -19,9 +18,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/coupon"
)
...
...
@@ -35,7 +32,7 @@ public class AdminCouponController {
private
LitemallCouponUserService
couponUserService
;
@RequiresPermissions
(
"admin:coupon:list"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"优惠券管理"
},
button
=
"查询"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"优惠券管理"
},
button
=
"查询"
)
@GetMapping
(
"/list"
)
public
Object
list
(
String
name
,
Short
type
,
Short
status
,
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
...
...
@@ -43,41 +40,32 @@ public class AdminCouponController {
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
List
<
LitemallCoupon
>
couponList
=
couponService
.
querySelective
(
name
,
type
,
status
,
page
,
limit
,
sort
,
order
);
long
total
=
PageInfo
.
of
(
couponList
).
getTotal
();
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
couponList
);
return
ResponseUtil
.
ok
(
data
);
return
ResponseUtil
.
okList
(
couponList
);
}
@RequiresPermissions
(
"admin:coupon:listuser"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"优惠券管理"
},
button
=
"查询用户"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"优惠券管理"
},
button
=
"查询用户"
)
@GetMapping
(
"/listuser"
)
public
Object
listuser
(
Integer
userId
,
Integer
couponId
,
Short
status
,
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
defaultValue
=
"10"
)
Integer
limit
,
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
List
<
LitemallCouponUser
>
couponList
=
couponUserService
.
queryList
(
userId
,
couponId
,
status
,
page
,
limit
,
sort
,
order
);
long
total
=
PageInfo
.
of
(
couponList
).
getTotal
();
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
couponList
);
return
ResponseUtil
.
ok
(
data
);
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
defaultValue
=
"10"
)
Integer
limit
,
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
List
<
LitemallCouponUser
>
couponList
=
couponUserService
.
queryList
(
userId
,
couponId
,
status
,
page
,
limit
,
sort
,
order
);
return
ResponseUtil
.
okList
(
couponList
);
}
private
Object
validate
(
LitemallCoupon
coupon
)
{
String
name
=
coupon
.
getName
();
if
(
StringUtils
.
isEmpty
(
name
)){
if
(
StringUtils
.
isEmpty
(
name
))
{
return
ResponseUtil
.
badArgument
();
}
return
null
;
}
@RequiresPermissions
(
"admin:coupon:create"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"优惠券管理"
},
button
=
"添加"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"优惠券管理"
},
button
=
"添加"
)
@PostMapping
(
"/create"
)
public
Object
create
(
@RequestBody
LitemallCoupon
coupon
)
{
Object
error
=
validate
(
coupon
);
...
...
@@ -86,7 +74,7 @@ public class AdminCouponController {
}
// 如果是兑换码类型,则这里需要生存一个兑换码
if
(
coupon
.
getType
().
equals
(
CouponConstant
.
TYPE_CODE
)){
if
(
coupon
.
getType
().
equals
(
CouponConstant
.
TYPE_CODE
))
{
String
code
=
couponService
.
generateCode
();
coupon
.
setCode
(
code
);
}
...
...
@@ -96,7 +84,7 @@ public class AdminCouponController {
}
@RequiresPermissions
(
"admin:coupon:read"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"优惠券管理"
},
button
=
"详情"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"优惠券管理"
},
button
=
"详情"
)
@GetMapping
(
"/read"
)
public
Object
read
(
@NotNull
Integer
id
)
{
LitemallCoupon
coupon
=
couponService
.
findById
(
id
);
...
...
@@ -104,7 +92,7 @@ public class AdminCouponController {
}
@RequiresPermissions
(
"admin:coupon:update"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"优惠券管理"
},
button
=
"编辑"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"优惠券管理"
},
button
=
"编辑"
)
@PostMapping
(
"/update"
)
public
Object
update
(
@RequestBody
LitemallCoupon
coupon
)
{
Object
error
=
validate
(
coupon
);
...
...
@@ -118,7 +106,7 @@ public class AdminCouponController {
}
@RequiresPermissions
(
"admin:coupon:delete"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"优惠券管理"
},
button
=
"删除"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"优惠券管理"
},
button
=
"删除"
)
@PostMapping
(
"/delete"
)
public
Object
delete
(
@RequestBody
LitemallCoupon
coupon
)
{
couponService
.
deleteById
(
coupon
.
getId
());
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminFeedbackController.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
;
/**
* @author Yogeek
...
...
@@ -35,19 +32,15 @@ public class AdminFeedbackController {
private
LitemallFeedbackService
feedbackService
;
@RequiresPermissions
(
"admin:feedback:list"
)
@RequiresPermissionsDesc
(
menu
=
{
"用户管理"
,
"意见反馈"
},
button
=
"查询"
)
@RequiresPermissionsDesc
(
menu
=
{
"用户管理"
,
"意见反馈"
},
button
=
"查询"
)
@GetMapping
(
"/list"
)
public
Object
list
(
Integer
userId
,
String
username
,
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
defaultValue
=
"10"
)
Integer
limit
,
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
List
<
LitemallFeedback
>
feedbackList
=
feedbackService
.
querySelective
(
userId
,
username
,
page
,
limit
,
sort
,
order
);
long
total
=
PageInfo
.
of
(
feedbackList
).
getTotal
();
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
feedbackList
);
return
ResponseUtil
.
ok
(
data
);
List
<
LitemallFeedback
>
feedbackList
=
feedbackService
.
querySelective
(
userId
,
username
,
page
,
limit
,
sort
,
order
);
return
ResponseUtil
.
okList
(
feedbackList
);
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminFootprintController.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/footprint"
)
...
...
@@ -31,19 +28,15 @@ public class AdminFootprintController {
private
LitemallFootprintService
footprintService
;
@RequiresPermissions
(
"admin:footprint:list"
)
@RequiresPermissionsDesc
(
menu
=
{
"用户管理"
,
"用户足迹"
},
button
=
"查询"
)
@RequiresPermissionsDesc
(
menu
=
{
"用户管理"
,
"用户足迹"
},
button
=
"查询"
)
@GetMapping
(
"/list"
)
public
Object
list
(
String
userId
,
String
goodsId
,
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
defaultValue
=
"10"
)
Integer
limit
,
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
List
<
LitemallFootprint
>
footprintList
=
footprintService
.
querySelective
(
userId
,
goodsId
,
page
,
limit
,
sort
,
order
);
long
total
=
PageInfo
.
of
(
footprintList
).
getTotal
();
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
footprintList
);
return
ResponseUtil
.
ok
(
data
);
List
<
LitemallFootprint
>
footprintList
=
footprintService
.
querySelective
(
userId
,
goodsId
,
page
,
limit
,
sort
,
order
);
return
ResponseUtil
.
okList
(
footprintList
);
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminGoodsController.java
View file @
324c8da3
...
...
@@ -27,6 +27,7 @@ public class AdminGoodsController {
/**
* 查询商品
*
* @param goodsId
* @param goodsSn
* @param name
* @param page
...
...
@@ -38,12 +39,12 @@ public class AdminGoodsController {
@RequiresPermissions
(
"admin:goods:list"
)
@RequiresPermissionsDesc
(
menu
=
{
"商品管理"
,
"商品管理"
},
button
=
"查询"
)
@GetMapping
(
"/list"
)
public
Object
list
(
String
goodsSn
,
String
name
,
public
Object
list
(
Integer
goodsId
,
String
goodsSn
,
String
name
,
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
defaultValue
=
"10"
)
Integer
limit
,
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
return
adminGoodsService
.
list
(
goodsSn
,
name
,
page
,
limit
,
sort
,
order
);
return
adminGoodsService
.
list
(
goodsId
,
goodsSn
,
name
,
page
,
limit
,
sort
,
order
);
}
@GetMapping
(
"/catAndBrand"
)
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminGrouponController.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
;
import
org.linlinjava.litemall.admin.annotation.RequiresPermissionsDesc
;
import
org.linlinjava.litemall.admin.task.GrouponRuleExpiredTask
;
import
org.linlinjava.litemall.admin.util.AdminResponseCode
;
import
org.linlinjava.litemall.core.task.TaskService
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.core.validator.Order
;
import
org.linlinjava.litemall.core.validator.Sort
;
...
...
@@ -14,12 +16,15 @@ import org.linlinjava.litemall.db.domain.LitemallGrouponRules;
import
org.linlinjava.litemall.db.service.LitemallGoodsService
;
import
org.linlinjava.litemall.db.service.LitemallGrouponRulesService
;
import
org.linlinjava.litemall.db.service.LitemallGrouponService
;
import
org.linlinjava.litemall.db.util.GrouponConstant
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
java.math.BigDecimal
;
import
java.time.Duration
;
import
java.time.LocalDateTime
;
import
java.time.temporal.ChronoUnit
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -37,46 +42,43 @@ public class AdminGrouponController {
private
LitemallGoodsService
goodsService
;
@Autowired
private
LitemallGrouponService
grouponService
;
@Autowired
private
TaskService
taskService
;
@RequiresPermissions
(
"admin:groupon:read"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"团购管理"
},
button
=
"详情"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"团购管理"
},
button
=
"详情"
)
@GetMapping
(
"/listRecord"
)
public
Object
listRecord
(
String
grouponId
,
public
Object
listRecord
(
String
groupon
Rule
Id
,
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
defaultValue
=
"10"
)
Integer
limit
,
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
List
<
LitemallGroupon
>
grouponList
=
grouponService
.
querySelective
(
grouponId
,
page
,
limit
,
sort
,
order
);
long
total
=
PageInfo
.
of
(
grouponList
).
getTotal
();
List
<
LitemallGroupon
>
grouponList
=
grouponService
.
querySelective
(
grouponRuleId
,
page
,
limit
,
sort
,
order
);
List
<
Map
<
String
,
Object
>>
record
s
=
new
ArrayList
<>();
List
<
Map
<
String
,
Object
>>
groupon
s
=
new
ArrayList
<>();
for
(
LitemallGroupon
groupon
:
grouponList
)
{
try
{
Map
<
String
,
Object
>
R
ecordData
=
new
HashMap
<>();
Map
<
String
,
Object
>
r
ecordData
=
new
HashMap
<>();
List
<
LitemallGroupon
>
subGrouponList
=
grouponService
.
queryJoinRecord
(
groupon
.
getId
());
LitemallGrouponRules
rules
=
rulesService
.
query
ById
(
groupon
.
getRulesId
());
LitemallGrouponRules
rules
=
rulesService
.
find
ById
(
groupon
.
getRulesId
());
LitemallGoods
goods
=
goodsService
.
findById
(
rules
.
getGoodsId
());
R
ecordData
.
put
(
"groupon"
,
groupon
);
R
ecordData
.
put
(
"subGroupons"
,
subGrouponList
);
R
ecordData
.
put
(
"rules"
,
rules
);
R
ecordData
.
put
(
"goods"
,
goods
);
r
ecordData
.
put
(
"groupon"
,
groupon
);
r
ecordData
.
put
(
"subGroupons"
,
subGrouponList
);
r
ecordData
.
put
(
"rules"
,
rules
);
r
ecordData
.
put
(
"goods"
,
goods
);
record
s
.
add
(
R
ecordData
);
groupon
s
.
add
(
r
ecordData
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
);
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
records
);
return
ResponseUtil
.
ok
(
data
);
return
ResponseUtil
.
okList
(
groupons
,
grouponList
);
}
@RequiresPermissions
(
"admin:groupon:list"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"团购管理"
},
button
=
"查询"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"团购管理"
},
button
=
"查询"
)
@GetMapping
(
"/list"
)
public
Object
list
(
String
goodsId
,
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
...
...
@@ -84,12 +86,7 @@ public class AdminGrouponController {
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
List
<
LitemallGrouponRules
>
rulesList
=
rulesService
.
querySelective
(
goodsId
,
page
,
limit
,
sort
,
order
);
long
total
=
PageInfo
.
of
(
rulesList
).
getTotal
();
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
rulesList
);
return
ResponseUtil
.
ok
(
data
);
return
ResponseUtil
.
okList
(
rulesList
);
}
private
Object
validate
(
LitemallGrouponRules
grouponRules
)
{
...
...
@@ -114,7 +111,7 @@ public class AdminGrouponController {
}
@RequiresPermissions
(
"admin:groupon:update"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"团购管理"
},
button
=
"编辑"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"团购管理"
},
button
=
"编辑"
)
@PostMapping
(
"/update"
)
public
Object
update
(
@RequestBody
LitemallGrouponRules
grouponRules
)
{
Object
error
=
validate
(
grouponRules
);
...
...
@@ -122,6 +119,14 @@ public class AdminGrouponController {
return
error
;
}
LitemallGrouponRules
rules
=
rulesService
.
findById
(
grouponRules
.
getId
());
if
(
rules
==
null
){
return
ResponseUtil
.
badArgumentValue
();
}
if
(!
rules
.
getStatus
().
equals
(
GrouponConstant
.
RULE_STATUS_ON
)){
return
ResponseUtil
.
fail
(
AdminResponseCode
.
GROUPON_GOODS_OFFLINE
,
"团购已经下线"
);
}
Integer
goodsId
=
grouponRules
.
getGoodsId
();
LitemallGoods
goods
=
goodsService
.
findById
(
goodsId
);
if
(
goods
==
null
)
{
...
...
@@ -139,7 +144,7 @@ public class AdminGrouponController {
}
@RequiresPermissions
(
"admin:groupon:create"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"团购管理"
},
button
=
"添加"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"团购管理"
},
button
=
"添加"
)
@PostMapping
(
"/create"
)
public
Object
create
(
@RequestBody
LitemallGrouponRules
grouponRules
)
{
Object
error
=
validate
(
grouponRules
);
...
...
@@ -150,19 +155,28 @@ public class AdminGrouponController {
Integer
goodsId
=
grouponRules
.
getGoodsId
();
LitemallGoods
goods
=
goodsService
.
findById
(
goodsId
);
if
(
goods
==
null
)
{
return
ResponseUtil
.
badArgumentValue
();
return
ResponseUtil
.
fail
(
AdminResponseCode
.
GROUPON_GOODS_UNKNOWN
,
"团购商品不存在"
);
}
if
(
rulesService
.
countByGoodsId
(
goodsId
)
>
0
){
return
ResponseUtil
.
fail
(
AdminResponseCode
.
GROUPON_GOODS_EXISTED
,
"团购商品已经存在"
);
}
grouponRules
.
setGoodsName
(
goods
.
getName
());
grouponRules
.
setPicUrl
(
goods
.
getPicUrl
());
grouponRules
.
setStatus
(
GrouponConstant
.
RULE_STATUS_ON
);
rulesService
.
createRules
(
grouponRules
);
LocalDateTime
now
=
LocalDateTime
.
now
();
LocalDateTime
expire
=
grouponRules
.
getExpireTime
();
long
delay
=
ChronoUnit
.
MILLIS
.
between
(
now
,
expire
);
// 团购过期任务
taskService
.
addTask
(
new
GrouponRuleExpiredTask
(
grouponRules
.
getId
(),
delay
));
return
ResponseUtil
.
ok
(
grouponRules
);
}
@RequiresPermissions
(
"admin:groupon:delete"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"团购管理"
},
button
=
"删除"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"团购管理"
},
button
=
"删除"
)
@PostMapping
(
"/delete"
)
public
Object
delete
(
@RequestBody
LitemallGrouponRules
grouponRules
)
{
Integer
id
=
grouponRules
.
getId
();
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminHistoryController.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.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/history"
)
...
...
@@ -29,19 +26,15 @@ public class AdminHistoryController {
private
LitemallSearchHistoryService
searchHistoryService
;
@RequiresPermissions
(
"admin:history:list"
)
@RequiresPermissionsDesc
(
menu
=
{
"用户管理"
,
"搜索历史"
},
button
=
"查询"
)
@RequiresPermissionsDesc
(
menu
=
{
"用户管理"
,
"搜索历史"
},
button
=
"查询"
)
@GetMapping
(
"/list"
)
public
Object
list
(
String
userId
,
String
keyword
,
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
defaultValue
=
"10"
)
Integer
limit
,
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
List
<
LitemallSearchHistory
>
footprintList
=
searchHistoryService
.
querySelective
(
userId
,
keyword
,
page
,
limit
,
sort
,
order
);
long
total
=
PageInfo
.
of
(
footprintList
).
getTotal
();
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
footprintList
);
return
ResponseUtil
.
ok
(
data
);
List
<
LitemallSearchHistory
>
historyList
=
searchHistoryService
.
querySelective
(
userId
,
keyword
,
page
,
limit
,
sort
,
order
);
return
ResponseUtil
.
okList
(
historyList
);
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminIndexController.java
View file @
324c8da3
...
...
@@ -51,14 +51,14 @@ public class AdminIndexController {
}
@RequiresPermissions
(
"index:permission:read"
)
@RequiresPermissionsDesc
(
menu
=
{
"其他"
,
"权限测试"
},
button
=
"权限读"
)
@RequiresPermissionsDesc
(
menu
=
{
"其他"
,
"权限测试"
},
button
=
"权限读"
)
@GetMapping
(
"/read"
)
public
Object
read
()
{
return
ResponseUtil
.
ok
(
"hello world, this is admin service"
);
}
@RequiresPermissions
(
"index:permission:write"
)
@RequiresPermissionsDesc
(
menu
=
{
"其他"
,
"权限测试"
},
button
=
"权限写"
)
@RequiresPermissionsDesc
(
menu
=
{
"其他"
,
"权限测试"
},
button
=
"权限写"
)
@PostMapping
(
"/write"
)
public
Object
write
()
{
return
ResponseUtil
.
ok
(
"hello world, this is admin service"
);
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminIssueController.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/issue"
)
...
...
@@ -30,7 +27,7 @@ public class AdminIssueController {
private
LitemallIssueService
issueService
;
@RequiresPermissions
(
"admin:issue:list"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"通用问题"
},
button
=
"查询"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"通用问题"
},
button
=
"查询"
)
@GetMapping
(
"/list"
)
public
Object
list
(
String
question
,
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
...
...
@@ -38,12 +35,7 @@ public class AdminIssueController {
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
List
<
LitemallIssue
>
issueList
=
issueService
.
querySelective
(
question
,
page
,
limit
,
sort
,
order
);
long
total
=
PageInfo
.
of
(
issueList
).
getTotal
();
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
issueList
);
return
ResponseUtil
.
ok
(
data
);
return
ResponseUtil
.
okList
(
issueList
);
}
private
Object
validate
(
LitemallIssue
issue
)
{
...
...
@@ -59,7 +51,7 @@ public class AdminIssueController {
}
@RequiresPermissions
(
"admin:issue:create"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"通用问题"
},
button
=
"添加"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"通用问题"
},
button
=
"添加"
)
@PostMapping
(
"/create"
)
public
Object
create
(
@RequestBody
LitemallIssue
issue
)
{
Object
error
=
validate
(
issue
);
...
...
@@ -78,7 +70,7 @@ public class AdminIssueController {
}
@RequiresPermissions
(
"admin:issue:update"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"通用问题"
},
button
=
"编辑"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"通用问题"
},
button
=
"编辑"
)
@PostMapping
(
"/update"
)
public
Object
update
(
@RequestBody
LitemallIssue
issue
)
{
Object
error
=
validate
(
issue
);
...
...
@@ -93,7 +85,7 @@ public class AdminIssueController {
}
@RequiresPermissions
(
"admin:issue:delete"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"通用问题"
},
button
=
"删除"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"通用问题"
},
button
=
"删除"
)
@PostMapping
(
"/delete"
)
public
Object
delete
(
@RequestBody
LitemallIssue
issue
)
{
Integer
id
=
issue
.
getId
();
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminKeywordController.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/keyword"
)
...
...
@@ -30,7 +27,7 @@ public class AdminKeywordController {
private
LitemallKeywordService
keywordService
;
@RequiresPermissions
(
"admin:keyword:list"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"关键词"
},
button
=
"查询"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"关键词"
},
button
=
"查询"
)
@GetMapping
(
"/list"
)
public
Object
list
(
String
keyword
,
String
url
,
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
...
...
@@ -38,12 +35,7 @@ public class AdminKeywordController {
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
List
<
LitemallKeyword
>
keywordList
=
keywordService
.
querySelective
(
keyword
,
url
,
page
,
limit
,
sort
,
order
);
long
total
=
PageInfo
.
of
(
keywordList
).
getTotal
();
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
keywordList
);
return
ResponseUtil
.
ok
(
data
);
return
ResponseUtil
.
okList
(
keywordList
);
}
private
Object
validate
(
LitemallKeyword
keywords
)
{
...
...
@@ -55,19 +47,19 @@ public class AdminKeywordController {
}
@RequiresPermissions
(
"admin:keyword:create"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"关键词"
},
button
=
"添加"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"关键词"
},
button
=
"添加"
)
@PostMapping
(
"/create"
)
public
Object
create
(
@RequestBody
LitemallKeyword
keyword
s
)
{
Object
error
=
validate
(
keyword
s
);
public
Object
create
(
@RequestBody
LitemallKeyword
keyword
)
{
Object
error
=
validate
(
keyword
);
if
(
error
!=
null
)
{
return
error
;
}
keywordService
.
add
(
keyword
s
);
return
ResponseUtil
.
ok
(
keyword
s
);
keywordService
.
add
(
keyword
);
return
ResponseUtil
.
ok
(
keyword
);
}
@RequiresPermissions
(
"admin:keyword:read"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"关键词"
},
button
=
"详情"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"关键词"
},
button
=
"详情"
)
@GetMapping
(
"/read"
)
public
Object
read
(
@NotNull
Integer
id
)
{
LitemallKeyword
keyword
=
keywordService
.
findById
(
id
);
...
...
@@ -75,21 +67,21 @@ public class AdminKeywordController {
}
@RequiresPermissions
(
"admin:keyword:update"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"关键词"
},
button
=
"编辑"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"关键词"
},
button
=
"编辑"
)
@PostMapping
(
"/update"
)
public
Object
update
(
@RequestBody
LitemallKeyword
keyword
s
)
{
Object
error
=
validate
(
keyword
s
);
public
Object
update
(
@RequestBody
LitemallKeyword
keyword
)
{
Object
error
=
validate
(
keyword
);
if
(
error
!=
null
)
{
return
error
;
}
if
(
keywordService
.
updateById
(
keyword
s
)
==
0
)
{
if
(
keywordService
.
updateById
(
keyword
)
==
0
)
{
return
ResponseUtil
.
updatedDataFailed
();
}
return
ResponseUtil
.
ok
(
keyword
s
);
return
ResponseUtil
.
ok
(
keyword
);
}
@RequiresPermissions
(
"admin:keyword:delete"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"关键词"
},
button
=
"删除"
)
@RequiresPermissionsDesc
(
menu
=
{
"商场管理"
,
"关键词"
},
button
=
"删除"
)
@PostMapping
(
"/delete"
)
public
Object
delete
(
@RequestBody
LitemallKeyword
keyword
)
{
Integer
id
=
keyword
.
getId
();
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminLogController.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
;
...
...
@@ -12,12 +11,12 @@ import org.linlinjava.litemall.db.domain.LitemallLog;
import
org.linlinjava.litemall.db.service.LitemallLogService
;
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.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.constraints.NotNull
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/admin/log"
)
...
...
@@ -29,7 +28,7 @@ public class AdminLogController {
private
LitemallLogService
logService
;
@RequiresPermissions
(
"admin:log:list"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"操作日志"
},
button
=
"查询"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"操作日志"
},
button
=
"查询"
)
@GetMapping
(
"/list"
)
public
Object
list
(
String
name
,
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
...
...
@@ -37,11 +36,6 @@ public class AdminLogController {
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
List
<
LitemallLog
>
logList
=
logService
.
querySelective
(
name
,
page
,
limit
,
sort
,
order
);
long
total
=
PageInfo
.
of
(
logList
).
getTotal
();
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
logList
);
return
ResponseUtil
.
ok
(
data
);
return
ResponseUtil
.
okList
(
logList
);
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminOrderController.java
View file @
324c8da3
...
...
@@ -5,6 +5,9 @@ import org.apache.commons.logging.LogFactory;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.linlinjava.litemall.admin.annotation.RequiresPermissionsDesc
;
import
org.linlinjava.litemall.admin.service.AdminOrderService
;
import
org.linlinjava.litemall.core.express.ExpressService
;
import
org.linlinjava.litemall.core.notify.NotifyService
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.core.validator.Order
;
import
org.linlinjava.litemall.core.validator.Sort
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -22,6 +25,8 @@ public class AdminOrderController {
@Autowired
private
AdminOrderService
adminOrderService
;
@Autowired
private
ExpressService
expressService
;
/**
* 查询订单
...
...
@@ -47,6 +52,16 @@ public class AdminOrderController {
return
adminOrderService
.
list
(
userId
,
orderSn
,
orderStatusArray
,
page
,
limit
,
sort
,
order
);
}
/**
* 查询物流公司
*
* @return
*/
@GetMapping
(
"/channel"
)
public
Object
channel
()
{
return
ResponseUtil
.
ok
(
expressService
.
getVendors
());
}
/**
* 订单详情
*
...
...
@@ -99,5 +114,4 @@ public class AdminOrderController {
public
Object
reply
(
@RequestBody
String
body
)
{
return
adminOrderService
.
reply
(
body
);
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminRegionController.java
View file @
324c8da3
...
...
@@ -37,17 +37,7 @@ public class AdminRegionController {
public
Object
list
()
{
List
<
RegionVo
>
regionVoList
=
new
ArrayList
<>();
List
<
LitemallRegion
>
litemallRegions
=
regionService
.
getAll
();
Map
<
Byte
,
List
<
LitemallRegion
>>
collect
=
litemallRegions
.
stream
().
collect
(
Collectors
.
groupingBy
(
LitemallRegion:
:
getType
));
byte
provinceType
=
1
;
List
<
LitemallRegion
>
provinceList
=
collect
.
get
(
provinceType
);
byte
cityType
=
2
;
List
<
LitemallRegion
>
city
=
collect
.
get
(
cityType
);
Map
<
Integer
,
List
<
LitemallRegion
>>
cityListMap
=
city
.
stream
().
collect
(
Collectors
.
groupingBy
(
LitemallRegion:
:
getPid
));
byte
areaType
=
3
;
List
<
LitemallRegion
>
areas
=
collect
.
get
(
areaType
);
Map
<
Integer
,
List
<
LitemallRegion
>>
areaListMap
=
areas
.
stream
().
collect
(
Collectors
.
groupingBy
(
LitemallRegion:
:
getPid
));
List
<
LitemallRegion
>
provinceList
=
regionService
.
queryByPid
(
0
);
for
(
LitemallRegion
province
:
provinceList
)
{
RegionVo
provinceVO
=
new
RegionVo
();
provinceVO
.
setId
(
province
.
getId
());
...
...
@@ -57,7 +47,7 @@ public class AdminRegionController {
List
<
LitemallRegion
>
cityList
=
cityListMap
.
get
(
province
.
getId
());
List
<
RegionVo
>
cityVOList
=
new
ArrayList
<>();
for
(
LitemallRegion
city
Vo
:
cityList
)
{
for
(
LitemallRegion
city
:
cityList
)
{
RegionVo
cityVO
=
new
RegionVo
();
cityVO
.
setId
(
cityVo
.
getId
());
cityVO
.
setName
(
cityVo
.
getName
());
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminRoleController.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
;
import
org.linlinjava.litemall.admin.annotation.RequiresPermissionsDesc
;
import
org.linlinjava.litemall.admin.util.AdminResponseCode
;
import
org.linlinjava.litemall.admin.vo.PermVo
;
import
org.linlinjava.litemall.admin.util.Permission
;
import
org.linlinjava.litemall.admin.util.PermissionUtil
;
import
org.linlinjava.litemall.admin.vo.PermVo
;
import
org.linlinjava.litemall.core.util.JacksonUtil
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.core.validator.Order
;
...
...
@@ -45,7 +44,7 @@ public class AdminRoleController {
private
LitemallAdminService
adminService
;
@RequiresPermissions
(
"admin:role:list"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"角色管理"
},
button
=
"角色查询"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"角色管理"
},
button
=
"角色查询"
)
@GetMapping
(
"/list"
)
public
Object
list
(
String
name
,
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
...
...
@@ -53,16 +52,11 @@ public class AdminRoleController {
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
List
<
LitemallRole
>
roleList
=
roleService
.
querySelective
(
name
,
page
,
limit
,
sort
,
order
);
long
total
=
PageInfo
.
of
(
roleList
).
getTotal
();
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
roleList
);
return
ResponseUtil
.
ok
(
data
);
return
ResponseUtil
.
okList
(
roleList
);
}
@GetMapping
(
"/options"
)
public
Object
options
(){
public
Object
options
()
{
List
<
LitemallRole
>
roleList
=
roleService
.
queryAll
();
List
<
Map
<
String
,
Object
>>
options
=
new
ArrayList
<>(
roleList
.
size
());
...
...
@@ -73,11 +67,11 @@ public class AdminRoleController {
options
.
add
(
option
);
}
return
ResponseUtil
.
ok
(
options
);
return
ResponseUtil
.
ok
List
(
options
);
}
@RequiresPermissions
(
"admin:role:read"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"角色管理"
},
button
=
"角色详情"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"角色管理"
},
button
=
"角色详情"
)
@GetMapping
(
"/read"
)
public
Object
read
(
@NotNull
Integer
id
)
{
LitemallRole
role
=
roleService
.
findById
(
id
);
...
...
@@ -95,7 +89,7 @@ public class AdminRoleController {
}
@RequiresPermissions
(
"admin:role:create"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"角色管理"
},
button
=
"角色添加"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"角色管理"
},
button
=
"角色添加"
)
@PostMapping
(
"/create"
)
public
Object
create
(
@RequestBody
LitemallRole
role
)
{
Object
error
=
validate
(
role
);
...
...
@@ -103,7 +97,7 @@ public class AdminRoleController {
return
error
;
}
if
(
roleService
.
checkExist
(
role
.
getName
())){
if
(
roleService
.
checkExist
(
role
.
getName
()))
{
return
ResponseUtil
.
fail
(
ROLE_NAME_EXIST
,
"角色已经存在"
);
}
...
...
@@ -113,7 +107,7 @@ public class AdminRoleController {
}
@RequiresPermissions
(
"admin:role:update"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"角色管理"
},
button
=
"角色编辑"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"角色管理"
},
button
=
"角色编辑"
)
@PostMapping
(
"/update"
)
public
Object
update
(
@RequestBody
LitemallRole
role
)
{
Object
error
=
validate
(
role
);
...
...
@@ -126,7 +120,7 @@ public class AdminRoleController {
}
@RequiresPermissions
(
"admin:role:delete"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"角色管理"
},
button
=
"角色删除"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"角色管理"
},
button
=
"角色删除"
)
@PostMapping
(
"/delete"
)
public
Object
delete
(
@RequestBody
LitemallRole
role
)
{
Integer
id
=
role
.
getId
();
...
...
@@ -136,10 +130,10 @@ public class AdminRoleController {
// 如果当前角色所对应管理员仍存在,则拒绝删除角色。
List
<
LitemallAdmin
>
adminList
=
adminService
.
all
();
for
(
LitemallAdmin
admin
:
adminList
){
for
(
LitemallAdmin
admin
:
adminList
)
{
Integer
[]
roleIds
=
admin
.
getRoleIds
();
for
(
Integer
roleId
:
roleIds
){
if
(
id
.
equals
(
roleId
)){
for
(
Integer
roleId
:
roleIds
)
{
if
(
id
.
equals
(
roleId
))
{
return
ResponseUtil
.
fail
(
ROLE_USER_EXIST
,
"当前角色存在管理员,不能删除"
);
}
}
...
...
@@ -155,9 +149,9 @@ public class AdminRoleController {
private
List
<
PermVo
>
systemPermissions
=
null
;
private
Set
<
String
>
systemPermissionsString
=
null
;
private
List
<
PermVo
>
getSystemPermissions
(){
private
List
<
PermVo
>
getSystemPermissions
()
{
final
String
basicPackage
=
"org.linlinjava.litemall.admin"
;
if
(
systemPermissions
==
null
){
if
(
systemPermissions
==
null
)
{
List
<
Permission
>
permissions
=
PermissionUtil
.
listPermission
(
context
,
basicPackage
);
systemPermissions
=
PermissionUtil
.
listPermVo
(
permissions
);
systemPermissionsString
=
PermissionUtil
.
listPermissionString
(
permissions
);
...
...
@@ -165,15 +159,14 @@ public class AdminRoleController {
return
systemPermissions
;
}
private
Set
<
String
>
getAssignedPermissions
(
Integer
roleId
){
private
Set
<
String
>
getAssignedPermissions
(
Integer
roleId
)
{
// 这里需要注意的是,如果存在超级权限*,那么这里需要转化成当前所有系统权限。
// 之所以这么做,是因为前端不能识别超级权限,所以这里需要转换一下。
Set
<
String
>
assignedPermissions
=
null
;
if
(
permissionService
.
checkSuperPermission
(
roleId
)){
if
(
permissionService
.
checkSuperPermission
(
roleId
))
{
getSystemPermissions
();
assignedPermissions
=
systemPermissionsString
;
}
else
{
}
else
{
assignedPermissions
=
permissionService
.
queryByRoleId
(
roleId
);
}
...
...
@@ -186,7 +179,7 @@ public class AdminRoleController {
* @return 系统所有权限列表和管理员已分配权限
*/
@RequiresPermissions
(
"admin:role:permission:get"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"角色管理"
},
button
=
"权限详情"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"角色管理"
},
button
=
"权限详情"
)
@GetMapping
(
"/permissions"
)
public
Object
getPermissions
(
Integer
roleId
)
{
List
<
PermVo
>
systemPermissions
=
getSystemPermissions
();
...
...
@@ -206,23 +199,23 @@ public class AdminRoleController {
* @return
*/
@RequiresPermissions
(
"admin:role:permission:update"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"角色管理"
},
button
=
"权限变更"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"角色管理"
},
button
=
"权限变更"
)
@PostMapping
(
"/permissions"
)
public
Object
updatePermissions
(
@RequestBody
String
body
)
{
Integer
roleId
=
JacksonUtil
.
parseInteger
(
body
,
"roleId"
);
List
<
String
>
permissions
=
JacksonUtil
.
parseStringList
(
body
,
"permissions"
);
if
(
roleId
==
null
||
permissions
==
null
){
if
(
roleId
==
null
||
permissions
==
null
)
{
return
ResponseUtil
.
badArgument
();
}
// 如果修改的角色是超级权限,则拒绝修改。
if
(
permissionService
.
checkSuperPermission
(
roleId
)){
if
(
permissionService
.
checkSuperPermission
(
roleId
))
{
return
ResponseUtil
.
fail
(
AdminResponseCode
.
ROLE_SUPER_SUPERMISSION
,
"当前角色的超级权限不能变更"
);
}
// 先删除旧的权限,再更新新的权限
permissionService
.
deleteByRoleId
(
roleId
);
for
(
String
permission
:
permissions
){
for
(
String
permission
:
permissions
)
{
LitemallPermission
litemallPermission
=
new
LitemallPermission
();
litemallPermission
.
setRoleId
(
roleId
);
litemallPermission
.
setPermission
(
permission
);
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminStatController.java
View file @
324c8da3
...
...
@@ -26,7 +26,7 @@ public class AdminStatController {
private
StatService
statService
;
@RequiresPermissions
(
"admin:stat:user"
)
@RequiresPermissionsDesc
(
menu
=
{
"统计管理"
,
"用户统计"
},
button
=
"查询"
)
@RequiresPermissionsDesc
(
menu
=
{
"统计管理"
,
"用户统计"
},
button
=
"查询"
)
@GetMapping
(
"/user"
)
public
Object
statUser
()
{
List
<
Map
>
rows
=
statService
.
statUser
();
...
...
@@ -38,7 +38,7 @@ public class AdminStatController {
}
@RequiresPermissions
(
"admin:stat:order"
)
@RequiresPermissionsDesc
(
menu
=
{
"统计管理"
,
"订单统计"
},
button
=
"查询"
)
@RequiresPermissionsDesc
(
menu
=
{
"统计管理"
,
"订单统计"
},
button
=
"查询"
)
@GetMapping
(
"/order"
)
public
Object
statOrder
()
{
List
<
Map
>
rows
=
statService
.
statOrder
();
...
...
@@ -51,7 +51,7 @@ public class AdminStatController {
}
@RequiresPermissions
(
"admin:stat:goods"
)
@RequiresPermissionsDesc
(
menu
=
{
"统计管理"
,
"商品统计"
},
button
=
"查询"
)
@RequiresPermissionsDesc
(
menu
=
{
"统计管理"
,
"商品统计"
},
button
=
"查询"
)
@GetMapping
(
"/goods"
)
public
Object
statGoods
()
{
List
<
Map
>
rows
=
statService
.
statGoods
();
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminStorageController.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
;
...
...
@@ -19,9 +18,7 @@ import org.springframework.web.multipart.MultipartFile;
import
javax.validation.constraints.NotNull
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/admin/storage"
)
...
...
@@ -35,7 +32,7 @@ public class AdminStorageController {
private
LitemallStorageService
litemallStorageService
;
@RequiresPermissions
(
"admin:storage:list"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"对象存储"
},
button
=
"查询"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"对象存储"
},
button
=
"查询"
)
@GetMapping
(
"/list"
)
public
Object
list
(
String
key
,
String
name
,
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
...
...
@@ -43,25 +40,21 @@ public class AdminStorageController {
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
List
<
LitemallStorage
>
storageList
=
litemallStorageService
.
querySelective
(
key
,
name
,
page
,
limit
,
sort
,
order
);
long
total
=
PageInfo
.
of
(
storageList
).
getTotal
();
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
storageList
);
return
ResponseUtil
.
ok
(
data
);
return
ResponseUtil
.
okList
(
storageList
);
}
@RequiresPermissions
(
"admin:storage:create"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"对象存储"
},
button
=
"上传"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"对象存储"
},
button
=
"上传"
)
@PostMapping
(
"/create"
)
public
Object
create
(
@RequestParam
(
"file"
)
MultipartFile
file
)
throws
IOException
{
String
originalFilename
=
file
.
getOriginalFilename
();
LitemallStorage
litemallStorage
=
storageService
.
store
(
file
.
getInputStream
(),
file
.
getSize
(),
file
.
getContentType
(),
originalFilename
);
LitemallStorage
litemallStorage
=
storageService
.
store
(
file
.
getInputStream
(),
file
.
getSize
(),
file
.
getContentType
(),
originalFilename
);
return
ResponseUtil
.
ok
(
litemallStorage
);
}
@RequiresPermissions
(
"admin:storage:read"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"对象存储"
},
button
=
"详情"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"对象存储"
},
button
=
"详情"
)
@PostMapping
(
"/read"
)
public
Object
read
(
@NotNull
Integer
id
)
{
LitemallStorage
storageInfo
=
litemallStorageService
.
findById
(
id
);
...
...
@@ -72,7 +65,7 @@ public class AdminStorageController {
}
@RequiresPermissions
(
"admin:storage:update"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"对象存储"
},
button
=
"编辑"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"对象存储"
},
button
=
"编辑"
)
@PostMapping
(
"/update"
)
public
Object
update
(
@RequestBody
LitemallStorage
litemallStorage
)
{
if
(
litemallStorageService
.
update
(
litemallStorage
)
==
0
)
{
...
...
@@ -82,7 +75,7 @@ public class AdminStorageController {
}
@RequiresPermissions
(
"admin:storage:delete"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"对象存储"
},
button
=
"删除"
)
@RequiresPermissionsDesc
(
menu
=
{
"系统管理"
,
"对象存储"
},
button
=
"删除"
)
@PostMapping
(
"/delete"
)
public
Object
delete
(
@RequestBody
LitemallStorage
litemallStorage
)
{
String
key
=
litemallStorage
.
getKey
();
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminTopicController.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
;
...
...
@@ -8,7 +7,9 @@ import org.linlinjava.litemall.admin.annotation.RequiresPermissionsDesc;
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.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.StringUtils
;
...
...
@@ -17,6 +18,7 @@ import org.springframework.web.bind.annotation.*;
import
javax.validation.constraints.NotNull
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -29,9 +31,11 @@ public class AdminTopicController {
@Autowired
private
LitemallTopicService
topicService
;
@Autowired
private
LitemallGoodsService
goodsService
;
@RequiresPermissions
(
"admin:topic:list"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"专题管理"
},
button
=
"查询"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"专题管理"
},
button
=
"查询"
)
@GetMapping
(
"/list"
)
public
Object
list
(
String
title
,
String
subtitle
,
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
...
...
@@ -39,12 +43,7 @@ public class AdminTopicController {
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
List
<
LitemallTopic
>
topicList
=
topicService
.
querySelective
(
title
,
subtitle
,
page
,
limit
,
sort
,
order
);
long
total
=
PageInfo
.
of
(
topicList
).
getTotal
();
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
topicList
);
return
ResponseUtil
.
ok
(
data
);
return
ResponseUtil
.
okList
(
topicList
);
}
private
Object
validate
(
LitemallTopic
topic
)
{
...
...
@@ -64,7 +63,7 @@ public class AdminTopicController {
}
@RequiresPermissions
(
"admin:topic:create"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"专题管理"
},
button
=
"添加"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"专题管理"
},
button
=
"添加"
)
@PostMapping
(
"/create"
)
public
Object
create
(
@RequestBody
LitemallTopic
topic
)
{
Object
error
=
validate
(
topic
);
...
...
@@ -76,15 +75,25 @@ public class AdminTopicController {
}
@RequiresPermissions
(
"admin:topic:read"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"专题管理"
},
button
=
"详情"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"专题管理"
},
button
=
"详情"
)
@GetMapping
(
"/read"
)
public
Object
read
(
@NotNull
Integer
id
)
{
LitemallTopic
topic
=
topicService
.
findById
(
id
);
return
ResponseUtil
.
ok
(
topic
);
Integer
[]
goodsIds
=
topic
.
getGoods
();
List
<
LitemallGoods
>
goodsList
=
null
;
if
(
goodsIds
==
null
||
goodsIds
.
length
==
0
)
{
goodsList
=
new
ArrayList
<>();
}
else
{
goodsList
=
goodsService
.
queryByIds
(
goodsIds
);
}
Map
<
String
,
Object
>
data
=
new
HashMap
<>(
2
);
data
.
put
(
"topic"
,
topic
);
data
.
put
(
"goodsList"
,
goodsList
);
return
ResponseUtil
.
ok
(
data
);
}
@RequiresPermissions
(
"admin:topic:update"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"专题管理"
},
button
=
"编辑"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"专题管理"
},
button
=
"编辑"
)
@PostMapping
(
"/update"
)
public
Object
update
(
@RequestBody
LitemallTopic
topic
)
{
Object
error
=
validate
(
topic
);
...
...
@@ -98,7 +107,7 @@ public class AdminTopicController {
}
@RequiresPermissions
(
"admin:topic:delete"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"专题管理"
},
button
=
"删除"
)
@RequiresPermissionsDesc
(
menu
=
{
"推广管理"
,
"专题管理"
},
button
=
"删除"
)
@PostMapping
(
"/delete"
)
public
Object
delete
(
@RequestBody
LitemallTopic
topic
)
{
topicService
.
deleteById
(
topic
.
getId
());
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminUserController.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
;
import
org.linlinjava.litemall.admin.annotation.RequiresPermissionsDesc
;
import
org.linlinjava.litemall.core.util.RegexUtil
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.core.util.bcrypt.BCryptPasswordEncoder
;
import
org.linlinjava.litemall.core.validator.Order
;
import
org.linlinjava.litemall.core.validator.Sort
;
import
org.linlinjava.litemall.db.domain.LitemallUser
;
import
org.linlinjava.litemall.db.service.LitemallUserService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.StringUtils
;
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.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.constraints.NotEmpty
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
static
org
.
linlinjava
.
litemall
.
admin
.
util
.
AdminResponseCode
.*;
@RestController
@RequestMapping
(
"/admin/user"
)
...
...
@@ -34,7 +28,7 @@ public class AdminUserController {
private
LitemallUserService
userService
;
@RequiresPermissions
(
"admin:user:list"
)
@RequiresPermissionsDesc
(
menu
=
{
"用户管理"
,
"会员管理"
},
button
=
"查询"
)
@RequiresPermissionsDesc
(
menu
=
{
"用户管理"
,
"会员管理"
},
button
=
"查询"
)
@GetMapping
(
"/list"
)
public
Object
list
(
String
username
,
String
mobile
,
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
...
...
@@ -42,11 +36,6 @@ public class AdminUserController {
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
List
<
LitemallUser
>
userList
=
userService
.
querySelective
(
username
,
mobile
,
page
,
limit
,
sort
,
order
);
long
total
=
PageInfo
.
of
(
userList
).
getTotal
();
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
userList
);
return
ResponseUtil
.
ok
(
data
);
return
ResponseUtil
.
okList
(
userList
);
}
}
litemall-admin-api/src/test/java/org/linlinjava/litemall/admin/PermissionTest.java
View file @
324c8da3
...
...
@@ -2,9 +2,9 @@ package org.linlinjava.litemall.admin;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.linlinjava.litemall.admin.vo.PermVo
;
import
org.linlinjava.litemall.admin.util.Permission
;
import
org.linlinjava.litemall.admin.util.PermissionUtil
;
import
org.linlinjava.litemall.admin.vo.PermVo
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.context.ApplicationContext
;
...
...
litemall-admin/.babelrc
deleted
100644 → 0
View file @
693cf5cd
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
}],
"stage-2"
],
"plugins": ["transform-vue-jsx", "transform-runtime"],
"env": {
"development":{
"plugins": ["dynamic-import-node"]
}
}
}
litemall-admin/.editorconfig
View file @
324c8da3
# http://editorconfig.org
# http
s
://editorconfig.org
root = true
[*]
...
...
Prev
1
2
3
4
5
6
7
8
…
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