mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
支持多个root节点
This commit is contained in:
@@ -10,6 +10,8 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RequestMapping("/resource")
|
||||
@RestController
|
||||
@SysLog(module = "资源管理")
|
||||
@@ -22,12 +24,12 @@ public class ResourceController extends BaseController{
|
||||
|
||||
@PostMapping("/apiTree")
|
||||
@SysLog(action = "获取接口树")
|
||||
public ResourceTreeDto apiTree() {
|
||||
public List<ResourceTreeDto> apiTree() {
|
||||
return this.service.apiTree();
|
||||
}
|
||||
@PostMapping("/menuTree")
|
||||
@SysLog(action = "获取菜单树")
|
||||
public ResourceTreeDto menuTree() {
|
||||
public List<ResourceTreeDto> menuTree() {
|
||||
return this.service.menuTree();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,12 @@ import cn.lihongjie.coal.entity.ResourceEntity;
|
||||
import org.springframework.data.jpa.repository.EntityGraph;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface ResourceRepository extends BaseRepository<ResourceEntity> {
|
||||
|
||||
|
||||
@EntityGraph(attributePaths = {"children"})
|
||||
ResourceEntity findByTypeAndParentIsNull(String type);
|
||||
List<ResourceEntity> findAllByTypeAndParentIsNull(String type);
|
||||
}
|
||||
@@ -11,6 +11,8 @@ import org.mapstruct.MappingConstants;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.control.DeepClone;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper(
|
||||
componentModel = MappingConstants.ComponentModel.SPRING,
|
||||
uses = {CommonMapper.class},
|
||||
@@ -25,5 +27,5 @@ public interface ResourceMapper {
|
||||
|
||||
void updateEntity(@MappingTarget ResourceEntity entity, UpdateResourceDto dto);
|
||||
|
||||
ResourceTreeDto toTreeDto(ResourceEntity byTypeAndParentIsNull);
|
||||
List<ResourceTreeDto> toTreeDto(List<ResourceEntity> byTypeAndParentIsNull);
|
||||
}
|
||||
|
||||
@@ -184,13 +184,13 @@ public class ResourceService extends BaseService<ResourceEntity, ResourceReposit
|
||||
return urls;
|
||||
}
|
||||
|
||||
public ResourceTreeDto menuTree() {
|
||||
public List<ResourceTreeDto> menuTree() {
|
||||
|
||||
return this.mapper.toTreeDto(this.repository.findByTypeAndParentIsNull("0"));
|
||||
return this.mapper.toTreeDto(this.repository.findAllByTypeAndParentIsNull("0"));
|
||||
|
||||
}
|
||||
|
||||
public ResourceTreeDto apiTree() {
|
||||
return this.mapper.toTreeDto(this.repository.findByTypeAndParentIsNull("3"));
|
||||
public List<ResourceTreeDto> apiTree() {
|
||||
return this.mapper.toTreeDto(this.repository.findAllByTypeAndParentIsNull("3"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user