Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 39699f8c
由
LN
编写于
2021-09-23 15:46:20 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
增加组权限验证
1 个父辈
d5acd9d8
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
61 行增加
和
8 行删除
src/main/java/com/neotel/smfcore/core/system/rest/TaskController.java
src/main/java/com/neotel/smfcore/security/rest/GroupController.java
src/main/java/com/neotel/smfcore/security/service/po/User.java
src/main/resources/messages.properties
src/main/resources/messages_en_US.properties
src/main/resources/messages_ja_JP.properties
src/main/resources/messages_zh_CN.properties
src/main/resources/messages_zh_TW.properties
src/main/java/com/neotel/smfcore/core/system/rest/TaskController.java
查看文件 @
39699f8
...
@@ -3,7 +3,9 @@ package com.neotel.smfcore.core.system.rest;
...
@@ -3,7 +3,9 @@ package com.neotel.smfcore.core.system.rest;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
com.neotel.smfcore.common.bean.PageData
;
import
com.neotel.smfcore.common.bean.PageData
;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.common.utils.QueryHelp
;
import
com.neotel.smfcore.common.utils.QueryHelp
;
import
com.neotel.smfcore.common.utils.SecurityUtils
;
import
com.neotel.smfcore.core.device.enums.OP_STATUS
;
import
com.neotel.smfcore.core.device.enums.OP_STATUS
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.storage.service.po.Storage
;
import
com.neotel.smfcore.core.storage.service.po.Storage
;
...
@@ -13,6 +15,8 @@ import com.neotel.smfcore.core.system.rest.bean.query.TaskQueryCondition;
...
@@ -13,6 +15,8 @@ import com.neotel.smfcore.core.system.rest.bean.query.TaskQueryCondition;
import
com.neotel.smfcore.core.system.service.manager.IDataLogManager
;
import
com.neotel.smfcore.core.system.service.manager.IDataLogManager
;
import
com.neotel.smfcore.core.system.service.po.DataLog
;
import
com.neotel.smfcore.core.system.service.po.DataLog
;
import
com.neotel.smfcore.core.system.util.TaskService
;
import
com.neotel.smfcore.core.system.util.TaskService
;
import
com.neotel.smfcore.security.service.manager.IUserManager
;
import
com.neotel.smfcore.security.service.po.User
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
...
@@ -50,6 +54,8 @@ public class TaskController {
...
@@ -50,6 +54,8 @@ public class TaskController {
@Autowired
@Autowired
private
DataCache
dataCache
;
private
DataCache
dataCache
;
@Autowired
private
IUserManager
userManager
;
// @ApiOperation("导出用户数据")
// @ApiOperation("导出用户数据")
// @GetMapping(value = "/download")
// @GetMapping(value = "/download")
...
@@ -86,6 +92,10 @@ public class TaskController {
...
@@ -86,6 +92,10 @@ public class TaskController {
if
(
groupId
!=
null
&&
groupId
.
equals
(
"-1"
)){
if
(
groupId
!=
null
&&
groupId
.
equals
(
"-1"
)){
groupId
=
""
;
groupId
=
""
;
}
}
User
curruser
=
userManager
.
get
(
SecurityUtils
.
getCurrentUserId
());
if
(!
curruser
.
getGroups
().
contains
(
groupId
)){
throw
new
ValidateException
(
"smfcode.nogroupaccess"
,
"没有组[{0}]的操作权限"
,
new
String
[]
{
groupId
});
}
return
getTaskList
(
groupId
,
null
);
return
getTaskList
(
groupId
,
null
);
}
}
...
...
src/main/java/com/neotel/smfcore/security/rest/GroupController.java
查看文件 @
39699f8
...
@@ -2,7 +2,9 @@ package com.neotel.smfcore.security.rest;
...
@@ -2,7 +2,9 @@ package com.neotel.smfcore.security.rest;
import
com.neotel.smfcore.common.bean.PageData
;
import
com.neotel.smfcore.common.bean.PageData
;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.common.utils.Constants
;
import
com.neotel.smfcore.common.utils.QueryHelp
;
import
com.neotel.smfcore.common.utils.QueryHelp
;
import
com.neotel.smfcore.common.utils.SecurityUtils
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.storage.service.manager.IStorageManager
;
import
com.neotel.smfcore.core.storage.service.manager.IStorageManager
;
import
com.neotel.smfcore.core.storage.service.po.Storage
;
import
com.neotel.smfcore.core.storage.service.po.Storage
;
...
@@ -14,6 +16,7 @@ import com.neotel.smfcore.security.rest.bean.query.MenuQueryCondition;
...
@@ -14,6 +16,7 @@ import com.neotel.smfcore.security.rest.bean.query.MenuQueryCondition;
import
com.neotel.smfcore.security.service.manager.IGroupManager
;
import
com.neotel.smfcore.security.service.manager.IGroupManager
;
import
com.neotel.smfcore.security.service.manager.IMenuManager
;
import
com.neotel.smfcore.security.service.manager.IMenuManager
;
import
com.neotel.smfcore.security.service.manager.IUserManager
;
import
com.neotel.smfcore.security.service.manager.IUserManager
;
import
com.neotel.smfcore.security.service.manager.impl.UserManagerImpl
;
import
com.neotel.smfcore.security.service.po.Group
;
import
com.neotel.smfcore.security.service.po.Group
;
import
com.neotel.smfcore.security.service.po.User
;
import
com.neotel.smfcore.security.service.po.User
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
...
@@ -89,10 +92,14 @@ public class GroupController {
...
@@ -89,10 +92,14 @@ public class GroupController {
Group
group
=
Group
.
defaulGroup
();
Group
group
=
Group
.
defaulGroup
();
groups
.
add
(
group
);
groups
.
add
(
group
);
List
<
Group
>
resultGroups
=
new
ArrayList
<>();
List
<
Group
>
resultGroups
=
new
ArrayList
<>();
User
curruser
=
userManager
.
get
(
SecurityUtils
.
getCurrentUserId
());
for
(
Group
g
:
for
(
Group
g
:
groups
)
{
groups
)
{
if
(
dataCache
.
getCidsByGroupId
(
g
.
getId
(),
true
).
size
()
>
0
)
{
if
(
curruser
.
hasGroup
(
g
.
getId
()))
{
resultGroups
.
add
(
g
);
if
(
dataCache
.
getCidsByGroupId
(
g
.
getId
(),
true
).
size
()
>
0
)
{
resultGroups
.
add
(
g
);
}
}
}
}
}
return
new
ResponseEntity
<>(
groupMapper
.
toDto
(
resultGroups
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
groupMapper
.
toDto
(
resultGroups
),
HttpStatus
.
OK
);
...
@@ -102,8 +109,21 @@ public class GroupController {
...
@@ -102,8 +109,21 @@ public class GroupController {
@PostMapping
@PostMapping
@PreAuthorize
(
"@el.check('group:add')"
)
@PreAuthorize
(
"@el.check('group:add')"
)
public
ResponseEntity
<
Object
>
create
(
@RequestBody
GroupDto
groupDto
)
{
public
ResponseEntity
<
Object
>
create
(
@RequestBody
GroupDto
groupDto
)
{
Group
resources
=
groupMapper
.
toEntity
(
groupDto
);
Group
resources
=
groupMapper
.
toEntity
(
groupDto
);
groupManager
.
saveGroup
(
resources
);
resources
=
groupManager
.
saveGroup
(
resources
);
//创建分组的人默认增加组权限
User
curruser
=
userManager
.
get
(
SecurityUtils
.
getCurrentUserId
());
curruser
.
getGroups
().
add
(
resources
.
getId
());
userManager
.
save
(
curruser
);
if
(!
curruser
.
getUsername
().
equals
(
Constants
.
SUPER_USERNAME
))
{
//管理员默认增加组权限
User
adminUser
=
userManager
.
findByUserName
(
Constants
.
SUPER_USERNAME
);
adminUser
.
getGroups
().
add
(
resources
.
getId
());
userManager
.
save
(
adminUser
);
}
return
new
ResponseEntity
<>(
HttpStatus
.
CREATED
);
return
new
ResponseEntity
<>(
HttpStatus
.
CREATED
);
}
}
...
@@ -115,6 +135,10 @@ public class GroupController {
...
@@ -115,6 +135,10 @@ public class GroupController {
if
(
resources
.
getId
()
==
null
)
{
if
(
resources
.
getId
()
==
null
)
{
throw
new
ValidateException
(
"smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"ID"
}
);
throw
new
ValidateException
(
"smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"ID"
}
);
}
}
User
curruser
=
userManager
.
get
(
SecurityUtils
.
getCurrentUserId
());
if
(!
curruser
.
hasGroup
(
resources
.
getId
())){
throw
new
ValidateException
(
"smfcode.nogroupaccess"
,
"没有组[{0}]的操作权限"
,
new
String
[]
{
resources
.
getGroupName
()});
}
groupManager
.
saveGroup
(
resources
);
groupManager
.
saveGroup
(
resources
);
return
new
ResponseEntity
<>(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>(
HttpStatus
.
NO_CONTENT
);
}
}
...
@@ -132,6 +156,10 @@ public class GroupController {
...
@@ -132,6 +156,10 @@ public class GroupController {
if
(
group
==
null
){
if
(
group
==
null
){
throw
new
ValidateException
(
"smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"group"
}
);
throw
new
ValidateException
(
"smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"group"
}
);
}
}
User
curruser
=
userManager
.
get
(
SecurityUtils
.
getCurrentUserId
());
if
(!
curruser
.
hasGroup
(
group
.
getId
())){
throw
new
ValidateException
(
"smfcode.nogroupaccess"
,
"没有组[{0}]的操作权限"
,
new
String
[]
{
group
.
getGroupName
()});
}
// //查找组下是否有设备
// //查找组下是否有设备
// Query query = new Query(Criteria.where("groupId").is(id));
// Query query = new Query(Criteria.where("groupId").is(id));
// List<Storage> storages = storageManager.findByQuery(query);
// List<Storage> storages = storageManager.findByQuery(query);
...
...
src/main/java/com/neotel/smfcore/security/service/po/User.java
查看文件 @
39699f8
...
@@ -58,4 +58,14 @@ public class User extends BasePo implements Serializable {
...
@@ -58,4 +58,14 @@ public class User extends BasePo implements Serializable {
private
String
checkCode
;
private
String
checkCode
;
public
boolean
hasGroup
(
String
groupId
)
{
if
(
groupId
==
null
||
groupId
.
equals
(
""
)
||
groupId
.
equals
(
"-1"
))
{
return
true
;
}
else
if
(
getGroups
().
contains
(
groupId
))
{
return
true
;
}
return
false
;
}
}
}
src/main/resources/messages.properties
查看文件 @
39699f8
...
@@ -84,7 +84,8 @@ smfcore.barcodeSetting=\u6761\u7801\u8BBE\u7F6E
...
@@ -84,7 +84,8 @@ smfcore.barcodeSetting=\u6761\u7801\u8BBE\u7F6E
smfcore.posNotExist
=
\u
4ED3
\u
4F4D
\u
4E0D
\u
5B58
\u5728
smfcore.posNotExist
=
\u
4ED3
\u
4F4D
\u
4E0D
\u
5B58
\u5728
smfcore.error
=
\u
51FA
\u9519
{0}
smfcore.error
=
\u
51FA
\u9519
{0}
smfcore.userManager
=
\u7528\u6237\u
7BA1
\u7406
smfcore.userManager
=
\u7528\u6237\u
7BA1
\u7406
smfcode.cannotRemove
=
\u5220\u9664\u
5E93
\u
4F4D
\u5931\u
8D25
\u
FF0C
\u
5E93
\u
4F4D[{0}]
\u
4E2D
\u6709\u6599
smfcode.cannotRemove
=
\u5220\u9664\u
5E93
\u
4F4D
\u5931\u
8D25
\u
FF0C
\u
5E93
\u
4F4D[{0}]
\u
4E2D
\u6709\u6599
smfcode.nogroupaccess=
\u
6CA1
\u6709\u
7EC4[{0}]
\u7684\u
64CD
\u
4F5C
\u6743\u9650
...
...
src/main/resources/messages_en_US.properties
查看文件 @
39699f8
...
@@ -84,4 +84,5 @@ smfcore.barcodeSetting=Barcode setting
...
@@ -84,4 +84,5 @@ smfcore.barcodeSetting=Barcode setting
smfcore.posNotExist
=
Positions do not exist
smfcore.posNotExist
=
Positions do not exist
smfcore.error
=
Error{0}
smfcore.error
=
Error{0}
smfcore.userManager
=
User Management
smfcore.userManager
=
User Management
smfcode.cannotRemove
=
Failed to delete the location, there is material in the location [{0}].
\ No newline at end of file
\ No newline at end of file
smfcode.cannotRemove
=
Failed to delete the location, there is material in the location [{0}].
smfcode.nogroupaccess
=
No operation rights for the group [{0}]
\ No newline at end of file
\ No newline at end of file
src/main/resources/messages_ja_JP.properties
查看文件 @
39699f8
...
@@ -84,4 +84,5 @@ smfcore.barcodeSetting=\u30D0\u30FC\u30B3\u30FC\u30C9\u8A2D\u5B9A
...
@@ -84,4 +84,5 @@ smfcore.barcodeSetting=\u30D0\u30FC\u30B3\u30FC\u30C9\u8A2D\u5B9A
smfcore.posNotExist
=
\u
30E9
\u
30A4
\u
30D6
\u
30E9
\u
30EA
\u
30FC
\u
30B9
\u
30DA
\u
30FC
\u
30B9
\u
304C
\u
5B58
\u5728\u3057\u
306A
\u3044
smfcore.posNotExist
=
\u
30E9
\u
30A4
\u
30D6
\u
30E9
\u
30EA
\u
30FC
\u
30B9
\u
30DA
\u
30FC
\u
30B9
\u
304C
\u
5B58
\u5728\u3057\u
306A
\u3044
smfcore.error
=
\u
8AA4
\u
308A{0}
smfcore.error
=
\u
8AA4
\u
308A{0}
smfcore.userManager
=
\u
30E6
\u
30FC
\u
30B6
\u
30FC
\u
7BA1
\u7406
smfcore.userManager
=
\u
30E6
\u
30FC
\u
30B6
\u
30FC
\u
7BA1
\u7406
smfcode.cannotRemove
=
\u
30B9
\u
30C8
\u
30C3
\u
30AF
\u
30EC
\u
30D9
\u
30EB
\u
306E
\u
524A
\u9664\u
306B
\u5931\u6557\u3057\u
307E
\u3057\u
305F
\u3002\u
30B9
\u
30C8
\u
30C3
\u
30AF
\u
30EC
\u
30D9
\u
30EB[{0}]
\u
306B
\u6750\u6599\u
304C
\u3042\u
308A
\u
307E
\u3059\u3002
\ No newline at end of file
\ No newline at end of file
smfcode.cannotRemove
=
\u
30B9
\u
30C8
\u
30C3
\u
30AF
\u
30EC
\u
30D9
\u
30EB
\u
306E
\u
524A
\u9664\u
306B
\u5931\u6557\u3057\u
307E
\u3057\u
305F
\u3002\u
30B9
\u
30C8
\u
30C3
\u
30AF
\u
30EC
\u
30D9
\u
30EB[{0}]
\u
306B
\u6750\u6599\u
304C
\u3042\u
308A
\u
307E
\u3059\u3002
smfcode.nogroupaccess
=
\u
30B0
\u
30EB
\u
30FC
\u
30D7[{0}]
\u
306E
\u
64CD
\u
4F5C
\u
6A29
\u9650\u
304C
\u3042\u
308A
\u
307E
\u
305B
\u3093\u3002
\ No newline at end of file
\ No newline at end of file
src/main/resources/messages_zh_CN.properties
查看文件 @
39699f8
...
@@ -85,4 +85,5 @@ smfcore.posNotExist=\u4ED3\u4F4D\u4E0D\u5B58\u5728
...
@@ -85,4 +85,5 @@ smfcore.posNotExist=\u4ED3\u4F4D\u4E0D\u5B58\u5728
smfcore.error
=
\u
51FA
\u9519
{0}
smfcore.error
=
\u
51FA
\u9519
{0}
smfcore.userManager
=
\u7528\u6237\u
7BA1
\u7406
smfcore.userManager
=
\u7528\u6237\u
7BA1
\u7406
smfcode.cannotRemove
=
\u5220\u9664\u
5E93
\u
4F4D
\u5931\u
8D25
\u
FF0C
\u
5E93
\u
4F4D[{0}]
\u
4E2D
\u6709\u6599
smfcode.cannotRemove
=
\u5220\u9664\u
5E93
\u
4F4D
\u5931\u
8D25
\u
FF0C
\u
5E93
\u
4F4D[{0}]
\u
4E2D
\u6709\u6599
smfcode.nogroupaccess
=
\u
6CA1
\u6709\u
7EC4[{0}]
\u7684\u
64CD
\u
4F5C
\u6743\u9650
src/main/resources/messages_zh_TW.properties
查看文件 @
39699f8
...
@@ -84,4 +84,5 @@ smfcore.barcodeSetting=\u689D\u78BC\u8A2D\u7F6E
...
@@ -84,4 +84,5 @@ smfcore.barcodeSetting=\u689D\u78BC\u8A2D\u7F6E
smfcore.posNotExist
=
\u
5EAB
\u
4F4D
\u
4E0D
\u
5B58
\u5728
smfcore.posNotExist
=
\u
5EAB
\u
4F4D
\u
4E0D
\u
5B58
\u5728
smfcore.error
=
\u
51FA
\u
932F{0}
smfcore.error
=
\u
51FA
\u
932F{0}
smfcore.userManager
=
\u7528\u6236\u
7BA1
\u7406
smfcore.userManager
=
\u7528\u6236\u
7BA1
\u7406
smfcode.cannotRemove
=
\u
522A
\u9664\u
5EAB
\u
4F4D
\u5931\u6557\u
FF0C
\u
5EAB
\u
4F4D[{0}]
\u
4E2D
\u6709\u6599
\ No newline at end of file
\ No newline at end of file
smfcode.cannotRemove
=
\u
522A
\u9664\u
5EAB
\u
4F4D
\u5931\u6557\u
FF0C
\u
5EAB
\u
4F4D[{0}]
\u
4E2D
\u6709\u6599
smfcode.nogroupaccess
=
\u
6C92
\u6709\u
7D44[{0}]
\u7684\u
64CD
\u
4F5C
\u
6B0A
\ No newline at end of file
\ No newline at end of file
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论