Browse Source

权限管理类

tags/v1.0.0^2
chengwang 1 year ago
parent
commit
68c7316493
18 changed files with 368 additions and 205 deletions
  1. +19
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/PermissionController.java
  2. +43
    -44
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/RoleController.java
  3. +36
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/dto/RolePermissionDto.java
  4. +42
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Menu.java
  5. +46
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/OpPermissions.java
  6. +43
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/OpRolePermission.java
  7. +42
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Role.java
  8. +43
    -5
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/RoleMenu.java
  9. +0
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/RoleMenuMapper.java
  10. +0
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/UserRoleMapper.java
  11. +21
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/query/RoleClientQuery.java
  12. +0
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/RoleMenuServiceImpl.java
  13. +3
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/permissions/OpPermissionsService.java
  14. +25
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/permissions/OpPermissionsServiceImpl.java
  15. +1
    -5
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/role/IRoleService.java
  16. +1
    -127
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/role/RoleServiceImpl.java
  17. +0
    -7
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/add/AddUserService.java
  18. +3
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/RoleListVo.java

+ 19
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/PermissionController.java View File

@@ -1,6 +1,11 @@
package com.tuoheng.admin.controller;

import com.tuoheng.admin.query.RoleClientQuery;
import com.tuoheng.admin.service.permissions.OpPermissionsService;
import com.tuoheng.common.core.common.BaseController;
import com.tuoheng.common.core.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@@ -11,5 +16,18 @@ import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/permission")
public class PermissionController extends BaseController {
public class PermissionController{

@Autowired
private OpPermissionsService permissionService;

/**
* 根据 RoleId 获取用户权限
*
* @return
*/
@GetMapping("/getRolePermission")
public JsonResult getMenuAndPermissionByRoleId(RoleClientQuery query) {
return permissionService.getRolePermissionByRoleId(query);
}
}

+ 43
- 44
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/RoleController.java View File

@@ -2,7 +2,6 @@ package com.tuoheng.admin.controller;

import com.tuoheng.admin.entity.Role;
import com.tuoheng.admin.query.RoleQuery;
import com.tuoheng.admin.service.report.IReportService;
import com.tuoheng.admin.service.role.IRoleService;
import com.tuoheng.common.core.annotation.Log;
import com.tuoheng.common.core.enums.LogType;
@@ -21,47 +20,47 @@ public class RoleController {
@Autowired
private IRoleService roleService;

/**
* 获取角色列表
* @param roleQuery
* @return
*/
@GetMapping("/index")
public JsonResult index(RoleQuery roleQuery){
return roleService.getRoleList(roleQuery);
}
/**
* 添加角色
* @param entity
* @return
*/
@PostMapping("/add")
public JsonResult add(@RequestBody Role entity){
return roleService.editRole(entity);
}
/**
* 编辑角色
* @param entity
* @return
*/
@PutMapping("/edit")
public JsonResult edit(@RequestBody Role entity){
return roleService.editRole(entity);
}
/**
* 删除角色
*
* @param roleIds 角色ID
* @return
*/
@Log(title = "角色管理", logType = LogType.DELETE)
// @RequiresPermissions("sys:role:delete")
@DeleteMapping("/delete/{roleIds}")
public JsonResult delete(@PathVariable("roleIds") Integer[] roleIds) {
return roleService.deleteByList(roleIds);
}
// /**
// * 获取角色列表
// * @param roleQuery
// * @return
// */
// @GetMapping("/index")
// public JsonResult index(RoleQuery roleQuery){
// return roleService.getRoleList(roleQuery);
// }
//
// /**
// * 添加角色
// * @param entity
// * @return
// */
// @PostMapping("/add")
// public JsonResult add(@RequestBody Role entity){
// return roleService.editRole(entity);
// }
//
// /**
// * 编辑角色
// * @param entity
// * @return
// */
// @PutMapping("/edit")
// public JsonResult edit(@RequestBody Role entity){
// return roleService.editRole(entity);
// }
//
// /**
// * 删除角色
// *
// * @param roleIds 角色ID
// * @return
// */
// @Log(title = "角色管理", logType = LogType.DELETE)
//// @RequiresPermissions("sys:role:delete")
// @DeleteMapping("/delete/{roleIds}")
// public JsonResult delete(@PathVariable("roleIds") Integer[] roleIds) {
// return roleService.deleteByList(roleIds);
//
// }
}

+ 36
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/dto/RolePermissionDto.java View File

@@ -0,0 +1,36 @@
package com.tuoheng.admin.dto;


import com.tuoheng.admin.entity.Menu;
import com.tuoheng.admin.entity.OpPermissions;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.util.List;

/**
* @author chenjiandong
* @description: TODO
* @date 2022/11/16 14:55
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class RolePermissionDto {
/**
* 角色id
*/
private Integer roleId;
/**
*对应的菜单集合->及子菜单(按钮)
*/
private List<Menu> opMenusList;
/**
* 对应的权限集合
*/
private List<OpPermissions> permissionsList;

}

