huang
2025-05-20 e5b578d2c586ca9f664e31d3759952752255fdd3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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;
 
/**
 * <p>
 * 角色表 前端控制器
 * </p>
 *
 * @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<Role> 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);
    }
}