Xiajijian
2026-06-11 8eedb5cd0a3f49d553d6121b5da701d56b479fb8
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
package com.ard.web.controller.data;
 
import com.ard.common.annotation.Log;
import com.ard.common.core.controller.BaseController;
import com.ard.common.core.domain.AjaxResult;
import com.ard.common.core.page.TableDataInfo;
import com.ard.common.enums.BusinessType;
import com.ard.common.utils.poi.ExcelUtil;
import com.ard.data.region.domain.ArdDeptRegion;
import com.ard.data.region.domain.ConflictCheckResult;
import com.ard.data.region.domain.PointQueryDTO;
import com.ard.data.region.service.IArdDeptRegionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
 
import javax.validation.Valid;
import java.util.List;
 
/**
 * 部门区域Controller
 *
 * @author ruoyi
 */
@Api(tags = "部门区域接口")
@RestController
@RequestMapping("/data/region")
public class ArdDeptRegionController extends BaseController {
    @Autowired
    private IArdDeptRegionService ardDeptRegionService;
 
    /**
     * 查询部门区域列表
     */
    @ApiOperation("查询部门区域列表")
    @PreAuthorize("@ss.hasPermi('data:region:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArdDeptRegion ardDeptRegion) {
        startPage();
        List<ArdDeptRegion> list = ardDeptRegionService.selectArdDeptRegionList(ardDeptRegion);
        return getDataTable(list);
    }
 
    /**
     * 导出部门区域列表
     */
    @ApiOperation("导出部门区域列表")
    @PreAuthorize("@ss.hasPermi('data:region:export')")
    @Log(title = "部门区域", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ArdDeptRegion ardDeptRegion) {
        List<ArdDeptRegion> list = ardDeptRegionService.selectArdDeptRegionList(ardDeptRegion);
        ExcelUtil<ArdDeptRegion> util = new ExcelUtil<ArdDeptRegion>(ArdDeptRegion.class);
        return util.exportExcel(list, "部门区域数据");
    }
 
    /**
     * 获取部门区域详细信息
     */
    @ApiOperation("获取部门区域详细信息")
    @PreAuthorize("@ss.hasPermi('data:region:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(ardDeptRegionService.selectArdDeptRegionById(id));
    }
 
    /**
     * 检查区域冲突(画区域时调用)
     */
    @ApiOperation("检查区域冲突")
    @PostMapping("/check")
    public AjaxResult checkConflict(@Valid @RequestBody ArdDeptRegion ardDeptRegion) {
        ConflictCheckResult result = ardDeptRegionService.checkConflict(ardDeptRegion);
        if (result.getHasConflict()) {
            return AjaxResult.error(result.getMessage(), result);
        }
        return AjaxResult.success(result.getMessage(), result);
    }
 
    /**
     * 新增部门区域
     */
    @ApiOperation("新增部门区域")
    @PreAuthorize("@ss.hasPermi('data:region:add')")
    @Log(title = "部门区域", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@Valid @RequestBody ArdDeptRegion ardDeptRegion) {
        if (!ardDeptRegionService.checkRegionNameUnique(ardDeptRegion)) {
            return error("新增区域'" + ardDeptRegion.getRegionName() + "'失败,区域名称已存在");
        }
        return toAjax(ardDeptRegionService.insertArdDeptRegion(ardDeptRegion));
    }
 
    /**
     * 修改部门区域
     */
    @ApiOperation("修改部门区域")
    @PreAuthorize("@ss.hasPermi('data:region:edit')")
    @Log(title = "部门区域", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody ArdDeptRegion ardDeptRegion) {
        if (!ardDeptRegionService.checkRegionNameUnique(ardDeptRegion)) {
            return error("修改区域'" + ardDeptRegion.getRegionName() + "'失败,区域名称已存在");
        }
        return toAjax(ardDeptRegionService.updateArdDeptRegion(ardDeptRegion));
    }
 
    /**
     * 修改状态(启用/禁用)
     */
    @ApiOperation("修改状态")
    @PreAuthorize("@ss.hasPermi('data:region:edit')")
    @Log(title = "部门区域", businessType = BusinessType.UPDATE)
    @PutMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody ArdDeptRegion ardDeptRegion)
    {
        return toAjax(ardDeptRegionService.updateStatus(ardDeptRegion.getId(), ardDeptRegion.getStatus()));
    }
 
    /**
     * 删除部门区域
     */
    @ApiOperation("删除部门区域")
    @PreAuthorize("@ss.hasPermi('data:region:remove')")
    @Log(title = "部门区域", businessType = BusinessType.DELETE)
    @DeleteMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(ardDeptRegionService.deleteArdDeptRegionByIds(ids));
    }
 
    /**
     * 根据坐标查询所属区域
     */
    @ApiOperation("根据坐标查询所属区域")
    @PostMapping("/getByPoint")
    public AjaxResult getRegionByPoint(@RequestBody PointQueryDTO query) {
        ArdDeptRegion region = ardDeptRegionService.selectRegionByPoint(query.getLat(), query.getLng());
        if (region == null) {
            return error("该坐标不在任何区域内");
        }
        return success(region);
    }
}