| | |
| | | package com.gkhy.web.controller.system; |
| | | |
| | | import java.util.List; |
| | | import org.apache.commons.lang3.ArrayUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | 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.PutMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.gkhy.common.annotation.Anonymous; |
| | | import com.gkhy.common.annotation.Log; |
| | | import com.gkhy.common.constant.UserConstants; |
| | | import com.gkhy.common.core.controller.BaseController; |
| | | import com.gkhy.common.core.domain.AjaxResult; |
| | | import com.gkhy.common.core.domain.R; |
| | | import com.gkhy.common.core.domain.entity.SysDept; |
| | | import com.gkhy.common.enums.BusinessType; |
| | | import com.gkhy.common.utils.StringUtils; |
| | | import com.gkhy.system.service.ISysDeptService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.commons.lang3.ArrayUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 部门信息 |
| | | * |
| | | * @author expert |
| | | */ |
| | | @Api(tags = "部门-业务处室") |
| | | @RestController |
| | | @RequestMapping("/system/dept") |
| | | public class SysDeptController extends BaseController |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dept:list')") |
| | | @GetMapping("/list") |
| | | public AjaxResult list(SysDept dept) |
| | | @ApiOperation(value = "获取部门列表") |
| | | public R<List<SysDept>> list(SysDept dept) |
| | | { |
| | | List<SysDept> depts = deptService.selectDeptList(dept); |
| | | return success(depts); |
| | | return R.ok(depts); |
| | | } |
| | | |
| | | |
| | | // @PreAuthorize("@ss.hasPermi('system:dept:list')") |
| | | @GetMapping("/getOutDeptList") |
| | | @ApiOperation(value = "获取部门列表(公开)") |
| | | @Anonymous |
| | | public R<List<SysDept>> getOutDeptList(SysDept dept) |
| | | { |
| | | List<SysDept> depts = deptService.getOutDeptList(dept); |
| | | return R.ok(depts); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dept:list')") |
| | | @GetMapping("/list/exclude/{deptId}") |
| | | public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType = "query", name = "deptId", dataType = "Long", required = true, value = "部门id"), |
| | | }) |
| | | @ApiOperation(value = "查询部门列表(排除节点)") |
| | | public R<List<SysDept>> excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) |
| | | { |
| | | List<SysDept> depts = deptService.selectDeptList(new SysDept()); |
| | | depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")); |
| | | return success(depts); |
| | | return R.ok(depts); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dept:query')") |
| | | @GetMapping(value = "/{deptId}") |
| | | public AjaxResult getInfo(@PathVariable Long deptId) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType = "query", name = "deptId", dataType = "Long", required = true, value = "部门id"), |
| | | }) |
| | | @ApiOperation(value = "根据部门编号获取详细信息") |
| | | public R<SysDept> getInfo(@PathVariable Long deptId) |
| | | { |
| | | deptService.checkDeptDataScope(deptId); |
| | | return success(deptService.selectDeptById(deptId)); |
| | | return R.ok(deptService.selectDeptById(deptId)); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dept:add')") |
| | | @Log(title = "部门管理", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | @PostMapping("/add") |
| | | @ApiOperation(value = "新增部门业务处室") |
| | | public AjaxResult add(@Validated @RequestBody SysDept dept) |
| | | { |
| | | if (!deptService.checkDeptNameUnique(dept)) |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dept:edit')") |
| | | @Log(title = "部门管理", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "修改部门门业务处室") |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysDept dept) |
| | | { |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:dept:remove')") |
| | | @Log(title = "部门管理", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{deptId}") |
| | | @ApiOperation(value = "删除部门门业务处室") |
| | | public AjaxResult remove(@PathVariable Long deptId) |
| | | { |
| | | if (deptService.hasChildByDeptId(deptId)) |
| | |
| | | { |
| | | return warn("部门存在用户,不允许删除"); |
| | | } |
| | | //todo 校验专家是否申请复用 |
| | | deptService.checkDeptDataScope(deptId); |
| | | return toAjax(deptService.deleteDeptById(deptId)); |
| | | } |