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 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)); } }