+ 42
- 3
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Menu.java View File

@@ -1,13 +1,17 @@
package com.tuoheng.admin.entity;

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.tuoheng.common.core.common.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.List;

/**
@@ -19,12 +23,18 @@ import java.util.List;
* @since 2020-10-30
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("op_menus")
public class Menu extends BaseEntity {
public class Menu {

private static final long serialVersionUID = 1L;

/**
* 主键ID
*/
@TableId(value = "id", type = IdType.AUTO)
private Integer id;

/**
* 父级ID
*/
@@ -70,6 +80,35 @@ public class Menu extends BaseEntity {
*/
private Integer sort;

/**
* 添加人
*/
private Integer createUser;

/**
* 创建时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;

/**
* 更新人
*/
private Integer updateUser;

/**
* 更新时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;

/**
* 有效标识
*/
private Integer mark;

/**
* 子级菜单
*/

+ 46
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/OpPermissions.java View File

@@ -1,10 +1,15 @@
package com.tuoheng.admin.entity;

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.tuoheng.common.core.common.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
* 权限配置表
@@ -12,7 +17,17 @@ import lombok.Data;
*/
@TableName(value ="op_permissions")
@Data
public class OpPermissions extends BaseEntity {
public class OpPermissions {

private static final long serialVersionUID = 1L;

/**
* 主键ID
*/
@TableId(value = "id", type = IdType.AUTO)
private Integer id;



/**
* 所属client
@@ -49,6 +64,35 @@ public class OpPermissions extends BaseEntity {
*/
private String apiUrl;

/**
* 添加人
*/
private Integer createUser;

/**
* 创建时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;

/**
* 更新人
*/
private Integer updateUser;

/**
* 更新时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;

/**
* 有效标识
*/
private Integer mark;

/**
* 是否选中
*/

+ 43
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/OpRolePermission.java View File

@@ -1,9 +1,15 @@
package com.tuoheng.admin.entity;

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.fasterxml.jackson.annotation.JsonFormat;
import com.tuoheng.common.core.common.BaseEntity;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
* 角色可操作的permission
@@ -11,7 +17,14 @@ import lombok.Data;
*/
@TableName(value ="op_role_permission")
@Data
public class OpRolePermission extends BaseEntity {
public class OpRolePermission{

/**
* 主键ID
*/
@TableId(value = "id", type = IdType.AUTO)
private Integer id;


/**
* 角色id
@@ -24,4 +37,33 @@ public class OpRolePermission extends BaseEntity {

@TableField(exist = false)
private static final long serialVersionUID = 1L;

/**
* 添加人
*/
private Integer createUser;

/**
* 创建时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;

/**
* 更新人
*/
private Integer updateUser;

/**
* 更新时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;

/**
* 有效标识
*/
private Integer mark;
}

+ 42
- 3
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Role.java View File

@@ -1,10 +1,16 @@
package com.tuoheng.admin.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.tuoheng.common.core.common.BaseEntity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
* <p>
@@ -15,13 +21,18 @@ import lombok.experimental.Accessors;
* @since 2020-10-31
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("op_roles")
public class Role extends BaseEntity {
public class Role {

private static final long serialVersionUID = 1L;

/**
* 主键ID
*/
@TableId(value = "id", type = IdType.AUTO)
private Integer id;

/**
* 租户id
*/
@@ -47,4 +58,32 @@ public class Role extends BaseEntity {
*/
private String remark;

/**
* 添加人
*/
private Integer createUser;

/**
* 创建时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;

/**
* 更新人
*/
private Integer updateUser;

/**
* 更新时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;

/**
* 有效标识
*/
private Integer mark;
}

+ 43
- 5
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/RoleMenu.java View File

@@ -1,11 +1,15 @@
package com.tuoheng.admin.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import com.tuoheng.common.core.common.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
* <p>
@@ -16,22 +20,56 @@ import lombok.experimental.Accessors;
* @since 2020-10-30
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("op_role_menu")
public class RoleMenu extends BaseEntity {
public class RoleMenu {

private static final long serialVersionUID = 1L;

/**
* 主键ID
*/
@TableId(value = "id", type = IdType.AUTO)
private Integer id;

/**
* 角色ID
*/
private String roleId;
private Integer roleId;

/**
* 菜单ID
*/
private String menuId;

/**
* 添加人
*/
private Integer createUser;

/**
* 创建时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;

/**
* 更新人
*/
private Integer updateUser;

/**
* 更新时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;

/**
* 有效标识
*/
private Integer mark;


}

+ 0
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/RoleMenuMapper.java View File

@@ -1,7 +1,6 @@
package com.tuoheng.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tuoheng.admin.entity.RoleMenu;

/**
* @Author ChengWang

+ 0
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/UserRoleMapper.java View File

@@ -1,7 +1,6 @@
package com.tuoheng.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tuoheng.admin.entity.Role;
import com.tuoheng.admin.entity.UserRole;
import org.apache.ibatis.annotations.Param;


+ 21
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/query/RoleClientQuery.java View File

@@ -0,0 +1,21 @@
package com.tuoheng.admin.query;


import com.tuoheng.common.core.common.BaseQuery;
import lombok.Data;

/**
* @Author xiaoying
* @Date 2022/11/25 17:56
*/
@Data
public class RoleClientQuery extends BaseQuery {
/**
* 角色id
*/
private Integer roleId;
/**
* 标识
*/
private String clientId;
}

+ 0
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/RoleMenuServiceImpl.java View File

@@ -1,6 +1,5 @@
package com.tuoheng.admin.service.impl;

import com.tuoheng.admin.entity.RoleMenu;
import com.tuoheng.admin.mapper.RoleMenuMapper;
import com.tuoheng.admin.service.IRoleMenuService;
import com.tuoheng.common.core.common.BaseServiceImpl;

+ 3
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/permissions/OpPermissionsService.java View File

@@ -2,10 +2,13 @@ package com.tuoheng.admin.service.permissions;

import com.baomidou.mybatisplus.extension.service.IService;
import com.tuoheng.admin.entity.OpPermissions;
import com.tuoheng.admin.query.RoleClientQuery;
import com.tuoheng.common.core.utils.JsonResult;

/**
* @Author ChengWang
* @Date 2022/12/16
*/
public interface OpPermissionsService extends IService<OpPermissions> {
JsonResult getRolePermissionByRoleId(RoleClientQuery query);
}

+ 25
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/permissions/OpPermissionsServiceImpl.java View File

@@ -2,8 +2,13 @@ package com.tuoheng.admin.service.permissions;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tuoheng.admin.entity.OpPermissions;
import com.tuoheng.admin.mapper.MenuMapper;
import com.tuoheng.admin.mapper.OpPermissionsMapper;
import com.tuoheng.admin.mapper.RoleMenuMapper;
import com.tuoheng.admin.query.RoleClientQuery;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
@@ -13,5 +18,24 @@ import org.springframework.stereotype.Service;

@Service
@Slf4j
public class OpPermissionsServiceImpl extends ServiceImpl<OpPermissionsMapper, OpPermissions> {
public class OpPermissionsServiceImpl extends ServiceImpl<OpPermissionsMapper, OpPermissions> implements OpPermissionsService{

@Autowired
private MenuMapper menuMapper;

@Autowired
private OpPermissionsMapper opPermissionsMapper;

@Autowired
private RoleMenuMapper roleMenuMapper;


@Override
public JsonResult getRolePermissionByRoleId(RoleClientQuery query) {




return null;
}
}

+ 1
- 5
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/role/IRoleService.java View File

@@ -9,10 +9,6 @@ import com.tuoheng.common.core.utils.JsonResult;
* @Author ChengWang
* @Date 2022/12/16
*/
public interface IRoleService extends IBaseService<Role> {
JsonResult getRoleList(RoleQuery roleQuery);
public interface IRoleService {

JsonResult editRole(Role entity);

JsonResult deleteByList(Integer[] roleIds);
}

+ 1
- 127
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/role/RoleServiceImpl.java View File

@@ -1,143 +1,17 @@
package com.tuoheng.admin.service.role;


import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tuoheng.admin.entity.Role;
import com.tuoheng.admin.mapper.RoleMapper;
import com.tuoheng.admin.query.RoleQuery;
import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.admin.vo.RoleListVo;
import com.tuoheng.common.core.common.BaseEntity;
import com.tuoheng.common.core.common.BaseServiceImpl;
import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
* @Author ChengWang
* @Date 2022/12/16
*/
@Service
public class RoleServiceImpl extends BaseServiceImpl<RoleMapper, Role> implements IRoleService {
public class RoleServiceImpl implements IRoleService {

@Autowired
private RoleMapper roleMapper;

/**
* 获取角色列表
* @param roleQuery
* @return
*/
@Override
public JsonResult getRoleList(RoleQuery roleQuery) {
IPage<Role> page = new Page<>(roleQuery.getPage(), roleQuery.getLimit());
// 查询条件
QueryWrapper<Role> queryWrapper = new QueryWrapper<>();
// 租户ID
queryWrapper.eq("tenant_id", CurrentUserUtil.getTenantId());
// 角色名称
if (!StringUtils.isEmpty(roleQuery.getRoleName())) {
queryWrapper.like("role_name", roleQuery.getRoleName());
}
queryWrapper.eq("mark", 1);
//queryWrapper.orderByAsc("sort");
queryWrapper.orderByAsc("create_time");
queryWrapper.ne("code", "super");
// 查询分页数据
IPage<Role> pageData = roleMapper.selectPage(page, queryWrapper);
pageData.convert(x -> {
RoleListVo roleListVo = Convert.convert(RoleListVo.class, x);
// TODO...
return roleListVo;
});
return JsonResult.success(pageData);
}

/**
* 添加或编辑
* @param entity
* @return
*/
@Override
public JsonResult editRole(Role entity) {
if (StringUtils.isNotEmpty(entity.getId())) {
// 更新
Integer count = roleMapper.selectCount(new LambdaQueryWrapper<Role>()
.ne(Role::getId, entity.getId())
.eq(Role::getTenantId, CurrentUserUtil.getTenantId())
.eq(Role::getCode, entity.getCode())
.eq(Role::getMark, 1));
//当前用户
entity.setUpdateUser(CurrentUserUtil.getUserId());
if (count > 0) {
return JsonResult.error("系统中已存在相同的角色编码");
}
} else {
// 添加
Integer count = roleMapper.selectCount(new LambdaQueryWrapper<Role>()
.eq(Role::getTenantId, CurrentUserUtil.getTenantId())
.eq(Role::getCode, entity.getCode())
.eq(Role::getMark, 1));
if (count > 0) {
return JsonResult.error("系统中已存在相同的角色编码");
}
entity.setCreateUser(CurrentUserUtil.getUserId());
entity.setTenantId(CurrentUserUtil.getTenantId());
}

return super.edit(entity);

}

/**
*删除角色
* @param roleIds
* @return
*/
@Override
public JsonResult deleteByList(Integer[] roleIds) {
List<Role> roles = roleMapper.selectList(new LambdaQueryWrapper<Role>()
.eq(Role::getStatus, 1)
.eq(BaseEntity::getMark, 1)
.eq(Role::getTenantId, CurrentUserUtil.getTenantId()));
List<String> collect = roles.stream().filter(t -> !t.getCode().equals("001"))
.filter(t -> t.getCode().equals("003"))
.filter(t -> t.getCode().equals("004"))
.filter(t -> t.getCode().equals("006"))
.filter(t -> t.getCode().equals("007"))
.filter(t -> t.getCode().equals("008"))
.map(t -> t.getId()).collect(Collectors.toList());
if (collect.contains(roleIds)) {
return JsonResult.error("初始化配置角色不能删除");
}
// for (Integer roleId : roleIds) {
// List<RoleMenu> roleMenus = roleMenuMapper.selectList(Wrappers.<RoleMenu>lambdaQuery().eq(RoleMenu::getRoleId, roleId).eq(BaseEntity::getMark, 1));
// if (roleMenus.size() > 0 && StringUtils.isNotEmpty(roleMenus)) {
// return JsonResult.error("该角色已配置菜单不能删除!");
// }
// List<OpRolePermission> opRolePermissionList = opRolePermissionMapper.selectList(Wrappers.<OpRolePermission>lambdaQuery().eq(OpRolePermission::getRoleId,roleId).eq(BaseEntity::getMark, 1));
// if (opRolePermissionList.size() > 0 && StringUtils.isNotEmpty(opRolePermissionList)) {
// return JsonResult.error("该角色已配置权限不能删除!");
// }
// List<UserRoleDto> userRoles = userRoleMapper.getListByRoleId(roleId, ShiroUtils.getTenantId());
// if (userRoles.size() > 0 && StringUtils.isNotEmpty(userRoles)) {
// return JsonResult.error("该角色已经分配用户不能删除!");
// }
// Role role = roleMapper.selectById(roleId);
// role.setMark(0);
// roleMapper.updateById(role);
// }


return null;
}
}

+ 0
- 7
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/add/AddUserService.java View File

@@ -1,15 +1,11 @@
package com.tuoheng.admin.service.user.add;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tuoheng.admin.entity.Role;
import com.tuoheng.admin.entity.Tenant;
import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.enums.code.dept.AddDeptCodeEnum;
import com.tuoheng.admin.enums.code.user.AddUserCodeEnum;
import com.tuoheng.admin.mapper.TenantMapper;
import com.tuoheng.admin.mapper.UserMapper;
import com.tuoheng.admin.request.dept.AddDeptRequest;
import com.tuoheng.admin.service.third.oidc.OidcService;
import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.common.core.config.common.CommonConfig;
@@ -19,11 +15,8 @@ import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* 添加用户业务层处理
*

+ 3
- 3
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/RoleListVo.java View File

@@ -15,7 +15,7 @@ public class RoleListVo {
/**
* 角色ID
*/
private Integer id;
private String id;

/**
* 角色名称
@@ -41,7 +41,7 @@ public class RoleListVo {
/**
* 添加人
*/
private Integer createUser;
private String createUser;

/**
* 创建时间
@@ -53,7 +53,7 @@ public class RoleListVo {
/**
* 更新人
*/
private Integer updateUser;
private String updateUser;

/**
* 更新时间

Loading…
Cancel
Save