value
2024-05-15 862d71a72acc5f7b4f5a2e7b7b7303d73b800691
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package com.yuanchu.mom.controller;
 
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.mom.annotation.ValueAuth;
import com.yuanchu.mom.annotation.ValueClassify;
import com.yuanchu.mom.dto.RolePowerDto;
import com.yuanchu.mom.pojo.Role;
import com.yuanchu.mom.service.PowerService;
import com.yuanchu.mom.service.RoleService;
import com.yuanchu.mom.utils.JackSonUtil;
import com.yuanchu.mom.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
 
import java.util.Map;
 
@RequestMapping("/role")
@RestController
@Api(tags = "角色模块")
@AllArgsConstructor
public class RoleController {
 
    private RoleService roleService;
 
    private PowerService powerService;
 
    @ValueAuth
    @ApiOperation(value = "获取角色列表枚举")
    @GetMapping("/selectRoleList")
    public Result selectRoleList(){
        return Result.success(roleService.selectList());
    }
 
    @ValueClassify("角色管理")
    @ApiOperation(value = "获取角色列表")
    @PostMapping("/selectRoleLists")
    public Result selectRoleLists(@RequestBody Map<String, Object> data) throws Exception {
        Page page = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("page")), Page.class);
        Role role = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("entity")), Role.class);
        return Result.success(roleService.selectUserList(page, role));
    }
    @ValueClassify("角色管理")
    @ApiOperation(value = "删除角色列表")
    @PostMapping("/delRole")
    public Result delRole(Integer id){
        return Result.success(roleService.delRole(id));
    }
    @ValueAuth
    @ApiOperation(value = "通过角色id查询权限列表")
    @PostMapping("/selectPowerByRoleId")
    public Result<?> selectPowerByRoleId(Integer id) {
        return Result.success(powerService.selectPowerByRoleId(id));
    }
 
    @ApiOperation(value = "获取菜单")
    @GetMapping("/selectMenuList")
    @ValueAuth
    public Result<?> selectMenuList() {
        return Result.success(roleService.selectMenuList());
    }
    @ValueClassify("角色管理")
    @ApiOperation(value = "添加角色")
    @PostMapping("/addRole")
    public Result<?> addRole(String str) {
        RolePowerDto powers = JSON.parseObject(str, RolePowerDto.class);
        return Result.success(roleService.addRole(powers));
    }
    @ValueClassify("角色管理")
    @ApiOperation(value = "修改角色信息")
    @PostMapping("/upRole")
    public Result<?> upRole(String str) {
        RolePowerDto powers = JSON.parseObject(str, RolePowerDto.class);
        return Result.success(roleService.upRole(powers));
    }
}