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
9c2372bb
Commit
9c2372bb
authored
Mar 16, 2020
by
zzrdark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.用户模块
parent
7d1b62ad
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
738 additions
and
25 deletions
+738
-25
workspace.xml
.idea/workspace.xml
+0
-0
cneeds_server.sql
cneeds-common-data/db/cneeds_server.sql
+27
-0
SysRoleDao.java
...ta/src/main/java/com/mx/cneeds/server/dao/SysRoleDao.java
+5
-1
SysUserDeptDao.java
...rc/main/java/com/mx/cneeds/server/dao/SysUserDeptDao.java
+20
-0
SysUserFuncDao.java
...rc/main/java/com/mx/cneeds/server/dao/SysUserFuncDao.java
+20
-0
SysUserDeptEntity.java
...n/java/com/mx/cneeds/server/entity/SysUserDeptEntity.java
+36
-0
SysUserFuncEntity.java
...n/java/com/mx/cneeds/server/entity/SysUserFuncEntity.java
+36
-0
SysRoleDao.xml
cneeds-common-data/src/main/resources/mapper/SysRoleDao.xml
+9
-0
SysUserDeptDao.xml
...-common-data/src/main/resources/mapper/SysUserDeptDao.xml
+23
-0
SysUserFuncDao.xml
...-common-data/src/main/resources/mapper/SysUserFuncDao.xml
+20
-0
UserDto.java
...-pojo/src/main/java/com/mx/cneeds/common/dto/UserDto.java
+8
-0
SystemController.java
...x/cneeds/server/datashow/web/system/SystemController.java
+56
-2
SysRoleService.java
...ava/com/mx/cneeds/server/user/service/SysRoleService.java
+7
-0
SysUserDeptService.java
...com/mx/cneeds/server/user/service/SysUserDeptService.java
+26
-0
SysUserFuncService.java
...com/mx/cneeds/server/user/service/SysUserFuncService.java
+26
-0
SysUserRoleService.java
...com/mx/cneeds/server/user/service/SysUserRoleService.java
+2
-0
SysUserService.java
...ava/com/mx/cneeds/server/user/service/SysUserService.java
+8
-0
SysRoleServiceImpl.java
...x/cneeds/server/user/service/impl/SysRoleServiceImpl.java
+19
-0
SysUserDeptServiceImpl.java
...eeds/server/user/service/impl/SysUserDeptServiceImpl.java
+58
-0
SysUserFuncServiceImpl.java
...eeds/server/user/service/impl/SysUserFuncServiceImpl.java
+59
-0
SysUserRoleServiceImpl.java
...eeds/server/user/service/impl/SysUserRoleServiceImpl.java
+16
-0
SysUserServiceImpl.java
...x/cneeds/server/user/service/impl/SysUserServiceImpl.java
+60
-1
SysRoleController.java
...java/com/mx/cneeds/server/user/web/SysRoleController.java
+18
-4
SysUserController.java
...java/com/mx/cneeds/server/user/web/SysUserController.java
+12
-17
SysUserDeptController.java
.../com/mx/cneeds/server/user/web/SysUserDeptController.java
+83
-0
SysUserFuncController.java
.../com/mx/cneeds/server/user/web/SysUserFuncController.java
+84
-0
No files found.
.idea/workspace.xml
View file @
9c2372bb
This diff is collapsed.
Click to expand it.
cneeds-common-data/db/cneeds_server.sql
View file @
9c2372bb
...
...
@@ -245,3 +245,30 @@ CREATE TABLE `sys_user_role` (
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
1
CHARACTER
SET
=
utf8
COLLATE
=
utf8_general_ci
COMMENT
=
'角色用户映射表'
ROW_FORMAT
=
Dynamic
;
SET
FOREIGN_KEY_CHECKS
=
1
;
-- ----------------------------
-- Table structure for sys_user_dept
-- 系统 - 用户部门关系表
-- ----------------------------
DROP
TABLE
IF
EXISTS
`sys_user_dept`
;
CREATE
TABLE
`sys_user_dept`
(
`id`
bigint
(
20
)
NOT
NULL
AUTO_INCREMENT
,
`user_id`
bigint
(
20
)
DEFAULT
NULL
COMMENT
'用户id'
,
`dept_id`
bigint
(
20
)
DEFAULT
NULL
COMMENT
'部门id'
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
466
CHARACTER
SET
=
utf8
COLLATE
=
utf8_general_ci
COMMENT
=
'部门与角色映射表'
ROW_FORMAT
=
Dynamic
;
-- ----------------------------
-- Table structure for sys_user_func
-- 系统 - 用户功能关系表
-- ----------------------------
DROP
TABLE
IF
EXISTS
`sys_user_func`
;
CREATE
TABLE
`sys_user_func`
(
`id`
bigint
(
20
)
NOT
NULL
AUTO_INCREMENT
,
`user_id`
bigint
(
20
)
DEFAULT
NULL
COMMENT
'用户Id'
,
`func_id`
bigint
(
20
)
DEFAULT
NULL
COMMENT
'功能Id'
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
489
CHARACTER
SET
=
utf8
COLLATE
=
utf8_general_ci
COMMENT
=
'功能与角色映射表'
ROW_FORMAT
=
Dynamic
;
cneeds-common-data/src/main/java/com/mx/cneeds/server/dao/SysRoleDao.java
View file @
9c2372bb
...
...
@@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import
com.mx.cneeds.server.entity.SysRoleEntity
;
import
org.apache.ibatis.annotations.Mapper
;
import
java.util.List
;
import
java.util.Map
;
/**
* 角色表
*
...
...
@@ -13,5 +16,6 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public
interface
SysRoleDao
extends
BaseMapper
<
SysRoleEntity
>
{
List
<
SysRoleEntity
>
queryList
(
Map
<
String
,
Object
>
params
);
}
cneeds-common-data/src/main/java/com/mx/cneeds/server/dao/SysUserDeptDao.java
0 → 100644
View file @
9c2372bb
package
com
.
mx
.
cneeds
.
server
.
dao
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.mx.cneeds.server.entity.SysUserDeptEntity
;
import
org.apache.ibatis.annotations.Mapper
;
/**
* 部门与角色映射表
*
* @author Mark
* @email sunlightcs@gmail.com
* @date 2020-03-16 11:22:10
*/
@Mapper
public
interface
SysUserDeptDao
extends
BaseMapper
<
SysUserDeptEntity
>
{
/**
* 根据角色ID数组,批量删除
*/
int
deleteBatch
(
Long
[]
roleIds
);
}
cneeds-common-data/src/main/java/com/mx/cneeds/server/dao/SysUserFuncDao.java
0 → 100644
View file @
9c2372bb
package
com
.
mx
.
cneeds
.
server
.
dao
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.mx.cneeds.server.entity.SysUserFuncEntity
;
import
org.apache.ibatis.annotations.Mapper
;
/**
* 功能与角色映射表
*
* @author Mark
* @email sunlightcs@gmail.com
* @date 2020-03-16 11:22:10
*/
@Mapper
public
interface
SysUserFuncDao
extends
BaseMapper
<
SysUserFuncEntity
>
{
/**
* 根据角色ID数组,批量删除
*/
int
deleteBatch
(
Long
[]
roleIds
);
}
cneeds-common-data/src/main/java/com/mx/cneeds/server/entity/SysUserDeptEntity.java
0 → 100644
View file @
9c2372bb
package
com
.
mx
.
cneeds
.
server
.
entity
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.Date
;
/**
* 部门与角色映射表
*
* @author Mark
* @email sunlightcs@gmail.com
* @date 2020-03-16 11:22:10
*/
@Data
@TableName
(
"sys_user_dept"
)
public
class
SysUserDeptEntity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
*
*/
@TableId
private
Long
id
;
/**
* 用户id
*/
private
Long
userId
;
/**
* 部门id
*/
private
Long
deptId
;
}
cneeds-common-data/src/main/java/com/mx/cneeds/server/entity/SysUserFuncEntity.java
0 → 100644
View file @
9c2372bb
package
com
.
mx
.
cneeds
.
server
.
entity
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.Date
;
/**
* 功能与角色映射表
*
* @author Mark
* @email sunlightcs@gmail.com
* @date 2020-03-16 11:22:10
*/
@Data
@TableName
(
"sys_user_func"
)
public
class
SysUserFuncEntity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
*
*/
@TableId
private
Long
id
;
/**
* 用户Id
*/
private
Long
userId
;
/**
* 功能Id
*/
private
Long
funcId
;
}
cneeds-common-data/src/main/resources/mapper/SysRoleDao.xml
View file @
9c2372bb
...
...
@@ -13,4 +13,12 @@
</resultMap>
<select
id=
"queryList"
resultType=
"com.mx.cneeds.server.entity.SysRoleEntity"
>
select t1.* from sys_role t1 where
1 = 1
<if
test=
"sql_filter != null"
>
and ${sql_filter}
</if>
</select>
</mapper>
\ No newline at end of file
cneeds-common-data/src/main/resources/mapper/SysUserDeptDao.xml
0 → 100644
View file @
9c2372bb
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.mx.cneeds.server.dao.SysUserDeptDao"
>
<!-- 可根据自己的需求,是否要使用 -->
<resultMap
type=
"com.mx.cneeds.server.entity.SysUserDeptEntity"
id=
"sysUserDeptMap"
>
<result
property=
"id"
column=
"id"
/>
<result
property=
"userId"
column=
"user_id"
/>
<result
property=
"deptId"
column=
"dept_id"
/>
</resultMap>
<delete
id=
"deleteBatch"
>
delete from sys_user_dept where user_id in
<foreach
item=
"userId"
collection=
"array"
open=
"("
separator=
","
close=
")"
>
#{userId}
</foreach>
</delete>
</mapper>
\ No newline at end of file
cneeds-common-data/src/main/resources/mapper/SysUserFuncDao.xml
0 → 100644
View file @
9c2372bb
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.mx.cneeds.server.dao.SysUserFuncDao"
>
<!-- 可根据自己的需求,是否要使用 -->
<resultMap
type=
"com.mx.cneeds.server.entity.SysUserFuncEntity"
id=
"sysUserFuncMap"
>
<result
property=
"id"
column=
"id"
/>
<result
property=
"userId"
column=
"user_id"
/>
<result
property=
"funcId"
column=
"func_id"
/>
</resultMap>
<delete
id=
"deleteBatch"
>
delete from sys_user_func where user_id in
<foreach
item=
"userId"
collection=
"array"
open=
"("
separator=
","
close=
")"
>
#{userId}
</foreach>
</delete>
</mapper>
\ No newline at end of file
cneeds-common-pojo/src/main/java/com/mx/cneeds/common/dto/UserDto.java
View file @
9c2372bb
...
...
@@ -4,6 +4,7 @@ import lombok.Data;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.List
;
/**
* @ClassName UserDto
...
...
@@ -45,4 +46,11 @@ public class UserDto implements Serializable {
* 部门id
*/
private
Long
deptId
;
private
List
<
Long
>
funcIdList
;
private
List
<
Long
>
deptIdList
;
private
Long
roleId
;
}
cneeds-server-datashow/src/main/java/com/mx/cneeds/server/datashow/web/system/SystemController.java
View file @
9c2372bb
...
...
@@ -65,6 +65,10 @@ public class SystemController {
return
new
R
().
put
(
"data"
,
pageDto
);
}
/**
* 查询出角色关联的模块
* @return
*/
@PostMapping
(
"/func/listAll"
)
public
R
selectTreeFunc
(){
List
<
FuncDto
>
dtos
=
userClient
.
funcListAll
();
...
...
@@ -86,6 +90,32 @@ public class SystemController {
return
new
R
().
put
(
"data"
,
result
);
}
/**
* 查询出用户关联的模块
* @return
*/
@PostMapping
(
"/func/user/listAll"
)
public
R
selectTreeFuncUser
(){
List
<
FuncDto
>
dtos
=
userClient
.
funcListAll
();
List
<
TreeVo
>
rootList
=
new
ArrayList
<>();
List
<
TreeVo
>
bodyList
=
new
ArrayList
<>();
dtos
.
forEach
(
dto
->
{
TreeVo
vo
=
new
TreeVo
(
dto
.
getFuncId
(),
dto
.
getName
(),
dto
.
getParentId
());
if
(
dto
.
getParentId
()
==
0L
){
rootList
.
add
(
vo
);
}
else
{
bodyList
.
add
(
vo
);
}
});
TreeToolUtils
utils
=
new
TreeToolUtils
(
rootList
,
bodyList
);
List
<
TreeVo
>
result
=
utils
.
getTree
();
return
new
R
().
put
(
"data"
,
result
);
}
@PostMapping
(
"/dept/list"
)
public
R
deptList
(
@RequestParam
(
required
=
false
)
Integer
page
,
@RequestParam
(
required
=
false
)
Integer
pageSize
,
...
...
@@ -199,6 +229,32 @@ public class SystemController {
return
new
R
().
put
(
"data"
,
result
);
}
@PostMapping
(
"/dept/user/listAllTree"
)
public
R
selectTreeDeptUserParent
(){
UserDto
userDto
=
userClient
.
userInfo
(
UserUtils
.
getUserName
());
List
<
DepartmentDto
>
dtos
=
userClient
.
deptListAll
();
List
<
TreeVo
>
rootList
=
new
ArrayList
<>();
List
<
TreeVo
>
bodyList
=
new
ArrayList
<>();
dtos
.
forEach
(
dto
->
{
TreeVo
vo
=
new
TreeVo
(
dto
.
getDeptId
(),
dto
.
getName
(),
dto
.
getParentId
());
if
(
dto
.
getParentId
()==
null
){
rootList
.
add
(
vo
);
}
else
if
(
rootList
.
size
()
==
0
&&
dto
.
getParentId
().
equals
(
userDto
.
getDeptId
())){
rootList
.
add
(
vo
);
}
else
{
bodyList
.
add
(
vo
);
}
});
TreeToolUtils
utils
=
new
TreeToolUtils
(
rootList
,
bodyList
);
List
<
TreeVo
>
result
=
utils
.
getTree
();
return
new
R
().
put
(
"data"
,
result
);
}
@PostMapping
(
"/role/list"
)
public
R
roleList
(
@RequestParam
(
required
=
false
)
Integer
page
,
@RequestParam
(
required
=
false
)
Integer
pageSize
,
...
...
@@ -253,7 +309,6 @@ public class SystemController {
BeanUtils
.
copyProperties
(
vo
,
dto
);
userClient
.
updateRole
(
dto
);
return
R
.
ok
();
}
@PostMapping
(
"/role/delete"
)
...
...
@@ -288,7 +343,6 @@ public class SystemController {
orderField
=
RequestParamterConverter
.
toLine
(
orderField
);
}
PageDto
pageDto
=
userClient
.
userList
(
page
,
pageSize
,
orderField
,
order
);
return
new
R
().
put
(
"data"
,
pageDto
);
...
...
cneeds-server-user/src/main/java/com/mx/cneeds/server/user/service/SysRoleService.java
View file @
9c2372bb
package
com
.
mx
.
cneeds
.
server
.
user
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.mx.cneeds.common.annotation.DataFilter
;
import
com.mx.cneeds.common.pager.PageUtils
;
import
com.mx.cneeds.server.entity.SysRoleEntity
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -19,8 +20,14 @@ public interface SysRoleService extends IService<SysRoleEntity> {
PageUtils
queryPage
(
Map
<
String
,
Object
>
params
);
@DataFilter
(
subDept
=
true
,
user
=
false
,
tableAlias
=
"t1"
)
List
<
SysRoleEntity
>
queryList
(
Map
<
String
,
Object
>
params
);
void
saveRole
(
SysRoleEntity
role
,
List
<
Long
>
funcIdList
,
List
<
Long
>
deptIdList
);
@Transactional
(
rollbackFor
=
Exception
.
class
)
void
update
(
SysRoleEntity
role
,
List
<
Long
>
funcIdList
,
List
<
Long
>
deptIdList
);
void
deleteBatch
(
Long
[]
roleIds
);
}
cneeds-server-user/src/main/java/com/mx/cneeds/server/user/service/SysUserDeptService.java
0 → 100644
View file @
9c2372bb
package
com
.
mx
.
cneeds
.
server
.
user
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.mx.cneeds.common.pager.PageUtils
;
import
com.mx.cneeds.server.entity.SysUserDeptEntity
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
import
java.util.Map
;
/**
* 部门与角色映射表
*
* @author Mark
* @email sunlightcs@gmail.com
* @date 2020-03-16 11:22:10
*/
public
interface
SysUserDeptService
extends
IService
<
SysUserDeptEntity
>
{
PageUtils
queryPage
(
Map
<
String
,
Object
>
params
);
int
deleteBatch
(
Long
[]
userIds
);
void
saveOrUpdate
(
Long
userId
,
List
<
Long
>
deptIdList
);
}
cneeds-server-user/src/main/java/com/mx/cneeds/server/user/service/SysUserFuncService.java
0 → 100644
View file @
9c2372bb
package
com
.
mx
.
cneeds
.
server
.
user
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.mx.cneeds.common.pager.PageUtils
;
import
com.mx.cneeds.server.entity.SysUserFuncEntity
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
import
java.util.Map
;
/**
* 功能与角色映射表
*
* @author Mark
* @email sunlightcs@gmail.com
* @date 2020-03-16 11:22:10
*/
public
interface
SysUserFuncService
extends
IService
<
SysUserFuncEntity
>
{
PageUtils
queryPage
(
Map
<
String
,
Object
>
params
);
int
deleteBatch
(
Long
[]
userIds
);
void
saveOrUpdate
(
Long
userId
,
List
<
Long
>
menuIdList
);
}
cneeds-server-user/src/main/java/com/mx/cneeds/server/user/service/SysUserRoleService.java
View file @
9c2372bb
...
...
@@ -25,5 +25,7 @@ public interface SysUserRoleService extends IService<SysUserRoleEntity> {
List
<
Long
>
queryRoleIdList
(
Long
userId
);
int
deleteBatch
(
Long
[]
roleIds
);
void
saveOrUpdate
(
Long
userId
,
Long
roleId
);
}
cneeds-server-user/src/main/java/com/mx/cneeds/server/user/service/SysUserService.java
View file @
9c2372bb
...
...
@@ -3,7 +3,9 @@ package com.mx.cneeds.server.user.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.mx.cneeds.common.pager.PageUtils
;
import
com.mx.cneeds.server.entity.SysUserEntity
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
import
java.util.Map
;
/**
...
...
@@ -18,5 +20,11 @@ public interface SysUserService extends IService<SysUserEntity> {
PageUtils
queryPage
(
Map
<
String
,
Object
>
params
);
SysUserEntity
queryUserByUsername
(
String
username
);
void
deleteBatch
(
Long
[]
userIds
);
void
saveUser
(
SysUserEntity
user
,
List
<
Long
>
funcIdList
,
List
<
Long
>
deptIdList
,
Long
roleId
);
void
update
(
SysUserEntity
user
,
List
<
Long
>
funcIdList
,
List
<
Long
>
deptIdList
);
}
cneeds-server-user/src/main/java/com/mx/cneeds/server/user/service/impl/SysRoleServiceImpl.java
View file @
9c2372bb
package
com
.
mx
.
cneeds
.
server
.
user
.
service
.
impl
;
import
com.mx.cneeds.common.annotation.DataFilter
;
import
com.mx.cneeds.common.pager.PageUtils
;
import
com.mx.cneeds.common.pager.Query
;
import
com.mx.cneeds.server.dao.SysRoleDao
;
...
...
@@ -38,6 +39,12 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleDao, SysRoleEntity> i
return
new
PageUtils
(
page
);
}
@Override
@DataFilter
(
subDept
=
true
,
user
=
false
,
tableAlias
=
"t1"
)
public
List
<
SysRoleEntity
>
queryList
(
Map
<
String
,
Object
>
params
)
{
return
baseMapper
.
queryList
(
params
);
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
...
...
@@ -54,6 +61,18 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleDao, SysRoleEntity> i
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
update
(
SysRoleEntity
role
,
List
<
Long
>
funcIdList
,
List
<
Long
>
deptIdList
)
{
this
.
updateById
(
role
);
//更新角色与菜单关系
sysRoleFuncService
.
saveOrUpdate
(
role
.
getRoleId
(),
funcIdList
);
//保存角色与部门关系
sysRoleDeptService
.
saveOrUpdate
(
role
.
getRoleId
(),
deptIdList
);
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
deleteBatch
(
Long
[]
roleIds
)
{
//删除角色
this
.
removeByIds
(
Arrays
.
asList
(
roleIds
));
...
...
cneeds-server-user/src/main/java/com/mx/cneeds/server/user/service/impl/SysUserDeptServiceImpl.java
0 → 100644
View file @
9c2372bb
package
com
.
mx
.
cneeds
.
server
.
user
.
service
.
impl
;
import
com.mx.cneeds.common.pager.PageUtils
;
import
com.mx.cneeds.common.pager.Query
;
import
com.mx.cneeds.server.dao.SysUserDeptDao
;
import
com.mx.cneeds.server.entity.SysRoleDeptEntity
;
import
com.mx.cneeds.server.entity.SysUserDeptEntity
;
import
com.mx.cneeds.server.user.service.SysUserDeptService
;
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
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
org.springframework.transaction.annotation.Transactional
;
@Service
(
"sysUserDeptService"
)
public
class
SysUserDeptServiceImpl
extends
ServiceImpl
<
SysUserDeptDao
,
SysUserDeptEntity
>
implements
SysUserDeptService
{
@Override
public
PageUtils
queryPage
(
Map
<
String
,
Object
>
params
)
{
IPage
<
SysUserDeptEntity
>
page
=
this
.
page
(
new
Query
<
SysUserDeptEntity
>().
getPage
(
params
),
new
QueryWrapper
<
SysUserDeptEntity
>()
);
return
new
PageUtils
(
page
);
}
@Override
public
int
deleteBatch
(
Long
[]
userIds
){
return
baseMapper
.
deleteBatch
(
userIds
);
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
saveOrUpdate
(
Long
userId
,
List
<
Long
>
deptIdList
)
{
//先删除用户与部门关系
deleteBatch
(
new
Long
[]{
userId
});
if
(
deptIdList
.
size
()
==
0
){
return
;
}
//保存用户与菜单关系
for
(
Long
deptId
:
deptIdList
){
SysUserDeptEntity
sysUserDeptEntity
=
new
SysUserDeptEntity
();
sysUserDeptEntity
.
setDeptId
(
deptId
);
sysUserDeptEntity
.
setUserId
(
userId
);
this
.
save
(
sysUserDeptEntity
);
}
}
}
cneeds-server-user/src/main/java/com/mx/cneeds/server/user/service/impl/SysUserFuncServiceImpl.java
0 → 100644
View file @
9c2372bb
package
com
.
mx
.
cneeds
.
server
.
user
.
service
.
impl
;
import
com.mx.cneeds.common.pager.PageUtils
;
import
com.mx.cneeds.common.pager.Query
;
import
com.mx.cneeds.server.dao.SysUserFuncDao
;
import
com.mx.cneeds.server.entity.SysRoleFuncEntity
;
import
com.mx.cneeds.server.entity.SysUserFuncEntity
;
import
com.mx.cneeds.server.user.service.SysUserFuncService
;
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
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
org.springframework.transaction.annotation.Transactional
;
@Service
(
"sysUserFuncService"
)
public
class
SysUserFuncServiceImpl
extends
ServiceImpl
<
SysUserFuncDao
,
SysUserFuncEntity
>
implements
SysUserFuncService
{
@Override
public
PageUtils
queryPage
(
Map
<
String
,
Object
>
params
)
{
IPage
<
SysUserFuncEntity
>
page
=
this
.
page
(
new
Query
<
SysUserFuncEntity
>().
getPage
(
params
),
new
QueryWrapper
<
SysUserFuncEntity
>()
);
return
new
PageUtils
(
page
);
}
@Override
public
int
deleteBatch
(
Long
[]
userIds
){
return
baseMapper
.
deleteBatch
(
userIds
);
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
saveOrUpdate
(
Long
userId
,
List
<
Long
>
menuIdList
)
{
//先删除角色与菜单关系
deleteBatch
(
new
Long
[]{
userId
});
if
(
menuIdList
.
size
()
==
0
){
return
;
}
//保存用户与菜单关系
for
(
Long
funcId
:
menuIdList
){
SysUserFuncEntity
sysUserFuncEntity
=
new
SysUserFuncEntity
();
sysUserFuncEntity
.
setFuncId
(
funcId
);
sysUserFuncEntity
.
setUserId
(
userId
);
this
.
save
(
sysUserFuncEntity
);
}
}
}
cneeds-server-user/src/main/java/com/mx/cneeds/server/user/service/impl/SysUserRoleServiceImpl.java
View file @
9c2372bb
...
...
@@ -36,4 +36,20 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleDao, SysUserR
public
int
deleteBatch
(
Long
[]
roleIds
){
return
baseMapper
.
deleteBatch
(
roleIds
);
}
@Override
public
void
saveOrUpdate
(
Long
userId
,
Long
roleId
)
{
//先删除用户与角色关系
this
.
remove
(
new
QueryWrapper
<
SysUserRoleEntity
>().
eq
(
"user_id"
,
userId
));
//保存用户与角色关系
SysUserRoleEntity
sysUserRoleEntity
=
new
SysUserRoleEntity
();
sysUserRoleEntity
.
setUserId
(
userId
);
sysUserRoleEntity
.
setRoleId
(
roleId
);
this
.
save
(
sysUserRoleEntity
);
}
}
cneeds-server-user/src/main/java/com/mx/cneeds/server/user/service/impl/SysUserServiceImpl.java
View file @
9c2372bb
...
...
@@ -4,17 +4,32 @@ import com.mx.cneeds.common.pager.PageUtils;
import
com.mx.cneeds.common.pager.Query
;
import
com.mx.cneeds.server.dao.SysUserDao
;
import
com.mx.cneeds.server.entity.SysUserEntity
;
import
com.mx.cneeds.server.user.service.SysUserService
;
import
com.mx.cneeds.server.user.service.*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
org.springframework.transaction.annotation.Transactional
;
@Service
(
"sysUserService"
)
public
class
SysUserServiceImpl
extends
ServiceImpl
<
SysUserDao
,
SysUserEntity
>
implements
SysUserService
{
@Autowired
private
SysUserFuncService
sysUserFuncService
;
@Autowired
private
SysUserDeptService
sysUserDeptService
;
@Autowired
private
SysUserRoleService
sysUserRoleService
;
@Override
public
PageUtils
queryPage
(
Map
<
String
,
Object
>
params
)
{
IPage
<
SysUserEntity
>
page
=
this
.
page
(
...
...
@@ -32,4 +47,48 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUserEntity> i
.
eq
(
"username"
,
username
));
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
deleteBatch
(
Long
[]
userIds
)
{
//删除角色
this
.
removeByIds
(
Arrays
.
asList
(
userIds
));
//删除用户与菜单关联
sysUserFuncService
.
deleteBatch
(
userIds
);
//删除用户与部门关联
sysUserDeptService
.
deleteBatch
(
userIds
);
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
saveUser
(
SysUserEntity
user
,
List
<
Long
>
funcIdList
,
List
<
Long
>
deptIdList
,
Long
roleId
)
{
user
.
setCreateTime
(
new
Date
());
this
.
save
(
user
);
//保存用户与角色关系
sysUserRoleService
.
saveOrUpdate
(
user
.
getUserId
(),
roleId
);
//保存角色与菜单关系
sysUserFuncService
.
saveOrUpdate
(
user
.
getUserId
(),
funcIdList
);
//保存角色与部门关系
sysUserDeptService
.
saveOrUpdate
(
user
.
getUserId
(),
deptIdList
);
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
update
(
SysUserEntity
user
,
List
<
Long
>
funcIdList
,
List
<
Long
>
deptIdList
)
{
this
.
updateById
(
user
);
//更新用户与菜单关系
sysUserFuncService
.
saveOrUpdate
(
user
.
getUserId
(),
funcIdList
);
//保存用户与部门关系
sysUserDeptService
.
saveOrUpdate
(
user
.
getUserId
(),
deptIdList
);
}
}
cneeds-server-user/src/main/java/com/mx/cneeds/server/user/web/SysRoleController.java
View file @
9c2372bb
package
com
.
mx
.
cneeds
.
server
.
user
.
web
;
import
com.mx.cneeds.common.dto.DepartmentDto
;
import
com.mx.cneeds.common.dto.RoleDto
;
import
com.mx.cneeds.common.pager.PageUtils
;
import
com.mx.cneeds.common.result.R
;
...
...
@@ -73,6 +74,18 @@ public class SysRoleController {
return
page
;
}
@RequestMapping
(
"/listAll"
)
public
List
<
RoleDto
>
listAll
(
@RequestParam
Map
<
String
,
Object
>
params
){
List
<
SysRoleEntity
>
sysRoleEntityList
=
sysRoleService
.
queryList
(
params
);
List
<
RoleDto
>
roleDtoList
=
new
ArrayList
<>();
sysRoleEntityList
.
forEach
(
sysRoleEntity
->
{
RoleDto
roleDto
=
new
RoleDto
();
BeanUtils
.
copyProperties
(
sysRoleEntity
,
roleDto
);
roleDtoList
.
add
(
roleDto
);
});
return
roleDtoList
;
}
/**
* 信息
...
...
@@ -113,10 +126,11 @@ public class SysRoleController {
* 修改
*/
@RequestMapping
(
"/update"
)
public
R
update
(
@RequestBody
SysRoleEntity
sysRole
){
ValidatorUtils
.
validateEntity
(
sysRole
);
sysRoleService
.
updateById
(
sysRole
);
public
R
update
(
@RequestBody
RoleDto
dto
){
ValidatorUtils
.
validateEntity
(
dto
);
SysRoleEntity
sysRole
=
new
SysRoleEntity
();
BeanUtils
.
copyProperties
(
dto
,
sysRole
);
sysRoleService
.
update
(
sysRole
,
dto
.
getFuncIdList
(),
dto
.
getDeptIdList
());
return
R
.
ok
();
}
...
...
cneeds-server-user/src/main/java/com/mx/cneeds/server/user/web/SysUserController.java
View file @
9c2372bb
...
...
@@ -31,18 +31,10 @@ public class SysUserController {
private
SysUserService
sysUserService
;
public
R
Login
(
UserVo
userVo
){
return
new
R
().
put
(
"user"
,
""
);
}
/**
* 列表
*/
@RequestMapping
(
"/list"
)
// @RequiresPermissions("sys:sysuser:list")
public
PageUtils
list
(
@RequestParam
Map
<
String
,
Object
>
params
){
PageUtils
page
=
sysUserService
.
queryPage
(
params
);
return
page
;
...
...
@@ -53,7 +45,6 @@ public class SysUserController {
* 信息
*/
// @RequestMapping("/info/{userId}")
// @RequiresPermissions("sys:sysuser:info")
public
R
info
(
@PathVariable
(
"userId"
)
Long
userId
){
SysUserEntity
sysUser
=
sysUserService
.
getById
(
userId
);
...
...
@@ -72,10 +63,13 @@ public class SysUserController {
* 保存
*/
@RequestMapping
(
"/save"
)
// @RequiresPermissions("sys:sysuser:save")
public
R
save
(
@RequestBody
SysUserEntity
sysUser
){
sysUserService
.
save
(
sysUser
);
public
R
save
(
@RequestBody
UserDto
dto
){
SysUserEntity
sysUser
=
new
SysUserEntity
(
);
BeanUtils
.
copyProperties
(
dto
,
sysUser
);
sysUserService
.
saveUser
(
sysUser
,
dto
.
getFuncIdList
(),
dto
.
getDeptIdList
(),
dto
.
getRoleId
());
return
R
.
ok
();
}
...
...
@@ -83,10 +77,12 @@ public class SysUserController {
* 修改
*/
@RequestMapping
(
"/update"
)
// @RequiresPermissions("sys:sysuser:update")
public
R
update
(
@RequestBody
SysUserEntity
sysUser
){
public
R
update
(
@RequestBody
UserDto
dto
){
SysUserEntity
sysUser
=
new
SysUserEntity
();
BeanUtils
.
copyProperties
(
dto
,
sysUser
);
ValidatorUtils
.
validateEntity
(
sysUser
);
sysUserService
.
update
ById
(
sysUser
);
sysUserService
.
update
(
sysUser
,
dto
.
getFuncIdList
(),
dto
.
getDeptIdList
()
);
return
R
.
ok
();
}
...
...
@@ -95,9 +91,8 @@ public class SysUserController {
* 删除
*/
@RequestMapping
(
"/delete"
)
// @RequiresPermissions("sys:sysuser:delete")
public
R
delete
(
@RequestBody
Long
[]
userIds
){
sysUserService
.
removeByIds
(
Arrays
.
asList
(
userIds
)
);
sysUserService
.
deleteBatch
(
userIds
);
return
R
.
ok
();
}
...
...
cneeds-server-user/src/main/java/com/mx/cneeds/server/user/web/SysUserDeptController.java
0 → 100644
View file @
9c2372bb
package
com
.
mx
.
cneeds
.
server
.
user
.
web
;
import
java.util.Arrays
;
import
java.util.Map
;
import
com.mx.cneeds.common.pager.PageUtils
;
import
com.mx.cneeds.common.result.R
;
import
com.mx.cneeds.common.validator.ValidatorUtils
;
import
com.mx.cneeds.server.entity.SysUserDeptEntity
;
import
com.mx.cneeds.server.user.service.SysUserDeptService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* 部门与角色映射表
*
* @author Mark
* @email sunlightcs@gmail.com
* @date 2020-03-16 11:22:10
*/
@RestController
@RequestMapping
(
"sys/userdept"
)
public
class
SysUserDeptController
{
@Autowired
private
SysUserDeptService
sysUserDeptService
;
/**
* 列表
*/
@RequestMapping
(
"/list"
)
public
R
list
(
@RequestParam
Map
<
String
,
Object
>
params
){
PageUtils
page
=
sysUserDeptService
.
queryPage
(
params
);
return
R
.
ok
().
put
(
"page"
,
page
);
}
/**
* 信息
*/
@RequestMapping
(
"/info/{id}"
)
public
R
info
(
@PathVariable
(
"id"
)
Long
id
){
SysUserDeptEntity
sysUserDept
=
sysUserDeptService
.
getById
(
id
);
return
R
.
ok
().
put
(
"sysUserDept"
,
sysUserDept
);
}
/**
* 保存
*/
@RequestMapping
(
"/save"
)
public
R
save
(
@RequestBody
SysUserDeptEntity
sysUserDept
){
sysUserDeptService
.
save
(
sysUserDept
);
return
R
.
ok
();
}
/**
* 修改
*/
@RequestMapping
(
"/update"
)
public
R
update
(
@RequestBody
SysUserDeptEntity
sysUserDept
){
ValidatorUtils
.
validateEntity
(
sysUserDept
);
sysUserDeptService
.
updateById
(
sysUserDept
);
return
R
.
ok
();
}
/**
* 删除
*/
@RequestMapping
(
"/delete"
)
public
R
delete
(
@RequestBody
Long
[]
ids
){
sysUserDeptService
.
removeByIds
(
Arrays
.
asList
(
ids
));
return
R
.
ok
();
}
}
cneeds-server-user/src/main/java/com/mx/cneeds/server/user/web/SysUserFuncController.java
0 → 100644
View file @
9c2372bb
package
com
.
mx
.
cneeds
.
server
.
user
.
web
;
import
java.util.Arrays
;
import
java.util.Map
;
import
com.mx.cneeds.common.pager.PageUtils
;
import
com.mx.cneeds.common.result.R
;
import
com.mx.cneeds.common.validator.ValidatorUtils
;
import
com.mx.cneeds.server.entity.SysUserFuncEntity
;
import
com.mx.cneeds.server.user.service.SysUserFuncService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* 功能与角色映射表
*
* @author Mark
* @email sunlightcs@gmail.com
* @date 2020-03-16 11:22:10
*/
@RestController
@RequestMapping
(
"sys/userfunc"
)
public
class
SysUserFuncController
{
@Autowired
private
SysUserFuncService
sysUserFuncService
;
/**
* 列表
*/
@RequestMapping
(
"/list"
)
public
R
list
(
@RequestParam
Map
<
String
,
Object
>
params
){
PageUtils
page
=
sysUserFuncService
.
queryPage
(
params
);
return
R
.
ok
().
put
(
"page"
,
page
);
}
/**
* 信息
*/
@RequestMapping
(
"/info/{id}"
)
public
R
info
(
@PathVariable
(
"id"
)
Long
id
){
SysUserFuncEntity
sysUserFunc
=
sysUserFuncService
.
getById
(
id
);
return
R
.
ok
().
put
(
"sysUserFunc"
,
sysUserFunc
);
}
/**
* 保存
*/
@RequestMapping
(
"/save"
)
public
R
save
(
@RequestBody
SysUserFuncEntity
sysUserFunc
){
sysUserFuncService
.
save
(
sysUserFunc
);
return
R
.
ok
();
}
/**
* 修改
*/
@RequestMapping
(
"/update"
)
public
R
update
(
@RequestBody
SysUserFuncEntity
sysUserFunc
){
ValidatorUtils
.
validateEntity
(
sysUserFunc
);
sysUserFuncService
.
updateById
(
sysUserFunc
);
return
R
.
ok
();
}
/**
* 删除
*/
@RequestMapping
(
"/delete"
)
public
R
delete
(
@RequestBody
Long
[]
ids
){
sysUserFuncService
.
removeByIds
(
Arrays
.
asList
(
ids
));
return
R
.
ok
();
}
}
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