Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
smart_gov_platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
smart_gov_platform
Commits
d98d3d6c
Commit
d98d3d6c
authored
Jun 02, 2022
by
廖旭伟
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
4985c6ac
3028e9b1
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
215 additions
and
343 deletions
+215
-343
portal-manager/doc/api.md
portal-manager/doc/api.md
+96
-294
portal-manager/src/main/java/com/mortals/xhx/module/menu/web/MenuController.java
.../java/com/mortals/xhx/module/menu/web/MenuController.java
+19
-0
portal-manager/src/main/java/com/mortals/xhx/module/role/service/RoleAuthService.java
.../com/mortals/xhx/module/role/service/RoleAuthService.java
+2
-2
portal-manager/src/main/java/com/mortals/xhx/module/role/service/RoleUserService.java
.../com/mortals/xhx/module/role/service/RoleUserService.java
+5
-2
portal-manager/src/main/java/com/mortals/xhx/module/role/service/impl/RoleAuthServiceImpl.java
...als/xhx/module/role/service/impl/RoleAuthServiceImpl.java
+35
-15
portal-manager/src/main/java/com/mortals/xhx/module/role/service/impl/RoleUserServiceImpl.java
...als/xhx/module/role/service/impl/RoleUserServiceImpl.java
+6
-23
portal-manager/src/main/java/com/mortals/xhx/module/role/web/RoleAuthController.java
...a/com/mortals/xhx/module/role/web/RoleAuthController.java
+4
-4
portal-manager/src/main/java/com/mortals/xhx/module/role/web/RoleUserController.java
...a/com/mortals/xhx/module/role/web/RoleUserController.java
+20
-0
portal-manager/src/main/java/com/mortals/xhx/module/user/model/vo/UserVo.java
...ain/java/com/mortals/xhx/module/user/model/vo/UserVo.java
+0
-2
portal-manager/src/test/java/com/mortals/httpclient/menu/MenuController.http
...test/java/com/mortals/httpclient/menu/MenuController.http
+6
-1
portal-manager/src/test/java/com/mortals/httpclient/role/RoleAuthController.http
.../java/com/mortals/httpclient/role/RoleAuthController.http
+11
-0
portal-manager/src/test/java/com/mortals/httpclient/role/RoleUserController.http
.../java/com/mortals/httpclient/role/RoleUserController.http
+11
-0
No files found.
portal-manager/doc/api.md
View file @
d98d3d6c
This diff is collapsed.
Click to expand it.
portal-manager/src/main/java/com/mortals/xhx/module/menu/web/MenuController.java
View file @
d98d3d6c
...
@@ -110,5 +110,24 @@ public class MenuController extends BaseCRUDJsonBodyMappingController<MenuServic
...
@@ -110,5 +110,24 @@ public class MenuController extends BaseCRUDJsonBodyMappingController<MenuServic
return
ret
.
toJSONString
();
return
ret
.
toJSONString
();
}
}
/**
* 查询所有可用菜单(树)
*/
@PostMapping
(
value
=
"findAll"
)
public
String
findAll
()
{
JSONObject
ret
=
new
JSONObject
();
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_SUCCESS
);
try
{
List
<
MenuEntity
>
menuEntityList
=
this
.
service
.
findAllEnable
();
ret
.
put
(
KEY_RESULT_DATA
,
menuEntityList
);
}
catch
(
Exception
e
)
{
log
.
error
(
"更新错误"
,
e
);
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_FAILURE
);
ret
.
put
(
KEY_RESULT_MSG
,
e
.
getMessage
());
}
return
ret
.
toJSONString
();
}
}
}
\ No newline at end of file
portal-manager/src/main/java/com/mortals/xhx/module/role/service/RoleAuthService.java
View file @
d98d3d6c
...
@@ -15,7 +15,7 @@ import com.mortals.xhx.module.role.model.RoleAuthQuery;
...
@@ -15,7 +15,7 @@ import com.mortals.xhx.module.role.model.RoleAuthQuery;
public
interface
RoleAuthService
extends
ICRUDService
<
RoleAuthEntity
,
Long
>
{
public
interface
RoleAuthService
extends
ICRUDService
<
RoleAuthEntity
,
Long
>
{
/**
/**
* 角色分配资源
* 角色分配
菜单
资源
*/
*/
void
doDistributionSource
(
RoleAuthQuery
query
);
void
assignMenu
(
RoleAuthQuery
query
);
}
}
\ No newline at end of file
portal-manager/src/main/java/com/mortals/xhx/module/role/service/RoleUserService.java
View file @
d98d3d6c
...
@@ -12,7 +12,10 @@ import com.mortals.xhx.module.role.model.RoleUserQuery;
...
@@ -12,7 +12,10 @@ import com.mortals.xhx.module.role.model.RoleUserQuery;
* @date 2022-05-25
* @date 2022-05-25
*/
*/
public
interface
RoleUserService
extends
ICRUDService
<
RoleUserEntity
,
Long
>{
public
interface
RoleUserService
extends
ICRUDService
<
RoleUserEntity
,
Long
>{
void
doDistributionUser
(
RoleUserQuery
query
);
void
doDistributionRole
(
RoleUserQuery
query
);
/**
* 给用户分配角色
* @param query
*/
void
assignRoleToUser
(
RoleUserQuery
query
);
}
}
\ No newline at end of file
portal-manager/src/main/java/com/mortals/xhx/module/role/service/impl/RoleAuthServiceImpl.java
View file @
d98d3d6c
...
@@ -3,37 +3,57 @@ package com.mortals.xhx.module.role.service.impl;
...
@@ -3,37 +3,57 @@ package com.mortals.xhx.module.role.service.impl;
import
com.mortals.framework.service.impl.AbstractCRUDServiceImpl
;
import
com.mortals.framework.service.impl.AbstractCRUDServiceImpl
;
import
com.mortals.xhx.module.menu.model.MenuEntity
;
import
com.mortals.xhx.module.menu.model.MenuQuery
;
import
com.mortals.xhx.module.menu.service.MenuService
;
import
com.mortals.xhx.module.role.dao.RoleAuthDao
;
import
com.mortals.xhx.module.role.dao.RoleAuthDao
;
import
com.mortals.xhx.module.role.model.RoleAuthEntity
;
import
com.mortals.xhx.module.role.model.RoleAuthEntity
;
import
com.mortals.xhx.module.role.model.RoleAuthQuery
;
import
com.mortals.xhx.module.role.model.RoleAuthQuery
;
import
com.mortals.xhx.module.role.service.RoleAuthService
;
import
com.mortals.xhx.module.role.service.RoleAuthService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.HashMap
;
import
java.util.stream.Collectors
;
import
java.util.List
;
import
java.util.Map
;
@Service
(
"roleAuthService"
)
@Service
(
"roleAuthService"
)
public
class
RoleAuthServiceImpl
extends
AbstractCRUDServiceImpl
<
RoleAuthDao
,
RoleAuthEntity
,
Long
>
implements
RoleAuthService
{
public
class
RoleAuthServiceImpl
extends
AbstractCRUDServiceImpl
<
RoleAuthDao
,
RoleAuthEntity
,
Long
>
implements
RoleAuthService
{
@Autowired
private
MenuService
menuService
;
@Override
@Override
public
void
doDistributionSource
(
RoleAuthQuery
query
)
{
public
void
assignMenu
(
RoleAuthQuery
query
)
{
// 删除角色资源老数据
Map
<
Long
,
MenuEntity
>
menuEntityMap
=
menuService
.
find
(
new
MenuQuery
()).
stream
().
collect
(
Collectors
.
toMap
(
x
->
x
.
getId
(),
y
->
y
));
// 删除角色菜单资源老数据
Long
roleId
=
query
.
getRoleId
();
Long
roleId
=
query
.
getRoleId
();
Map
<
String
,
Object
>
condition
=
new
HashMap
<>();
Map
<
String
,
Object
>
condition
=
new
HashMap
<>();
condition
.
put
(
"roleId"
,
roleId
);
condition
.
put
(
"roleId"
,
roleId
);
this
.
dao
.
delete
(
condition
);
this
.
dao
.
delete
(
condition
);
List
<
RoleAuthEntity
>
list
=
new
ArrayList
<>();
Set
<
Long
>
curSet
=
query
.
getMenuIdList
().
stream
().
collect
(
Collectors
.
toSet
());
// for (Long sourceId : query.getResourceIdList()) {
query
.
getMenuIdList
().
stream
().
forEach
(
item
->
{
// RoleAuthEntity entity = new RoleAuthEntity();
buildMenus
(
curSet
,
menuEntityMap
.
get
(
item
),
menuEntityMap
);
// entity.setRoleId(roleId);
});
// entity.setResourceId(sourceId);
List
<
RoleAuthEntity
>
list
=
curSet
.
stream
().
map
(
item
->
{
// list.add(entity);
RoleAuthEntity
entity
=
new
RoleAuthEntity
();
// }
entity
.
setRoleId
(
roleId
);
this
.
dao
.
insertBatch
(
list
);
entity
.
setMenuId
(
item
);
return
entity
;
}).
collect
(
Collectors
.
toList
());
this
.
save
(
list
);
}
private
void
buildMenus
(
Set
<
Long
>
curSet
,
MenuEntity
menuEntity
,
Map
<
Long
,
MenuEntity
>
menuEntityMap
)
{
if
(!
ObjectUtils
.
isEmpty
(
menuEntity
))
{
if
(!
curSet
.
contains
(
menuEntity
.
getId
()))
{
curSet
.
add
(
menuEntity
.
getId
());
}
if
(!
ObjectUtils
.
isEmpty
(
menuEntity
.
getParentId
()))
{
buildMenus
(
curSet
,
menuEntityMap
.
get
(
menuEntity
.
getParentId
()),
menuEntityMap
);
}
}
}
}
}
}
\ No newline at end of file
portal-manager/src/main/java/com/mortals/xhx/module/role/service/impl/RoleUserServiceImpl.java
View file @
d98d3d6c
...
@@ -25,31 +25,14 @@ import java.util.Map;
...
@@ -25,31 +25,14 @@ import java.util.Map;
public
class
RoleUserServiceImpl
extends
AbstractCRUDServiceImpl
<
RoleUserDao
,
RoleUserEntity
,
Long
>
implements
RoleUserService
{
public
class
RoleUserServiceImpl
extends
AbstractCRUDServiceImpl
<
RoleUserDao
,
RoleUserEntity
,
Long
>
implements
RoleUserService
{
@Override
@Override
public
void
doDistributionUser
(
RoleUserQuery
query
)
{
public
void
assignRoleToUser
(
RoleUserQuery
query
)
{
Long
roleId
=
query
.
getRoleId
();
//删除当前用户所有关联角色
// 删除角色对应的用户信息
Map
<
String
,
Object
>
condition
=
new
HashMap
<>(
1
);
condition
.
put
(
"roleId"
,
roleId
);
dao
.
delete
(
condition
);
List
<
Long
>
userIdList
=
query
.
getUserIdList
();
List
<
RoleUserEntity
>
list
=
new
ArrayList
<>();
for
(
Long
userId
:
userIdList
)
{
RoleUserEntity
rolseUser
=
new
RoleUserEntity
();
rolseUser
.
setRoleId
(
roleId
);
rolseUser
.
setUserId
(
userId
);
list
.
add
(
rolseUser
);
}
this
.
dao
.
insertBatch
(
list
);
}
@Override
public
void
doDistributionRole
(
RoleUserQuery
query
)
{
// 删除角色对应的用户信息
Long
userId
=
query
.
getUserId
();
Long
userId
=
query
.
getUserId
();
Map
<
String
,
Object
>
condition
=
new
HashMap
<>(
1
);
Map
<
String
,
Object
>
condition
=
new
HashMap
<>(
1
);
condition
.
put
(
"userId"
,
userId
);
condition
.
put
(
"userId"
,
userId
);
dao
.
delete
(
condition
);
dao
.
delete
(
condition
);
//新增用户角色
List
<
Long
>
roleIdList
=
query
.
getRoleIdList
();
List
<
Long
>
roleIdList
=
query
.
getRoleIdList
();
List
<
RoleUserEntity
>
list
=
new
ArrayList
<>();
List
<
RoleUserEntity
>
list
=
new
ArrayList
<>();
for
(
Long
roleId
:
roleIdList
)
{
for
(
Long
roleId
:
roleIdList
)
{
...
@@ -58,7 +41,7 @@ public class RoleUserServiceImpl extends AbstractCRUDServiceImpl<RoleUserDao, Ro
...
@@ -58,7 +41,7 @@ public class RoleUserServiceImpl extends AbstractCRUDServiceImpl<RoleUserDao, Ro
rolseUser
.
setUserId
(
userId
);
rolseUser
.
setUserId
(
userId
);
list
.
add
(
rolseUser
);
list
.
add
(
rolseUser
);
}
}
this
.
dao
.
insertBatch
(
list
);
this
.
save
(
list
);
}
}
}
}
\ No newline at end of file
portal-manager/src/main/java/com/mortals/xhx/module/role/web/RoleAuthController.java
View file @
d98d3d6c
...
@@ -38,12 +38,12 @@ public class RoleAuthController extends BaseCRUDJsonBodyMappingController<RoleAu
...
@@ -38,12 +38,12 @@ public class RoleAuthController extends BaseCRUDJsonBodyMappingController<RoleAu
}
}
/**
/**
* 分配菜单
* 分配菜单
到角色
*/
*/
@PostMapping
(
value
=
"
distributionSourc
e"
)
@PostMapping
(
value
=
"
assignMenuToRol
e"
)
public
String
distributionUser
(
@RequestBody
RoleAuthQuery
query
)
{
public
String
assignMenuToRole
(
@RequestBody
RoleAuthQuery
query
)
{
try
{
try
{
service
.
doDistributionSource
(
query
);
service
.
assignMenu
(
query
);
JSONObject
ret
=
new
JSONObject
();
JSONObject
ret
=
new
JSONObject
();
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_SUCCESS
);
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_SUCCESS
);
return
ret
.
toJSONString
();
return
ret
.
toJSONString
();
...
...
portal-manager/src/main/java/com/mortals/xhx/module/role/web/RoleUserController.java
View file @
d98d3d6c
...
@@ -55,4 +55,24 @@ public class RoleUserController extends BaseCRUDJsonBodyMappingController<RoleUs
...
@@ -55,4 +55,24 @@ public class RoleUserController extends BaseCRUDJsonBodyMappingController<RoleUs
}
}
/**
* 给用户分配角色
*/
@PostMapping
(
value
=
"assignRoleToUser"
)
public
String
assignRoleToUser
(
@RequestBody
RoleUserQuery
query
)
{
JSONObject
ret
=
new
JSONObject
();
try
{
this
.
service
.
assignRoleToUser
(
query
);
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_SUCCESS
);
ret
.
put
(
KEY_RESULT_MSG
,
"分配角色成功!"
);
recordSysLog
(
request
,
getCurUser
(),
"分配角色成功!"
);
return
ret
.
toJSONString
();
}
catch
(
Exception
e
)
{
log
.
error
(
"分配角色错误"
,
e
);
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_FAILURE
);
ret
.
put
(
KEY_RESULT_MSG
,
super
.
convertException
(
e
));
return
ret
.
toJSONString
();
}
}
}
}
\ No newline at end of file
portal-manager/src/main/java/com/mortals/xhx/module/user/model/vo/UserVo.java
View file @
d98d3d6c
...
@@ -48,6 +48,4 @@ public class UserVo extends BaseEntityLong {
...
@@ -48,6 +48,4 @@ public class UserVo extends BaseEntityLong {
/** 查询条件 */
/** 查询条件 */
private
String
query
;
private
String
query
;
/** 角色id */
private
Long
roleId
;
}
}
\ No newline at end of file
portal-manager/src/test/java/com/mortals/httpclient/menu/MenuController.http
View file @
d98d3d6c
...
@@ -6,7 +6,8 @@ Content-Type: application/json
...
@@ -6,7 +6,8 @@ Content-Type: application/json
{
{
"page":1,
"page":1,
"size":10
"size":10,
"parentId":2
}
}
...
@@ -47,5 +48,9 @@ Authorization: {{authToken}}
...
@@ -47,5 +48,9 @@ Authorization: {{authToken}}
Accept: application/json
Accept: application/json
###菜单信息业务列表
POST {{baseUrl}}/menu/findAll
Authorization: {{authToken}}
Content-Type: application/json
portal-manager/src/test/java/com/mortals/httpclient/role/RoleAuthController.http
View file @
d98d3d6c
...
@@ -10,6 +10,17 @@ Content-Type: application/json
...
@@ -10,6 +10,17 @@ Content-Type: application/json
}
}
###分配菜单到角色
POST {{baseUrl}}/role/auth/assignMenuToRole
Authorization: {{authToken}}
Content-Type: application/json
{
"roleId":2,
"menuIdList":[2]
}
###角色菜单权限关联更新与保存
###角色菜单权限关联更新与保存
POST {{baseUrl}}/role/auth/save
POST {{baseUrl}}/role/auth/save
Authorization: {{authToken}}
Authorization: {{authToken}}
...
...
portal-manager/src/test/java/com/mortals/httpclient/role/RoleUserController.http
View file @
d98d3d6c
...
@@ -10,6 +10,17 @@ Content-Type: application/json
...
@@ -10,6 +10,17 @@ Content-Type: application/json
}
}
###分配用户到角色
POST {{baseUrl}}/role/user/assignRoleToUser
Authorization: {{authToken}}
Content-Type: application/json
{
"userId":1,
"roleIdList":[1,2]
}
###角色用户关联更新与保存
###角色用户关联更新与保存
POST {{baseUrl}}/role/user/save
POST {{baseUrl}}/role/user/save
Authorization: {{authToken}}
Authorization: {{authToken}}
...
...
Write
Preview
Markdown
is supported
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