2024-04-22 18:39:37 +08:00
|
|
|
package com.atguigu.auth.controller;
|
|
|
|
|
|
|
|
import com.atguigu.auth.service.SysRoleService;
|
|
|
|
import com.atguigu.common.result.Result;
|
|
|
|
import com.atguigu.model.system.SysRole;
|
2024-04-22 18:48:19 +08:00
|
|
|
import com.atguigu.vo.system.SysRoleQueryVo;
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
2024-04-22 18:39:37 +08:00
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
2024-04-22 18:50:22 +08:00
|
|
|
import org.springframework.web.bind.annotation.*;
|
2024-04-22 18:39:37 +08:00
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
@Api(tags = "角色管理")
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("/admin/system/sysRole")
|
|
|
|
public class SysRoleController {
|
|
|
|
@Autowired
|
|
|
|
private SysRoleService sysRoleService;
|
|
|
|
|
|
|
|
@ApiOperation(value = "查询全部角色列表")
|
|
|
|
@GetMapping("findAll")
|
|
|
|
public Result<List<SysRole>> findAll() {
|
|
|
|
List<SysRole> sysRoleList = sysRoleService.list();
|
|
|
|
return Result.success(sysRoleList);
|
|
|
|
}
|
2024-04-22 18:48:19 +08:00
|
|
|
|
|
|
|
@ApiOperation("角色条件分页查询")
|
|
|
|
@GetMapping("{page}/{limit}")
|
|
|
|
public Result<IPage<SysRole>> pageResult(@PathVariable Long page, @PathVariable Long limit, SysRoleQueryVo sysRoleQueryVo) {
|
|
|
|
IPage<SysRole> sysRoleIPage = sysRoleService.pageResult(page, limit, sysRoleQueryVo);
|
|
|
|
return Result.success(sysRoleIPage);
|
|
|
|
}
|
2024-04-22 18:50:22 +08:00
|
|
|
|
|
|
|
@ApiOperation(value = "新增角色")
|
|
|
|
@PostMapping("save")
|
|
|
|
public Result<SysRole> save(@RequestBody SysRole sysRole) {
|
|
|
|
sysRoleService.save(sysRole);
|
|
|
|
return Result.success();
|
|
|
|
}
|
|
|
|
|
|
|
|
@ApiOperation(value = "修改角色")
|
2024-04-22 18:51:07 +08:00
|
|
|
@PutMapping("update")
|
|
|
|
public Result<SysRole> update(@RequestBody SysRole sysRole) {
|
|
|
|
sysRoleService.updateById(sysRole);
|
|
|
|
return Result.success();
|
|
|
|
}
|
2024-04-22 18:52:05 +08:00
|
|
|
|
|
|
|
@ApiOperation(value = "删除角色")
|
|
|
|
@DeleteMapping("remove/{id}")
|
|
|
|
public Result<SysRole> remove(@PathVariable Long id) {
|
|
|
|
sysRoleService.removeById(id);
|
|
|
|
return Result.success();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-04-22 18:39:37 +08:00
|
|
|
}
|