diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/DeptLazyVO.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/DeptLazyVO.java deleted file mode 100644 index 3863409e..00000000 --- a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/DeptLazyVO.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the dreamlu.net developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: Chill 庄骞 (smallchill@163.com) - */ -package org.springblade.system.vo; - -import com.fasterxml.jackson.annotation.JsonInclude; -import io.swagger.annotations.ApiModel; -import lombok.Data; -import lombok.EqualsAndHashCode; - -/** - * 视图实体类 - * - * @author Chill - */ -@Data -@EqualsAndHashCode(callSuper = true) -@ApiModel(value = "DeptLazyVO对象", description = "DeptLazyVO对象") -public class DeptLazyVO extends DeptVO { - private static final long serialVersionUID = 1L; - - @JsonInclude(JsonInclude.Include.NON_EMPTY) - private Boolean hasChildren; - -} diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/DeptVO.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/DeptVO.java index 819e5089..2f96d2f6 100644 --- a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/DeptVO.java +++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/DeptVO.java @@ -57,6 +57,12 @@ public class DeptVO extends Dept implements INode { @JsonInclude(JsonInclude.Include.NON_EMPTY) private List children; + /** + * 是否有子孙节点 + */ + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private Boolean hasChildren; + @Override public List getChildren() { if (this.children == null) { @@ -65,6 +71,15 @@ public class DeptVO extends Dept implements INode { return this.children; } + @Override + public Boolean getHasChildren() { + if (children.size() > 0) { + return true; + } else { + return this.hasChildren; + } + } + /** * 上级机构 */ diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/DeptController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/DeptController.java index f0ce8384..3ce50034 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/controller/DeptController.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/controller/DeptController.java @@ -31,7 +31,6 @@ import org.springblade.core.tool.node.INode; import org.springblade.core.tool.utils.Func; import org.springblade.system.entity.Dept; import org.springblade.system.service.IDeptService; -import org.springblade.system.vo.DeptLazyVO; import org.springblade.system.vo.DeptVO; import org.springblade.system.wrapper.DeptWrapper; import org.springframework.cache.annotation.CacheEvict; @@ -96,7 +95,7 @@ public class DeptController extends BladeController { @ApiOperationSupport(order = 3) @ApiOperation(value = "懒加载列表", notes = "传入dept") public R> lazyList(@ApiIgnore @RequestParam Map dept, @RequestParam(required = false, defaultValue = "0") Long parentId, BladeUser bladeUser) { - List list = deptService.lazyList(bladeUser.getTenantId(), parentId, dept); + List list = deptService.lazyList(bladeUser.getTenantId(), parentId, dept); return R.data(DeptWrapper.build().listNodeLazyVO(list)); } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/mapper/DeptMapper.java b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/DeptMapper.java index db89eb9f..8b05f0cc 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/mapper/DeptMapper.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/DeptMapper.java @@ -18,7 +18,7 @@ package org.springblade.system.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.springblade.system.entity.Dept; -import org.springblade.system.vo.DeptLazyVO; +import org.springblade.system.vo.DeptVO; import org.springblade.system.vo.DeptVO; import java.util.List; @@ -39,7 +39,7 @@ public interface DeptMapper extends BaseMapper { * @param param * @return */ - List lazyList(String tenantId, Long parentId, Map param); + List lazyList(String tenantId, Long parentId, Map param); /** * 获取树形节点 diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/mapper/DeptMapper.xml b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/DeptMapper.xml index ab9f9a85..83cbd79b 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/mapper/DeptMapper.xml +++ b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/DeptMapper.xml @@ -15,7 +15,7 @@ - + @@ -88,7 +88,7 @@ dept.id AS "key", ( SELECT - count( 1 ) > 0 + CASE WHEN count(1) > 0 THEN 1 ELSE 0 END FROM blade_dept WHERE diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/IDeptService.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/IDeptService.java index dff5cb66..dc3d5414 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/service/IDeptService.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/IDeptService.java @@ -18,7 +18,7 @@ package org.springblade.system.service; import com.baomidou.mybatisplus.extension.service.IService; import org.springblade.system.entity.Dept; -import org.springblade.system.vo.DeptLazyVO; +import org.springblade.system.vo.DeptVO; import org.springblade.system.vo.DeptVO; import java.util.List; @@ -39,7 +39,7 @@ public interface IDeptService extends IService { * @param param * @return */ - List lazyList(String tenantId, Long parentId, Map param); + List lazyList(String tenantId, Long parentId, Map param); /** * 树形结构 diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DeptServiceImpl.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DeptServiceImpl.java index b72e8c16..5331ef20 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DeptServiceImpl.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DeptServiceImpl.java @@ -28,7 +28,7 @@ import org.springblade.core.tool.utils.StringPool; import org.springblade.system.entity.Dept; import org.springblade.system.mapper.DeptMapper; import org.springblade.system.service.IDeptService; -import org.springblade.system.vo.DeptLazyVO; +import org.springblade.system.vo.DeptVO; import org.springblade.system.vo.DeptVO; import org.springframework.stereotype.Service; @@ -44,7 +44,7 @@ import java.util.Map; public class DeptServiceImpl extends ServiceImpl implements IDeptService { @Override - public List lazyList(String tenantId, Long parentId, Map param) { + public List lazyList(String tenantId, Long parentId, Map param) { if (AuthUtil.isAdministrator()) { tenantId = StringPool.EMPTY; } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DeptWrapper.java b/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DeptWrapper.java index 264d4e26..ccca6472 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DeptWrapper.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DeptWrapper.java @@ -25,7 +25,6 @@ import org.springblade.core.tool.utils.Func; import org.springblade.system.cache.DictCache; import org.springblade.system.cache.SysCache; import org.springblade.system.entity.Dept; -import org.springblade.system.vo.DeptLazyVO; import org.springblade.system.vo.DeptVO; import java.util.List; @@ -68,7 +67,7 @@ public class DeptWrapper extends BaseEntityWrapper { return ForestNodeMerger.merge(collect); } - public List listNodeLazyVO(List list) { + public List listNodeLazyVO(List list) { List collect = list.stream().peek(dept -> { String category = DictCache.getValue("org_category", dept.getDeptCategory()); Objects.requireNonNull(dept).setDeptCategoryName(category);