Commit 9fbf1bf2 authored by hongguangwu's avatar hongguangwu

1.5.8-hgw-权限-角色-账号

parent e4785ef0
...@@ -17,6 +17,7 @@ package com.yifu.cloud.plus.v1.yifu.permission.entity;/* ...@@ -17,6 +17,7 @@ package com.yifu.cloud.plus.v1.yifu.permission.entity;/*
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute; import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
...@@ -106,10 +107,7 @@ public class SysUserInfo extends BaseEntity { ...@@ -106,10 +107,7 @@ public class SysUserInfo extends BaseEntity {
/** /**
* 角色名称合集 * 角色名称合集
*/ */
@ExcelAttribute(name = "角色名称合集", maxLength = 200) @TableField(exist = false)
@Length(max = 200, message = "角色名称合集不能超过200个字符")
@ExcelProperty("角色名称合集")
@Schema(description = "角色名称合集")
private String roleNames; private String roleNames;
} }
...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.permission.service.SysRoleInfoService; import com.yifu.cloud.plus.v1.permission.service.SysRoleInfoService;
import com.yifu.cloud.plus.v1.permission.service.SysUserRoleResService; import com.yifu.cloud.plus.v1.permission.service.SysUserRoleResService;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog; import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.permission.entity.SysRoleInfo; import com.yifu.cloud.plus.v1.yifu.permission.entity.SysRoleInfo;
...@@ -113,10 +114,13 @@ public class SysRoleInfoController { ...@@ -113,10 +114,13 @@ public class SysRoleInfoController {
@DeleteMapping("/{fdId}") @DeleteMapping("/{fdId}")
@PreAuthorize("@pms.hasPermission('ekp_sysroleinfo_del')") @PreAuthorize("@pms.hasPermission('ekp_sysroleinfo_del')")
public R<Boolean> removeById(@PathVariable String fdId) { public R<Boolean> removeById(@PathVariable String fdId) {
SysRoleInfo roleInfo = sysRoleInfoService.getById(fdId);
if (roleInfo == null || Common.isEmpty(roleInfo.getFdId()) || Common.isEmpty(roleInfo.getRoleName())) {
return R.failed("未找到角色");
}
// 删除关联表 // 删除关联表
sysUserRoleResService.deleteByRoleId(fdId); sysUserRoleResService.deleteByRoleId(fdId);
// 假删除角色表 // 假删除角色表
SysRoleInfo roleInfo = sysRoleInfoService.getById(fdId);
roleInfo.setDeleteFlag(CommonConstants.ONE_INT); roleInfo.setDeleteFlag(CommonConstants.ONE_INT);
sysRoleInfoService.updateById(roleInfo); sysRoleInfoService.updateById(roleInfo);
return R.ok(); return R.ok();
...@@ -133,10 +137,13 @@ public class SysRoleInfoController { ...@@ -133,10 +137,13 @@ public class SysRoleInfoController {
@PostMapping("/freezeById") @PostMapping("/freezeById")
@PreAuthorize("@pms.hasPermission('ekp_sysroleinfo_freeze')") @PreAuthorize("@pms.hasPermission('ekp_sysroleinfo_freeze')")
public R<Boolean> freezeById(@RequestParam String fdId) { public R<Boolean> freezeById(@RequestParam String fdId) {
SysRoleInfo roleInfo = sysRoleInfoService.getById(fdId);
if (roleInfo == null || Common.isEmpty(roleInfo.getFdId()) || Common.isEmpty(roleInfo.getRoleName())) {
return R.failed("未找到角色");
}
// 删除关联表 // 删除关联表
sysUserRoleResService.deleteByRoleId(fdId); sysUserRoleResService.deleteByRoleId(fdId);
// 冻结角色表 // 冻结角色表
SysRoleInfo roleInfo = sysRoleInfoService.getById(fdId);
roleInfo.setStatus(CommonConstants.ONE_INT); roleInfo.setStatus(CommonConstants.ONE_INT);
sysRoleInfoService.updateById(roleInfo); sysRoleInfoService.updateById(roleInfo);
return R.ok(); return R.ok();
......
...@@ -134,27 +134,25 @@ public class SysRoleInfoServiceImpl extends ServiceImpl<SysRoleInfoMapper, SysRo ...@@ -134,27 +134,25 @@ public class SysRoleInfoServiceImpl extends ServiceImpl<SysRoleInfoMapper, SysRo
@Override @Override
public String getAllRoleDataAuthByUserId(String userId) { public String getAllRoleDataAuthByUserId(String userId) {
List<String> authList = baseMapper.getAllRoleDataAuthByUserId(userId); List<String> authList = baseMapper.getAllRoleDataAuthByUserId(userId);
String auths = ""; StringBuilder auths = new StringBuilder();
if (authList != null && !authList.isEmpty()) { if (authList != null && !authList.isEmpty()) {
String[] authArr; String[] authArr;
Set<String> authSet = new HashSet<>(); Set<String> authSet = new HashSet<>();
for (String auth : authList) { for (String auth : authList) {
authArr = auth.split(","); authArr = auth.split(",");
for (String subAuth : authArr) { Collections.addAll(authSet, authArr);
authSet.add(subAuth);
}
} }
boolean flag = false; boolean flag = false;
for (String subAuth : authSet) { for (String subAuth : authSet) {
if (flag) { if (flag) {
auths = auths + "," + subAuth; auths.append(",").append(subAuth);
} else { } else {
auths = subAuth; auths.append(subAuth);
flag = true; flag = true;
} }
} }
} }
return auths; return auths.toString();
} }
private LambdaQueryWrapper buildQueryWrapper(SysRoleInfoSearchVo entity) { private LambdaQueryWrapper buildQueryWrapper(SysRoleInfoSearchVo entity) {
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
a.fd_mobile_no, a.fd_mobile_no,
a.fd_email, a.fd_email,
a.status, a.status,
a.role_names, GROUP_CONCAT(r.role_name ORDER BY r.create_time asc) as role_names,
a.CREATE_BY, a.CREATE_BY,
a.CREATE_NAME, a.CREATE_NAME,
a.CREATE_TIME, a.CREATE_TIME,
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
AND a.status = #{sysUserInfo.status} AND a.status = #{sysUserInfo.status}
</if> </if>
<if test="sysUserInfo.roleNames != null and sysUserInfo.roleNames.trim() != ''"> <if test="sysUserInfo.roleNames != null and sysUserInfo.roleNames.trim() != ''">
AND a.role_names like concat('%',#{sysUserInfo.roleNames},'%') AND r.role_name like concat('%',#{sysUserInfo.roleNames},'%')
</if> </if>
<if test="sysUserInfo.createBy != null and sysUserInfo.createBy.trim() != ''"> <if test="sysUserInfo.createBy != null and sysUserInfo.createBy.trim() != ''">
AND a.CREATE_BY = #{sysUserInfo.createBy} AND a.CREATE_BY = #{sysUserInfo.createBy}
...@@ -106,10 +106,14 @@ ...@@ -106,10 +106,14 @@
SELECT SELECT
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
FROM sys_user_info a FROM sys_user_info a
LEFT JOIN sys_user_role_res res on a.fd_id=res.user_id
LEFT JOIN sys_role_info r on res.role_id=r.fd_id and r.delete_flag = 0 and r.status = 0
<where> <where>
1=1 1=1
<include refid="sysUserInfo_where"/> <include refid="sysUserInfo_where"/>
</where> </where>
GROUP BY a.fd_id
order by a.CREATE_TIME desc order by a.CREATE_TIME desc
</select> </select>
</mapper> </mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment