|
@@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.system.controller.admin.dept;
|
|
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
|
|
+import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
|
|
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptListReqVO;
|
|
|
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptRespVO;
|
|
|
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptSaveReqVO;
|
|
@@ -15,12 +17,14 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
-
|
|
|
+import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.validation.Valid;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
+import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
|
|
|
|
|
@Tag(name = "管理后台 - 部门")
|
|
|
@RestController
|
|
@@ -28,9 +32,16 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
@Validated
|
|
|
public class DeptController {
|
|
|
|
|
|
+ @Resource
|
|
|
+ private AdminUserApi adminUserApi;
|
|
|
+ @Resource
|
|
|
+ private DeptApi deptApi;
|
|
|
@Resource
|
|
|
private DeptService deptService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private PermissionApi permissionApi;
|
|
|
+
|
|
|
@PostMapping("create")
|
|
|
@Operation(summary = "创建部门")
|
|
|
@PreAuthorize("@ss.hasPermission('system:dept:create')")
|
|
@@ -67,15 +78,17 @@ public class DeptController {
|
|
|
@GetMapping(value = {"/list-all-simple", "/simple-list"})
|
|
|
@Operation(summary = "获取部门精简信息列表", description = "只包含被开启的部门,主要用于前端的下拉选项")
|
|
|
public CommonResult<List<DeptSimpleRespVO>> getSimpleDeptList() {
|
|
|
- List<DeptDO> list = deptService.getDeptList(
|
|
|
- new DeptListReqVO().setStatus(CommonStatusEnum.ENABLE.getStatus()));
|
|
|
+ List<DeptDO> list;
|
|
|
+ list = deptService.getDeptList(new DeptListReqVO().setStatus(CommonStatusEnum.ENABLE.getStatus()));
|
|
|
return success(BeanUtils.toBean(list, DeptSimpleRespVO.class));
|
|
|
}
|
|
|
|
|
|
@GetMapping(value = {"/list-all-simple-dept", "/simple-list-dept"})
|
|
|
@Operation(summary = "获取子部门精简信息列表", description = "只包含被开启的部门,主要用于前端的下拉选项")
|
|
|
public CommonResult<List<DeptSimpleRespVO>> getSimpleDeptListByDept(@RequestParam("id") Long id) {
|
|
|
- List<DeptDO> list = deptService.getDeptListByDept(id);
|
|
|
+ Long deptId = adminUserApi.getUser(getLoginUserId()).getDeptId();
|
|
|
+ Long collegeId = deptApi.getCollegeId(deptId);
|
|
|
+ List<DeptDO> list = deptService.getDeptListByDept(collegeId);
|
|
|
return success(BeanUtils.toBean(list, DeptSimpleRespVO.class));
|
|
|
}
|
|
|
|
|
@@ -89,6 +102,4 @@ public class DeptController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
}
|