package com.ruoyi.web.controller.station;
|
|
import java.util.List;
|
|
import com.ruoyi.common.core.domain.Ztree;
|
import com.ruoyi.system.domain.SysDept;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.ui.ModelMap;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.station.domain.MjDept;
|
import com.ruoyi.station.service.IMjDeptService;
|
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
/**
|
* 部门Controller
|
*
|
* @author ruoyi
|
* @date 2020-08-07
|
*/
|
@Controller
|
@RequestMapping("/station/dept")
|
public class MjDeptController extends BaseController
|
{
|
private String prefix = "station/dept";
|
|
@Autowired
|
private IMjDeptService mjDeptService;
|
|
@RequiresPermissions("station:dept:view")
|
@GetMapping()
|
public String dept()
|
{
|
return prefix + "/dept";
|
}
|
|
/**
|
* 查询部门列表
|
*/
|
@RequiresPermissions("station:dept:list")
|
@PostMapping("/list")
|
@ResponseBody
|
public TableDataInfo list(MjDept mjDept)
|
{
|
List<MjDept> list = mjDeptService.selectMjDeptList(mjDept);
|
return getDataTable(list);
|
}
|
|
/**
|
* 导出部门列表
|
*/
|
@RequiresPermissions("station:dept:export")
|
@Log(title = "部门", businessType = BusinessType.EXPORT)
|
@PostMapping("/export")
|
@ResponseBody
|
public AjaxResult export(MjDept mjDept)
|
{
|
List<MjDept> list = mjDeptService.selectMjDeptList(mjDept);
|
ExcelUtil<MjDept> util = new ExcelUtil<MjDept>(MjDept.class);
|
return util.exportExcel(list, "dept");
|
}
|
|
/**
|
* 新增部门
|
*/
|
@GetMapping("/add")
|
public String add()
|
{
|
return prefix + "/add";
|
}
|
|
/**
|
* 新增保存部门
|
*/
|
@RequiresPermissions("station:dept:add")
|
@Log(title = "部门", businessType = BusinessType.INSERT)
|
@PostMapping("/add")
|
@ResponseBody
|
public AjaxResult addSave(MjDept mjDept)
|
{
|
return toAjax(mjDeptService.insertMjDept(mjDept));
|
}
|
|
/**
|
* 修改部门
|
*/
|
@GetMapping("/edit/{id}")
|
public String edit(@PathVariable("id") String id, ModelMap mmap)
|
{
|
MjDept mjDept = mjDeptService.selectMjDeptById(id);
|
mmap.put("mjDept", mjDept);
|
return prefix + "/edit";
|
}
|
|
/**
|
* 修改保存部门
|
*/
|
@RequiresPermissions("station:dept:edit")
|
@Log(title = "部门", businessType = BusinessType.UPDATE)
|
@PostMapping("/edit")
|
@ResponseBody
|
public AjaxResult editSave(MjDept mjDept)
|
{
|
return toAjax(mjDeptService.updateMjDept(mjDept));
|
}
|
|
/**
|
* 删除部门
|
*/
|
@RequiresPermissions("station:dept:remove")
|
@Log(title = "部门", businessType = BusinessType.DELETE)
|
@PostMapping( "/remove")
|
@ResponseBody
|
public AjaxResult remove(String ids)
|
{
|
return toAjax(mjDeptService.deleteMjDeptByIds(ids));
|
}
|
|
/**
|
* 校验部门名称
|
*/
|
@PostMapping("/checkDeptNameUnique")
|
@ResponseBody
|
public String checkDeptNameUnique(MjDept dept)
|
{
|
return mjDeptService.checkDeptNameUnique(dept);
|
}
|
|
/**
|
* 选择部门树
|
*
|
* @param deptId 部门ID
|
* @param excludeId 排除ID
|
*/
|
@GetMapping(value = { "/selectDeptTree/{deptId}", "/selectDeptTree/{deptId}/{excludeId}" })
|
public String selectDeptTree(@PathVariable("deptId") String deptId,
|
@PathVariable(value = "excludeId", required = false) String excludeId, ModelMap mmap)
|
{
|
mmap.put("dept", mjDeptService.selectMjDeptById(deptId));
|
mmap.put("excludeId", excludeId);
|
return prefix + "/tree";
|
}
|
|
/**
|
* 加载部门列表树
|
*/
|
@GetMapping("/treeData")
|
@ResponseBody
|
public List<Ztree> treeData()
|
{
|
List<Ztree> ztrees = mjDeptService.selectDeptTree(new MjDept());
|
return ztrees;
|
}
|
|
/**
|
* 加载部门列表树
|
*/
|
@PostMapping("/treeData2")
|
@ResponseBody
|
public List<Ztree> treeData2()
|
{
|
List<Ztree> ztrees = mjDeptService.selectDeptTree(new MjDept());
|
return ztrees;
|
}
|
|
/**
|
* 新增部门
|
*/
|
@GetMapping("/add2")
|
public String add2()
|
{
|
return prefix + "/add2";
|
}
|
|
/**
|
* 删除部门
|
*/
|
@GetMapping( "/remove2")
|
@ResponseBody
|
public AjaxResult remove2(String ids)
|
{
|
return toAjax(mjDeptService.deleteMjDeptByIds(ids));
|
}
|
}
|