123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- package com.ruoyi.system.controller;
- import com.ruoyi.common.core.utils.StringUtils;
- import com.ruoyi.common.core.utils.poi.ExcelUtil;
- import com.ruoyi.common.core.web.controller.BaseController;
- import com.ruoyi.common.core.web.domain.AjaxResult;
- import com.ruoyi.common.core.web.page.TableDataInfo;
- import com.ruoyi.common.log.annotation.Log;
- import com.ruoyi.common.log.enums.BusinessType;
- import com.ruoyi.common.security.annotation.RequiresPermissions;
- import com.ruoyi.common.security.utils.SecurityUtils;
- import com.ruoyi.system.domain.SysDeptJl;
- import com.ruoyi.system.service.ISysDeptJlService;
- import com.ruoyi.system.service.ISysDeptService;
- import com.ruoyi.system.utils.OtherConstants;
- import com.ruoyi.system.utils.SubCodeUtil;
- import com.ruoyi.system.validate.group.AddGroup;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.validation.annotation.Validated;
- import org.springframework.web.bind.annotation.*;
- import javax.servlet.http.HttpServletResponse;
- import java.util.List;
- import java.util.Map;
- /**
- * 吉林地区管理Controller
- *
- * @author CH
- * @date 2022-03-25
- */
- @RestController
- @RequestMapping("/jlDept")
- public class SysDeptJlController extends BaseController
- {
- @Autowired
- private ISysDeptJlService sysDeptJlService;
- @Autowired
- private ISysDeptService sysDeptService;
- /**
- * 查询吉林地区管理列表
- */
- @RequiresPermissions("system:jlDept:list")
- @GetMapping("/list")
- public TableDataInfo list(SysDeptJl sysDeptJl)
- {
- startPage();
- List<SysDeptJl> list = sysDeptJlService.selectSysDeptJlList(sysDeptJl);
- return getDataTable(list);
- }
- /** 根据登陆人查前三级地区信息 */
- @GetMapping("/getLevel")
- public TableDataInfo getLevelList()
- {
- Map<String,String> map = SubCodeUtil.getSubCode(SecurityUtils.getAreaCode());
- List<SysDeptJl> list = sysDeptJlService.getLevelList(map.get("code"),map.get("level"));
- return getDataTable(list);
- }
- /** 根据登陆人查前三级地区信息 */
- @GetMapping("/getLevelZS")
- public TableDataInfo getLevelListZS()
- {
- Map<String,String> map = SubCodeUtil.getSubCode(SecurityUtils.getAreaCode());
- List<SysDeptJl> list = sysDeptJlService.getLevelListZS(map.get("code"),map.get("level"));
- return getDataTable(list);
- }
- @GetMapping("/getList")
- public AjaxResult getList(SysDeptJl sysDeptJl)
- {
- if(StringUtils.isEmpty(sysDeptJl.getParentId()) && StringUtils.isEmpty(sysDeptJl.getId())){
- sysDeptJl.setParentId(OtherConstants.DEPT_ID_GJ);
- }
- List<SysDeptJl> list = sysDeptJlService.selectSysDeptJlList(sysDeptJl);
- return AjaxResult.success(list);
- }
- @GetMapping("/tree")
- public AjaxResult tree(SysDeptJl sysDeptJl)
- {
- List<SysDeptJl> list = sysDeptJlService.selectSysDeptJlTree(sysDeptJl);
- return AjaxResult.success(list);
- }
- @GetMapping("/treeFiveLevel")
- public AjaxResult treeFiveLevel(SysDeptJl sysDeptJl)
- {
- List<SysDeptJl> list = sysDeptJlService.selectSysDeptJlTreeFiveLevel(sysDeptJl);
- return AjaxResult.success(list);
- }
- /**
- *
- * 同步行政区 到部门表
- */
- @RequiresPermissions("system:jlDept:syncToDept")
- @Log(title = "吉林地区同步部门", businessType = BusinessType.INSERT)
- @GetMapping("/syncToDept")
- public AjaxResult syncToDept()
- {
- return toAjax(sysDeptService.syncToDept());
- }
- /**
- * 导出吉林地区管理列表
- */
- @RequiresPermissions("system:jlDept:export")
- @Log(title = "吉林地区管理", businessType = BusinessType.EXPORT)
- @PostMapping("/export")
- public void export(HttpServletResponse response, SysDeptJl sysDeptJl)
- {
- List<SysDeptJl> list = sysDeptJlService.selectSysDeptJlList(sysDeptJl);
- ExcelUtil<SysDeptJl> util = new ExcelUtil<SysDeptJl>(SysDeptJl.class);
- util.exportExcel(response, list, "吉林地区管理数据");
- }
- /**
- * 获取吉林地区管理详细信息
- */
- @RequiresPermissions("system:jlDept:query")
- @GetMapping(value = "/{id}")
- public AjaxResult getInfo(@PathVariable("id") String id)
- {
- return AjaxResult.success(sysDeptJlService.selectSysDeptJlById(id));
- }
- /**
- * 新增吉林地区管理
- */
- @RequiresPermissions("system:jlDept:add")
- @Log(title = "吉林地区管理", businessType = BusinessType.INSERT)
- @PostMapping
- public AjaxResult add(@Validated({AddGroup.class}) @RequestBody SysDeptJl sysDeptJl)
- {
- sysDeptJlService.checkParentId(sysDeptJl.getParentId());
- return toAjax(sysDeptJlService.insertSysDeptJl(sysDeptJl));
- }
- /**
- * 修改吉林地区管理
- */
- @RequiresPermissions("system:jlDept:edit")
- @Log(title = "吉林地区管理", businessType = BusinessType.UPDATE)
- @PutMapping
- public AjaxResult edit(@Validated @RequestBody SysDeptJl sysDeptJl)
- {
- return toAjax(sysDeptJlService.updateSysDeptJl(sysDeptJl));
- }
- /**
- * 删除吉林地区管理
- */
- @RequiresPermissions("system:jlDept:remove")
- @Log(title = "吉林地区管理", businessType = BusinessType.DELETE)
- @DeleteMapping("/{ids}")
- public AjaxResult remove(@PathVariable String[] ids)
- {
- for (String id : ids) {
- sysDeptJlService.checkChildrenLevel(id);
- }
- return toAjax(sysDeptJlService.deleteSysDeptJlByIds(ids));
- }
- @GetMapping(value = "/getLocationName/{code}")
- public String getLocationName(@PathVariable("code") String code)
- {
- return sysDeptJlService.getLocationName(code);
- }
- }
|