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
d85b43d7
Commit
d85b43d7
authored
Jan 06, 2021
by
ysongq
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dm_dev' of
http://gitlab.ioubuy.cn/yaobenzhang/dm_project
into dm_dev
parents
8a3abdeb
c050d053
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
130 additions
and
130 deletions
+130
-130
ApiInfoOutTypeEnum.java
...m/jz/dm/common/enums/apiInterface/ApiInfoOutTypeEnum.java
+16
-0
AuthController.java
...ay/src/main/java/com/jz/dm/controller/AuthController.java
+2
-2
ProducerController.java
...rc/main/java/com/jz/dm/controller/ProducerController.java
+1
-1
AuthInfoDto.java
...teway/src/main/java/com/jz/dm/models/dto/AuthInfoDto.java
+0
-3
AuthListInfoReq.java
.../main/java/com/jz/dm/models/req/auth/AuthListInfoReq.java
+9
-0
ApiInterfaceReq.java
.../main/java/com/jz/dm/models/req/make/ApiInterfaceReq.java
+7
-11
MakeApiSaveInfoReq.java
...in/java/com/jz/dm/models/req/make/MakeApiSaveInfoReq.java
+0
-71
MakeBigDataApiReq.java
...ain/java/com/jz/dm/models/req/make/MakeBigDataApiReq.java
+8
-7
ProducerService.java
...eway/src/main/java/com/jz/dm/service/ProducerService.java
+1
-1
AuthServiceImpl.java
...src/main/java/com/jz/dm/service/impl/AuthServiceImpl.java
+19
-2
OrganizationManageImpl.java
...n/java/com/jz/dm/service/impl/OrganizationManageImpl.java
+1
-0
ProducerServiceImpl.java
...main/java/com/jz/dm/service/impl/ProducerServiceImpl.java
+23
-18
ApiQueryService.java
.../main/java/com/jz/dm/service/request/ApiQueryService.java
+38
-10
HttpsUtils.java
...-common/src/main/java/com/jz/common/utils/HttpsUtils.java
+4
-3
Result.java
jz-dm-common/src/main/java/com/jz/common/utils/Result.java
+1
-1
No files found.
jz-dm-apigateway/src/main/java/com/jz/dm/common/enums/apiInterface/ApiInfoOutTypeEnum.java
0 → 100644
View file @
d85b43d7
package
com
.
jz
.
dm
.
common
.
enums
.
apiInterface
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.common.enums.apiInterface
* @PROJECT_NAME: jz-dm-parent
* @NAME: ApiInfoOutTypeEnum
* @DATE: 2021-1-6/11:14
* @DAY_NAME_SHORT: 周三
* @Description: 输出类型
**/
public
enum
ApiInfoOutTypeEnum
{
JSON
,
XML
,
FLOW
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/controller/AuthController.java
View file @
d85b43d7
...
@@ -81,8 +81,8 @@ public class AuthController {
...
@@ -81,8 +81,8 @@ public class AuthController {
* @Author: Mr.zhang
* @Author: Mr.zhang
* @Date: 2020-12-26
* @Date: 2020-12-26
*/
*/
// @ApiOperation("认证信息修改
")
@ApiOperation
(
"取消授权
"
)
//
@PostMapping(value = "/update-auth-info")
@PostMapping
(
value
=
"/update-auth-info"
)
public
Mono
<
Result
>
updateAuthListInfo
(
@RequestBody
@Valid
AuthInfoUpdateReq
req
)
{
public
Mono
<
Result
>
updateAuthListInfo
(
@RequestBody
@Valid
AuthInfoUpdateReq
req
)
{
return
Mono
.
fromSupplier
(()
->
authService
.
updateAuthInfo
(
req
));
return
Mono
.
fromSupplier
(()
->
authService
.
updateAuthInfo
(
req
));
}
}
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/controller/ProducerController.java
View file @
d85b43d7
...
@@ -104,7 +104,7 @@ public class ProducerController {
...
@@ -104,7 +104,7 @@ public class ProducerController {
*/
*/
@ApiOperation
(
"保存修改的api信息"
)
@ApiOperation
(
"保存修改的api信息"
)
@PostMapping
(
value
=
"/保存修改的api信息"
)
@PostMapping
(
value
=
"/保存修改的api信息"
)
public
Mono
<
Result
>
saveUpdateAPiInfo
(
@RequestBody
@Valid
MakeApiSaveInfo
Req
req
)
{
public
Mono
<
Result
>
saveUpdateAPiInfo
(
@RequestBody
@Valid
ApiInterface
Req
req
)
{
return
Mono
.
fromSupplier
(()
->
producerService
.
saveUpdateAPiInfo
(
req
));
return
Mono
.
fromSupplier
(()
->
producerService
.
saveUpdateAPiInfo
(
req
));
}
}
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/dto/AuthInfoDto.java
View file @
d85b43d7
...
@@ -24,9 +24,6 @@ public class AuthInfoDto implements Serializable {
...
@@ -24,9 +24,6 @@ public class AuthInfoDto implements Serializable {
@ApiModelProperty
(
value
=
"授权组织id"
)
@ApiModelProperty
(
value
=
"授权组织id"
)
private
Long
apiOrgId
;
private
Long
apiOrgId
;
/* @ApiModelProperty(value = "api应用id")
private Long apiInterfaceId;*/
@ApiModelProperty
(
value
=
"授权组织名称"
)
@ApiModelProperty
(
value
=
"授权组织名称"
)
private
String
orgName
;
private
String
orgName
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/auth/AuthListInfoReq.java
View file @
d85b43d7
...
@@ -2,6 +2,7 @@ package com.jz.dm.models.req.auth;
...
@@ -2,6 +2,7 @@ package com.jz.dm.models.req.auth;
import
com.jz.common.bean.BasePageBean
;
import
com.jz.common.bean.BasePageBean
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.io.Serializable
;
...
@@ -18,4 +19,12 @@ import java.io.Serializable;
...
@@ -18,4 +19,12 @@ import java.io.Serializable;
@Data
@Data
@ApiModel
(
"认证信息列表请求体"
)
@ApiModel
(
"认证信息列表请求体"
)
public
class
AuthListInfoReq
extends
BasePageBean
implements
Serializable
{
public
class
AuthListInfoReq
extends
BasePageBean
implements
Serializable
{
@ApiModelProperty
(
value
=
"apiKey api唯一标识"
,
required
=
false
)
private
String
apiKey
;
@ApiModelProperty
(
value
=
"授权码"
,
required
=
false
)
private
String
authCode
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/make/ApiInterfaceReq.java
View file @
d85b43d7
...
@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
...
@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
import
lombok.Data
;
import
lombok.Data
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.NotNull
;
import
java.io.Serializable
;
/**
/**
* @author ZC
* @author ZC
...
@@ -17,7 +18,7 @@ import javax.validation.constraints.NotNull;
...
@@ -17,7 +18,7 @@ import javax.validation.constraints.NotNull;
**/
**/
@Data
@Data
@ApiModel
(
value
=
"api基本信息"
)
@ApiModel
(
value
=
"api基本信息"
)
public
class
ApiInterfaceReq
{
public
class
ApiInterfaceReq
implements
Serializable
{
@ApiModelProperty
(
value
=
"api类型:1 实时接入 2 数据银行制作API, 3 数据银行制作数据包 6标签查询 9自定义"
,
required
=
true
)
@ApiModelProperty
(
value
=
"api类型:1 实时接入 2 数据银行制作API, 3 数据银行制作数据包 6标签查询 9自定义"
,
required
=
true
)
@NotNull
(
message
=
"api类型不能为空"
)
@NotNull
(
message
=
"api类型不能为空"
)
public
String
apiType
;
public
String
apiType
;
...
@@ -25,8 +26,7 @@ public class ApiInterfaceReq {
...
@@ -25,8 +26,7 @@ public class ApiInterfaceReq {
@ApiModelProperty
(
value
=
"接口描述"
,
required
=
false
)
@ApiModelProperty
(
value
=
"接口描述"
,
required
=
false
)
public
String
apiDesc
;
public
String
apiDesc
;
@ApiModelProperty
(
value
=
"传输方式:http https"
,
required
=
true
)
@ApiModelProperty
(
value
=
"传输方式"
,
required
=
true
)
@NotNull
(
message
=
"传输方式不能为空"
)
@NotNull
(
message
=
"传输方式不能为空"
)
public
String
transMode
;
public
String
transMode
;
...
@@ -58,14 +58,10 @@ public class ApiInterfaceReq {
...
@@ -58,14 +58,10 @@ public class ApiInterfaceReq {
public
Long
projectId
;
public
Long
projectId
;
@ApiModelProperty
(
value
=
"状态"
,
required
=
false
)
public
String
status
;
/*@ApiModelProperty(value = "api名称",required = false)
@ApiModelProperty
(
value
=
"更新时传入api自增id"
,
required
=
false
)
public String apiName;
public
Long
id
;
*/
/* @ApiModelProperty(value = "状态",required = false)
public String status;*/
//@ApiModelProperty(value = "更新时传入api自增id",required = false)
//public Long id;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/make/MakeApiSaveInfoReq.java
deleted
100644 → 0
View file @
8a3abdeb
package
com
.
jz
.
dm
.
models
.
req
.
make
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
javax.validation.constraints.NotNull
;
import
java.io.Serializable
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.req.make
* @PROJECT_NAME: jz-dm-parent
* @NAME: MakeApiSaveInfoReq
* @DATE: 2020-12-29/10:00
* @DAY_NAME_SHORT: 周二
* @Description:
**/
@Data
@ApiModel
(
"保存API基本信息请求体"
)
public
class
MakeApiSaveInfoReq
implements
Serializable
{
@ApiModelProperty
(
value
=
"id"
,
required
=
true
)
@NotNull
(
message
=
"id不能为空"
)
public
Long
id
;
@ApiModelProperty
(
value
=
"api类型"
,
required
=
true
)
@NotNull
(
message
=
"api类型不能为空"
)
public
String
apiType
;
@ApiModelProperty
(
value
=
"apiId 等价于apiKey"
,
required
=
true
)
@NotNull
(
message
=
"apiId不能为空"
)
public
String
apiId
;
@ApiModelProperty
(
value
=
"接口描述"
,
required
=
false
)
public
String
apiDesc
;
@ApiModelProperty
(
value
=
"api版本"
,
required
=
false
)
public
String
version
;
@ApiModelProperty
(
value
=
"加密方式"
,
required
=
true
)
@NotNull
(
message
=
"加密方式不能为空"
)
public
String
transMode
;
@ApiModelProperty
(
value
=
"传输方式"
,
required
=
true
)
@NotNull
(
message
=
"传输方式不能为空"
)
public
String
type
;
@ApiModelProperty
(
value
=
"目标地址"
,
required
=
true
)
@NotNull
(
message
=
"目标地址不能为空"
)
public
String
targetUrl
;
@ApiModelProperty
(
value
=
"超时时间"
,
required
=
true
)
@NotNull
(
message
=
"超时时间不能为空"
)
public
String
timeout
;
@ApiModelProperty
(
value
=
"api描述"
,
required
=
false
)
public
String
apiFunction
;
@ApiModelProperty
(
value
=
"项目编号"
,
required
=
true
)
@NotNull
(
message
=
"项目编号不能为空"
)
public
String
projectId
;
@ApiModelProperty
(
value
=
"列"
,
required
=
false
)
public
String
columnCode
;
@ApiModelProperty
(
value
=
"状态"
,
required
=
false
)
public
String
status
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/make/MakeBigDataApiReq.java
View file @
d85b43d7
...
@@ -23,13 +23,16 @@ public class MakeBigDataApiReq implements Serializable {
...
@@ -23,13 +23,16 @@ public class MakeBigDataApiReq implements Serializable {
@ApiModelProperty
(
value
=
"id--更新时id不能为空"
,
required
=
false
)
@ApiModelProperty
(
value
=
"id--更新时id不能为空"
,
required
=
false
)
private
Long
id
;
private
Long
id
;
@ApiModelProperty
(
value
=
"数据类型:api类型:1 实时接入 2 数据银行制作API, 3 数据银行制作数据包 6标签查询 8 查询hive数据源 9自定义"
,
required
=
true
)
/*
@ApiModelProperty(value = "数据类型:api类型:1 实时接入 2 数据银行制作API, 3 数据银行制作数据包 6标签查询 8 查询hive数据源 9自定义",required = true)
@NotNull(message = "apiType不能为空")
@NotNull(message = "apiType不能为空")
private
String
apiType
;
private String apiType;
*/
//@ApiModelProperty(value = "apiId 等价于apiKey",required = true)
@ApiModelProperty
(
value
=
"接入类型:对应字典表key"
,
required
=
true
)
//@NotNull(message = "apiId不能为空")
@NotNull
(
message
=
"接入类型不能为空"
)
//public String apiId;
public
String
joinType
;
@ApiModelProperty
(
value
=
"是否分页"
,
required
=
false
)
public
Integer
page
;
@ApiModelProperty
(
value
=
"数据源Id"
,
required
=
true
)
@ApiModelProperty
(
value
=
"数据源Id"
,
required
=
true
)
@NotNull
(
message
=
"数据源Id不能为空"
)
@NotNull
(
message
=
"数据源Id不能为空"
)
...
@@ -47,8 +50,6 @@ public class MakeBigDataApiReq implements Serializable {
...
@@ -47,8 +50,6 @@ public class MakeBigDataApiReq implements Serializable {
@NotNull
(
message
=
"处理类型不能为空"
)
@NotNull
(
message
=
"处理类型不能为空"
)
private
String
handleType
;
private
String
handleType
;
@ApiModelProperty
(
value
=
"是否分页"
,
required
=
false
)
private
long
page
;
@ApiModelProperty
(
value
=
"请求参数"
,
required
=
true
)
@ApiModelProperty
(
value
=
"请求参数"
,
required
=
true
)
@NotNull
(
message
=
"请求参数不能为空"
)
@NotNull
(
message
=
"请求参数不能为空"
)
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/ProducerService.java
View file @
d85b43d7
...
@@ -73,7 +73,7 @@ public interface ProducerService {
...
@@ -73,7 +73,7 @@ public interface ProducerService {
* @param req
* @param req
* @return
* @return
*/
*/
Result
saveUpdateAPiInfo
(
MakeApiSaveInfo
Req
req
);
Result
saveUpdateAPiInfo
(
ApiInterface
Req
req
);
/**
/**
* 数据银行制作API/数据包
* 数据银行制作API/数据包
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/AuthServiceImpl.java
View file @
d85b43d7
...
@@ -64,6 +64,12 @@ public class AuthServiceImpl implements AuthService {
...
@@ -64,6 +64,12 @@ public class AuthServiceImpl implements AuthService {
public
Result
getAuthListInfo
(
AuthListInfoReq
req
)
{
public
Result
getAuthListInfo
(
AuthListInfoReq
req
)
{
IPage
<
AuthInfoDto
>
page
=
new
Page
<>(
req
.
getPageNum
(),
req
.
getPageSize
());
IPage
<
AuthInfoDto
>
page
=
new
Page
<>(
req
.
getPageNum
(),
req
.
getPageSize
());
QueryWrapper
<
AuthInfoDto
>
query
=
new
QueryWrapper
<>();
QueryWrapper
<
AuthInfoDto
>
query
=
new
QueryWrapper
<>();
if
(
StringUtils
.
isNotBlank
(
req
.
getApiKey
())){
query
.
eq
(
"ai.api_key"
,
req
.
getApiKey
());
}
if
(
StringUtils
.
isNotBlank
(
req
.
getAuthCode
())){
query
.
eq
(
"au.auth_code"
,
req
.
getAuthCode
());
}
query
.
eq
(
"au.is_deleted"
,
0
);
query
.
eq
(
"au.is_deleted"
,
0
);
query
.
orderByDesc
(
"au.create_date"
);
query
.
orderByDesc
(
"au.create_date"
);
IPage
<
AuthInfoDto
>
listSelectApiAuth
=
apiAuthMapper
.
listSelectApiAuth
(
page
,
query
);
IPage
<
AuthInfoDto
>
listSelectApiAuth
=
apiAuthMapper
.
listSelectApiAuth
(
page
,
query
);
...
@@ -234,8 +240,18 @@ public class AuthServiceImpl implements AuthService {
...
@@ -234,8 +240,18 @@ public class AuthServiceImpl implements AuthService {
*/
*/
@Override
@Override
public
Result
updateAuthInfo
(
AuthInfoUpdateReq
req
)
{
public
Result
updateAuthInfo
(
AuthInfoUpdateReq
req
)
{
//TODO 认证后是否可以修改
ApiAuth
apiAuth
=
apiAuthMapper
.
selectById
(
req
.
getId
());
return
null
;
if
(
null
==
apiAuth
){
return
Result
.
of_error
(
ResultMsg
.
DATA_NOT_EXIST
);
}
UpdateWrapper
<
ApiAuth
>
updateWra
=
new
UpdateWrapper
<>();
updateWra
.
set
(
"is_deleted"
,
1
);
updateWra
.
set
(
"status"
,
GeneralStatusTypeEnum
.
UN_VALID
.
name
());
updateWra
.
eq
(
"id"
,
req
.
getId
());
if
(
apiAuthMapper
.
update
(
null
,
updateWra
)
==
0
){
return
Result
.
of_error
(
ResultMsg
.
UPDATE_FAIL
);
}
return
Result
.
of_success
(
ResultMsg
.
UPDATE_SUCCESS
);
}
}
/**
/**
...
@@ -274,6 +290,7 @@ public class AuthServiceImpl implements AuthService {
...
@@ -274,6 +290,7 @@ public class AuthServiceImpl implements AuthService {
public
ApiAuth
getAuthUser
(
String
authCode
,
Long
apiId
)
{
public
ApiAuth
getAuthUser
(
String
authCode
,
Long
apiId
)
{
QueryWrapper
<
ApiAuth
>
query
=
new
QueryWrapper
<>();
QueryWrapper
<
ApiAuth
>
query
=
new
QueryWrapper
<>();
query
.
eq
(
"auth_code"
,
authCode
);
query
.
eq
(
"auth_code"
,
authCode
);
query
.
eq
(
"status"
,
GeneralStatusTypeEnum
.
VALID
.
name
());
query
.
eq
(
"api_interface_id"
,
apiId
);
query
.
eq
(
"api_interface_id"
,
apiId
);
query
.
eq
(
"is_deleted"
,
0
);
query
.
eq
(
"is_deleted"
,
0
);
return
apiAuthMapper
.
selectOne
(
query
);
return
apiAuthMapper
.
selectOne
(
query
);
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/OrganizationManageImpl.java
View file @
d85b43d7
...
@@ -193,6 +193,7 @@ public class OrganizationManageImpl implements OrganizationManageService {
...
@@ -193,6 +193,7 @@ public class OrganizationManageImpl implements OrganizationManageService {
public
ApiOrg
getAuthOrganization
(
Long
apiOrgId
)
{
public
ApiOrg
getAuthOrganization
(
Long
apiOrgId
)
{
QueryWrapper
<
ApiOrg
>
query
=
new
QueryWrapper
<>();
QueryWrapper
<
ApiOrg
>
query
=
new
QueryWrapper
<>();
query
.
eq
(
"id"
,
apiOrgId
);
query
.
eq
(
"id"
,
apiOrgId
);
query
.
eq
(
"status"
,
OrgStatusEnum
.
NORMAL
.
name
());
query
.
eq
(
"is_deleted"
,
0
);
query
.
eq
(
"is_deleted"
,
0
);
return
apiOrgMapper
.
selectOne
(
query
);
return
apiOrgMapper
.
selectOne
(
query
);
}
}
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/ProducerServiceImpl.java
View file @
d85b43d7
...
@@ -15,6 +15,7 @@ import com.jz.common.utils.RedisUtils;
...
@@ -15,6 +15,7 @@ import com.jz.common.utils.RedisUtils;
import
com.jz.common.utils.Result
;
import
com.jz.common.utils.Result
;
import
com.jz.dm.common.constant.TagConstants
;
import
com.jz.dm.common.constant.TagConstants
;
import
com.jz.dm.common.enums.GeneralStatusTypeEnum
;
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.enums.apiInterface.ApiStatusEnum
;
import
com.jz.dm.common.enums.produce.ProducerStatusTypeEnum
;
import
com.jz.dm.common.enums.produce.ProducerStatusTypeEnum
;
import
com.jz.dm.common.util.RandomUtil
;
import
com.jz.dm.common.util.RandomUtil
;
...
@@ -99,7 +100,7 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -99,7 +100,7 @@ public class ProducerServiceImpl implements ProducerService {
}
}
/**
/**
* 制作自定义Api
*
DMP
制作自定义Api
*
*
* @param req
* @param req
* @return
* @return
...
@@ -118,29 +119,33 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -118,29 +119,33 @@ public class ProducerServiceImpl implements ProducerService {
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRES_NEW
)
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRES_NEW
)
public
Result
addDataBankApiInfo
(
MakeDataBankApiReq
req
)
{
public
Result
addDataBankApiInfo
(
MakeDataBankApiReq
req
)
{
SysUserDto
currentUser
=
getLoginUser
(
RedisMessageConstant
.
SENDTYPE_LOGIN_SYS
);
//
SysUserDto currentUser = getLoginUser(RedisMessageConstant.SENDTYPE_LOGIN_SYS);
if
(
null
==
currentUser
)
{
//
if (null == currentUser) {
return
Result
.
of_error
(
ResultMsg
.
USER_NOT_LOGIN
);
//
return Result.of_error(ResultMsg.USER_NOT_LOGIN);
}
//
}
List
<
ApiInterfaceFile
>
fileSource
=
List
<
ApiInterfaceFile
>
fileSource
=
apiInterfaceFileMapper
.
selectList
(
new
QueryWrapper
<
ApiInterfaceFile
>().
eq
(
"file_source"
,
"2"
));
apiInterfaceFileMapper
.
selectList
(
new
QueryWrapper
<
ApiInterfaceFile
>().
eq
(
"file_source"
,
"2"
));
if
(
fileSource
.
size
()
==
0
||
fileSource
.
size
()
>=
2
)
{
if
(
fileSource
.
size
()
==
0
||
fileSource
.
size
()
>=
2
)
{
return
Result
.
of_error
(
"文件夹信息异常!"
);
return
Result
.
of_error
(
"文件夹信息异常!"
);
}
}
if
(
StringUtils
.
isNotBlank
(
req
.
getOutputType
())
&&
(!
req
.
getOutputType
().
contains
(
ApiInfoOutTypeEnum
.
JSON
.
name
())
||
!
req
.
getOutputType
().
contains
(
ApiInfoOutTypeEnum
.
FLOW
.
name
())
)){
return
Result
.
of_error
(
"输出类型不存在!"
);
}
String
apiKey
=
""
;
String
apiKey
=
""
;
if
(
StringUtils
.
isNotBlank
(
req
.
getJoinType
())
if
(
StringUtils
.
isNotBlank
(
req
.
getJoinType
())
&&
"10006"
.
equals
(
req
.
getJoinType
()))
{
//数据银行制作API
&&
"10006"
.
equals
(
req
.
getJoinType
()))
{
//数据银行制作API
apiKey
=
RandomUtil
.
getStringRandom
(
16
);
apiKey
=
RandomUtil
.
getStringRandom
(
16
);
ApiInterface
anInterface
=
new
ApiInterface
();
ApiInterface
anInterface
=
new
ApiInterface
();
anInterface
.
setCreateUser
(
""
);
//anInterface.setCreateUser(currentUser.getUserName()
);
anInterface
.
setApiType
(
"2"
);
//数据银行制作api
anInterface
.
setApiType
(
"2"
);
//数据银行制作api
anInterface
.
setStatus
(
ProducerStatusTypeEnum
.
ISSUE
.
name
());
//发布
anInterface
.
setStatus
(
ProducerStatusTypeEnum
.
ISSUE
.
name
());
//发布
anInterface
.
setApiKey
(
apiKey
);
//apiKey
anInterface
.
setApiKey
(
apiKey
);
//apiKey
anInterface
.
setFileId
(
req
.
getFileId
());
BeanUtils
.
copyProperties
(
req
,
anInterface
);
BeanUtils
.
copyProperties
(
req
,
anInterface
);
int
resIn
=
apiInterfaceMapper
.
insert
(
anInterface
);
int
resIn
=
apiInterfaceMapper
.
insert
(
anInterface
);
ApiInterfaceCustom
interfaceCustom
=
new
ApiInterfaceCustom
();
ApiInterfaceCustom
interfaceCustom
=
new
ApiInterfaceCustom
();
interfaceCustom
.
setCreateUser
(
""
);
//interfaceCustom.setCreateUser(currentUser.getUserName()
);
interfaceCustom
.
setApiKey
(
apiKey
);
interfaceCustom
.
setApiKey
(
apiKey
);
interfaceCustom
.
setApiInterfaceId
(
anInterface
.
getId
());
interfaceCustom
.
setApiInterfaceId
(
anInterface
.
getId
());
BeanUtils
.
copyProperties
(
req
,
interfaceCustom
);
BeanUtils
.
copyProperties
(
req
,
interfaceCustom
);
...
@@ -188,7 +193,7 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -188,7 +193,7 @@ public class ProducerServiceImpl implements ProducerService {
public
Result
addBigDataMakeApi
(
MakeBigDataApiReq
req
)
{
public
Result
addBigDataMakeApi
(
MakeBigDataApiReq
req
)
{
SysUserDto
currentUser
=
getLoginUser
(
RedisMessageConstant
.
SENDTYPE_LOGIN_SYS
);
SysUserDto
currentUser
=
getLoginUser
(
RedisMessageConstant
.
SENDTYPE_LOGIN_SYS
);
if
(
null
==
currentUser
)
{
if
(
null
==
currentUser
)
{
return
Result
.
of_error
(
ResultMsg
.
USER_NOT_LOGIN
);
return
Result
.
of_error
(
"用户信息不存在"
);
}
}
QueryWrapper
<
ApiOpenApiEsFields
>
queryOpenApi
=
new
QueryWrapper
<>();
QueryWrapper
<
ApiOpenApiEsFields
>
queryOpenApi
=
new
QueryWrapper
<>();
queryOpenApi
.
eq
(
"es_database"
,
req
.
getEsDatabase
());
queryOpenApi
.
eq
(
"es_database"
,
req
.
getEsDatabase
());
...
@@ -222,9 +227,6 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -222,9 +227,6 @@ public class ProducerServiceImpl implements ProducerService {
//api信息在redis中的key
//api信息在redis中的key
String
redisValueOfKey
=
RandomUtil
.
getStringRandom
(
16
);
String
redisValueOfKey
=
RandomUtil
.
getStringRandom
(
16
);
if
(
null
!=
dataSource
)
{
if
(
null
!=
dataSource
)
{
redisTemplate
.
opsForValue
().
set
(
TagConstants
.
OPEN_API_HANDLER_INFO_NAMESPACE
+
redisValueOfKey
,
req
.
getHandleType
());
//es相关信息
//redisTemplate.opsForValue().set(TagConstants.OPEN_API_ESTAG_INFO_NAMESPACE + redisValueOfKey, req);
//存入调用的基本ApiKey信息
//存入调用的基本ApiKey信息
redisTemplate
.
opsForValue
().
set
(
redisValueOfKey
,
req
);
redisTemplate
.
opsForValue
().
set
(
redisValueOfKey
,
req
);
//esjdbc 连接地址 用于接口中调用获取es数据
//esjdbc 连接地址 用于接口中调用获取es数据
...
@@ -232,7 +234,7 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -232,7 +234,7 @@ public class ProducerServiceImpl implements ProducerService {
}
}
int
result
=
0
;
int
result
=
0
;
ApiOpenApiEsTagconfig
apiEsTagconfig
=
new
ApiOpenApiEsTagconfig
();
ApiOpenApiEsTagconfig
apiEsTagconfig
=
new
ApiOpenApiEsTagconfig
();
if
(
null
!=
req
.
getId
()
&&
""
.
equals
(
req
.
getId
()))
{
//更新
if
(
null
!=
req
.
getId
()
&&
!
""
.
equals
(
req
.
getId
()))
{
//更新
apiEsTagconfig
.
setUpdateDate
(
new
Date
());
apiEsTagconfig
.
setUpdateDate
(
new
Date
());
apiEsTagconfig
.
setUpdateUser
(
currentUser
.
getUserName
());
apiEsTagconfig
.
setUpdateUser
(
currentUser
.
getUserName
());
BeanUtils
.
copyProperties
(
req
,
apiEsTagconfig
);
BeanUtils
.
copyProperties
(
req
,
apiEsTagconfig
);
...
@@ -259,7 +261,7 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -259,7 +261,7 @@ public class ProducerServiceImpl implements ProducerService {
public
Result
saveInterfaceAPi
(
ApiInterfaceReq
req
)
{
public
Result
saveInterfaceAPi
(
ApiInterfaceReq
req
)
{
SysUserDto
currentUser
=
getLoginUser
(
RedisMessageConstant
.
SENDTYPE_LOGIN_SYS
);
SysUserDto
currentUser
=
getLoginUser
(
RedisMessageConstant
.
SENDTYPE_LOGIN_SYS
);
if
(
null
==
currentUser
)
{
if
(
null
==
currentUser
)
{
return
Result
.
of_error
(
ResultMsg
.
USER_NOT_LOGIN
);
return
Result
.
of_error
(
"用户信息不存在"
);
}
}
QueryWrapper
<
ApiInterfaceFile
>
query
=
new
QueryWrapper
<>();
QueryWrapper
<
ApiInterfaceFile
>
query
=
new
QueryWrapper
<>();
query
.
eq
(
"project_id"
,
req
.
getProjectId
());
query
.
eq
(
"project_id"
,
req
.
getProjectId
());
...
@@ -303,6 +305,8 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -303,6 +305,8 @@ public class ProducerServiceImpl implements ProducerService {
if
(
apiInterfaceMapper
.
insert
(
apiInterface
)
==
0
)
{
if
(
apiInterfaceMapper
.
insert
(
apiInterface
)
==
0
)
{
throw
ResponseException
.
of_error
(
"保存Api信息失败!"
);
throw
ResponseException
.
of_error
(
"保存Api信息失败!"
);
}
}
//缓存到redis中
redisUtils
.
set
(
apiKey
,
req
);
return
Result
.
of_success
(
ResultMsg
.
INSERT_SUCCESS
,
apiKey
);
return
Result
.
of_success
(
ResultMsg
.
INSERT_SUCCESS
,
apiKey
);
}
}
...
@@ -313,22 +317,23 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -313,22 +317,23 @@ public class ProducerServiceImpl implements ProducerService {
* @return
* @return
*/
*/
@Override
@Override
public
Result
saveUpdateAPiInfo
(
MakeApiSaveInfo
Req
req
)
{
public
Result
saveUpdateAPiInfo
(
ApiInterface
Req
req
)
{
SysUserDto
currentUser
=
getLoginUser
(
RedisMessageConstant
.
SENDTYPE_LOGIN_SYS
);
SysUserDto
currentUser
=
getLoginUser
(
RedisMessageConstant
.
SENDTYPE_LOGIN_SYS
);
if
(
null
==
currentUser
)
{
if
(
null
==
currentUser
)
{
return
Result
.
of_error
(
ResultMsg
.
USER_NOT_LOGIN
);
return
Result
.
of_error
(
"用户信息不存在"
);
}
}
ApiInterface
apiInterface
=
apiInterfaceMapper
.
selectById
(
req
.
getId
());
ApiInterface
apiInterface
=
apiInterfaceMapper
.
selectById
(
req
.
getId
());
if
(
null
==
apiInterface
)
{
if
(
null
==
apiInterface
)
{
return
Result
.
of_error
(
ResultMsg
.
DATA_NOT_FOUND
);
return
Result
.
of_error
(
ResultMsg
.
DATA_NOT_FOUND
);
}
}
if
(
StringUtils
.
isBlank
(
req
.
get
Type
())
||
"0"
.
equals
(
req
.
get
Type
()))
{
if
(
StringUtils
.
isBlank
(
req
.
get
SignType
())
||
"0"
.
equals
(
req
.
getSign
Type
()))
{
return
Result
.
of_error
(
"加密类型错误!"
);
return
Result
.
of_error
(
"加密类型错误!"
);
}
}
apiInterface
.
setApiType
(
req
.
getApiType
());
apiInterface
.
setApiType
(
req
.
getApiType
());
apiInterface
.
setApiDesc
(
req
.
getApiDesc
());
apiInterface
.
setApiDesc
(
req
.
getApiDesc
());
apiInterface
.
setJoinType
(
req
.
getJoinType
());
apiInterface
.
setVersion
(
RandomUtil
.
generateVersion
(
apiInterface
.
getVersion
()));
//版本自动累加
apiInterface
.
setVersion
(
RandomUtil
.
generateVersion
(
apiInterface
.
getVersion
()));
//版本自动累加
apiInterface
.
setSignType
(
req
.
getType
());
apiInterface
.
setSignType
(
req
.
get
Sign
Type
());
apiInterface
.
setApiProtocl
(
req
.
getTransMode
());
//传输方式 https http
apiInterface
.
setApiProtocl
(
req
.
getTransMode
());
//传输方式 https http
if
(
StringUtils
.
isNotBlank
(
req
.
getTargetUrl
()))
{
if
(
StringUtils
.
isNotBlank
(
req
.
getTargetUrl
()))
{
apiInterface
.
setTargetUrl
(
req
.
getTargetUrl
());
apiInterface
.
setTargetUrl
(
req
.
getTargetUrl
());
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/request/ApiQueryService.java
View file @
d85b43d7
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.jz.common.utils.HttpsUtils
;
import
com.jz.common.utils.HttpsUtils
;
import
com.jz.common.utils.RedisUtils
;
import
com.jz.common.utils.RedisUtils
;
import
com.jz.dm.common.enums.GatewayResultCode
;
import
com.jz.dm.common.enums.GatewayResultCode
;
import
com.jz.dm.common.enums.apiInterface.ApiInfoOutTypeEnum
;
import
com.jz.dm.common.exception.GatewayException
;
import
com.jz.dm.common.exception.GatewayException
;
import
com.jz.dm.common.util.OpenApiRequest
;
import
com.jz.dm.common.util.OpenApiRequest
;
import
com.jz.dm.common.util.OpenApiResponse
;
import
com.jz.dm.common.util.OpenApiResponse
;
...
@@ -66,26 +67,39 @@ public class ApiQueryService implements OpenApiService {
...
@@ -66,26 +67,39 @@ public class ApiQueryService implements OpenApiService {
if
(
StringUtils
.
isNotBlank
(
selectType
))
{
if
(
StringUtils
.
isNotBlank
(
selectType
))
{
try
{
try
{
switch
(
selectType
)
{
switch
(
selectType
)
{
case
"
QUERY_TAG"
:
//标签
查询
case
"
10001"
:
//实时接入
查询
break
;
break
;
case
"
BIG_DATA_QUERY"
:
//大数据
查询
case
"
10003"
:
//标签
查询
break
;
break
;
case
"CUSTOM_QUERY"
:
//自定义查询(三方查询)
case
"10002"
:
//大数据查询
if
(
StringUtils
.
isNotBlank
(
apiInterface
)){
//redis中存在
JSONObject
jsonBigData
=
JSONObject
.
parseObject
(
apiInterface
);
String
targetUrl
=
jsonBigData
.
getString
(
"targetUrl"
);
rangRequestTarget
(
ApiInfoOutTypeEnum
.
JSON
.
name
(),
targetUrl
,
paramMap
,
response
);
}
else
{
//缓存中不存在 查询数据库
ApiInterface
apiInfo
=
apiInterfaceService
.
getApiInfo
(
request
.
getAppKey
());
if
(
apiInfo
==
null
){
throw
new
GatewayException
(
GatewayResultCode
.
REQUEST_INFO_UNEXIST
);
}
rangRequestTarget
(
ApiInfoOutTypeEnum
.
JSON
.
name
(),
apiInfo
.
getTargetUrl
(),
paramMap
,
response
);
}
break
;
case
"10004"
:
//自定义查询(三方查询)
if
(
StringUtils
.
isNotBlank
(
apiInterface
)){
//redis中存在
if
(
StringUtils
.
isNotBlank
(
apiInterface
)){
//redis中存在
JSONObject
jsonCustom
=
JSONObject
.
parseObject
(
apiInterface
);
JSONObject
jsonCustom
=
JSONObject
.
parseObject
(
apiInterface
);
String
targetUrl
=
jsonCustom
.
getString
(
"targetUrl"
);
String
targetUrl
=
jsonCustom
.
getString
(
"targetUrl"
);
rangRequestTarget
(
"json"
,
targetUrl
,
null
,
response
);
rangRequestTarget
(
ApiInfoOutTypeEnum
.
JSON
.
name
()
,
targetUrl
,
null
,
response
);
}
else
{
//redis中不存在,查询数据库
}
else
{
//redis中不存在,查询数据库
ApiInterface
apiReqDto
=
ApiInterface
apiReqDto
=
apiInterfaceService
.
getReqTargetInfo
(
request
.
getAppKey
());
apiInterfaceService
.
getReqTargetInfo
(
request
.
getAppKey
());
if
(
null
==
apiReqDto
)
{
if
(
null
==
apiReqDto
)
{
throw
new
GatewayException
(
GatewayResultCode
.
REQUEST_INFO_UNEXIST
);
throw
new
GatewayException
(
GatewayResultCode
.
REQUEST_INFO_UNEXIST
);
}
}
rangRequestTarget
(
"json"
,
apiReqDto
.
getTargetUrl
(),
null
,
response
);
rangRequestTarget
(
ApiInfoOutTypeEnum
.
JSON
.
name
()
,
apiReqDto
.
getTargetUrl
(),
null
,
response
);
}
}
break
;
break
;
case
"
DATA_BANK_QUERY
"
:
//数据银行查询
case
"
10006
"
:
//数据银行查询
if
(
null
!=
apiInterface
)
{
//redis中存在
if
(
StringUtils
.
isNotBlank
(
apiInterface
)
)
{
//redis中存在
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
apiInterface
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
apiInterface
);
String
targetUrl
=
jsonObject
.
getString
(
"targetUrl"
);
String
targetUrl
=
jsonObject
.
getString
(
"targetUrl"
);
String
outputType
=
jsonObject
.
getString
(
"outputType"
);
String
outputType
=
jsonObject
.
getString
(
"outputType"
);
...
@@ -99,7 +113,21 @@ public class ApiQueryService implements OpenApiService {
...
@@ -99,7 +113,21 @@ public class ApiQueryService implements OpenApiService {
rangRequestTarget
(
apiReqDto
.
getOutputType
(),
apiReqDto
.
getTargetUrl
(),
paramMap
,
response
);
rangRequestTarget
(
apiReqDto
.
getOutputType
(),
apiReqDto
.
getTargetUrl
(),
paramMap
,
response
);
}
}
break
;
break
;
case
"DATA_BAG_QUERY"
:
//数据银行数据包查询
case
"10007"
:
//数据银行数据包查询
if
(
StringUtils
.
isNotBlank
(
apiInterface
)){
//从redis中获取数据
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
apiInterface
);
String
targetUrl
=
jsonObject
.
getString
(
"targetUrl"
);
String
outputType
=
jsonObject
.
getString
(
"outputType"
);
rangRequestTarget
(
outputType
,
targetUrl
,
paramMap
,
response
);
}
else
{
//不存在查询数据库
ApiInterface
apiReqDto
=
apiInterfaceService
.
getReqTargetInfo
(
request
.
getAppKey
());
if
(
null
==
apiReqDto
)
{
throw
new
GatewayException
(
GatewayResultCode
.
REQUEST_INFO_UNEXIST
);
}
rangRequestTarget
(
apiReqDto
.
getOutputType
(),
apiReqDto
.
getTargetUrl
(),
paramMap
,
response
);
}
break
;
break
;
default
:
default
:
response
.
setCode
(
GatewayResultCode
.
ILLEGAL_REQUEST
.
getCode
());
response
.
setCode
(
GatewayResultCode
.
ILLEGAL_REQUEST
.
getCode
());
...
@@ -116,9 +144,9 @@ public class ApiQueryService implements OpenApiService {
...
@@ -116,9 +144,9 @@ public class ApiQueryService implements OpenApiService {
}
}
private
void
rangRequestTarget
(
String
outputType
,
String
targetUrl
,
Map
<
String
,
String
>
param
,
OpenApiResponse
response
)
{
private
void
rangRequestTarget
(
String
outputType
,
String
targetUrl
,
Map
<
String
,
String
>
param
,
OpenApiResponse
response
)
{
if
(
"flow"
.
equals
(
outputType
))
{
//文件流形式请求
if
(
ApiInfoOutTypeEnum
.
FLOW
.
name
()
.
equals
(
outputType
))
{
//文件流形式请求
// httpsUtils.doGetImg()TODO 流形式未实现
// httpsUtils.doGetImg()TODO 流形式未实现
}
else
if
(
"json"
.
equals
(
outputType
))
{
}
else
if
(
ApiInfoOutTypeEnum
.
JSON
.
name
()
.
equals
(
outputType
))
{
String
respResult
=
httpsUtils
.
doGet
(
targetUrl
,
param
);
String
respResult
=
httpsUtils
.
doGet
(
targetUrl
,
param
);
response
.
setAttribute
(
respResult
);
response
.
setAttribute
(
respResult
);
}
else
{
}
else
{
...
...
jz-dm-common/src/main/java/com/jz/common/utils/HttpsUtils.java
View file @
d85b43d7
package
com
.
jz
.
common
.
utils
;
package
com
.
jz
.
common
.
utils
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.toolkit.CollectionUtils
;
import
com.baomidou.mybatisplus.core.toolkit.CollectionUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
@@ -44,7 +45,7 @@ public class HttpsUtils {
...
@@ -44,7 +45,7 @@ public class HttpsUtils {
* @param headers 请求头
* @param headers 请求头
* @return
* @return
*/
*/
public
String
submitPost
(
String
url
,
String
params
,
Map
<
String
,
String
>
headers
)
{
public
String
submitPost
(
String
url
,
JSONObject
params
,
Map
<
String
,
String
>
headers
)
{
CloseableHttpClient
httpClient
=
getHttpClient
();
CloseableHttpClient
httpClient
=
getHttpClient
();
String
body
=
null
;
String
body
=
null
;
CloseableHttpResponse
response
=
null
;
CloseableHttpResponse
response
=
null
;
...
@@ -56,8 +57,8 @@ public class HttpsUtils {
...
@@ -56,8 +57,8 @@ public class HttpsUtils {
httpPost
.
addHeader
(
e
.
getKey
(),
e
.
getValue
());
httpPost
.
addHeader
(
e
.
getKey
(),
e
.
getValue
());
}
}
}
}
if
(
StringUtils
.
isNotBlank
(
params
))
{
if
(
StringUtils
.
isNotBlank
(
params
.
toString
()
))
{
httpPost
.
setEntity
(
new
StringEntity
(
params
,
Consts
.
UTF_8
));
httpPost
.
setEntity
(
new
StringEntity
(
params
.
toString
()
,
Consts
.
UTF_8
));
}
}
response
=
httpClient
.
execute
(
httpPost
);
response
=
httpClient
.
execute
(
httpPost
);
body
=
getBody
(
response
.
getEntity
());
body
=
getBody
(
response
.
getEntity
());
...
...
jz-dm-common/src/main/java/com/jz/common/utils/Result.java
View file @
d85b43d7
...
@@ -143,7 +143,7 @@ public class Result<T> implements Serializable {
...
@@ -143,7 +143,7 @@ public class Result<T> implements Serializable {
Result
resultJson
=
new
Result
(
ResultCode
.
FAILURE
.
getCode
(),
data
);
Result
resultJson
=
new
Result
(
ResultCode
.
FAILURE
.
getCode
(),
data
);
return
resultJson
;
return
resultJson
;
}
}
@Deprecated
//
@Deprecated
public
static
Result
of_error
(
String
msg
)
{
public
static
Result
of_error
(
String
msg
)
{
Result
resultJson
=
new
Result
(
ResultCode
.
FAILURE
.
getCode
(),
null
,
msg
);
Result
resultJson
=
new
Result
(
ResultCode
.
FAILURE
.
getCode
(),
null
,
msg
);
return
resultJson
;
return
resultJson
;
...
...
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