guigu-oa/service-oa/src/main/java/com/atguigu/auth/controller/SysRoleController.java

59 lines
1.9 KiB
Java

package com.atguigu.auth.controller;
import com.atguigu.auth.service.SysRoleService;
import com.atguigu.common.result.Result;
import com.atguigu.model.system.SysRole;
import com.atguigu.vo.system.SysRoleQueryVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
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);
}
@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);
}
@ApiOperation(value = "新增角色")
@PostMapping("save")
public Result<SysRole> save(@RequestBody SysRole sysRole) {
sysRoleService.save(sysRole);
return Result.success();
}
@ApiOperation(value = "修改角色")
@PutMapping("update")
public Result<SysRole> update(@RequestBody SysRole sysRole) {
sysRoleService.updateById(sysRole);
return Result.success();
}
@ApiOperation(value = "删除角色")
@DeleteMapping("remove/{id}")
public Result<SysRole> remove(@PathVariable Long id) {
sysRoleService.removeById(id);
return Result.success();
}
}