1
13693261870
2022-09-16 762f2fb45db004618ba099aa3c0bd89dba1eb843
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
package com.landtool.lanbase.modules.org.controller;
 
import java.io.IOException;
import java.util.List;
import java.util.Map;
 
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiParam;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.landtool.lanbase.modules.sys.entity.SysRoleGroup;
import com.landtool.lanbase.modules.sys.service.SysRoleGroupService;
import com.landtool.lanbase.common.annotation.LogAction;
import com.landtool.lanbase.common.utils.PageUtils;
import com.landtool.lanbase.common.utils.Query;
import com.landtool.lanbase.common.utils.Result;
import com.landtool.lanbase.modules.sys.controller.AbstractController;
import javax.servlet.http.HttpServletResponse;
 
/**
 * @author 莫佳佳
 * @Description: TODO(群组与角色关联关系表)
 * @date 2018-03-28
 */
@Controller
@RequestMapping("/org/grouprole")
public class OrgGroupRoleController extends AbstractController{
 
    @Autowired
    private SysRoleGroupService roleGroupService;
    
    /**
     * 列表
     */
    @LogAction("用户管理,群组管理>角色设置,群组管理>角色查询,查询")
    @RequestMapping("/list")
//    @RequiresPermissions("sys:rolegroup:list")
    public void list(@RequestParam Map<String, Object> params,
                       HttpServletResponse response) throws IOException {
        //查询列表数据
        Query query = new Query(params);
 
        List<Map<String,Object>> roleList = roleGroupService.findRoleList(query);
        int total = roleGroupService.findRoleTotal(query);
 
        PageUtils pageUtil = new PageUtils(roleList, total, query.getLimit(), query.getPage());
 
        response.setHeader("Content-Type","application/json;charset=UTF-8");
        response.getWriter().write(JSONObject.toJSONString(Result.ok().put("page", pageUtil)));
    }
 
    @RequestMapping(value="/selectedList",method={RequestMethod.POST,RequestMethod.GET})
    public void selectedList(@RequestParam Map<String,Object> params,HttpServletResponse response)throws IOException {
        Query query = new Query(params);
 
        List<Map<String,Object>> selectedRoleList = roleGroupService.queryListForSelectedRole(query);
        int total = roleGroupService.queryTotalForSelectedRole(query);
 
        PageUtils pageUtil = new PageUtils(selectedRoleList,total,query.getLimit(),query.getPage());
 
        response.setHeader("Content-Type","application/json;charset=UTF-8");
        response.getWriter().write(JSONObject.toJSONString(Result.ok().put("page", pageUtil)));
    }
    
    /**
     * 信息
     */
    @RequestMapping("/info/{roleid}")
//    @RequiresPermissions("sys:rolegroup:info")
    @ResponseBody
    public Result info( @RequestParam(value = "roleid",required = true) Long roleId,
                       @RequestParam(value = "groupid",required = true,defaultValue = "0") Long groupId){
        SysRoleGroup roleGroup = roleGroupService.queryObject(roleId,groupId);
 
        return Result.ok().put("roleGroup", roleGroup);
    }
    
    /**
     * 保存
     */
    @LogAction("用户管理,群组管理>角色设置,群组管理>角色新增,新增")
    @RequestMapping("/save")
//    @RequiresPermissions("sys:rolegroup:save")
    @ResponseBody
    public Result save(@RequestBody JSONObject json){
        SysRoleGroup roleGroup = new SysRoleGroup();
        Long roleId = json.getLong("roleId");
        Long groupId = json.getLong("groupId");
        roleGroup.setGroupId(groupId);
        roleGroup.setRoleId(roleId);
        roleGroupService.save(roleGroup);
        return Result.ok();
    }
    
    /**
     * 修改
     */
    @LogAction("用户管理,群组管理>角色设置,群组管理>角色修改,修改")
    @RequestMapping("/update")
//    @RequiresPermissions("sys:rolegroup:update")
    @ResponseBody
    public Result update(@RequestBody SysRoleGroup rolegroup){
        roleGroupService.update(rolegroup);
        
        return Result.ok();
    }
    
    /**
     * 删除
     */
    @LogAction("用户管理,群组管理>角色设置,群组管理>角色删除,删除")
    @RequestMapping("/delete")
//    @RequiresPermissions("sys:rolegroup:delete")
    @ResponseBody
    public Result delete(@RequestBody JSONObject json){
        Long roleId = json.getLong("roleId");
        Long[] groupIds = new Long[1];
        groupIds[0] = json.getLong("groupId");
        roleGroupService.deleteBatchByRoleIdAndGroupIds(roleId,groupIds);
        return Result.ok();
    }
    
}