Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
education
Project
Project
Details
Activity
Releases
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
李丛阳
education
Commits
6764ed76
Commit
6764ed76
authored
Dec 06, 2017
by
李丛阳
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
education sys 1.01
parent
c0c3a7e3
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
103 additions
and
145 deletions
+103
-145
AuthenticationServiceImpl.java
.../rcisoft/core/service/impl/AuthenticationServiceImpl.java
+2
-12
JwtUserDetailServiceImpl.java
...g/rcisoft/core/service/impl/JwtUserDetailServiceImpl.java
+11
-9
JwtUserFactory.java
src/main/java/org/rcisoft/core/util/JwtUserFactory.java
+1
-1
SysController.java
src/main/java/org/rcisoft/sys/controller/SysController.java
+0
-41
DeptController.java
.../java/org/rcisoft/sys/dept/controller/DeptController.java
+3
-4
RoleController.java
.../java/org/rcisoft/sys/role/controller/RoleController.java
+15
-15
RoleRepository.java
src/main/java/org/rcisoft/sys/role/dao/RoleRepository.java
+19
-19
SysRole.java
src/main/java/org/rcisoft/sys/role/entity/SysRole.java
+4
-3
RoleService.java
src/main/java/org/rcisoft/sys/role/service/RoleService.java
+13
-13
RoleServiceImpl.java
...va/org/rcisoft/sys/role/service/impl/RoleServiceImpl.java
+24
-24
SysUser.java
src/main/java/org/rcisoft/sys/user/entity/SysUser.java
+8
-0
roleMapper.xml
src/main/resources/mapper/sys/role/mapper/roleMapper.xml
+3
-4
No files found.
src/main/java/org/rcisoft/core/service/impl/AuthenticationServiceImpl.java
View file @
6764ed76
...
...
@@ -38,16 +38,7 @@ public class AuthenticationServiceImpl implements AuthenticationService {
@Autowired
private
PasswordEncoder
passwordEncoder
;
/*@Autowired
public AuthenticationServiceImpl(AuthenticationManager authenticationManager,
UserDetailsService userDetailsService,
SysUserMapper sysUserMapper,
PasswordEncoder passwordEncoder) {
this.authenticationManager = authenticationManager;
this.userDetailsService = userDetailsService;
this.sysUserMapper = sysUserMapper;
this.passwordEncoder = passwordEncoder;
}*/
@Value
(
"${jwt.tokenHead}"
)
private
String
tokenHead
;
...
...
@@ -69,8 +60,7 @@ public class AuthenticationServiceImpl implements AuthenticationService {
@Override
public
String
login
(
String
username
,
String
password
)
{
UsernamePasswordAuthenticationToken
upToken
=
new
UsernamePasswordAuthenticationToken
(
username
,
password
);
//进入到 UserDetailsService loadUserByUsername 方法
/*进入到 UserDetailsService(JwtUserDetailServiceImpl) loadUserByUsername 方法*/
final
Authentication
authentication
=
authenticationManager
.
authenticate
(
upToken
);
SecurityContextHolder
.
getContext
().
setAuthentication
(
authentication
);
final
UserDetails
userDetails
=
userDetailsService
.
loadUserByUsername
(
username
);
...
...
src/main/java/org/rcisoft/core/service/impl/JwtUserDetailServiceImpl.java
View file @
6764ed76
package
org
.
rcisoft
.
core
.
service
.
impl
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.rcisoft.core.util.JwtUserFactory
;
import
org.rcisoft.sys.role.entity.SysRole
;
import
org.rcisoft.sys.user.dao.SysUserMapper
;
import
org.rcisoft.sys.user.entity.SysUser
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -8,8 +10,8 @@ import org.springframework.security.core.userdetails.UserDetails;
import
org.springframework.security.core.userdetails.UserDetailsService
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
org.springframework.stereotype.Service
;
import
tk.mybatis.mapper.entity.Example
;
import
java.util.Collections
;
import
java.util.List
;
/**
...
...
@@ -25,17 +27,17 @@ public class JwtUserDetailServiceImpl implements UserDetailsService {
@Override
public
UserDetails
loadUserByUsername
(
String
username
)
throws
UsernameNotFoundException
{
//调用持久层从数据库获取用户信息
/*Example example = new Example(SysUser.class);
Example.Criteria criteria = example.createCriteria();*/
List
<
SysUser
>
sysUser
=
sysUserMapper
.
queryUserByName
(
username
);
//List<SysUser> sysUser = sysUserMapper.selectByExample(example);
if
(
sysUser
==
null
||
sysUser
.
size
()
==
0
)
List
<
SysUser
>
sysUser
List
=
sysUserMapper
.
queryUserByName
(
username
);
if
(
sysUser
List
==
null
||
sysUserList
.
size
()
==
0
)
throw
new
UsernameNotFoundException
(
"用户名不存在"
);
/*List<SysRole> roles = sysRoleRepository.findRolesByUserId(sysUser.getId()); //根据用户id或者用户权限列表
SysUser
sysUser
=
sysUserList
.
get
(
0
);
/*根据用户查询用户权限*/
List
<
SysRole
>
roles
=
sysRoleRepository
.
findRolesByUserId
(
sysUser
.
getBusinessId
());
if
(
CollectionUtils
.
isEmpty
(
roles
))
roles
=
Collections
.
emptyList
();
sysUser.setRole
s(roles);*/
return
JwtUserFactory
.
create
(
sysUser
.
get
(
0
)
);
sysUser
.
setRole
List
(
roles
);
return
JwtUserFactory
.
create
(
sysUser
);
}
}
src/main/java/org/rcisoft/core/util/JwtUserFactory.java
View file @
6764ed76
...
...
@@ -26,7 +26,7 @@ public final class JwtUserFactory {
}
/**
* 讲User的List<Role>转换成JwtUser<GrantedAuthority>
* 讲User的List<
Sys
Role>转换成JwtUser<GrantedAuthority>
private static List<GrantedAuthority> map2GrantedAuthorities(List<SysRole> authorities){
return authorities.stream()
...
...
src/main/java/org/rcisoft/sys/controller/SysController.java
deleted
100644 → 0
View file @
c0c3a7e3
package
org
.
rcisoft
.
sys
.
controller
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiOperation
;
import
org.rcisoft.core.result.Result
;
import
org.springframework.web.bind.annotation.*
;
/**
* Created by lcy on 17/8/13.
*/
@RestController
@RequestMapping
(
value
=
"sys"
)
public
class
SysController
{
/**
* login
* @param
* @param
* @return
@PostMapping(value = "/login")
public AjaxResponse login(String account, String pwd,AjaxResponse response){
Map<String,Object> map = new HashMap<String,Object>();
User user = null;
//登录成功
String token = JwtUtil.setClaim(account);
map.put("user", user);
map.put("token", token);
response.setSuccessMessage("登录成功",map);
return response;
}*/
@ApiOperation
(
value
=
"获取用户详细信息"
,
notes
=
"根据url的id来获取用户详细信息"
)
@ApiImplicitParam
(
name
=
"id"
,
value
=
"用户ID"
,
required
=
true
,
dataType
=
"Integer"
,
paramType
=
"path"
)
@GetMapping
(
value
=
"/user/{id}"
,
produces
=
"application/json; charset=utf-8"
)
public
Result
testApi
(
@PathVariable
(
value
=
"id"
)
Integer
id
,
Result
result
){
result
.
setCode
(
400
);
result
.
setData
(
id
);
return
result
;
}
}
src/main/java/org/rcisoft/sys/dept/controller/DeptController.java
View file @
6764ed76
...
...
@@ -12,11 +12,10 @@ import org.rcisoft.core.result.Result;
import
org.rcisoft.core.validate.ValidatedResult
;
import
org.rcisoft.sys.dept.entity.Dept
;
import
org.rcisoft.sys.dept.service.DeptService
;
import
org.rcisoft.sys.role.entity.Role
;
import
org.rcisoft.sys.role.entity.
Sys
Role
;
import
org.rcisoft.sys.role.service.RoleService
;
import
org.rcisoft.sys.user.service.UserService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -59,8 +58,8 @@ public class DeptController extends ResponseController {
@ApiImplicitParam
(
name
=
"code"
,
value
=
"权限code"
,
required
=
false
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"remarks"
,
value
=
"备注"
,
required
=
false
,
dataType
=
"varchar"
)})
@GetMapping
(
"queryRolesSelect"
)
public
List
<
Role
>
queryRolesSelect
(
Role
r
ole
){
return
roleServiceImpl
.
queryRolesSelect
(
r
ole
);
public
List
<
SysRole
>
queryRolesSelect
(
SysRole
sysR
ole
){
return
roleServiceImpl
.
queryRolesSelect
(
sysR
ole
);
}
...
...
src/main/java/org/rcisoft/sys/role/controller/RoleController.java
View file @
6764ed76
...
...
@@ -9,7 +9,7 @@ import org.rcisoft.core.constant.MessageConstant;
import
org.rcisoft.core.model.PersistModel
;
import
org.rcisoft.core.result.Result
;
import
org.rcisoft.core.validate.ValidatedResult
;
import
org.rcisoft.sys.role.entity.Role
;
import
org.rcisoft.sys.role.entity.
Sys
Role
;
import
org.rcisoft.sys.role.service.RoleService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.BindingResult
;
...
...
@@ -24,7 +24,7 @@ import java.util.List;
*/
@RestController
@RequestMapping
(
"/role"
)
public
class
RoleController
extends
PaginationController
<
Role
>
{
public
class
RoleController
extends
PaginationController
<
Sys
Role
>
{
@Autowired
private
RoleService
roleServiceImpl
;
...
...
@@ -35,9 +35,9 @@ public class RoleController extends PaginationController<Role> {
@ApiImplicitParam
(
name
=
"code"
,
value
=
"权限code"
,
required
=
false
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"remarks"
,
value
=
"备注"
,
required
=
false
,
dataType
=
"varchar"
)})
@GetMapping
(
value
=
"queryRoleValidate"
)
public
String
queryRoleValidate
(
Role
r
ole
){
List
<
Role
>
roleList
=
roleServiceImpl
.
queryRolesByPagination
(
getPaginationUtility
(),
r
ole
);
if
(
r
oleList
.
size
()==
0
)
public
String
queryRoleValidate
(
SysRole
sysR
ole
){
List
<
SysRole
>
sysRoleList
=
roleServiceImpl
.
queryRolesByPagination
(
getPaginationUtility
(),
sysR
ole
);
if
(
sysR
oleList
.
size
()==
0
)
return
"true"
;
else
return
"false"
;
...
...
@@ -49,8 +49,8 @@ public class RoleController extends PaginationController<Role> {
@ApiImplicitParam
(
name
=
"code"
,
value
=
"权限code"
,
required
=
false
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"remarks"
,
value
=
"备注"
,
required
=
false
,
dataType
=
"varchar"
)})
@GetMapping
(
value
=
"queryRoles"
)
public
GridModel
queryRoles
(
Role
r
ole
){
roleServiceImpl
.
queryRolesByPagination
(
getPaginationUtility
(),
r
ole
);
public
GridModel
queryRoles
(
SysRole
sysR
ole
){
roleServiceImpl
.
queryRolesByPagination
(
getPaginationUtility
(),
sysR
ole
);
GridModel
gridModel
=
getGridModelResponse
();
return
gridModel
;
}
...
...
@@ -63,8 +63,8 @@ public class RoleController extends PaginationController<Role> {
@ApiImplicitParam
(
name
=
"code"
,
value
=
"权限code"
,
required
=
false
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"remarks"
,
value
=
"备注"
,
required
=
false
,
dataType
=
"varchar"
)})
@GetMapping
(
value
=
"queryRolesByUser/{userId}"
)
public
GridModel
queryRolesByUser
(
@PathVariable
(
"userId"
)
String
userId
,
Role
r
ole
){
roleServiceImpl
.
queryUserRolesByPagination
(
getPaginationUtility
(),
userId
,
r
ole
);
public
GridModel
queryRolesByUser
(
@PathVariable
(
"userId"
)
String
userId
,
SysRole
sysR
ole
){
roleServiceImpl
.
queryUserRolesByPagination
(
getPaginationUtility
(),
userId
,
sysR
ole
);
GridModel
gridModel
=
getGridModelResponse
();
return
gridModel
;
}
...
...
@@ -77,19 +77,19 @@ public class RoleController extends PaginationController<Role> {
@ApiImplicitParam
(
name
=
"code"
,
value
=
"权限code"
,
required
=
false
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"remarks"
,
value
=
"备注"
,
required
=
false
,
dataType
=
"varchar"
)})
@PostMapping
(
value
=
"adminLog/roleAdd"
)
public
Result
roleAdd
(
@Valid
Role
r
ole
,
BindingResult
br
){
PersistModel
persistModel
=
roleServiceImpl
.
persistRole
(
r
ole
,
getToken
());
public
Result
roleAdd
(
@Valid
SysRole
sysR
ole
,
BindingResult
br
){
PersistModel
persistModel
=
roleServiceImpl
.
persistRole
(
sysR
ole
,
getToken
());
if
(
persistModel
.
isSuccessBySinglePersist
())
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
r
ole
);
sysR
ole
);
else
return
Result
.
builder
(
new
PersistModel
(
2
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
r
ole
);
sysR
ole
);
}
@ApiOperation
(
value
=
"to 修改用户页面"
,
notes
=
"to 修改用户页面"
)
...
...
@@ -108,7 +108,7 @@ public class RoleController extends PaginationController<Role> {
@ApiImplicitParam
(
name
=
"code"
,
value
=
"权限code"
,
required
=
false
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"remarks"
,
value
=
"备注"
,
required
=
false
,
dataType
=
"varchar"
)})
@PostMapping
(
value
=
"adminLog/roleUpdate"
)
public
Result
roleUpdate
(
@Valid
Role
r
ole
,
BindingResult
br
){
public
Result
roleUpdate
(
@Valid
SysRole
sysR
ole
,
BindingResult
br
){
Result
result
=
new
Result
();
if
(
super
.
hasErrors
(
br
)){
ValidatedResult
vr
=
new
ValidatedResult
();
...
...
@@ -119,7 +119,7 @@ public class RoleController extends PaginationController<Role> {
MessageConstant
.
MESSAGE_ALERT_INFO_INVALID
,
vr
);
}
PersistModel
persistModel
=
roleServiceImpl
.
mergeRole
(
r
ole
,
getToken
());
PersistModel
persistModel
=
roleServiceImpl
.
mergeRole
(
sysR
ole
,
getToken
());
return
Result
.
builder
(
persistModel
,
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
...
...
src/main/java/org/rcisoft/sys/role/dao/RoleRepository.java
View file @
6764ed76
...
...
@@ -6,7 +6,7 @@ import org.apache.ibatis.annotations.ResultMap;
import
org.apache.ibatis.annotations.Select
;
import
org.rcisoft.core.base.BaseMapper
;
import
org.rcisoft.sys.dept.entity.DeptRole
;
import
org.rcisoft.sys.role.entity.Role
;
import
org.rcisoft.sys.role.entity.
Sys
Role
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
...
...
@@ -20,10 +20,10 @@ import java.util.Map;
* description:
*/
@Repository
public
interface
RoleRepository
extends
BaseMapper
<
Role
>
{
public
interface
RoleRepository
extends
BaseMapper
<
Sys
Role
>
{
/**
* 分页查询 roles
* @param
r
ole
* @param
sysR
ole
* @return
*/
@Select
(
"<script>select sys_role.*,sys_user.NAME as username from sys_role LEFT JOIN sys_user ON sys_role.CREATE_BY=sys_user.BUSINESS_ID where "
...
...
@@ -32,14 +32,14 @@ public interface RoleRepository extends BaseMapper<Role> {
//+ "<if test=\"phone !=null \">phone = #{phone} </if> <if test=\"usermail !=null \">usermail = #{usermail } </if>"
+
"</script>"
)
@ResultMap
(
value
=
"BaseResultMap"
)
List
<
Role
>
queryRoles
(
Role
r
ole
);
List
<
SysRole
>
queryRoles
(
SysRole
sysR
ole
);
@Select
(
"<script>select * from sys_role where "
+
"DEL_FLAG='0' "
+
"</script>"
)
@ResultMap
(
value
=
"BaseResultMap"
)
List
<
Role
>
queryRolesSelect
(
Role
r
ole
);
List
<
SysRole
>
queryRolesSelect
(
SysRole
sysR
ole
);
/**
* 根据角色id 删除对应权限
...
...
@@ -74,7 +74,7 @@ public interface RoleRepository extends BaseMapper<Role> {
int
insertBatchRoleDept
(
List
<
Map
>
deptRole
);
/**
* 分页查询 roles
* @param
r
ole
* @param
sysR
ole
* @return
*/
@Select
(
" <script>select "
...
...
@@ -87,23 +87,23 @@ public interface RoleRepository extends BaseMapper<Role> {
+
" LEFT JOIN sys_dept d ON d.BUSINESS_ID = dr.DEPT_ID "
+
" LEFT JOIN sys_role r on dr.ROLE_ID = r.BUSINESS_ID</script>"
)
@ResultMap
(
value
=
"drResultMap"
)
List
<
DeptRole
>
queryUserRolesByPagination
(
@Param
(
"userId"
)
String
userId
,
Role
r
ole
)
;
List
<
DeptRole
>
queryUserRolesByPagination
(
@Param
(
"userId"
)
String
userId
,
SysRole
sysR
ole
)
;
/**
* 分页查询 roles
* @param
r
ole
* @param
sysR
ole
* @return
*/
@Select
(
"<script>SELECT "
+
"
r
ole.BUSINESS_ID, "
+
"
r
ole.NAME, "
+
"
r
ole.CODE, "
+
"
r
ole.DATA_SCOPE, "
+
"
r
ole.FLAG, "
+
"
r
ole.DEL_FLAG, "
+
"
r
ole.CREATE_BY, "
+
"
r
ole.create_date, "
+
"
sysR
ole.BUSINESS_ID, "
+
"
sysR
ole.NAME, "
+
"
sysR
ole.CODE, "
+
"
sysR
ole.DATA_SCOPE, "
+
"
sysR
ole.FLAG, "
+
"
sysR
ole.DEL_FLAG, "
+
"
sysR
ole.CREATE_BY, "
+
"
sysR
ole.create_date, "
+
"IF ( "
+
" ( "
+
" SELECT "
+
...
...
@@ -111,18 +111,18 @@ public interface RoleRepository extends BaseMapper<Role> {
" FROM "
+
" SYS_DEPT_ROLE dr "
+
" WHERE "
+
" dr.ROLE_ID =
r
ole.BUSINESS_ID "
+
" dr.ROLE_ID =
sysR
ole.BUSINESS_ID "
+
" AND ur.USER_ID = #{deptId} "
+
" ) > 0, "
+
" '1', "
+
" '0' "
+
" ) AS checked "
+
"FROM "
+
" sys_role
r
ole "
+
" sys_role
sysR
ole "
+
"WHERE "
+
" DEL_FLAG = '0' and FLAG = '1'</script>"
)
@ResultMap
(
value
=
"BaseResultMap"
)
List
<
Role
>
queryDeptRolesByPagination
(
@Param
(
"deptId"
)
String
deptId
,
Role
r
ole
);
List
<
SysRole
>
queryDeptRolesByPagination
(
@Param
(
"deptId"
)
String
deptId
,
SysRole
sysR
ole
);
@Delete
(
"<script>DELETE from sys_dept_role_user where DEPT_ROLE_ID="
+
"("
...
...
src/main/java/org/rcisoft/sys/role/entity/Role.java
→
src/main/java/org/rcisoft/sys/role/entity/
Sys
Role.java
View file @
6764ed76
...
...
@@ -25,7 +25,7 @@ import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
public
class
Role
extends
IdEntity
<
Role
>
{
public
class
SysRole
extends
IdEntity
<
Sys
Role
>
{
private
static
final
long
serialVersionUID
=
-
437438239495993636L
;
...
...
@@ -40,14 +40,14 @@ public class Role extends IdEntity<Role> {
/*权限code*/
private
String
code
;
@Transient
private
String
checked
;
private
String
dataScope
;
@Transient
private
List
<
Menu
>
menuList
=
Lists
.
newArrayList
();
// 拥有菜单列表
public
Role
(
String
id
,
String
name
)
{
public
Sys
Role
(
String
id
,
String
name
)
{
this
();
this
.
businessId
=
id
;
this
.
name
=
name
;
...
...
@@ -69,6 +69,7 @@ public class Role extends IdEntity<Role> {
* 获取权限字符串列表
*/
@Transient
@JsonIgnore
public
List
<
String
>
getPermissions
()
{
List
<
String
>
permissions
=
Lists
.
newArrayList
();
for
(
Menu
menu
:
menuList
)
{
...
...
src/main/java/org/rcisoft/sys/role/service/RoleService.java
View file @
6764ed76
...
...
@@ -5,7 +5,7 @@ package org.rcisoft.sys.role.service;
import
org.rcisoft.common.component.PageUtil
;
import
org.rcisoft.core.model.PersistModel
;
import
org.rcisoft.sys.dept.entity.DeptRole
;
import
org.rcisoft.sys.role.entity.Role
;
import
org.rcisoft.sys.role.entity.
Sys
Role
;
import
java.util.List
;
...
...
@@ -16,17 +16,17 @@ public interface RoleService {
/**
* 保存
* @param
r
ole
* @param
sysR
ole
* @return
*/
PersistModel
persistRole
(
Role
role
,
String
token
);
PersistModel
persistRole
(
SysRole
sysRole
,
String
token
);
/**
* 修改
* @param
r
ole
* @param
sysR
ole
* @return
*/
PersistModel
mergeRole
(
Role
r
ole
,
String
token
);
PersistModel
mergeRole
(
SysRole
sysR
ole
,
String
token
);
/**
* 删除
...
...
@@ -38,17 +38,17 @@ public interface RoleService {
/**
* getByid
*/
Role
queryRoleById
(
String
id
);
Sys
Role
queryRoleById
(
String
id
);
/**
* 分页查询角色
* @param paginationUtility
* @param
r
ole
* @param
sysR
ole
* @return
*/
public
List
<
Role
>
queryRolesByPagination
(
PageUtil
<
Role
>
paginationUtility
,
Role
r
ole
);
public
List
<
SysRole
>
queryRolesByPagination
(
PageUtil
<
SysRole
>
paginationUtility
,
SysRole
sysR
ole
);
//select
List
<
Role
>
queryRolesSelect
(
Role
r
ole
);
List
<
SysRole
>
queryRolesSelect
(
SysRole
sysR
ole
);
/**
* 授权(赋予角色 权限)
...
...
@@ -63,17 +63,17 @@ public interface RoleService {
* 分页查询角色 根据 userId 进行checked
* @param paginationUtility
* @param userId
* @param
r
ole
* @param
sysR
ole
* @return
*/
public
List
<
DeptRole
>
queryUserRolesByPagination
(
PageUtil
<
Role
>
paginationUtility
,
String
userId
,
Role
r
ole
);
public
List
<
DeptRole
>
queryUserRolesByPagination
(
PageUtil
<
SysRole
>
paginationUtility
,
String
userId
,
SysRole
sysR
ole
);
/**
*
* @param paginationUtility
* @param DeptId
* @param
r
ole
* @param
sysR
ole
* @return
*/
public
List
<
Role
>
queryDeptRolesByPagination
(
PageUtil
<
Role
>
paginationUtility
,
String
DeptId
,
Role
r
ole
);
public
List
<
SysRole
>
queryDeptRolesByPagination
(
PageUtil
<
SysRole
>
paginationUtility
,
String
DeptId
,
SysRole
sysR
ole
);
}
src/main/java/org/rcisoft/sys/role/service/impl/RoleServiceImpl.java
View file @
6764ed76
...
...
@@ -9,7 +9,7 @@ import org.rcisoft.core.util.IdGen;
import
org.rcisoft.core.util.UserUtil
;
import
org.rcisoft.sys.dept.entity.DeptRole
;
import
org.rcisoft.sys.role.dao.RoleRepository
;
import
org.rcisoft.sys.role.entity.Role
;
import
org.rcisoft.sys.role.entity.
Sys
Role
;
import
org.rcisoft.sys.role.service.RoleService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -36,22 +36,22 @@ public class RoleServiceImpl implements RoleService {
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
isolation
=
Isolation
.
DEFAULT
)
@Override
public
PersistModel
persistRole
(
Role
r
ole
,
String
token
)
{
r
ole
.
setCommonBusinessId
();
public
PersistModel
persistRole
(
SysRole
sysR
ole
,
String
token
)
{
sysR
ole
.
setCommonBusinessId
();
//增加操作
UserUtil
.
setCurrentPersistOperation
(
r
ole
,
token
);
int
line
=
roleRepository
.
insertSelective
(
r
ole
);
log
.
info
(
UserUtil
.
getUserInfoProp
(
token
,
UserUtil
.
USER_USERNAME
)+
"新增了ID为"
+
r
ole
.
getBusinessId
()+
"的角色信息"
);
UserUtil
.
setCurrentPersistOperation
(
sysR
ole
,
token
);
int
line
=
roleRepository
.
insertSelective
(
sysR
ole
);
log
.
info
(
UserUtil
.
getUserInfoProp
(
token
,
UserUtil
.
USER_USERNAME
)+
"新增了ID为"
+
sysR
ole
.
getBusinessId
()+
"的角色信息"
);
return
new
PersistModel
(
line
);
}
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
isolation
=
Isolation
.
DEFAULT
)
@Override
public
PersistModel
mergeRole
(
Role
role
,
String
token
)
{
public
PersistModel
mergeRole
(
SysRole
sysRole
,
String
token
)
{
//修改操作
UserUtil
.
setCurrentMergeOperation
(
r
ole
,
token
);
int
line
=
roleRepository
.
updateByPrimaryKeySelective
(
r
ole
);
log
.
info
(
UserUtil
.
getUserInfoProp
(
token
,
UserUtil
.
USER_USERNAME
)+
"修改了ID为"
+
r
ole
.
getBusinessId
()+
"的角色信息"
);
UserUtil
.
setCurrentMergeOperation
(
sysR
ole
,
token
);
int
line
=
roleRepository
.
updateByPrimaryKeySelective
(
sysR
ole
);
log
.
info
(
UserUtil
.
getUserInfoProp
(
token
,
UserUtil
.
USER_USERNAME
)+
"修改了ID为"
+
sysR
ole
.
getBusinessId
()+
"的角色信息"
);
return
new
PersistModel
(
line
);
}
...
...
@@ -64,21 +64,21 @@ public class RoleServiceImpl implements RoleService {
line
=
roleRepository
.
deleteDeptRoleByRoleId
(
id
);
line
=
roleRepository
.
deleteRoleMenuByRoleId
(
id
);
Role
r
ole
=
roleRepository
.
selectByPrimaryKey
(
id
);
r
ole
.
setDelFlag
(
DelStatus
.
DELETED
.
getStatus
());
UserUtil
.
setCurrentMergeOperation
(
r
ole
,
token
);
line
=
roleRepository
.
updateByPrimaryKeySelective
(
r
ole
);
log
.
info
(
UserUtil
.
getUserInfoProp
(
token
,
UserUtil
.
USER_USERNAME
)+
"删除了ID为"
+
r
ole
.
getBusinessId
()+
"的角色信息"
);
SysRole
sysR
ole
=
roleRepository
.
selectByPrimaryKey
(
id
);
sysR
ole
.
setDelFlag
(
DelStatus
.
DELETED
.
getStatus
());
UserUtil
.
setCurrentMergeOperation
(
sysR
ole
,
token
);
line
=
roleRepository
.
updateByPrimaryKeySelective
(
sysR
ole
);
log
.
info
(
UserUtil
.
getUserInfoProp
(
token
,
UserUtil
.
USER_USERNAME
)+
"删除了ID为"
+
sysR
ole
.
getBusinessId
()+
"的角色信息"
);
return
new
PersistModel
(
line
);
}
@Override
public
List
<
Role
>
queryRolesByPagination
(
PageUtil
<
Role
>
paginationUtility
,
Role
r
ole
)
{
return
roleRepository
.
queryRoles
(
r
ole
);
public
List
<
SysRole
>
queryRolesByPagination
(
PageUtil
<
SysRole
>
paginationUtility
,
SysRole
sysR
ole
)
{
return
roleRepository
.
queryRoles
(
sysR
ole
);
}
@Override
public
List
<
DeptRole
>
queryUserRolesByPagination
(
PageUtil
<
Role
>
paginationUtility
,
String
userId
,
Role
r
ole
)
{
return
roleRepository
.
queryUserRolesByPagination
(
userId
,
r
ole
);
public
List
<
DeptRole
>
queryUserRolesByPagination
(
PageUtil
<
SysRole
>
paginationUtility
,
String
userId
,
SysRole
sysR
ole
)
{
return
roleRepository
.
queryUserRolesByPagination
(
userId
,
sysR
ole
);
}
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
isolation
=
Isolation
.
DEFAULT
)
@Override
...
...
@@ -104,8 +104,8 @@ public class RoleServiceImpl implements RoleService {
}
@Override
public
List
<
Role
>
queryDeptRolesByPagination
(
PageUtil
<
Role
>
paginationUtility
,
String
deptId
,
Role
r
ole
)
{
return
roleRepository
.
queryDeptRolesByPagination
(
deptId
,
r
ole
);
public
List
<
SysRole
>
queryDeptRolesByPagination
(
PageUtil
<
SysRole
>
paginationUtility
,
String
deptId
,
SysRole
sysR
ole
)
{
return
roleRepository
.
queryDeptRolesByPagination
(
deptId
,
sysR
ole
);
}
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
isolation
=
Isolation
.
DEFAULT
)
@Override
...
...
@@ -131,13 +131,13 @@ public class RoleServiceImpl implements RoleService {
}
@Override
public
Role
queryRoleById
(
String
id
)
{
public
Sys
Role
queryRoleById
(
String
id
)
{
return
roleRepository
.
selectByPrimaryKey
(
id
);
}
@Override
public
List
<
Role
>
queryRolesSelect
(
Role
r
ole
)
{
return
roleRepository
.
queryRolesSelect
(
r
ole
);
public
List
<
SysRole
>
queryRolesSelect
(
SysRole
sysR
ole
)
{
return
roleRepository
.
queryRolesSelect
(
sysR
ole
);
}
...
...
src/main/java/org/rcisoft/sys/user/entity/SysUser.java
View file @
6764ed76
package
org
.
rcisoft
.
sys
.
user
.
entity
;
import
com.google.common.collect.Lists
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.rcisoft.core.entity.IdEntity
;
import
org.rcisoft.sys.role.entity.SysRole
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
import
javax.persistence.Transient
;
import
java.util.List
;
/**
* Created by lcy on 17/11/21.
...
...
@@ -29,4 +33,8 @@ public class SysUser extends IdEntity<SysUser> {
private
String
name
;
@Transient
private
List
<
SysRole
>
roleList
=
Lists
.
newArrayList
();
// 拥有角色列表
}
src/main/resources/mapper/sys/role/mapper/roleMapper.xml
View file @
6764ed76
<?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=
"org.rcisoft.sys.
r
ole.dao.RoleRepository"
>
<mapper
namespace=
"org.rcisoft.sys.
sysR
ole.dao.RoleRepository"
>
<resultMap
id=
"BaseResultMap"
type=
"org.rcisoft.sys.
role.entity.
Role"
>
<resultMap
id=
"BaseResultMap"
type=
"org.rcisoft.sys.
sysRole.entity.Sys
Role"
>
<id
column=
"business_id"
jdbcType=
"VARCHAR"
property=
"businessId"
/>
<result
column=
"name"
jdbcType=
"VARCHAR"
property=
"name"
/>
<result
column=
"DATA_SCOPE"
jdbcType=
"VARCHAR"
property=
"dataScope"
/>
<result
column=
"CODE"
jdbcType=
"VARCHAR"
property=
"code"
/>
<result
column=
"checked"
jdbcType=
"VARCHAR"
property=
"checked"
/>
...
...
@@ -31,7 +30,7 @@
</resultMap>
<sql
id=
"Base_Column_List"
>
BUSINESS_ID,name,
DATA_SCOPE,
CODE,CREATE_BY,FLAG,UPDATE_BY,DEL_FLAG,update_date,create_date
BUSINESS_ID,name,CODE,CREATE_BY,FLAG,UPDATE_BY,DEL_FLAG,update_date,create_date
</sql>
<!--insertBatchRoleMenu 批量插入角色权限-->
...
...
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