wang-hao-jie
2022-08-25 57dcc73636bb7d8dce89c808eb8cc988a7512264
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
package com.ruoyi.web.controller.station;
 
import java.util.List;
 
import com.ruoyi.common.core.domain.Ztree;
import com.ruoyi.system.domain.SysDept;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.station.domain.MjDept;
import com.ruoyi.station.service.IMjDeptService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
 
/**
 * 部门Controller
 * 
 * @author ruoyi
 * @date 2020-08-07
 */
@Controller
@RequestMapping("/station/dept")
public class MjDeptController extends BaseController
{
    private String prefix = "station/dept";
 
    @Autowired
    private IMjDeptService mjDeptService;
 
    @RequiresPermissions("station:dept:view")
    @GetMapping()
    public String dept()
    {
        return prefix + "/dept";
    }
 
    /**
     * 查询部门列表
     */
    @RequiresPermissions("station:dept:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(MjDept mjDept)
    {
        List<MjDept> list = mjDeptService.selectMjDeptList(mjDept);
        return getDataTable(list);
    }
 
    /**
     * 导出部门列表
     */
    @RequiresPermissions("station:dept:export")
    @Log(title = "部门", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(MjDept mjDept)
    {
        List<MjDept> list = mjDeptService.selectMjDeptList(mjDept);
        ExcelUtil<MjDept> util = new ExcelUtil<MjDept>(MjDept.class);
        return util.exportExcel(list, "dept");
    }
 
    /**
     * 新增部门
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }
 
    /**
     * 新增保存部门
     */
    @RequiresPermissions("station:dept:add")
    @Log(title = "部门", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(MjDept mjDept)
    {
            return toAjax(mjDeptService.insertMjDept(mjDept));
    }
 
    /**
     * 修改部门
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        MjDept mjDept = mjDeptService.selectMjDeptById(id);
        mmap.put("mjDept", mjDept);
        return prefix + "/edit";
    }
 
    /**
     * 修改保存部门
     */
    @RequiresPermissions("station:dept:edit")
    @Log(title = "部门", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(MjDept mjDept)
    {
        return toAjax(mjDeptService.updateMjDept(mjDept));
    }
 
    /**
     * 删除部门
     */
    @RequiresPermissions("station:dept:remove")
    @Log(title = "部门", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(mjDeptService.deleteMjDeptByIds(ids));
    }
 
    /**
     * 校验部门名称
     */
    @PostMapping("/checkDeptNameUnique")
    @ResponseBody
    public String checkDeptNameUnique(MjDept dept)
    {
        return mjDeptService.checkDeptNameUnique(dept);
    }
 
    /**
     * 选择部门树
     *
     * @param deptId 部门ID
     * @param excludeId 排除ID
     */
    @GetMapping(value = { "/selectDeptTree/{deptId}", "/selectDeptTree/{deptId}/{excludeId}" })
    public String selectDeptTree(@PathVariable("deptId") String deptId,
                                 @PathVariable(value = "excludeId", required = false) String excludeId, ModelMap mmap)
    {
        mmap.put("dept", mjDeptService.selectMjDeptById(deptId));
        mmap.put("excludeId", excludeId);
        return prefix + "/tree";
    }
 
    /**
     * 加载部门列表树
     */
    @GetMapping("/treeData")
    @ResponseBody
    public List<Ztree> treeData()
    {
        List<Ztree> ztrees = mjDeptService.selectDeptTree(new MjDept());
        return ztrees;
    }
 
    /**
     * 加载部门列表树
     */
    @PostMapping("/treeData2")
    @ResponseBody
    public List<Ztree> treeData2()
    {
        List<Ztree> ztrees = mjDeptService.selectDeptTree(new MjDept());
        return ztrees;
    }
 
    /**
     * 新增部门
     */
    @GetMapping("/add2")
    public String add2()
    {
        return prefix + "/add2";
    }
 
    /**
     * 删除部门
     */
    @GetMapping( "/remove2")
    @ResponseBody
    public AjaxResult remove2(String ids)
    {
        return toAjax(mjDeptService.deleteMjDeptByIds(ids));
    }
}