zouyu
2 天以前 02f6d9e4d4f18060c41a7ea891c4c20adf92f335
src/main/java/com/ruoyi/project/system/controller/SysRoleController.java
@@ -2,6 +2,8 @@
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
@@ -45,10 +47,10 @@
    @Autowired
    private TokenService tokenService;
    @Autowired
    private SysPermissionService permissionService;
    @Autowired
    private ISysUserService userService;
@@ -93,15 +95,16 @@
    @PostMapping
    public AjaxResult add(@Validated @RequestBody SysRole role)
    {
        if (!roleService.checkRoleNameUnique(role))
        {
            return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
        }
        else if (!roleService.checkRoleKeyUnique(role))
        {
            return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
        }
//        if (!roleService.checkRoleNameUnique(role))
//        {
//            return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
//        }
//        else if (!roleService.checkRoleKeyUnique(role))
//        {
//            return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
//        }
        role.setCreateBy(getUsername());
        role.setTenantId(SecurityUtils.getLoginUser().getTenantId());
        return toAjax(roleService.insertRole(role));
    }
@@ -116,14 +119,14 @@
    {
        roleService.checkRoleAllowed(role);
        roleService.checkRoleDataScope(role.getRoleId());
        if (!roleService.checkRoleNameUnique(role))
        {
            return error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
        }
        else if (!roleService.checkRoleKeyUnique(role))
        {
            return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
        }
//        if (!roleService.checkRoleNameUnique(role))
//        {
//            return error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
//        }
//        else if (!roleService.checkRoleKeyUnique(role))
//        {
//            return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
//        }
        role.setUpdateBy(getUsername());
        
        if (roleService.updateRole(role) > 0)
@@ -132,8 +135,8 @@
            LoginUser loginUser = getLoginUser();
            if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin())
            {
                loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser()));
                loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName()));
                loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser()));
                tokenService.setLoginUser(loginUser);
            }
            return success();