wlzboy
4 天以前 cfe0b79fbea0fb1d7a5a796e71ada7d3b7812046
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
package com.ruoyi.web.controller.system;
 
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.SysDeptRegion;
import com.ruoyi.system.mapper.SysDeptRegionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
/**
 * 部门区域管理Controller
 * 
 * @author ruoyi
 */
@RestController
@RequestMapping("/system/dept/region")
public class SysDeptRegionController extends BaseController
{
    @Autowired
    private SysDeptRegionMapper deptRegionMapper;
 
    /**
     * 查询部门的区域列表
     */
    @PreAuthorize("@ss.hasPermi('system:dept:query')")
    @GetMapping("/list/{deptId}")
    public AjaxResult list(@PathVariable("deptId") Long deptId)
    {
        List<SysDeptRegion> list = deptRegionMapper.selectDeptRegionListByDeptId(deptId);
        return success(list);
    }
 
    /**
     * 新增部门区域
     */
    @PreAuthorize("@ss.hasPermi('system:dept:edit')")
    @PostMapping
    public AjaxResult add(@Validated @RequestBody SysDeptRegion deptRegion)
    {
        deptRegion.setCreateBy(getUsername());
        return toAjax(deptRegionMapper.insertDeptRegion(deptRegion));
    }
 
    /**
     * 修改部门区域
     */
    @PreAuthorize("@ss.hasPermi('system:dept:edit')")
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody SysDeptRegion deptRegion)
    {
        deptRegion.setUpdateBy(getUsername());
        return toAjax(deptRegionMapper.updateDeptRegion(deptRegion));
    }
 
    /**
     * 删除部门区域
     */
    @PreAuthorize("@ss.hasPermi('system:dept:edit')")
    @DeleteMapping("/{regionId}")
    public AjaxResult remove(@PathVariable Long regionId)
    {
        return toAjax(deptRegionMapper.deleteDeptRegionById(regionId));
    }
}