SysAreaController.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. package com.ruoyi.web.controller.system;
  2. import java.util.List;
  3. import javax.servlet.http.HttpServletResponse;
  4. import com.ruoyi.common.annotation.Anonymous;
  5. import com.ruoyi.common.core.page.TableDataInfo;
  6. import io.swagger.v3.oas.annotations.Operation;
  7. import org.springframework.security.access.prepost.PreAuthorize;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.web.bind.annotation.GetMapping;
  10. import org.springframework.web.bind.annotation.PostMapping;
  11. import org.springframework.web.bind.annotation.PutMapping;
  12. import org.springframework.web.bind.annotation.DeleteMapping;
  13. import org.springframework.web.bind.annotation.PathVariable;
  14. import org.springframework.web.bind.annotation.RequestBody;
  15. import org.springframework.web.bind.annotation.RequestMapping;
  16. import org.springframework.web.bind.annotation.RestController;
  17. import com.ruoyi.common.annotation.Log;
  18. import com.ruoyi.common.core.controller.BaseController;
  19. import com.ruoyi.common.core.domain.AjaxResult;
  20. import com.ruoyi.common.enums.BusinessType;
  21. import com.ruoyi.system.domain.SysArea;
  22. import com.ruoyi.system.service.ISysAreaService;
  23. import com.ruoyi.common.utils.poi.ExcelUtil;
  24. /**
  25. * 区域-省市区县Controller
  26. *
  27. * @author ruoyi
  28. * @date 2025-09-29
  29. */
  30. @RestController
  31. @RequestMapping("/system/area")
  32. public class SysAreaController extends BaseController
  33. {
  34. @Autowired
  35. private ISysAreaService sysAreaService;
  36. /**
  37. * 查询区域-省市区县列表
  38. */
  39. @PreAuthorize("@ss.hasPermi('system:area:list')")
  40. @GetMapping("/list")
  41. public AjaxResult list(SysArea sysArea)
  42. {
  43. List<SysArea> list = sysAreaService.selectSysAreaList(sysArea);
  44. return success(list);
  45. }
  46. @GetMapping("list/tree")
  47. @Operation(summary = "树形结构")
  48. @Anonymous
  49. public TableDataInfo listTree(SysArea criteria) {
  50. List<SysArea> data = sysAreaService.listTree(criteria);
  51. return getDataTable(data);
  52. }
  53. /**
  54. * 导出区域-省市区县列表
  55. */
  56. @PreAuthorize("@ss.hasPermi('system:area:export')")
  57. @Log(title = "区域-省市区县", businessType = BusinessType.EXPORT)
  58. @PostMapping("/export")
  59. public void export(HttpServletResponse response, SysArea sysArea)
  60. {
  61. List<SysArea> list = sysAreaService.selectSysAreaList(sysArea);
  62. ExcelUtil<SysArea> util = new ExcelUtil<SysArea>(SysArea.class);
  63. util.exportExcel(response, list, "区域-省市区县数据");
  64. }
  65. /**
  66. * 获取区域-省市区县详细信息
  67. */
  68. @PreAuthorize("@ss.hasPermi('system:area:query')")
  69. @GetMapping(value = "/{areaId}")
  70. public AjaxResult getInfo(@PathVariable("areaId") Long areaId)
  71. {
  72. return success(sysAreaService.selectSysAreaByAreaId(areaId));
  73. }
  74. /**
  75. * 新增区域-省市区县
  76. */
  77. @PreAuthorize("@ss.hasPermi('system:area:add')")
  78. @Log(title = "区域-省市区县", businessType = BusinessType.INSERT)
  79. @PostMapping
  80. public AjaxResult add(@RequestBody SysArea sysArea)
  81. {
  82. return toAjax(sysAreaService.insertSysArea(sysArea));
  83. }
  84. /**
  85. * 修改区域-省市区县
  86. */
  87. @PreAuthorize("@ss.hasPermi('system:area:edit')")
  88. @Log(title = "区域-省市区县", businessType = BusinessType.UPDATE)
  89. @PutMapping
  90. public AjaxResult edit(@RequestBody SysArea sysArea)
  91. {
  92. return toAjax(sysAreaService.updateSysArea(sysArea));
  93. }
  94. /**
  95. * 删除区域-省市区县
  96. */
  97. @PreAuthorize("@ss.hasPermi('system:area:remove')")
  98. @Log(title = "区域-省市区县", businessType = BusinessType.DELETE)
  99. @DeleteMapping("/{areaIds}")
  100. public AjaxResult remove(@PathVariable Long[] areaIds)
  101. {
  102. return toAjax(sysAreaService.deleteSysAreaByAreaIds(areaIds));
  103. }
  104. }