package com.mes.md.controller;
import com.mes.md.entity.Role;
import com.mes.md.service.RoleService;
import com.mes.utils.Result;
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;
/**
*
* 角色表 前端控制器
*
*
* @author wu
* @since 2024-08-28
*/
@Api(tags = "角色【增加角色,修改,删除,查询】")
@RestController
@RequestMapping("/role")
public class RoleController {
@Autowired
RoleService roleService;
@ApiOperation("返回所有角色")
@PostMapping("/findRolesAll")
@ResponseBody
public Result findRolesAll () {
List roles=roleService.findRolesAll();
return Result.build(200,"成功",roles);
}
@ApiOperation("添加角色")
@PostMapping("/addRole")
@ResponseBody
public Result addRole (@RequestBody Role role) {
int count=roleService.addRole(role);
String message=count>0?"角色添加成功:"+count:"角色添加失败!";
return Result.build(200,message,count);
}
@ApiOperation("修改角色")
@PostMapping("/updateRole")
@ResponseBody
public Result updateRole (@RequestBody Role role) {
int count=roleService.updateRole(role);
String message=count>0?"角色修改成功:"+count:"角色修改失败!";
return Result.build(200,message,count);
}
@ApiOperation("删除角色")
@PostMapping("/deleteRole")
@ResponseBody
public Result deleteRole (@RequestBody Role role) {
int count=roleService.deleteRole(role);
String message=count>0?"角色删除成功:"+count:"角色删除失败!";
return Result.build(200,message,count);
}
}