From 675b45becc2aa467b09921a482a8945d3ba0dd6c Mon Sep 17 00:00:00 2001
From: mitao <2763622819@qq.com>
Date: 星期二, 18 六月 2024 18:44:14 +0800
Subject: [PATCH] 1.提交【管理后台】 系统设置相关接口

---
 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java |   93 ++++++++++++++++++++++++----------------------
 1 files changed, 48 insertions(+), 45 deletions(-)

diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java
index f5298eb..cee3a8e 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java
@@ -1,18 +1,19 @@
 package com.ruoyi.system.controller;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.stream.Collectors;
-import javax.annotation.Resource;
-import javax.management.relation.Role;
-import javax.servlet.http.HttpServletResponse;
-
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.ruoyi.common.core.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.web.controller.BaseController;
+import com.ruoyi.common.core.web.domain.AjaxResult;
 import com.ruoyi.common.core.web.page.PageInfo;
+import com.ruoyi.common.core.web.page.TableDataInfo;
+import com.ruoyi.common.log.annotation.Log;
+import com.ruoyi.common.log.enums.BusinessType;
+import com.ruoyi.common.security.annotation.RequiresPermissions;
+import com.ruoyi.common.security.utils.SecurityUtils;
+import com.ruoyi.system.api.domain.SysDept;
+import com.ruoyi.system.api.domain.SysRole;
+import com.ruoyi.system.api.domain.SysUser;
 import com.ruoyi.system.domain.SysMenus;
 import com.ruoyi.system.domain.SysRoleMenu;
 import com.ruoyi.system.domain.SysUserRole;
@@ -27,21 +28,25 @@
 import com.ruoyi.system.service.ISysUserService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.stream.Collectors;
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.CollectionUtils;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-import com.ruoyi.common.core.utils.poi.ExcelUtil;
-import com.ruoyi.common.core.web.controller.BaseController;
-import com.ruoyi.common.core.web.domain.AjaxResult;
-import com.ruoyi.common.core.web.page.TableDataInfo;
-import com.ruoyi.common.log.annotation.Log;
-import com.ruoyi.common.log.enums.BusinessType;
-import com.ruoyi.common.security.annotation.RequiresPermissions;
-import com.ruoyi.common.security.utils.SecurityUtils;
-import com.ruoyi.system.api.domain.SysDept;
-import com.ruoyi.system.api.domain.SysRole;
-import com.ruoyi.system.api.domain.SysUser;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 
 /**
  * 角色信息
@@ -72,30 +77,29 @@
     @Resource
     private SysMenuMapper menuMapper;
 
-    @ApiOperation("获取所有角色信息根据公司id")
+    // @ApiOperation("获取所有角色信息根据公司id")
     @GetMapping("/list")
     public AjaxResult list(Integer companyId)
     {
         SysRole role = new SysRole();
-        role.setCompanyId(companyId);
         List<SysRole> list = roleService.selectRoleList(role);
         return AjaxResult.success(list);
     }
 
 
-
-    @ApiOperation("获取所有角色信息根据公司id--分页")
+    // @ApiOperation("获取所有角色信息根据公司id--分页")
     @GetMapping("/listPage")
     public AjaxResult listPage(Integer companyId,int pageNumber,int pageSize)
     {
         PageInfo<SysRole> pageInfo = new PageInfo<>(pageNumber, pageSize);
 
-        PageInfo<SysRole> page = roleService.page(pageInfo, new LambdaQueryWrapper<SysRole>().eq(SysRole::getCompanyId, companyId).ne(SysRole::getRoleId,20));
+        PageInfo<SysRole> page = roleService.page(pageInfo,
+                new LambdaQueryWrapper<SysRole>().ne(SysRole::getRoleId, 20));
         return AjaxResult.success(page);
     }
 
 
-    @ApiOperation("角色启用停用")
+    // @ApiOperation("角色启用停用")
     @GetMapping("/roleStart")
     public AjaxResult roleStart(Long roleId)
     {
@@ -109,7 +113,7 @@
     }
 
 
-
+    @Log(title = "角色管理", businessType = BusinessType.INSERT)
     @ApiOperation("添加角色")
     @PostMapping("/roleAdd")
     public AjaxResult roleAdd(@Validated @RequestBody RoleAddDto dto)
@@ -117,8 +121,7 @@
         SysRole role = new SysRole();
         role.setRoleName(dto.getRoleName());
         long count = roleService.count(Wrappers.lambdaQuery(SysRole.class)
-                    .eq(SysRole::getRoleName,dto.getRoleName())
-                    .eq(SysRole::getCompanyId,dto.getCompanyId()));
+                .eq(SysRole::getRoleName, dto.getRoleName()));
         if(count>0){
             return AjaxResult.error("角色已存在,请重新输入");
         }
@@ -126,12 +129,8 @@
         if(CollectionUtils.isEmpty(menuIds1)){
             return AjaxResult.error("菜单id不能为空");
         }
-        role.setMenuIds(dto.getMenuIds().toArray((new Long[dto.getMenuIds().size()])));
+        role.setMenuIds(dto.getMenuIds().toArray(new Long[0]));
         // 添加角色
-        role.setCompanyId(dto.getCompanyId());
-        role.setCarDataAuth(dto.getCarDataAuth());
-        role.setCarTrainOperAuth(dto.getCarTrainOperAuth());
-        role.setContractDataAuth(dto.getContractDataAuth());
         role.setCreateBy(SecurityUtils.getUsername());
         role.setCreateTime(new Date());
         roleService.insertRole(role);
@@ -149,15 +148,13 @@
 
 
     @ApiOperation("角色详情")
-    @GetMapping("/roleInfo")
-    public AjaxResult roleInfo( @RequestParam Long id)
+    @GetMapping("/roleInfo/{id}")
+    public AjaxResult roleInfo(
+            @ApiParam(value = "角色id", name = "id", required = true) @PathVariable("id") Long id)
     {
         SysRole role = roleService.selectRoleById(id);
         RoleInfoVo roleInfoVo = new RoleInfoVo();
         roleInfoVo.setRoleId(role.getRoleId());
-        roleInfoVo.setCarDataAuth(role.getCarDataAuth());
-        roleInfoVo.setCarTrainOperAuth(role.getCarTrainOperAuth());
-        roleInfoVo.setContractDataAuth(role.getContractDataAuth());
         roleInfoVo.setRoleName(role.getRoleName());
         // 获取当前角色的菜单id
         List<Long> menusId = sysRoleMenuMapper.selectList(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getRoleId, id)).stream().map(SysRoleMenu::getMenuId).collect(Collectors.toList());
@@ -224,6 +221,7 @@
         return AjaxResult.success(s1);
     }
 
+    @Log(title = "角色管理", businessType = BusinessType.UPDATE)
     @ApiOperation("编辑角色")
     @PostMapping("/roleUpdate")
     public AjaxResult roleUpdate(@Validated @RequestBody RoleUpdateDto dto)
@@ -231,14 +229,11 @@
         SysRole role = new SysRole();
         role.setRoleName(dto.getRoleName());
         SysRole one = roleService.getOne(new LambdaQueryWrapper<SysRole>().eq(SysRole::getRoleId, dto.getRoleId()));
-        List<SysRole> sysRoles = roleService.isExitUpdate(dto.getRoleName(),dto.getRoleId(),one.getCompanyId());
+        List<SysRole> sysRoles = roleService.isExitUpdate(dto.getRoleName(), dto.getRoleId());
         if(sysRoles.size()>0){
             return AjaxResult.error("角色已存在,请重新输入");
         }
         // 编辑角色
-        role.setCarDataAuth(dto.getCarDataAuth());
-        role.setCarTrainOperAuth(dto.getCarTrainOperAuth());
-        role.setContractDataAuth(dto.getContractDataAuth());
         role.setUpdateBy(SecurityUtils.getUsername());
         role.setUpdateTime(new Date());
         role.setRoleId(dto.getRoleId());
@@ -270,6 +265,14 @@
         return AjaxResult.success();
     }
 
+    @Log(title = "角色管理", businessType = BusinessType.DELETE)
+    @ApiOperation("删除角色")
+    @DeleteMapping("/{id}")
+    public AjaxResult removeRole(
+            @ApiParam(name = "id", value = "角色ID", required = true) @PathVariable Long id) {
+        roleService.removeRole(id);
+        return AjaxResult.success();
+    }
     @Log(title = "角色管理", businessType = BusinessType.EXPORT)
     @RequiresPermissions("system:role:export")
     @PostMapping("/export")

--
Gitblit v1.7.1