@@ -0,0 +1,14 @@ | |||
package com.tuoheng.admin.controller; | |||
import com.tuoheng.common.core.common.BaseController; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2022/12/16 | |||
*/ | |||
@RestController | |||
@RequestMapping("/role-menu") | |||
public class RoleMenuController extends BaseController { | |||
} |
@@ -0,0 +1,27 @@ | |||
package com.tuoheng.admin.entity; | |||
import com.baomidou.mybatisplus.annotation.TableField; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import com.tuoheng.common.core.common.BaseEntity; | |||
import lombok.Data; | |||
/** | |||
* 角色可操作的permission | |||
* @TableName op_role_permission | |||
*/ | |||
@TableName(value ="op_role_permission") | |||
@Data | |||
public class OpRolePermission extends BaseEntity { | |||
/** | |||
* 角色id | |||
*/ | |||
private String roleId; | |||
/** | |||
* 权限id | |||
*/ | |||
private String permissionId; | |||
@TableField(exist = false) | |||
private static final long serialVersionUID = 1L; | |||
} |
@@ -0,0 +1,37 @@ | |||
package com.tuoheng.admin.entity; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import com.tuoheng.common.core.common.BaseEntity; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
/** | |||
* <p> | |||
* 角色菜单关联表 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2020-10-30 | |||
*/ | |||
@Data | |||
@EqualsAndHashCode(callSuper = true) | |||
@Accessors(chain = true) | |||
@TableName("op_role_menu") | |||
public class RoleMenu extends BaseEntity { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 角色ID | |||
*/ | |||
private String roleId; | |||
/** | |||
* 菜单ID | |||
*/ | |||
private String menuId; | |||
} |
@@ -0,0 +1,11 @@ | |||
package com.tuoheng.admin.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.tuoheng.admin.entity.RoleMenu; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2022/12/16 | |||
*/ | |||
public interface RoleMenuMapper extends BaseMapper<RoleMenu> { | |||
} |
@@ -0,0 +1,11 @@ | |||
package com.tuoheng.admin.service; | |||
import com.tuoheng.admin.entity.RoleMenu; | |||
import com.tuoheng.common.core.common.IBaseService; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2022/12/16 | |||
*/ | |||
public interface IRoleMenuService extends IBaseService<RoleMenu> { | |||
} |
@@ -0,0 +1,15 @@ | |||
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; | |||
import org.springframework.stereotype.Service; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2022/12/16 | |||
*/ | |||
@Service | |||
public class RoleMenuServiceImpl extends BaseServiceImpl<RoleMenuMapper, RoleMenu> implements IRoleMenuService { | |||
} |
@@ -5,6 +5,7 @@ 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; | |||
@@ -118,6 +119,23 @@ public class RoleServiceImpl extends BaseServiceImpl<RoleMapper, Role> implement | |||
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,0 +1,6 @@ | |||
<?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="com.tuoheng.admin.mapper.RoleMenuMapper"> | |||
</mapper> |