Commit 1334c03f authored by zhangc's avatar zhangc

修改树查询

parent 346711d6
......@@ -38,9 +38,10 @@ public class ProducerController {
*/
@ApiOperation("获取文件夹列表")
@GetMapping(value = "/getFileCatalog")
public Mono<Result> getFileCatalog(@RequestParam(name = "projectId")Long projectId) {
public Mono<Result> getFileCatalog(@RequestParam(name = "projectId") Long projectId) {
return Mono.fromSupplier(() -> producerService.getFileCatalog(projectId));
}
/**
* @Description:创建文件夹
* @Author: Mr.zhang
......@@ -51,6 +52,7 @@ public class ProducerController {
public Mono<Result> createProjectFolder(@RequestBody @Valid CreateFolderReq req) {
return Mono.fromSupplier(() -> producerService.createProjectFolder(req));
}
/**
* @Description:服务发布列表
* @Author: Mr.zhang
......@@ -61,6 +63,7 @@ public class ProducerController {
public Mono<Result> getServiceIssueList(@RequestBody @Valid ServiceIssueReq req) {
return Mono.fromSupplier(() -> producerService.getServiceIssueList(req));
}
/**
* @Description:服务发布/服务取消
* @Author: Mr.zhang
......@@ -68,9 +71,9 @@ public class ProducerController {
*/
@ApiOperation("服务发布/服务取消")
@GetMapping(value = "/optionApiIssueStatus")
public Mono<Result> optionApiIssueStatus(@RequestParam(name = "id")Long id,
@RequestParam(name="optStatus")Boolean optStatus) {
return Mono.fromSupplier(() -> producerService.optionApiIssueStatus(id,optStatus));
public Mono<Result> optionApiIssueStatus(@RequestParam(name = "id") Long id,
@RequestParam(name = "optStatus") Boolean optStatus) {
return Mono.fromSupplier(() -> producerService.optionApiIssueStatus(id, optStatus));
}
/**
......@@ -81,7 +84,7 @@ public class ProducerController {
@ApiOperation("Api制作(获取ApiId)")
@PostMapping(value = "/getCustomApiId")
public Mono<Result> getCustomApiId() {
return Mono.fromSupplier(() ->producerService.getCustomApiId());
return Mono.fromSupplier(() -> producerService.getCustomApiId());
}
/**
......@@ -94,6 +97,7 @@ public class ProducerController {
public Mono<Result> makeCustomApi(@RequestBody @Valid ApiInterfaceReq req) {
return Mono.fromSupplier(() -> Result.of_success(producerService.saveInterfaceAPi(req)));
}
/**
* @Description:Api制作(数据查询/标签查询)
* @Author: Mr.zhang
......@@ -152,7 +156,7 @@ public class ProducerController {
}*/
/*
/*
*//**
* @Description:获取数据源配置
* @Author: Mr.zhang
......
......@@ -3,6 +3,7 @@ package com.jz.dm.mapper;
import com.jz.common.base.BaseMapper;
import com.jz.dm.models.domian.ApiInterfaceFile;
import com.jz.dm.models.dto.ApiInterfaceFileDto;
import com.jz.dm.models.dto.DataFileDto;
import java.util.List;
......@@ -22,4 +23,11 @@ public interface ApiInterfaceFileMapper extends BaseMapper<ApiInterfaceFile> {
* @return
*/
List<ApiInterfaceFileDto> getFileFolderLevel(Long projectId);
/**
* 查询出所有项目文件列表
* @param projectId
* @return
*/
List<DataFileDto> listFileFolders(Long projectId);
}
......@@ -9,6 +9,7 @@ import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.List;
/**
......@@ -58,4 +59,6 @@ public class ApiInterfaceFile extends BaseObject implements Serializable {
@TableField("status")
private String status;
@TableField(exist = false)
private List<ApiInterfaceFile> children;//子集
}
package com.jz.dm.models.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.dto
* @PROJECT_NAME: jz-dm-parent
* @NAME: DataFileDto
* @DATE: 2021-2-4/17:23
* @DAY_NAME_SHORT: 周四
* @Description:
**/
@Data
@ApiModel
public class DataFileDto implements Serializable {
@ApiModelProperty(value = "文件id")
private Long id;
@ApiModelProperty(value = "项目编号")
private Long projectId;
@ApiModelProperty(value = "父类id")
private Long parentId;
@ApiModelProperty(value = "文件名称")
private String name;
@ApiModelProperty(value = "子类集合")
private List<DataFileDto> children;
}
......@@ -16,12 +16,16 @@ import com.jz.dm.common.enums.GeneralStatusTypeEnum;
import com.jz.dm.common.enums.apiInterface.ApiInfoOutTypeEnum;
import com.jz.dm.common.enums.apiInterface.ApiStatusEnum;
import com.jz.dm.common.util.RandomUtil;
import com.jz.dm.mapper.*;
import com.jz.dm.mapper.ApiInterfaceCustomMapper;
import com.jz.dm.mapper.ApiInterfaceFileMapper;
import com.jz.dm.mapper.ApiInterfaceMapper;
import com.jz.dm.mapper.ApiOpenApiEsFieldsMapper;
import com.jz.dm.models.domian.ApiInterface;
import com.jz.dm.models.domian.ApiInterfaceCustom;
import com.jz.dm.models.domian.ApiInterfaceFile;
import com.jz.dm.models.domian.ApiOpenApiEsFields;
import com.jz.dm.models.dto.ApiServiceApplyDto;
import com.jz.dm.models.dto.DataFileDto;
import com.jz.dm.models.req.folder.CreateFolderReq;
import com.jz.dm.models.req.producer.ApiInterfaceReq;
import com.jz.dm.models.req.producer.ServiceIssueReq;
......@@ -95,9 +99,35 @@ public class ProducerServiceImpl implements ProducerService {
*/
@Override
public Result getFileCatalog(Long projectId) {
return Result.of_success(apiInterfaceFileMapper.getFileFolderLevel(projectId));
List<DataFileDto> interfaceFiles = apiInterfaceFileMapper.listFileFolders(projectId);
ArrayList<DataFileDto> children=null;
if (CollectionUtils.isNotEmpty(interfaceFiles)) {
// for (ApiInterfaceFile interfaceFile : interfaceFiles) {
//if (0 == interfaceFile.getParentId()){
children = recursiveTree(0L, interfaceFiles);
//}
// }
}
return Result.of_success(children);
//return Result.of_success(apiInterfaceFileMapper.getFileFolderLevel(projectId));
}
private ArrayList<DataFileDto> recursiveTree(Long parentId, List<DataFileDto> allList) {
ArrayList<DataFileDto> files = new ArrayList<>();
for (DataFileDto interfaceFile : allList) {
if (Objects.equals(parentId,interfaceFile.getParentId())){
DataFileDto file = new DataFileDto();
file.setId(interfaceFile.getId());
file.setProjectId(interfaceFile.getProjectId());
file.setParentId(interfaceFile.getParentId());
file.setChildren(recursiveTree(interfaceFile.getId(),allList));
files.add(file);
}
}
/* files.forEach(System.out::println);*/
return files;
}
/**
* 创建文件夹
......@@ -112,7 +142,7 @@ public class ProducerServiceImpl implements ProducerService {
if (null == interfaceFile) {
return Result.of_error("父级文件夹不存在!");
}
if (!req.getFileSource().equals(interfaceFile.getFileSource())){
if (!req.getFileSource().equals(interfaceFile.getFileSource())) {
return Result.of_error("父级文件类型错误!");
}
}
......@@ -143,7 +173,7 @@ public class ProducerServiceImpl implements ProducerService {
ApiInterfaceFile interfaceFile = new ApiInterfaceFile();
BeanUtils.copyProperties(req, interfaceFile);
interfaceFile.setStatus(GeneralStatusTypeEnum.VALID.name());
if (null == interfaceFile.getParentId() || "".equals(interfaceFile.getParentId())){
if (null == interfaceFile.getParentId() || "".equals(interfaceFile.getParentId())) {
interfaceFile.setParentId(0L);//默认父类id为零
}
if (apiInterfaceFileMapper.insert(interfaceFile) == 0) {
......@@ -221,7 +251,7 @@ public class ProducerServiceImpl implements ProducerService {
*/
@Override
public Result getCustomApiId() {
return Result.of_success(ResultMsg.SUCCESS,getApiKey());
return Result.of_success(ResultMsg.SUCCESS, getApiKey());
}
......@@ -235,7 +265,7 @@ public class ProducerServiceImpl implements ProducerService {
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
public Result addBigDataMakeApi(ApiInterfaceReq req) {
ApiInterface anInterface = apiInterfaceService.getApiInfo(req.apiKey);
if (null != anInterface){
if (null != anInterface) {
return Result.of_error("API已存在!");
}
if ("10002".equals(req.getApiType())) {//数据查询
......@@ -250,7 +280,7 @@ public class ProducerServiceImpl implements ProducerService {
return Result.of_error("限流次数不能小于或者等于零");
}
}
if (null == req.getSignType() || 0 ==req.getSignType()) {
if (null == req.getSignType() || 0 == req.getSignType()) {
return Result.of_error("加密类型错误!");
}
if (StringUtils.isNotBlank(req.getLimitType())) {
......@@ -270,7 +300,7 @@ public class ProducerServiceImpl implements ProducerService {
}
} else { //保存
ApiInterface apiInterface = saveApiBaseData(req);
if (saveApiExtendData(req,apiInterface.getId())) {
if (saveApiExtendData(req, apiInterface.getId())) {
throw ResponseException.of_error(ResultMsg.INSERT_FAIL);
}
}
......@@ -285,7 +315,7 @@ public class ProducerServiceImpl implements ProducerService {
* @param req
*/
private void saveTableField(ApiInterfaceReq req) {
if (StringUtils.isBlank(req.getTableFields())){
if (StringUtils.isBlank(req.getTableFields())) {
return;
}
QueryWrapper<ApiOpenApiEsFields> queryOpenApi = new QueryWrapper<>();
......@@ -330,7 +360,7 @@ public class ProducerServiceImpl implements ProducerService {
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public Result saveInterfaceAPi(ApiInterfaceReq req) {
ApiInterface anInterface = apiInterfaceService.getApiInfo(req.apiKey);
if (null != anInterface){
if (null != anInterface) {
return Result.of_error("API已存在!");
}
if (StringUtils.isNotBlank(req.getLimitType())) {
......@@ -346,7 +376,7 @@ public class ProducerServiceImpl implements ProducerService {
return Result.of_error("限流次数不能小于或者等于零");
}
}
if (StringUtils.isBlank(req.getTargetUrl())){
if (StringUtils.isBlank(req.getTargetUrl())) {
return Result.of_error("目标地址不存在!");
}
//校验文件夹信息
......@@ -354,7 +384,7 @@ public class ProducerServiceImpl implements ProducerService {
return Result.of_error("目标文件夹不存在!");
}
ApiInterface apiInterface = saveApiBaseData(req);
if (saveApiExtendData(req,apiInterface.getId())) {
if (saveApiExtendData(req, apiInterface.getId())) {
throw ResponseException.of_error("保存Api扩展信息失败!");
}
//缓存API信息
......@@ -364,11 +394,12 @@ public class ProducerServiceImpl implements ProducerService {
/**
* 保存APi扩展信息
*
* @param id
* @param req
* @return
*/
private boolean saveApiExtendData(ApiInterfaceReq req,Long id) {
private boolean saveApiExtendData(ApiInterfaceReq req, Long id) {
ApiInterfaceCustom custom = new ApiInterfaceCustom();
BeanUtils.copyProperties(req, custom);
custom.setApiInterfaceId(id);
......@@ -488,9 +519,9 @@ public class ProducerServiceImpl implements ProducerService {
ApiInterfaceCustom interfaceCustom = null;
if (null != apiInterface) {
QueryWrapper<ApiInterfaceCustom> query = new QueryWrapper<>();
query.eq("api_interface_id",req.getId());
query.eq("api_key",apiInterface.getApiKey());
query.eq("is_deleted",0);
query.eq("api_interface_id", req.getId());
query.eq("api_key", apiInterface.getApiKey());
query.eq("is_deleted", 0);
interfaceCustom = apiInterfaceCustomMapper.selectOne(query);
}
if (null == interfaceCustom) {
......@@ -579,7 +610,7 @@ public class ProducerServiceImpl implements ProducerService {
object.put("targetUrl", req.getTargetUrl());
object.put("outputType", ApiInfoOutTypeEnum.JSON.name());
object.put("reqType", req.getReqType());
object.put("apiType",req.getApiType());
object.put("apiType", req.getApiType());
String apiKey = TagConstants.OPEN_API_CACHE_KEY + req.getApiKey();
String paramKey = redisUtils.get(apiKey);
if (null != paramKey) {
......
......@@ -23,4 +23,13 @@
) src
ORDER BY id
</select>
<select id="listFileFolders" resultType="com.jz.dm.models.dto.DataFileDto">
SELECT id AS id,
project_id AS projectId,
file_name AS fileName,
parent_id AS parentId
FROM t_api_interface_file
WHERE project_id =#{projectId}
AND `status`='VALID' AND is_deleted =0
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment