SysAreaController.java 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. package com.xunmei.system.controller;
  2. import com.xunmei.common.core.exception.ServiceException;
  3. import com.xunmei.system.api.domain.SysArea;
  4. import com.xunmei.system.api.domain.SysOrg;
  5. import com.xunmei.system.mapper.SysOrgMapper;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.web.bind.annotation.GetMapping;
  8. import org.springframework.web.bind.annotation.PostMapping;
  9. import org.springframework.web.bind.annotation.PutMapping;
  10. import org.springframework.web.bind.annotation.DeleteMapping;
  11. import org.springframework.web.bind.annotation.PathVariable;
  12. import org.springframework.web.bind.annotation.RequestBody;
  13. import org.springframework.web.bind.annotation.RequestMapping;
  14. import org.springframework.web.bind.annotation.RestController;
  15. import com.xunmei.common.log.annotation.Log;
  16. import com.xunmei.common.log.enums.BusinessType;
  17. import com.xunmei.common.security.annotation.RequiresPermissions;
  18. import com.xunmei.system.service.ISysAreaService;
  19. import com.xunmei.common.core.web.controller.BaseController;
  20. import com.xunmei.common.core.web.domain.AjaxResult;
  21. import io.swagger.annotations.Api;
  22. import io.swagger.annotations.ApiOperation;
  23. import com.xunmei.common.core.web.page.TableDataInfo;
  24. /**
  25. * 【请填写功能名称】Controller
  26. *
  27. * @author xunmei
  28. * @date 2023-08-14
  29. */
  30. @Api(tags = {"SysArea"})
  31. @RestController
  32. @RequestMapping("/area")
  33. public class SysAreaController extends BaseController {
  34. @Autowired
  35. private ISysAreaService sysAreaService;
  36. @Autowired
  37. private SysOrgMapper sysOrgMapper;
  38. /**
  39. * 查询【请填写功能名称】列表
  40. */
  41. @ApiOperation(value = "查询SysArea列表")
  42. @RequiresPermissions("system:area:list")
  43. @GetMapping("/list")
  44. public TableDataInfo<SysArea> list(SysArea sysArea) {
  45. return sysAreaService.selectPage(sysArea);
  46. }
  47. /**
  48. * 获取【请填写功能名称】详细信息
  49. */
  50. @ApiOperation(value = "获取SysArea详细信息")
  51. @RequiresPermissions("system:area:query")
  52. @GetMapping(value = "/{id}")
  53. public AjaxResult getInfo(@PathVariable("id") Long id) {
  54. return success(sysAreaService.selectSysAreaById(id));
  55. }
  56. /**
  57. * 获取【请填写功能名称】详细信息
  58. */
  59. @ApiOperation(value = "根据机构获取区域")
  60. @GetMapping("/getAreaByOrg/{orgId}")
  61. public AjaxResult getAreaByOrg(@PathVariable("orgId") Long orgId) {
  62. /* SysOrg sysOrg = sysOrgMapper.selectSysOrgById(orgId);
  63. if (null==sysOrg.getType()){
  64. return error("该机构没有机构类型,请维护!");
  65. }*/
  66. return success(sysAreaService.getAreaByOrg(orgId));
  67. }
  68. /**
  69. * 新增【请填写功能名称】
  70. */
  71. @ApiOperation(value = "新增SysArea")
  72. @RequiresPermissions("system:area:add")
  73. @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
  74. @PostMapping
  75. public AjaxResult add(@RequestBody SysArea sysArea) {
  76. return toAjax(sysAreaService.insertSysArea(sysArea));
  77. }
  78. /**
  79. * 修改【请填写功能名称】
  80. */
  81. @ApiOperation(value = "修改SysArea")
  82. @RequiresPermissions("system:area:edit")
  83. @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
  84. @PutMapping
  85. public AjaxResult edit(@RequestBody SysArea sysArea) {
  86. return toAjax(sysAreaService.updateSysArea(sysArea));
  87. }
  88. /**
  89. * 删除【请填写功能名称】
  90. */
  91. @ApiOperation(value = "删除SysArea")
  92. @RequiresPermissions("system:area:remove")
  93. @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
  94. @DeleteMapping("/{ids}")
  95. public AjaxResult remove(@PathVariable Long[] ids) {
  96. return toAjax(sysAreaService.deleteSysAreaByIds(ids));
  97. }
  98. /**
  99. *按机构类型获取所有区域
  100. */
  101. @ApiOperation(value = "按机构类型获取所有区域")
  102. // @RequiresPermissions("system:area:list
  103. @GetMapping("/orgType/{orgType}")
  104. public AjaxResult listByOrgType(@PathVariable Integer orgType) {
  105. SysArea condition = new SysArea();
  106. condition.setOrgType(orgType.toString());
  107. condition.setPageNum(1L);
  108. condition.setPageSize(9999L);
  109. TableDataInfo table= sysAreaService.selectPage(condition);
  110. return success(table.getRows());
  111. }
  112. }