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;/*
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
......@@ -106,10 +107,7 @@ public class SysUserInfo extends BaseEntity {
/**
* 角色名称合集
*/
@ExcelAttribute(name = "角色名称合集", maxLength = 200)
@Length(max = 200, message = "角色名称合集不能超过200个字符")
@ExcelProperty("角色名称合集")
@Schema(description = "角色名称合集")
@TableField(exist = false)
private String roleNames;
}
......@@ -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.SysUserRoleResService;
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.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.permission.entity.SysRoleInfo;
......@@ -113,10 +114,13 @@ public class SysRoleInfoController {
@DeleteMapping("/{fdId}")
@PreAuthorize("@pms.hasPermission('ekp_sysroleinfo_del')")
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);
// 假删除角色表
SysRoleInfo roleInfo = sysRoleInfoService.getById(fdId);
roleInfo.setDeleteFlag(CommonConstants.ONE_INT);
sysRoleInfoService.updateById(roleInfo);
return R.ok();
......@@ -133,10 +137,13 @@ public class SysRoleInfoController {
@PostMapping("/freezeById")
@PreAuthorize("@pms.hasPermission('ekp_sysroleinfo_freeze')")
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);
// 冻结角色表
SysRoleInfo roleInfo = sysRoleInfoService.getById(fdId);
roleInfo.setStatus(CommonConstants.ONE_INT);
sysRoleInfoService.updateById(roleInfo);
return R.ok();
......
......@@ -134,27 +134,25 @@ public class SysRoleInfoServiceImpl extends ServiceImpl<SysRoleInfoMapper, SysRo
@Override
public String getAllRoleDataAuthByUserId(String userId) {
List<String> authList = baseMapper.getAllRoleDataAuthByUserId(userId);
String auths = "";
StringBuilder auths = new StringBuilder();
if (authList != null && !authList.isEmpty()) {
String[] authArr;
Set<String> authSet = new HashSet<>();
for (String auth : authList) {
authArr = auth.split(",");
for (String subAuth : authArr) {
authSet.add(subAuth);
}
Collections.addAll(authSet, authArr);
}
boolean flag = false;
for (String subAuth : authSet) {
if (flag) {
auths = auths + "," + subAuth;
auths.append(",").append(subAuth);
} else {
auths = subAuth;
auths.append(subAuth);
flag = true;
}
}
}
return auths;
return auths.toString();
}
private LambdaQueryWrapper buildQueryWrapper(SysRoleInfoSearchVo entity) {
......
......@@ -48,7 +48,7 @@
a.fd_mobile_no,
a.fd_email,
a.status,
a.role_names,
GROUP_CONCAT(r.role_name ORDER BY r.create_time asc) as role_names,
a.CREATE_BY,
a.CREATE_NAME,
a.CREATE_TIME,
......@@ -82,7 +82,7 @@
AND a.status = #{sysUserInfo.status}
</if>
<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 test="sysUserInfo.createBy != null and sysUserInfo.createBy.trim() != ''">
AND a.CREATE_BY = #{sysUserInfo.createBy}
......@@ -106,10 +106,14 @@
SELECT
<include refid="Base_Column_List"/>
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>
1=1
<include refid="sysUserInfo_where"/>
</where>
GROUP BY a.fd_id
order by a.CREATE_TIME desc
</select>
</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