|
@@ -3,10 +3,13 @@ package org.jetlinks.community.auth.web;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
import org.hswebframework.web.api.crud.entity.PagerResult;
|
|
import org.hswebframework.web.api.crud.entity.PagerResult;
|
|
import org.hswebframework.web.api.crud.entity.QueryOperation;
|
|
import org.hswebframework.web.api.crud.entity.QueryOperation;
|
|
import org.hswebframework.web.api.crud.entity.QueryParamEntity;
|
|
import org.hswebframework.web.api.crud.entity.QueryParamEntity;
|
|
import org.hswebframework.web.api.crud.entity.TreeSupportEntity;
|
|
import org.hswebframework.web.api.crud.entity.TreeSupportEntity;
|
|
|
|
+import org.hswebframework.web.authorization.Authentication;
|
|
|
|
+import org.hswebframework.web.authorization.Dimension;
|
|
import org.hswebframework.web.authorization.annotation.*;
|
|
import org.hswebframework.web.authorization.annotation.*;
|
|
import org.hswebframework.web.system.authorization.api.entity.DimensionEntity;
|
|
import org.hswebframework.web.system.authorization.api.entity.DimensionEntity;
|
|
import org.hswebframework.web.system.authorization.defaults.service.DefaultDimensionService;
|
|
import org.hswebframework.web.system.authorization.defaults.service.DefaultDimensionService;
|
|
@@ -15,6 +18,9 @@ import org.springframework.web.bind.annotation.*;
|
|
import reactor.core.publisher.Flux;
|
|
import reactor.core.publisher.Flux;
|
|
import reactor.core.publisher.Mono;
|
|
import reactor.core.publisher.Mono;
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
@RequestMapping("/organization")
|
|
@RequestMapping("/organization")
|
|
@RestController
|
|
@RestController
|
|
@Resource(id = "organization", name = "机构管理")
|
|
@Resource(id = "organization", name = "机构管理")
|
|
@@ -37,15 +43,26 @@ public class OrganizationController {
|
|
@Authorize(merge = false)
|
|
@Authorize(merge = false)
|
|
@Operation(summary = "获取全部机构信息")
|
|
@Operation(summary = "获取全部机构信息")
|
|
public Flux<DimensionEntity> getAllOrg() {
|
|
public Flux<DimensionEntity> getAllOrg() {
|
|
- return dimensionService
|
|
|
|
- .createQuery()
|
|
|
|
- .where(DimensionEntity::getTypeId, orgDimensionTypeId)
|
|
|
|
- .fetch();
|
|
|
|
|
|
+ return Authentication
|
|
|
|
+ .currentReactive()
|
|
|
|
+ .flatMapMany(auth -> {
|
|
|
|
+ List<String> list = auth.getDimensions(orgDimensionTypeId)
|
|
|
|
+ .stream()
|
|
|
|
+ .map(Dimension::getId)
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
|
+ return dimensionService.findById(list);
|
|
|
|
+ }
|
|
|
|
+ return dimensionService
|
|
|
|
+ .createQuery()
|
|
|
|
+ .where(DimensionEntity::getTypeId, orgDimensionTypeId)
|
|
|
|
+ .fetch();
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
@GetMapping("/_query")
|
|
@GetMapping("/_query")
|
|
@QueryAction
|
|
@QueryAction
|
|
- @QueryOperation(summary = "查询结构列表")
|
|
|
|
|
|
+ @QueryOperation(summary = "查询机构列表")
|
|
public Mono<PagerResult<DimensionEntity>> queryDimension(@Parameter(hidden = true) QueryParamEntity entity) {
|
|
public Mono<PagerResult<DimensionEntity>> queryDimension(@Parameter(hidden = true) QueryParamEntity entity) {
|
|
return entity
|
|
return entity
|
|
.toNestQuery(q -> q.where(DimensionEntity::getTypeId, orgDimensionTypeId))
|
|
.toNestQuery(q -> q.where(DimensionEntity::getTypeId, orgDimensionTypeId))
|
|
@@ -53,6 +70,24 @@ public class OrganizationController {
|
|
.as(dimensionService::queryPager);
|
|
.as(dimensionService::queryPager);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @GetMapping("/_query/_children/tree")
|
|
|
|
+ @QueryAction
|
|
|
|
+ @QueryOperation(summary = "查询机构列表(包含子机构)树结构")
|
|
|
|
+ public Mono<List<DimensionEntity>> queryChildrenTree(@Parameter(hidden = true) QueryParamEntity entity) {
|
|
|
|
+ return entity
|
|
|
|
+ .toNestQuery(q -> q.where(DimensionEntity::getTypeId, orgDimensionTypeId))
|
|
|
|
+ .execute(dimensionService::queryIncludeChildrenTree);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/_query/_children")
|
|
|
|
+ @QueryAction
|
|
|
|
+ @QueryOperation(summary = "查询机构列表(包含子机构)")
|
|
|
|
+ public Flux<DimensionEntity> queryChildren(@Parameter(hidden = true) QueryParamEntity entity) {
|
|
|
|
+ return entity
|
|
|
|
+ .toNestQuery(q -> q.where(DimensionEntity::getTypeId, orgDimensionTypeId))
|
|
|
|
+ .execute(dimensionService::queryIncludeChildren);
|
|
|
|
+ }
|
|
|
|
+
|
|
@PatchMapping
|
|
@PatchMapping
|
|
@SaveAction
|
|
@SaveAction
|
|
@Operation(summary = "保存机构信息")
|
|
@Operation(summary = "保存机构信息")
|