| | |
| | | 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.service.TokenService; |
| | | 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.service.ISysRoleService; |
| | | import com.ruoyi.system.service.ISysUserRoleService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import io.seata.common.util.StringUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | |
| | | { |
| | | @Autowired |
| | | private ISysRoleService roleService; |
| | | |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Autowired |
| | | private ISysUserService userService; |
| | | |
| | |
| | | |
| | | // @ApiOperation("获取所有角色信息根据公司id") |
| | | @GetMapping("/list") |
| | | public AjaxResult list(Integer companyId) |
| | | @ApiOperation("获取不分页角色列表") |
| | | public AjaxResult list() |
| | | { |
| | | SysRole role = new SysRole(); |
| | | List<SysRole> list = roleService.selectRoleList(role); |
| | |
| | | } |
| | | |
| | | |
| | | @ApiOperation("获取角色列表") |
| | | @ApiOperation("获取分页角色列表") |
| | | @PostMapping("/listPage") |
| | | public AjaxResult listPage(@Validated @RequestBody RoleQuery query) |
| | | { |
| | | tokenService.getLoginUser(); |
| | | PageInfo<SysRole> pageInfo = new PageInfo<>(query.getPageCurr(), query.getPageSize()); |
| | | |
| | | PageInfo<SysRole> page = roleService.page(pageInfo, |
| | | new LambdaQueryWrapper<SysRole>().ne(SysRole::getRoleId, 20) |
| | | .like(StringUtils.isNotBlank(query.getRoleName()), SysRole::getRoleName, |
| | | .like(StringUtils.hasLength(query.getRoleName()), SysRole::getRoleName, |
| | | query.getRoleName()).eq(SysRole::getDelFlag, "0")); |
| | | return AjaxResult.success(page); |
| | | } |
| | |
| | | @PostMapping("/roleAdd") |
| | | public AjaxResult roleAdd(@Validated @RequestBody RoleAddDto dto) |
| | | { |
| | | tokenService.getLoginUser(); |
| | | SysRole role = new SysRole(); |
| | | role.setRoleName(dto.getRoleName()); |
| | | long count = roleService.count(Wrappers.lambdaQuery(SysRole.class) |
| | | .eq(SysRole::getRoleName, dto.getRoleName())); |
| | | .eq(SysRole::getRoleName, dto.getRoleName()) |
| | | .eq(SysRole::getDelFlag,"0")); |
| | | if(count>0){ |
| | | return AjaxResult.error("角色已存在,请重新输入"); |
| | | } |
| | |
| | | if(CollectionUtils.isEmpty(menuIds1)){ |
| | | return AjaxResult.error("菜单id不能为空"); |
| | | } |
| | | role.setMenuIds(dto.getMenuIds().toArray(new Long[0])); |
| | | role.setMenuIds(dto.getMenuIds().toArray((new Long[dto.getMenuIds().size()]))); |
| | | // 添加角色 |
| | | role.setCreateBy(SecurityUtils.getUsername()); |
| | | role.setCreateTime(new Date()); |
| | |
| | | public AjaxResult roleInfo( |
| | | @ApiParam(value = "角色id", name = "id", required = true) @PathVariable("id") Long id) |
| | | { |
| | | tokenService.getLoginUser(); |
| | | SysRole role = roleService.selectRoleById(id); |
| | | RoleInfoVo roleInfoVo = new RoleInfoVo(); |
| | | roleInfoVo.setRoleId(role.getRoleId()); |
| | |
| | | @PostMapping("/roleUpdate") |
| | | public AjaxResult roleUpdate(@Validated @RequestBody RoleUpdateDto dto) |
| | | { |
| | | tokenService.getLoginUser(); |
| | | SysRole role = new SysRole(); |
| | | role.setRoleName(dto.getRoleName()); |
| | | SysRole one = roleService.getOne(new LambdaQueryWrapper<SysRole>().eq(SysRole::getRoleId, dto.getRoleId())); |