Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cneeds-server
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhangzr
cneeds-server
Commits
b8493227
Commit
b8493227
authored
Mar 09, 2020
by
zzrdark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.增加数据库数据
2.增加数据权限拦截 3.增加分页插件 4.增加系统模块查询
parent
ec75ecf6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
449 additions
and
17 deletions
+449
-17
workspace.xml
.idea/workspace.xml
+0
-0
cneeds_server.sql
cneeds-common-data/db/cneeds_server.sql
+1
-1
pom.xml
cneeds-common-data/pom.xml
+2
-1
SysDeptDao.java
...ta/src/main/java/com/mx/cneeds/server/dao/SysDeptDao.java
+9
-1
SysRoleDeptDao.java
...rc/main/java/com/mx/cneeds/server/dao/SysRoleDeptDao.java
+7
-0
SysUserRoleDao.java
...rc/main/java/com/mx/cneeds/server/dao/SysUserRoleDao.java
+8
-1
SysDeptDao.xml
cneeds-common-data/src/main/resources/mapper/SysDeptDao.xml
+5
-0
SysRoleDeptDao.xml
...-common-data/src/main/resources/mapper/SysRoleDeptDao.xml
+8
-0
SysUserRoleDao.xml
...-common-data/src/main/resources/mapper/SysUserRoleDao.xml
+4
-0
FuncDto.java
...-pojo/src/main/java/com/mx/cneeds/common/dto/FuncDto.java
+29
-0
PageDto.java
...-pojo/src/main/java/com/mx/cneeds/common/dto/PageDto.java
+51
-0
pom.xml
cneeds-common-utils/pom.xml
+2
-1
DataFilter.java
...main/java/com/mx/cneeds/common/annotation/DataFilter.java
+37
-0
Query.java
...utils/src/main/java/com/mx/cneeds/common/pager/Query.java
+4
-5
UserClient.java
...java/com/mx/cneeds/server/datashow/client/UserClient.java
+21
-0
SystemController.java
...x/cneeds/server/datashow/web/system/SystemController.java
+33
-0
UserController.java
.../mx/cneeds/server/datashow/web/system/UserController.java
+10
-4
DataFilterAspect.java
...va/com/mx/cneeds/server/user/common/DataFilterAspect.java
+121
-0
MybatisPlusConfig.java
...a/com/mx/cneeds/server/user/config/MybatisPlusConfig.java
+25
-0
SysDeptService.java
...ava/com/mx/cneeds/server/user/service/SysDeptService.java
+8
-0
SysRoleDeptService.java
...com/mx/cneeds/server/user/service/SysRoleDeptService.java
+6
-0
SysUserRoleService.java
...com/mx/cneeds/server/user/service/SysUserRoleService.java
+7
-0
SysDeptServiceImpl.java
...x/cneeds/server/user/service/impl/SysDeptServiceImpl.java
+34
-0
SysRoleDeptServiceImpl.java
...eeds/server/user/service/impl/SysRoleDeptServiceImpl.java
+7
-0
SysUserRoleServiceImpl.java
...eeds/server/user/service/impl/SysUserRoleServiceImpl.java
+8
-0
SysFuncController.java
...java/com/mx/cneeds/server/user/web/SysFuncController.java
+2
-3
No files found.
.idea/workspace.xml
View file @
b8493227
This diff is collapsed.
Click to expand it.
cneeds-common-data/db/cneeds_server.sql
View file @
b8493227
...
...
@@ -108,7 +108,7 @@ CREATE TABLE `sys_func` (
`parent_id`
bigint
(
20
)
NOT
NULL
,
`name`
varchar
(
50
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
DEFAULT
NULL
,
`url`
varchar
(
50
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
DEFAULT
NULL
,
`perms`
varchar
(
5
0
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
DEFAULT
NULL
,
`perms`
varchar
(
100
0
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
DEFAULT
NULL
,
`type`
int
(
11
)
DEFAULT
NULL
,
`order_num`
int
(
11
)
DEFAULT
NULL
,
PRIMARY
KEY
(
`func_id`
)
USING
BTREE
...
...
cneeds-common-data/pom.xml
View file @
b8493227
...
...
@@ -17,7 +17,8 @@
<mybatis.spring.boot.version>
1.3.0
</mybatis.spring.boot.version>
<pagehelper.spring.boot.version>
1.2.5
</pagehelper.spring.boot.version>
<mysql.version>
8.0.16
</mysql.version>
<mybatisplus.version>
3.1.2
</mybatisplus.version>
<!-- <mybatisplus.version>3.1.2</mybatisplus.version>-->
<mybatisplus.version>
3.0.7.1
</mybatisplus.version>
<druid.version>
1.1.13
</druid.version>
</properties>
...
...
cneeds-common-data/src/main/java/com/mx/cneeds/server/dao/SysDeptDao.java
View file @
b8493227
...
...
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import
com.mx.cneeds.server.entity.SysDeptEntity
;
import
org.apache.ibatis.annotations.Mapper
;
import
java.util.List
;
/**
* 部门表
*
...
...
@@ -13,5 +15,11 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public
interface
SysDeptDao
extends
BaseMapper
<
SysDeptEntity
>
{
/**
* 查询子部门ID列表
* @param parentId 上级部门ID
*/
List
<
Long
>
queryDetpIdList
(
Long
parentId
);
}
cneeds-common-data/src/main/java/com/mx/cneeds/server/dao/SysRoleDeptDao.java
View file @
b8493227
...
...
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import
com.mx.cneeds.server.entity.SysRoleDeptEntity
;
import
org.apache.ibatis.annotations.Mapper
;
import
java.util.List
;
/**
* 部门与角色映射表
*
...
...
@@ -13,5 +15,10 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public
interface
SysRoleDeptDao
extends
BaseMapper
<
SysRoleDeptEntity
>
{
/**
* 根据角色ID,获取部门ID列表
*/
List
<
Long
>
queryDeptIdList
(
Long
[]
roleIds
);
}
cneeds-common-data/src/main/java/com/mx/cneeds/server/dao/SysUserRoleDao.java
View file @
b8493227
...
...
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import
com.mx.cneeds.server.entity.SysUserRoleEntity
;
import
org.apache.ibatis.annotations.Mapper
;
import
java.util.List
;
/**
* 角色用户映射表
*
...
...
@@ -13,5 +15,10 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public
interface
SysUserRoleDao
extends
BaseMapper
<
SysUserRoleEntity
>
{
/**
* 根据用户ID,获取角色ID列表
*/
List
<
Long
>
queryRoleIdList
(
Long
userId
);
}
cneeds-common-data/src/main/resources/mapper/SysDeptDao.xml
View file @
b8493227
...
...
@@ -14,4 +14,8 @@
</resultMap>
<select
id=
"queryDetpIdList"
resultType=
"long"
>
select dept_id from sys_dept where parent_id = #{value} and del_flag = 0
</select>
</mapper>
\ No newline at end of file
cneeds-common-data/src/main/resources/mapper/SysRoleDeptDao.xml
View file @
b8493227
...
...
@@ -11,4 +11,11 @@
</resultMap>
<select
id=
"queryDeptIdList"
resultType=
"long"
>
select dept_id from sys_role_dept where role_id in
<foreach
item=
"roleId"
collection=
"array"
open=
"("
separator=
","
close=
")"
>
#{roleId}
</foreach>
</select>
</mapper>
\ No newline at end of file
cneeds-common-data/src/main/resources/mapper/SysUserRoleDao.xml
View file @
b8493227
...
...
@@ -10,5 +10,8 @@
<result
property=
"roleId"
column=
"role_id"
/>
</resultMap>
<select
id=
"queryRoleIdList"
resultType=
"long"
>
select role_id from sys_user_role where user_id = #{value}
</select>
</mapper>
\ No newline at end of file
cneeds-common-pojo/src/main/java/com/mx/cneeds/common/dto/FuncDto.java
0 → 100644
View file @
b8493227
package
com
.
mx
.
cneeds
.
common
.
dto
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @ClassName FuncDto
* @Author zzrdark
* @Date 2020-03-09 16:17
* @Description TODO
**/
@Data
public
class
FuncDto
implements
Serializable
{
private
Long
funcId
;
private
Long
parentId
;
private
String
name
;
private
String
url
;
private
String
perms
;
private
Integer
type
;
private
Integer
orderNum
;
}
cneeds-common-pojo/src/main/java/com/mx/cneeds/common/dto/PageDto.java
0 → 100644
View file @
b8493227
package
com
.
mx
.
cneeds
.
common
.
dto
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.List
;
/**
* @ClassName PageResult
* @Author zzrdark
* @Date 2020-03-09 16:01
* @Description TODO
**/
@Data
public
class
PageDto
implements
Serializable
{
/**
* 总记录数
*/
private
int
totalCount
;
/**
* 每页记录数
*/
private
int
pageSize
;
/**
* 总页数
*/
private
int
totalPage
;
/**
* 当前页数
*/
private
int
currPage
;
/**
* 列表数据
*/
private
List
<?>
list
;
/**
* 分页
* @param list 列表数据
* @param totalCount 总记录数
* @param pageSize 每页记录数
* @param currPage 当前页数
*/
public
PageDto
(
List
<?>
list
,
int
totalCount
,
int
pageSize
,
int
currPage
)
{
this
.
list
=
list
;
this
.
totalCount
=
totalCount
;
this
.
pageSize
=
pageSize
;
this
.
currPage
=
currPage
;
this
.
totalPage
=
(
int
)
Math
.
ceil
((
double
)
totalCount
/
pageSize
);
}
}
cneeds-common-utils/pom.xml
View file @
b8493227
...
...
@@ -13,7 +13,8 @@
<artifactId>
cneeds-common-utils
</artifactId>
<properties>
<mybatisplus.version>
3.1.2
</mybatisplus.version>
<!-- <mybatisplus.version>3.1.2</mybatisplus.version>-->
<mybatisplus.version>
3.0.7.1
</mybatisplus.version>
<commons.lang.version>
2.6
</commons.lang.version>
<commons.io.version>
2.5
</commons.io.version>
</properties>
...
...
cneeds-common-utils/src/main/java/com/mx/cneeds/common/annotation/DataFilter.java
0 → 100644
View file @
b8493227
/**
* Copyright (c) 2016-2019 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有,侵权必究!
*/
package
com
.
mx
.
cneeds
.
common
.
annotation
;
import
java.lang.annotation.*
;
/**
* 数据过滤
*
* @author Mark sunlightcs@gmail.com
*/
@Target
(
ElementType
.
METHOD
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
public
@interface
DataFilter
{
/** 表的别名 */
String
tableAlias
()
default
""
;
/** true:没有本部门数据权限,也能查询本人数据 */
boolean
user
()
default
true
;
/** true:拥有子部门数据权限 */
boolean
subDept
()
default
false
;
/** 部门ID */
String
deptId
()
default
"dept_id"
;
/** 用户ID */
String
userId
()
default
"user_id"
;
}
cneeds-common-utils/src/main/java/com/mx/cneeds/common/pager/Query.java
View file @
b8493227
...
...
@@ -9,7 +9,6 @@
package
com
.
mx
.
cneeds
.
common
.
pager
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.metadata.OrderItem
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.mx.cneeds.common.xss.SQLFilter
;
import
org.apache.commons.lang.StringUtils
;
...
...
@@ -53,9 +52,9 @@ public class Query<T> {
//前端字段排序
if
(
StringUtils
.
isNotEmpty
(
orderField
)
&&
StringUtils
.
isNotEmpty
(
order
)){
if
(
Constant
.
ASC
.
equalsIgnoreCase
(
order
))
{
return
page
.
addOrder
(
OrderItem
.
asc
(
orderField
)
);
return
page
.
setAsc
(
orderField
);
}
else
{
return
page
.
addOrder
(
OrderItem
.
desc
(
orderField
)
);
return
page
.
setDesc
(
orderField
);
}
}
...
...
@@ -66,9 +65,9 @@ public class Query<T> {
//默认排序
if
(
isAsc
)
{
page
.
addOrder
(
OrderItem
.
asc
(
defaultOrderField
)
);
page
.
setAsc
(
defaultOrderField
);
}
else
{
page
.
addOrder
(
OrderItem
.
desc
(
defaultOrderField
)
);
page
.
setDesc
(
defaultOrderField
);
}
return
page
;
...
...
cneeds-server-datashow/src/main/java/com/mx/cneeds/server/datashow/client/UserClient.java
0 → 100644
View file @
b8493227
package
com
.
mx
.
cneeds
.
server
.
datashow
.
client
;
import
com.mx.cneeds.common.dto.JwtToken
;
import
com.mx.cneeds.common.dto.PageDto
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
/**
* @ClassName UserClient
* @Author zzrdark
* @Date 2020-03-09 15:21
* @Description TODO
**/
@FeignClient
(
name
=
"CNEEDS-SERVER-USER"
)
public
interface
UserClient
{
@PostMapping
(
"/sys/func/list"
)
PageDto
funcList
();
}
cneeds-server-datashow/src/main/java/com/mx/cneeds/server/datashow/web/system/SystemController.java
0 → 100644
View file @
b8493227
package
com
.
mx
.
cneeds
.
server
.
datashow
.
web
.
system
;
import
com.mx.cneeds.common.dto.PageDto
;
import
com.mx.cneeds.common.result.R
;
import
com.mx.cneeds.server.datashow.client.UserClient
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* @ClassName SystemController
* @Author zzrdark
* @Date 2020-03-09 15:19
* @Description TODO
**/
@RestController
@Slf4j
@RequestMapping
(
"/sys"
)
public
class
SystemController
{
@Autowired
private
UserClient
userClient
;
@PostMapping
(
"/module/list"
)
public
R
funcList
(){
PageDto
pageDto
=
userClient
.
funcList
();
return
new
R
().
put
(
"data"
,
pageDto
);
}
}
cneeds-server-datashow/src/main/java/com/mx/cneeds/server/datashow/web/
user
/UserController.java
→
cneeds-server-datashow/src/main/java/com/mx/cneeds/server/datashow/web/
system
/UserController.java
View file @
b8493227
package
com
.
mx
.
cneeds
.
server
.
datashow
.
web
.
user
;
package
com
.
mx
.
cneeds
.
server
.
datashow
.
web
.
system
;
import
com.mx.cneeds.common.result.R
;
import
com.mx.cneeds.common.vo.UserInfoVo
;
import
com.mx.cneeds.server.datashow.client.AuthorizationClient
;
import
com.mx.cneeds.common.dto.JwtToken
;
import
com.mx.cneeds.server.datashow.client.UserClient
;
import
com.netflix.client.http.HttpResponse
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -29,6 +30,9 @@ public class UserController {
private
AuthorizationClient
authenticatorClient
;
@Autowired
private
UserClient
userClient
;
/**
* 登陆接口
* @param username
...
...
@@ -44,14 +48,16 @@ public class UserController {
}
@RequestMapping
(
"/info"
)
public
R
getInfo
(
HttpServletResponse
response
){
public
R
getInfo
(){
UserInfoVo
userInfoVo
=
new
UserInfoVo
();
log
.
info
(
"getInfo"
);
userInfoVo
.
setName
(
"admin"
);
userInfoVo
.
setIntroduction
(
"manager"
);
userInfoVo
.
setRoles
(
"admin"
);
userInfoVo
.
setRoles
(
"
book:editor,
admin"
);
userInfoVo
.
setAvatar
(
"avatar"
);
return
new
R
().
put
(
"data"
,
userInfoVo
);
}
}
cneeds-server-user/src/main/java/com/mx/cneeds/server/user/common/DataFilterAspect.java
0 → 100644
View file @
b8493227
/**
* Copyright (c) 2016-2019 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有,侵权必究!
*/
package
com
.
mx
.
cneeds
.
server
.
user
.
common
;
import
com.mx.cneeds.common.annotation.DataFilter
;
import
com.mx.cneeds.common.exception.RRException
;
import
com.mx.cneeds.common.pager.Constant
;
import
com.mx.cneeds.server.user.service.SysDeptService
;
import
com.mx.cneeds.server.user.service.SysRoleDeptService
;
import
com.mx.cneeds.server.user.service.SysUserRoleService
;
import
org.apache.commons.lang.StringUtils
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Before
;
import
org.aspectj.lang.annotation.Pointcut
;
import
org.aspectj.lang.reflect.MethodSignature
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
/**
* 数据过滤,切面处理类
*
* @author Mark sunlightcs@gmail.com
*/
@Aspect
@Component
public
class
DataFilterAspect
{
@Autowired
private
SysDeptService
sysDeptService
;
@Autowired
private
SysUserRoleService
sysUserRoleService
;
@Autowired
private
SysRoleDeptService
sysRoleDeptService
;
@Pointcut
(
"@annotation(com.mx.cneeds.common.annotation.DataFilter)"
)
public
void
dataFilterCut
()
{
}
@Before
(
"dataFilterCut()"
)
public
void
dataFilter
(
JoinPoint
point
)
throws
Throwable
{
Object
params
=
point
.
getArgs
()[
0
];
if
(
params
!=
null
&&
params
instanceof
Map
){
// SysUserEntity user = ShiroUtils.getUserEntity();
Long
userId
=
(
Long
)
((
Map
)
params
).
get
(
"userId"
);
//如果不是超级管理员,则进行数据过滤
if
(
userId
!=
Constant
.
SUPER_ADMIN
){
Map
map
=
(
Map
)
params
;
map
.
put
(
Constant
.
SQL_FILTER
,
getSQLFilter
(
userId
,
point
));
}
return
;
}
throw
new
RRException
(
"数据权限接口,只能是Map类型参数,且不能为NULL"
);
}
/**
* 获取数据过滤的SQL
*/
private
String
getSQLFilter
(
Long
userId
,
JoinPoint
point
){
MethodSignature
signature
=
(
MethodSignature
)
point
.
getSignature
();
DataFilter
dataFilter
=
signature
.
getMethod
().
getAnnotation
(
DataFilter
.
class
);
//获取表的别名
String
tableAlias
=
dataFilter
.
tableAlias
();
if
(
StringUtils
.
isNotBlank
(
tableAlias
)){
tableAlias
+=
"."
;
}
//部门ID列表
Set
<
Long
>
deptIdList
=
new
HashSet
<>();
//用户角色对应的部门ID列表
List
<
Long
>
roleIdList
=
sysUserRoleService
.
queryRoleIdList
(
userId
);
if
(
roleIdList
.
size
()
>
0
){
List
<
Long
>
userDeptIdList
=
sysRoleDeptService
.
queryDeptIdList
(
roleIdList
.
toArray
(
new
Long
[
roleIdList
.
size
()]));
deptIdList
.
addAll
(
userDeptIdList
);
}
//用户子部门ID列表
if
(
dataFilter
.
subDept
()){
List
<
Long
>
subDeptIdList
=
sysDeptService
.
getSubDeptIdList
(
userId
);
deptIdList
.
addAll
(
subDeptIdList
);
}
StringBuilder
sqlFilter
=
new
StringBuilder
();
sqlFilter
.
append
(
" ("
);
if
(
deptIdList
.
size
()
>
0
){
sqlFilter
.
append
(
tableAlias
).
append
(
dataFilter
.
deptId
()).
append
(
" in("
).
append
(
StringUtils
.
join
(
deptIdList
,
","
)).
append
(
")"
);
}
//没有本部门数据权限,也能查询本人数据
if
(
dataFilter
.
user
()){
if
(
deptIdList
.
size
()
>
0
){
sqlFilter
.
append
(
" or "
);
}
sqlFilter
.
append
(
tableAlias
).
append
(
dataFilter
.
userId
()).
append
(
"="
).
append
(
userId
);
}
sqlFilter
.
append
(
")"
);
if
(
sqlFilter
.
toString
().
trim
().
equals
(
"()"
)){
return
null
;
}
return
sqlFilter
.
toString
();
}
}
cneeds-server-user/src/main/java/com/mx/cneeds/server/user/config/MybatisPlusConfig.java
0 → 100644
View file @
b8493227
package
com
.
mx
.
cneeds
.
server
.
user
.
config
;
import
com.baomidou.mybatisplus.core.injector.ISqlInjector
;
import
com.baomidou.mybatisplus.extension.injector.LogicSqlInjector
;
import
com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
@Configuration
public
class
MybatisPlusConfig
{
/**
* 分页插件
*/
@Bean
public
PaginationInterceptor
paginationInterceptor
()
{
return
new
PaginationInterceptor
();
}
@Bean
public
ISqlInjector
sqlInjector
()
{
return
new
LogicSqlInjector
();
}
}
\ No newline at end of file
cneeds-server-user/src/main/java/com/mx/cneeds/server/user/service/SysDeptService.java
View file @
b8493227
...
...
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import
com.mx.cneeds.common.pager.PageUtils
;
import
com.mx.cneeds.server.entity.SysDeptEntity
;
import
java.util.List
;
import
java.util.Map
;
/**
...
...
@@ -16,5 +17,12 @@ import java.util.Map;
public
interface
SysDeptService
extends
IService
<
SysDeptEntity
>
{
PageUtils
queryPage
(
Map
<
String
,
Object
>
params
);
/**
* 获取子部门ID,用于数据过滤
*/
List
<
Long
>
getSubDeptIdList
(
Long
deptId
);
List
<
Long
>
queryDetpIdList
(
Long
parentId
);
}
cneeds-server-user/src/main/java/com/mx/cneeds/server/user/service/SysRoleDeptService.java
View file @
b8493227
...
...
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import
com.mx.cneeds.common.pager.PageUtils
;
import
com.mx.cneeds.server.entity.SysRoleDeptEntity
;
import
java.util.List
;
import
java.util.Map
;
/**
...
...
@@ -16,5 +17,10 @@ import java.util.Map;
public
interface
SysRoleDeptService
extends
IService
<
SysRoleDeptEntity
>
{
PageUtils
queryPage
(
Map
<
String
,
Object
>
params
);
/**
* 根据角色ID,获取部门ID列表
*/
List
<
Long
>
queryDeptIdList
(
Long
[]
roleIds
)
;
}
cneeds-server-user/src/main/java/com/mx/cneeds/server/user/service/SysUserRoleService.java
View file @
b8493227
...
...
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import
com.mx.cneeds.common.pager.PageUtils
;
import
com.mx.cneeds.server.entity.SysUserRoleEntity
;
import
java.util.List
;
import
java.util.Map
;
/**
...
...
@@ -16,5 +17,11 @@ import java.util.Map;
public
interface
SysUserRoleService
extends
IService
<
SysUserRoleEntity
>
{
PageUtils
queryPage
(
Map
<
String
,
Object
>
params
);
/**
* 根据用户ID,获取角色ID列表
* @param userId
*/
List
<
Long
>
queryRoleIdList
(
Long
userId
);
}
cneeds-server-user/src/main/java/com/mx/cneeds/server/user/service/impl/SysDeptServiceImpl.java
View file @
b8493227
...
...
@@ -6,6 +6,9 @@ import com.mx.cneeds.server.dao.SysDeptDao;
import
com.mx.cneeds.server.entity.SysDeptEntity
;
import
com.mx.cneeds.server.user.service.SysDeptService
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
...
...
@@ -26,4 +29,35 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptDao, SysDeptEntity> i
return
new
PageUtils
(
page
);
}
@Override
public
List
<
Long
>
getSubDeptIdList
(
Long
deptId
){
//部门及子部门ID列表
List
<
Long
>
deptIdList
=
new
ArrayList
<>();
//获取子部门ID
List
<
Long
>
subIdList
=
queryDetpIdList
(
deptId
);
getDeptTreeList
(
subIdList
,
deptIdList
);
return
deptIdList
;
}
@Override
public
List
<
Long
>
queryDetpIdList
(
Long
parentId
)
{
return
baseMapper
.
queryDetpIdList
(
parentId
);
}
/**
* 递归
*/
private
void
getDeptTreeList
(
List
<
Long
>
subIdList
,
List
<
Long
>
deptIdList
){
for
(
Long
deptId
:
subIdList
){
List
<
Long
>
list
=
queryDetpIdList
(
deptId
);
if
(
list
.
size
()
>
0
){
getDeptTreeList
(
list
,
deptIdList
);
}
deptIdList
.
add
(
deptId
);
}
}
}
cneeds-server-user/src/main/java/com/mx/cneeds/server/user/service/impl/SysRoleDeptServiceImpl.java
View file @
b8493227
...
...
@@ -6,6 +6,8 @@ import com.mx.cneeds.server.dao.SysRoleDeptDao;
import
com.mx.cneeds.server.entity.SysRoleDeptEntity
;
import
com.mx.cneeds.server.user.service.SysRoleDeptService
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.Map
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
...
...
@@ -25,4 +27,9 @@ public class SysRoleDeptServiceImpl extends ServiceImpl<SysRoleDeptDao, SysRoleD
return
new
PageUtils
(
page
);
}
@Override
public
List
<
Long
>
queryDeptIdList
(
Long
[]
roleIds
)
{
return
baseMapper
.
queryDeptIdList
(
roleIds
);
}
}
cneeds-server-user/src/main/java/com/mx/cneeds/server/user/service/impl/SysUserRoleServiceImpl.java
View file @
b8493227
...
...
@@ -6,6 +6,8 @@ import com.mx.cneeds.server.dao.SysUserRoleDao;
import
com.mx.cneeds.server.entity.SysUserRoleEntity
;
import
com.mx.cneeds.server.user.service.SysUserRoleService
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.Map
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
...
...
@@ -25,4 +27,10 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleDao, SysUserR
return
new
PageUtils
(
page
);
}
@Override
public
List
<
Long
>
queryRoleIdList
(
Long
userId
)
{
return
baseMapper
.
queryRoleIdList
(
userId
);
}
}
cneeds-server-user/src/main/java/com/mx/cneeds/server/user/web/SysFuncController.java
View file @
b8493227
...
...
@@ -32,10 +32,9 @@ public class SysFuncController {
*/
@RequestMapping
(
"/list"
)
// @RequiresPermissions("sys:sysfunc:list")
public
R
list
(
@RequestParam
Map
<
String
,
Object
>
params
){
public
PageUtils
list
(
@RequestParam
Map
<
String
,
Object
>
params
){
PageUtils
page
=
sysFuncService
.
queryPage
(
params
);
return
R
.
ok
().
put
(
"page"
,
page
);
return
page
;
}
...
...
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