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
126
127
128
129
130
131
package com.landtool.lanbase.modules.org.controller;
 
import java.util.Date;
import java.util.List;
import java.util.Map;
 
import com.landtool.lanbase.modules.org.entity.OrgUser;
import com.landtool.lanbase.modules.org.service.OrgUserGroupService;
import com.landtool.lanbase.modules.sys.controller.AbstractController;
 
import com.landtool.lanbase.modules.sys.service.SysRoleGroupService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
 
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.landtool.lanbase.modules.org.entity.OrgGroup;
import com.landtool.lanbase.modules.org.service.OrgGroupService;
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;
 
/**
 * @author zimao.guo
 * @Description: TODO(群组表)
 * @date 2018-03-14 15:22:21
 */
@RestController
@RequestMapping("/org/group")
public class OrgGroupController extends AbstractController {
 
    @Autowired
    private OrgGroupService groupService;
 
    @Autowired
    private OrgUserGroupService userGroupService;
 
    @Autowired
    private SysRoleGroupService roleGroupService;
    /**
     * 列表
     */
    @LogAction("用户管理,群组管理,群组查询,查询")
    @RequestMapping("/list")
//    @RequiresPermissions("org:group:list")
    @RequiresPermissions(value = {"org:group:list","org:group:edit"}, logical = Logical.OR)
    public Result list(@RequestParam Map<String, Object> params){
        //查询列表数据
        Query query = new Query(params);
 
        List<OrgGroup> groupList = groupService.queryList(query);
        int total = groupService.queryTotal(query);
        
        PageUtils pageUtil = new PageUtils(groupList, total, query.getLimit(), query.getPage());
        
        return Result.ok().put("page", pageUtil);
    }
    
    
    /**
     * 信息
     */
    @GetMapping("/info/{groupid}")
//    @RequiresPermissions("org:group:list")
    @RequiresPermissions(value = {"org:group:list","org:group:edit"}, logical = Logical.OR)
    @ApiOperation(
        value = "群组信息",
        notes = ""
        )
    public Result info(@ApiParam(name="groupid",value="Id",required=true)@PathVariable("groupid") Long groupid){
        OrgGroup group = groupService.queryObject(groupid);
        
        return Result.ok().put("group", group);
    }
    
    /**
     * 保存
     */
    @LogAction("用户管理,群组管理,群组新增,新增")
    @RequestMapping("/save")
    @RequiresPermissions("org:group:edit")
    public Result save(@RequestBody OrgGroup group){
        if(group.getGroupName() == null || group.getGroupName().length() == 0) {
            return Result.error("保存失败,存在特殊字符,请重新输入!");
        }
        OrgUser user = (OrgUser) SecurityUtils.getSubject().getPrincipal();
        group.setrCreateUser(user.getUserid());
        group.setrCreateDate(new Date());
        groupService.save(group);
        int groupid = groupService.queryGroupWithSEQ();
        return Result.ok().put("groupid",groupid);
    }
    
    /**
     * 修改
     */
    @LogAction("用户管理,群组管理,群组修改,修改")
    @RequestMapping("/update")
    @RequiresPermissions("org:group:edit")
    public Result update(@RequestBody OrgGroup group){
        if(group.getGroupName() == null || group.getGroupName().length() == 0) {
            return Result.error("保存失败,存在特殊字符,请重新输入!");
        }
        groupService.checkChangeForSystem(group);
        groupService.update(group);
        return Result.ok();
    }
    
    /**
     * 删除
     */
    @LogAction("用户管理,群组管理,群组删除,删除")
    @RequestMapping("/delete")
    @RequiresPermissions("org:group:edit")
    public Result delete(@RequestBody Long[] groupids){
        groupService.deleteBatch(groupids);
        userGroupService.deleteBatchByGroupId(groupids);
        roleGroupService.deleteBatchByGroupId(groupids);
        return Result.ok();
    }
    
}