merge
This commit is contained in:
@@ -22,7 +22,7 @@ import java.util.stream.Collectors;
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/11/14 13:20
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
* 说明: 权限服务层
|
||||
*/
|
||||
@Service
|
||||
public class SysAuthorityService {
|
||||
@@ -142,6 +142,8 @@ public class SysAuthorityService {
|
||||
* @return
|
||||
*/
|
||||
public List<SysAuthority> listByParentEnable(String parentId, String enable) {
|
||||
if(StringUtils.isEmpty(parentId))
|
||||
parentId=CommonConstant.ROOT;
|
||||
if (StringUtils.isNotEmpty(enable))
|
||||
return sysAuthorityRepository.getByParentIdAndEnable(parentId, enable);
|
||||
else
|
||||
@@ -177,7 +179,7 @@ public class SysAuthorityService {
|
||||
* @return
|
||||
*/
|
||||
public boolean disableChildrenByParentId(String parentId) {
|
||||
List<SysAuthority> sysAuthorities = listChildren(parentId);
|
||||
List<SysAuthority> sysAuthorities = disableChildren(parentId);
|
||||
if (CollectionUtils.isNotEmpty(sysAuthorities)) {
|
||||
List<SysAuthority> save = sysAuthorityRepository.save(sysAuthorities);
|
||||
return CollectionUtils.isNotEmpty(save);
|
||||
@@ -186,7 +188,7 @@ public class SysAuthorityService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归查询所有节点(包括禁用)
|
||||
* 根据状态递归查询所有节点
|
||||
*
|
||||
* @param parentId
|
||||
* @param enable
|
||||
@@ -216,7 +218,7 @@ public class SysAuthorityService {
|
||||
* @param parentId
|
||||
* @return
|
||||
*/
|
||||
private List<SysAuthority> listChildren(String parentId) {
|
||||
private List<SysAuthority> disableChildren(String parentId) {
|
||||
//获取结果
|
||||
List<SysAuthority> sysAuthoritys = listByParentEnable(parentId, CommonConstant.ISENABLE);
|
||||
//遍历子集
|
||||
@@ -226,7 +228,7 @@ public class SysAuthorityService {
|
||||
sysAuthority.setEnable(CommonConstant.ISNOTENABLE);
|
||||
sysAuthority.setModifiedTime(new Date());
|
||||
list.add(sysAuthority);
|
||||
list.addAll(listChildren(sysAuthority.getId()));
|
||||
list.addAll(disableChildren(sysAuthority.getId()));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
@@ -246,7 +248,7 @@ public class SysAuthorityService {
|
||||
if (CollectionUtils.isNotEmpty(sysAuthoritys)) {
|
||||
for (SysAuthority sysAuthority : sysAuthoritys) {
|
||||
list.add(sysAuthority);
|
||||
list.addAll(listChildren(sysAuthority.getId()));
|
||||
list.addAll(listChildrenForRemove(sysAuthority.getId()));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.util.List;
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/11/14 15:15
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
* 说明: 角色权限服务层
|
||||
*/
|
||||
@Service
|
||||
public class SysRoleAuthorityService {
|
||||
@@ -37,7 +37,7 @@ public class SysRoleAuthorityService {
|
||||
if (CollectionUtils.isNotEmpty(roleAuthorities)) {
|
||||
sysRoleAuthorityRepository.deleteInBatch(roleAuthorities);
|
||||
}
|
||||
//角色新增权限
|
||||
//新增角色权限
|
||||
list.forEach(roleAuthority -> {
|
||||
roleAuthority.setId(PassWordUtil.createId());
|
||||
roleAuthority.setModifiedTime(new Date());
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.stream.Collectors;
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/11/14 9:24
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
* 说明: 角色服务层
|
||||
*/
|
||||
@Service
|
||||
public class SysRoleService {
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.util.List;
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/11/14 14:15
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
* 说明: 用户角色服务层
|
||||
*/
|
||||
@Service
|
||||
public class SysUserRoleService {
|
||||
@@ -37,7 +37,7 @@ public class SysUserRoleService {
|
||||
if (CollectionUtils.isNotEmpty(sysUserRoles)) {
|
||||
sysUserRoleRepository.deleteInBatch(sysUserRoles);
|
||||
}
|
||||
//用户新增角色
|
||||
//新增用户角色
|
||||
list.forEach(sysUserRole -> {
|
||||
sysUserRole.setId(PassWordUtil.createId());
|
||||
sysUserRole.setCreateTime(new Date());
|
||||
|
||||
@@ -347,7 +347,7 @@ public class SysUserService {
|
||||
* @return
|
||||
*/
|
||||
private boolean checkPassWord(String passWord, String realPassWord, String salt) {
|
||||
// 根据密码盐值, 解码
|
||||
// 根据密码盐值 解码
|
||||
byte[] saltByte = EncodeUtils.hexDecode(salt);
|
||||
byte[] hashPassword = Digests.sha1(passWord.getBytes(), saltByte,
|
||||
PassWordUtil.HASH_INTERATIONS);
|
||||
|
||||
@@ -24,7 +24,7 @@ public class JSONObjResult {
|
||||
/**
|
||||
* 消息体
|
||||
*/
|
||||
private String message = "未知异常";
|
||||
private String message = "";
|
||||
/**
|
||||
* 返回数据
|
||||
*/
|
||||
|
||||
@@ -15,5 +15,4 @@ public class RestMessage implements Serializable {
|
||||
private String message;// 成功、错误返回提示信息
|
||||
private Object data;// 返回的数据
|
||||
private String id;// 新增、修改主鍵返回id
|
||||
private Integer code;//错误码
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class SysAuthorityControl {
|
||||
return JSONObjResult.toJSONObj("禁用子节点权限失败");
|
||||
}
|
||||
} else {
|
||||
// 如果是启用看父节点是否被禁用,一级的不需要判断
|
||||
// 如果是启用,看父节点是否被禁用,一级的不需要判断
|
||||
if (!CommonConstant.ROOT.equals(sysAuthority.getParentId())) {
|
||||
SysAuthority parent = sysAuthorityService.getById(sysAuthority.getParentId());
|
||||
if (parent != null && CommonEnum.YesOrNoEnum.NO.getCode().equals(parent.getEnable()))
|
||||
@@ -88,8 +88,6 @@ public class SysAuthorityControl {
|
||||
@ApiOperation(value = "根据父节点查询子节点")
|
||||
@ApiImplicitParam(name = "parentId", value = "父id,可为空", paramType = "query", dataType = "string")
|
||||
public JSONObject listByParentId(String parentId) {
|
||||
if (StringUtils.isEmpty(parentId))
|
||||
parentId = CommonConstant.ROOT;
|
||||
if (!CommonConstant.ROOT.equals(parentId) && sysAuthorityService.getById(parentId) == null)
|
||||
return JSONObjResult.toJSONObj("父节点不存在");
|
||||
List<SysAuthority> queryByParentId = sysAuthorityService.listByParentEnable(parentId, null);
|
||||
|
||||
@@ -113,8 +113,9 @@ public class SysRoleControl {
|
||||
return JSONObjResult.toJSONObj("该角色不存在");
|
||||
String ids[] = authorityIds.split(",");
|
||||
List<SysRoleAuthority> list = new ArrayList<>();
|
||||
SysRoleAuthority roleAuthority;
|
||||
for (String id : ids) {
|
||||
SysRoleAuthority roleAuthority = new SysRoleAuthority();
|
||||
roleAuthority = new SysRoleAuthority();
|
||||
roleAuthority.setRoleId(roleId);
|
||||
roleAuthority.setAuthorityId(id);
|
||||
list.add(roleAuthority);
|
||||
|
||||
@@ -179,8 +179,9 @@ public class SysUserControl {
|
||||
return JSONObjResult.toJSONObj("不能对管理员进行操作");
|
||||
String ids[] = roleIds.split(",");
|
||||
List<SysUserRole> list = new ArrayList<>();
|
||||
SysUserRole userRole;
|
||||
for (String id : ids) {
|
||||
SysUserRole userRole = new SysUserRole();
|
||||
userRole = new SysUserRole();
|
||||
userRole.setRoleId(id);
|
||||
userRole.setUserId(userId);
|
||||
list.add(userRole);
|
||||
|
||||
Reference in New Issue
Block a user