Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dm_project
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
姚本章
dm_project
Commits
1334c03f
Commit
1334c03f
authored
Feb 04, 2021
by
zhangc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改树查询
parent
346711d6
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
115 additions
and
27 deletions
+115
-27
ProducerController.java
...rc/main/java/com/jz/dm/controller/ProducerController.java
+12
-8
ApiInterfaceFileMapper.java
...rc/main/java/com/jz/dm/mapper/ApiInterfaceFileMapper.java
+8
-0
ApiInterfaceFile.java
...c/main/java/com/jz/dm/models/domian/ApiInterfaceFile.java
+3
-0
DataFileDto.java
...teway/src/main/java/com/jz/dm/models/dto/DataFileDto.java
+33
-0
ProducerServiceImpl.java
...main/java/com/jz/dm/service/impl/ProducerServiceImpl.java
+50
-19
ApiInterfaceFileMapper.xml
...eway/src/main/resources/mapper/ApiInterfaceFileMapper.xml
+9
-0
No files found.
jz-dm-apigateway/src/main/java/com/jz/dm/controller/ProducerController.java
View file @
1334c03f
...
...
@@ -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
...
...
@@ -117,7 +121,7 @@ public class ProducerController {
public Mono<Result> saveUpdateAPiInfo(@RequestBody @Valid ApiInterfaceReq req) {
return Mono.fromSupplier(() -> producerService.saveUpdateAPiInfo(req));
}*/
/* *//**
/* *//**
* @Description:Api制作(数据银行)
* @Author: Mr.zhang
* @Date: 2020-12-26
...
...
@@ -152,8 +156,8 @@ public class ProducerController {
}*/
/*
*//**
/*
*//**
* @Description:获取数据源配置
* @Author: Mr.zhang
* @Date: 2020-12-26
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/mapper/ApiInterfaceFileMapper.java
View file @
1334c03f
...
...
@@ -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
);
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiInterfaceFile.java
View file @
1334c03f
...
...
@@ -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
;
//子集
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/dto/DataFileDto.java
0 → 100644
View file @
1334c03f
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
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/ProducerServiceImpl.java
View file @
1334c03f
...
...
@@ -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
)
{
...
...
@@ -207,7 +237,7 @@ public class ProducerServiceImpl implements ProducerService {
updateWra
.
set
(
"status"
,
ApiStatusEnum
.
DRAFT
.
name
());
updateWra
.
eq
(
"id"
,
id
);
updateStatus
=
apiInterfaceMapper
.
update
(
null
,
updateWra
);
}
}
if
(
updateStatus
>
0
)
{
return
Result
.
of_success
(
ResultMsg
.
UPDATE_SUCCESS
);
}
...
...
@@ -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,15 +376,15 @@ public class ProducerServiceImpl implements ProducerService {
return
Result
.
of_error
(
"限流次数不能小于或者等于零"
);
}
}
if
(
StringUtils
.
isBlank
(
req
.
getTargetUrl
())){
return
Result
.
of_error
(
"目标地址不存在!"
);
if
(
StringUtils
.
isBlank
(
req
.
getTargetUrl
()))
{
return
Result
.
of_error
(
"目标地址不存在!"
);
}
//校验文件夹信息
if
(
checkFileifExist
(
req
.
getFileId
(),
req
.
getProjectId
()))
{
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
)
{
...
...
jz-dm-apigateway/src/main/resources/mapper/ApiInterfaceFileMapper.xml
View file @
1334c03f
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment