123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- package com.qmth.distributed.print.api;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.qmth.boot.api.constant.ApiConstant;
- import com.qmth.teachcloud.common.entity.SysRole;
- import com.qmth.teachcloud.common.service.SysRoleService;
- import com.qmth.teachcloud.common.util.Result;
- import com.qmth.teachcloud.common.util.ResultUtil;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.validation.BindingResult;
- import org.springframework.web.bind.annotation.*;
- import javax.validation.Valid;
- import java.security.NoSuchAlgorithmException;
- import java.util.List;
- /**
- * <p>
- * 角色表 前端控制器
- * </p>
- *
- * @author xf
- * @since 2021-03-23
- */
- @Api(tags = "角色Controller")
- @RestController
- @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/${prefix.url.sys}/role")
- public class SysRoleController {
- @Autowired
- private SysRoleService sysRoleService;
- /**
- * 查询
- *
- * @param name
- * @param enable
- * @param pageNumber
- * @param pageSize
- * @return
- */
- @ApiOperation(value = "查询")
- @RequestMapping(value = "/list", method = RequestMethod.POST)
- public Result list(@RequestParam(value = "name", required = false) String name,
- @RequestParam(value = "enable", required = false) Boolean enable,
- @RequestParam(value = "pageNumber", required = true) Integer pageNumber,
- @RequestParam(value = "pageSize", required = true) Integer pageSize) {
- return ResultUtil.ok(sysRoleService.list(name, enable, pageNumber, pageSize));
- }
- /**
- * 新增用户时查询角色方法
- *
- * @return
- */
- @ApiOperation(value = "新增用户时查询角色方法")
- @RequestMapping(value = "/list_to_user", method = RequestMethod.POST)
- public Result listToUser() {
- return ResultUtil.ok(sysRoleService.listToUser());
- }
- /**
- * 新增/修改
- *
- * @param role
- * @return
- */
- @ApiOperation(value = "新增/修改")
- @RequestMapping(value = "/save", method = RequestMethod.POST)
- public Result save(@Valid @RequestBody SysRole role, BindingResult bindingResult) {
- if (bindingResult.hasErrors()) {
- return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
- }
- return ResultUtil.ok(sysRoleService.saveRoleNew(role));
- }
- /**
- * 启用/禁用
- *
- * @param role
- * @return
- */
- @ApiOperation(value = "启用/禁用")
- @RequestMapping(value = "/enable", method = RequestMethod.POST)
- public Result enable(@RequestBody SysRole role) throws NoSuchAlgorithmException {
- return ResultUtil.ok(sysRoleService.enable(role));
- }
- /**
- * 删除
- *
- * @param id
- * @return
- */
- @ApiOperation(value = "删除")
- @RequestMapping(value = "/remove", method = RequestMethod.POST)
- public Result remove(Long id) {
- return ResultUtil.ok(sysRoleService.remove(id));
- }
- /**
- * 用户已绑定角色列表
- *
- * @param userId
- * @return
- */
- @ApiOperation(value = "用户已绑定角色列表")
- @RequestMapping(value = "/get_user_roles", method = RequestMethod.POST)
- public Result getUserRoles(@RequestParam(value = "userId", required = true) Long userId) {
- return ResultUtil.ok(sysRoleService.getUserRoles(userId));
- }
- }
|