mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package com.dg.core.controller;
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dg.core.ResultData;
import com.dg.core.annotation.Authorization;
import com.dg.core.annotation.CurrentUser;
import com.dg.core.db.gen.entity.RoleManagementEntity;
import com.dg.core.db.gen.entity.SysUser;
import com.dg.core.service.IRoleManagementService;
import com.dg.core.util.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
@Api(tags = {"角色管理接口"})
@RestController
@RequestMapping("/role")
public class RoleManagementController extends BaseController
{
 
    @Autowired
    IRoleManagementService iRoleManagementService;
 
    /**
     * 查询角色列表
     * @param pageNum
     * @param pageSize
     * @return
     */
    @ApiOperation("查询角色列表")
    @GetMapping("/getList")
    @Authorization
    public TableDataInfo selectConfigList(@RequestParam(value = "pageNum",required = false) Integer pageNum,
                                          @RequestParam(value = "pageSize",required = false) Integer pageSize,
                                          @RequestParam(value = "name",required = false) String name)
    {
        if(pageNum==null)
        {
            return getDataTable("分页不能为空");
        }
        if(pageSize==null)
        {
            return getDataTable("分页条数不能为空");
        }
 
        Page<RoleManagementEntity> pageParam = new Page<>(pageNum,pageSize);
        List<RoleManagementEntity> list = iRoleManagementService.selectConfigList(pageParam,pageSize,name);
 
        int num=iRoleManagementService.countNum(name);
        return getDataTable(list,num);
    }
 
    /**
     * 新增角色
     * @param entity
     * @return
     */
    @ApiOperation("新增角色")
    @PostMapping("/add")
    @Authorization
    public ResultData insertConfig(@RequestBody RoleManagementEntity entity, @CurrentUser SysUser sysUser)
    {
        entity.setCreateUserId(sysUser.getUserId()+"");
        return toAjax(iRoleManagementService.insertConfig(entity));
    }
 
    /**
     * 编辑角色
     * @param entity
     * @return
     */
    @ApiOperation("编辑角色")
    @PostMapping("/update")
    @Authorization
    public ResultData updateConfig(@RequestBody RoleManagementEntity entity,@CurrentUser SysUser sysUser)
    {
        entity.setUpdateUserId(sysUser.getUserId()+"");
        return toAjax(iRoleManagementService.updateConfig(entity));
    }
 
    /**
     * 删除角色
     * @param Id
     * @return
     */
    @DeleteMapping("/delete")
    @Authorization
    public ResultData deleteConfigById(@RequestParam(value = "Id",required = false) String Id)
    {
        if(StringUtils.isEmpty(Id))
        {
            return ResultData.error("Id 不能为空");
        }
        return toAjax(iRoleManagementService.deleteConfigById(Id));
    }
 
}