SysDeptJlController.java 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. package com.ruoyi.system.controller;
  2. import com.ruoyi.common.core.utils.StringUtils;
  3. import com.ruoyi.common.core.utils.poi.ExcelUtil;
  4. import com.ruoyi.common.core.web.controller.BaseController;
  5. import com.ruoyi.common.core.web.domain.AjaxResult;
  6. import com.ruoyi.common.core.web.page.TableDataInfo;
  7. import com.ruoyi.common.log.annotation.Log;
  8. import com.ruoyi.common.log.enums.BusinessType;
  9. import com.ruoyi.common.security.annotation.RequiresPermissions;
  10. import com.ruoyi.common.security.utils.SecurityUtils;
  11. import com.ruoyi.system.domain.SysDeptJl;
  12. import com.ruoyi.system.service.ISysDeptJlService;
  13. import com.ruoyi.system.service.ISysDeptService;
  14. import com.ruoyi.system.utils.OtherConstants;
  15. import com.ruoyi.system.utils.SubCodeUtil;
  16. import com.ruoyi.system.validate.group.AddGroup;
  17. import org.springframework.beans.factory.annotation.Autowired;
  18. import org.springframework.validation.annotation.Validated;
  19. import org.springframework.web.bind.annotation.*;
  20. import javax.servlet.http.HttpServletResponse;
  21. import java.util.List;
  22. import java.util.Map;
  23. /**
  24. * 吉林地区管理Controller
  25. *
  26. * @author CH
  27. * @date 2022-03-25
  28. */
  29. @RestController
  30. @RequestMapping("/jlDept")
  31. public class SysDeptJlController extends BaseController
  32. {
  33. @Autowired
  34. private ISysDeptJlService sysDeptJlService;
  35. @Autowired
  36. private ISysDeptService sysDeptService;
  37. /**
  38. * 查询吉林地区管理列表
  39. */
  40. @RequiresPermissions("system:jlDept:list")
  41. @GetMapping("/list")
  42. public TableDataInfo list(SysDeptJl sysDeptJl)
  43. {
  44. startPage();
  45. List<SysDeptJl> list = sysDeptJlService.selectSysDeptJlList(sysDeptJl);
  46. return getDataTable(list);
  47. }
  48. /** 根据登陆人查前三级地区信息 */
  49. @GetMapping("/getLevel")
  50. public TableDataInfo getLevelList()
  51. {
  52. Map<String,String> map = SubCodeUtil.getSubCode(SecurityUtils.getAreaCode());
  53. List<SysDeptJl> list = sysDeptJlService.getLevelList(map.get("code"),map.get("level"));
  54. return getDataTable(list);
  55. }
  56. /** 根据登陆人查前三级地区信息 */
  57. @GetMapping("/getLevelZS")
  58. public TableDataInfo getLevelListZS()
  59. {
  60. Map<String,String> map = SubCodeUtil.getSubCode(SecurityUtils.getAreaCode());
  61. List<SysDeptJl> list = sysDeptJlService.getLevelListZS(map.get("code"),map.get("level"));
  62. return getDataTable(list);
  63. }
  64. @GetMapping("/getList")
  65. public AjaxResult getList(SysDeptJl sysDeptJl)
  66. {
  67. if(StringUtils.isEmpty(sysDeptJl.getParentId()) && StringUtils.isEmpty(sysDeptJl.getId())){
  68. sysDeptJl.setParentId(OtherConstants.DEPT_ID_GJ);
  69. }
  70. List<SysDeptJl> list = sysDeptJlService.selectSysDeptJlList(sysDeptJl);
  71. return AjaxResult.success(list);
  72. }
  73. @GetMapping("/tree")
  74. public AjaxResult tree(SysDeptJl sysDeptJl)
  75. {
  76. List<SysDeptJl> list = sysDeptJlService.selectSysDeptJlTree(sysDeptJl);
  77. return AjaxResult.success(list);
  78. }
  79. @GetMapping("/treeFiveLevel")
  80. public AjaxResult treeFiveLevel(SysDeptJl sysDeptJl)
  81. {
  82. List<SysDeptJl> list = sysDeptJlService.selectSysDeptJlTreeFiveLevel(sysDeptJl);
  83. return AjaxResult.success(list);
  84. }
  85. /**
  86. *
  87. * 同步行政区 到部门表
  88. */
  89. @RequiresPermissions("system:jlDept:syncToDept")
  90. @Log(title = "吉林地区同步部门", businessType = BusinessType.INSERT)
  91. @GetMapping("/syncToDept")
  92. public AjaxResult syncToDept()
  93. {
  94. return toAjax(sysDeptService.syncToDept());
  95. }
  96. /**
  97. * 导出吉林地区管理列表
  98. */
  99. @RequiresPermissions("system:jlDept:export")
  100. @Log(title = "吉林地区管理", businessType = BusinessType.EXPORT)
  101. @PostMapping("/export")
  102. public void export(HttpServletResponse response, SysDeptJl sysDeptJl)
  103. {
  104. List<SysDeptJl> list = sysDeptJlService.selectSysDeptJlList(sysDeptJl);
  105. ExcelUtil<SysDeptJl> util = new ExcelUtil<SysDeptJl>(SysDeptJl.class);
  106. util.exportExcel(response, list, "吉林地区管理数据");
  107. }
  108. /**
  109. * 获取吉林地区管理详细信息
  110. */
  111. @RequiresPermissions("system:jlDept:query")
  112. @GetMapping(value = "/{id}")
  113. public AjaxResult getInfo(@PathVariable("id") String id)
  114. {
  115. return AjaxResult.success(sysDeptJlService.selectSysDeptJlById(id));
  116. }
  117. /**
  118. * 新增吉林地区管理
  119. */
  120. @RequiresPermissions("system:jlDept:add")
  121. @Log(title = "吉林地区管理", businessType = BusinessType.INSERT)
  122. @PostMapping
  123. public AjaxResult add(@Validated({AddGroup.class}) @RequestBody SysDeptJl sysDeptJl)
  124. {
  125. sysDeptJlService.checkParentId(sysDeptJl.getParentId());
  126. return toAjax(sysDeptJlService.insertSysDeptJl(sysDeptJl));
  127. }
  128. /**
  129. * 修改吉林地区管理
  130. */
  131. @RequiresPermissions("system:jlDept:edit")
  132. @Log(title = "吉林地区管理", businessType = BusinessType.UPDATE)
  133. @PutMapping
  134. public AjaxResult edit(@Validated @RequestBody SysDeptJl sysDeptJl)
  135. {
  136. return toAjax(sysDeptJlService.updateSysDeptJl(sysDeptJl));
  137. }
  138. /**
  139. * 删除吉林地区管理
  140. */
  141. @RequiresPermissions("system:jlDept:remove")
  142. @Log(title = "吉林地区管理", businessType = BusinessType.DELETE)
  143. @DeleteMapping("/{ids}")
  144. public AjaxResult remove(@PathVariable String[] ids)
  145. {
  146. for (String id : ids) {
  147. sysDeptJlService.checkChildrenLevel(id);
  148. }
  149. return toAjax(sysDeptJlService.deleteSysDeptJlByIds(ids));
  150. }
  151. @GetMapping(value = "/getLocationName/{code}")
  152. public String getLocationName(@PathVariable("code") String code)
  153. {
  154. return sysDeptJlService.getLocationName(code);
  155. }
  156. }