| | |
| | | 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; |
| | |
| | | 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; |
| | | |
| | | /** |
| | | * 角色信息 |
| | |
| | | @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) |
| | | { |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | @Log(title = "角色管理", businessType = BusinessType.INSERT) |
| | | @ApiOperation("添加角色") |
| | | @PostMapping("/roleAdd") |
| | | public AjaxResult roleAdd(@Validated @RequestBody RoleAddDto dto) |
| | |
| | | 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("角色已存在,请重新输入"); |
| | | } |
| | |
| | | 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); |
| | |
| | | |
| | | |
| | | @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()); |
| | |
| | | return AjaxResult.success(s1); |
| | | } |
| | | |
| | | @Log(title = "角色管理", businessType = BusinessType.UPDATE) |
| | | @ApiOperation("编辑角色") |
| | | @PostMapping("/roleUpdate") |
| | | public AjaxResult roleUpdate(@Validated @RequestBody RoleUpdateDto dto) |
| | |
| | | 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()); |
| | |
| | | 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") |