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
e5ac3d62
Commit
e5ac3d62
authored
Jan 05, 2021
by
ysongq
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/dm_dev' into dm_dev
parents
f680ff94
7ecbcfde
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
170 additions
and
71 deletions
+170
-71
api_gateway.sql
database/zc/api_gateway.sql
+5
-2
ApiDirectionController.java
...ain/java/com/jz/dm/controller/ApiDirectionController.java
+2
-2
ProducerController.java
...rc/main/java/com/jz/dm/controller/ProducerController.java
+3
-2
ApiInterface.java
...y/src/main/java/com/jz/dm/models/domian/ApiInterface.java
+17
-1
ApiInterfaceCustom.java
...main/java/com/jz/dm/models/domian/ApiInterfaceCustom.java
+5
-5
ApiInterfaceFile.java
...c/main/java/com/jz/dm/models/domian/ApiInterfaceFile.java
+5
-5
ApiInterfaceReq.java
.../main/java/com/jz/dm/models/req/make/ApiInterfaceReq.java
+3
-7
MakeDataBankApiReq.java
...in/java/com/jz/dm/models/req/make/MakeDataBankApiReq.java
+14
-3
ApiDirectionService.java
.../src/main/java/com/jz/dm/service/ApiDirectionService.java
+2
-2
ProducerService.java
...eway/src/main/java/com/jz/dm/service/ProducerService.java
+2
-1
ApiDirectionServiceImpl.java
.../java/com/jz/dm/service/impl/ApiDirectionServiceImpl.java
+14
-8
ProducerServiceImpl.java
...main/java/com/jz/dm/service/impl/ProducerServiceImpl.java
+65
-28
ApiQueryService.java
.../main/java/com/jz/dm/service/request/ApiQueryService.java
+24
-0
TestHttpReq.java
...y/src/test/java/com/jz/dm/gateway/orther/TestHttpReq.java
+1
-0
TestMakeApi.java
...y/src/test/java/com/jz/dm/gateway/orther/TestMakeApi.java
+6
-3
ResultMsg.java
...ommon/src/main/java/com/jz/common/constant/ResultMsg.java
+2
-2
No files found.
database/zc/api_gateway.sql
View file @
e5ac3d62
...
@@ -6,12 +6,15 @@ CREATE TABLE `t_api_interface` (
...
@@ -6,12 +6,15 @@ CREATE TABLE `t_api_interface` (
`api_name`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'api名称'
,
`api_name`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'api名称'
,
`api_desc`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'api描述'
,
`api_desc`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'api描述'
,
`api_protocl`
varchar
(
32
)
DEFAULT
NULL
COMMENT
'api请求协议:http,https'
,
`api_protocl`
varchar
(
32
)
DEFAULT
NULL
COMMENT
'api请求协议:http,https'
,
`api_path`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'请求地址'
`target_url`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'目标url'
,
`target_url`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'目标url'
,
`api_type`
varchar
(
50
)
NULL
DEFAULT
''
COMMENT
'api类型:1 实时接入 2 数据银行制作API, 3 数据银行制作数据包 6
标签查询 9自定义'
,
`api_type`
varchar
(
50
)
NULL
DEFAULT
''
COMMENT
'api类型:1 数据银行制作API 2 数据银行制作数据包, 3 API实时接入 6
标签查询 9自定义'
,
`api_function`
varchar
(
200
)
DEFAULT
NULL
COMMENT
'接口功能'
,
`api_function`
varchar
(
200
)
DEFAULT
NULL
COMMENT
'接口功能'
,
`join_type`
varchar
(
50
)
NULL
DEFAULT
NULL
COMMENT
'接入类型:字典表对应key值'
,
`join_type`
varchar
(
50
)
NULL
DEFAULT
NULL
COMMENT
'接入类型:字典表对应key值'
,
`test_example`
varchar
(
255
)
NULL
DEFAULT
NULL
COMMENT
'测试实例'
;
`test_example`
varchar
(
255
)
NULL
DEFAULT
NULL
COMMENT
'测试实例'
;
`status`
varchar
(
50
)
NOT
NULL
COMMENT
'状态(DRAFT-草稿 ISSUE-发布 OUTMODED-过时 4FREEZE-冻结 EXPIRY-失效)'
,
`status`
varchar
(
50
)
NOT
NULL
COMMENT
'状态(DRAFT-草稿 ISSUE-发布 OUTMODED-过时 4FREEZE-冻结 EXPIRY-失效)'
,
`output_type`
varchar
(
50
)
NULL
DEFAULT
'JSON'
COMMENT
'输出类型:flow 流形式输出, json格式输出'
,
`page`
tinyint
(
2
)
NULL
DEFAULT
'0'
COMMENT
'是否分页:0 false ,1 true'
,
`version`
varchar
(
20
)
DEFAULT
'1.0'
COMMENT
'版本号'
,
`version`
varchar
(
20
)
DEFAULT
'1.0'
COMMENT
'版本号'
,
`sign_type`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'加密方式: MD5 RSA'
,
`sign_type`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'加密方式: MD5 RSA'
,
`timeout`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'超时时间'
,
`timeout`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'超时时间'
,
...
@@ -39,6 +42,7 @@ CREATE TABLE `t_api_interface_custom` (
...
@@ -39,6 +42,7 @@ CREATE TABLE `t_api_interface_custom` (
`req_headers`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'请求头'
,
`req_headers`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'请求头'
,
`resp_code`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'响应状态码'
,
`resp_code`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'响应状态码'
,
`api_example`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'api返回样例'
,
`api_example`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'api返回样例'
,
`inbox_param`
varchar
(
300
)
NULL
DEFAULT
NULL
COMMENT
'固定参数'
,
`remark`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'备注'
,
`remark`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'备注'
,
`create_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
COMMENT
'创建时间'
,
`create_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
COMMENT
'创建时间'
,
`create_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'创建人'
,
`create_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'创建人'
,
...
@@ -54,7 +58,6 @@ CREATE TABLE `t_api_interface_file` (
...
@@ -54,7 +58,6 @@ CREATE TABLE `t_api_interface_file` (
`id`
bigint
(
20
)
unsigned
NOT
NULL
AUTO_INCREMENT
COMMENT
'api文件表自增ID'
,
`id`
bigint
(
20
)
unsigned
NOT
NULL
AUTO_INCREMENT
COMMENT
'api文件表自增ID'
,
`project_id`
bigint
(
20
)
NOT
NULL
COMMENT
'项目编号'
,
`project_id`
bigint
(
20
)
NOT
NULL
COMMENT
'项目编号'
,
`file_source`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'文件来源:,1 dmp, 2 数据银行'
,
`file_source`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'文件来源:,1 dmp, 2 数据银行'
,
`file_type`
varchar
(
20
)
DEFAULT
NULL
COMMENT
'文件类型:1 文件夹 ,2 文件'
,
`file_name`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'文件名称'
,
`file_name`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'文件名称'
,
`file_en_name`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'文件英文名称'
,
`file_en_name`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'文件英文名称'
,
`parent_id`
bigint
(
20
)
DEFAULT
NULL
COMMENT
'父类id'
,
`parent_id`
bigint
(
20
)
DEFAULT
NULL
COMMENT
'父类id'
,
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/controller/ApiDirectionController.java
View file @
e5ac3d62
...
@@ -36,8 +36,8 @@ public class ApiDirectionController {
...
@@ -36,8 +36,8 @@ public class ApiDirectionController {
*/
*/
@ApiOperation
(
"api类型列表"
)
@ApiOperation
(
"api类型列表"
)
@PostMapping
(
value
=
"/getApiTypeList"
)
@PostMapping
(
value
=
"/getApiTypeList"
)
public
Mono
<
Result
>
getApiTypeList
(
@RequestParam
(
name
=
"parent
Code"
)
String
parentCode
)
{
public
Mono
<
Result
>
getApiTypeList
(
@RequestParam
(
name
=
"parent
Key"
)
String
parentKey
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
apiDirectionService
.
getApiType
(
parent
Code
)));
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
apiDirectionService
.
getApiType
(
parent
Key
)));
}
}
/**
/**
* @Description:查询某个类型的字典值
* @Description:查询某个类型的字典值
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/controller/ProducerController.java
View file @
e5ac3d62
...
@@ -36,9 +36,10 @@ public class ProducerController {
...
@@ -36,9 +36,10 @@ public class ProducerController {
*/
*/
@ApiOperation
(
"Api制作(获取文件夹列表)"
)
@ApiOperation
(
"Api制作(获取文件夹列表)"
)
@GetMapping
(
value
=
"/getFileCatalog"
)
@GetMapping
(
value
=
"/getFileCatalog"
)
public
Mono
<
Result
>
getFileCatalog
(
@RequestParam
(
name
=
"pageNum"
,
defaultValue
=
"1"
,
required
=
false
)
String
pageNum
,
public
Mono
<
Result
>
getFileCatalog
(
@RequestParam
(
name
=
"projectId"
)
Long
projectId
,
@RequestParam
(
name
=
"pageNum"
,
defaultValue
=
"1"
,
required
=
false
)
String
pageNum
,
@RequestParam
(
name
=
"pageSize"
,
defaultValue
=
"10"
,
required
=
false
)
String
pageSize
)
{
@RequestParam
(
name
=
"pageSize"
,
defaultValue
=
"10"
,
required
=
false
)
String
pageSize
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
producerService
.
getFileCatalog
(
pageNum
,
pageSize
)));
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
producerService
.
getFileCatalog
(
p
rojectId
,
p
ageNum
,
pageSize
)));
}
}
/**
/**
* @Description:Api制作(自定义)
* @Description:Api制作(自定义)
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiInterface.java
View file @
e5ac3d62
...
@@ -49,10 +49,16 @@ public class ApiInterface extends BaseObject implements Serializable {
...
@@ -49,10 +49,16 @@ public class ApiInterface extends BaseObject implements Serializable {
private
String
apiProtocl
;
private
String
apiProtocl
;
/**
/**
* api类型:1
实时接入 2 数据银行制作API, 3 数据银行制作数据包 6
标签查询 9自定义'
* api类型:1
数据银行制作API 2 数据银行制作数据包, 3 API实时接入 6
标签查询 9自定义'
*/
*/
@TableField
(
"api_type"
)
@TableField
(
"api_type"
)
private
String
apiType
;
private
String
apiType
;
/**
* 请求地址
*/
@TableField
(
"api_path"
)
private
String
apiPath
;
/**
/**
* 目标url
* 目标url
*/
*/
...
@@ -68,6 +74,16 @@ public class ApiInterface extends BaseObject implements Serializable {
...
@@ -68,6 +74,16 @@ public class ApiInterface extends BaseObject implements Serializable {
*/
*/
@TableField
(
"test_example"
)
@TableField
(
"test_example"
)
private
String
testExample
;
private
String
testExample
;
/**
* '输出类型:flow 流形式输出, json格式输出',
*/
@TableField
(
"output_type"
)
private
String
outputType
;
/**
* 是否分页:0 false ,1 true
*/
@TableField
(
"page"
)
private
Boolean
page
;
/**
/**
* 状态(1-草稿 2-发布 3-过时 4-冻结 5-失效)
* 状态(1-草稿 2-发布 3-过时 4-冻结 5-失效)
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiInterfaceCustom.java
View file @
e5ac3d62
...
@@ -36,11 +36,6 @@ public class ApiInterfaceCustom extends BaseObject implements Serializable {
...
@@ -36,11 +36,6 @@ public class ApiInterfaceCustom extends BaseObject implements Serializable {
@TableField
(
"api_interface_id"
)
@TableField
(
"api_interface_id"
)
private
Long
apiInterfaceId
;
private
Long
apiInterfaceId
;
/**
* api类型:1 实时接入 2 数据银行制作API, 3 数据银行制作数据包 6标签查询 9自定义'
*/
@TableField
(
"api_type"
)
private
String
apiType
;
/**
/**
* api请求参数
* api请求参数
...
@@ -69,5 +64,10 @@ public class ApiInterfaceCustom extends BaseObject implements Serializable {
...
@@ -69,5 +64,10 @@ public class ApiInterfaceCustom extends BaseObject implements Serializable {
*/
*/
@TableField
(
"api_example"
)
@TableField
(
"api_example"
)
private
String
apiExample
;
private
String
apiExample
;
/**
* 固定参数
*/
@TableField
(
"inbox_param"
)
private
String
inboxParam
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiInterfaceFile.java
View file @
e5ac3d62
...
@@ -36,11 +36,11 @@ public class ApiInterfaceFile extends BaseObject implements Serializable {
...
@@ -36,11 +36,11 @@ public class ApiInterfaceFile extends BaseObject implements Serializable {
@TableField
(
"file_source"
)
@TableField
(
"file_source"
)
private
String
fileSource
;
private
String
fileSource
;
/**
/
//
**
* 文件类型:1 文件夹 ,2 文件
//
* 文件类型:1 文件夹 ,2 文件
*/
//
*/
@TableField
(
"file_type"
)
//
@TableField("file_type")
private
String
fileType
;
//
private String fileType;
/**
/**
* 文件名称
* 文件名称
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/make/ApiInterfaceReq.java
View file @
e5ac3d62
...
@@ -22,10 +22,6 @@ public class ApiInterfaceReq {
...
@@ -22,10 +22,6 @@ public class ApiInterfaceReq {
@NotNull
(
message
=
"api类型不能为空"
)
@NotNull
(
message
=
"api类型不能为空"
)
public
String
apiType
;
public
String
apiType
;
/* @ApiModelProperty(value = "apiId 等价于apiKey",required = true)
@NotNull(message = "apiId不能为空")
public String apiId;*/
@ApiModelProperty
(
value
=
"接口描述"
,
required
=
false
)
@ApiModelProperty
(
value
=
"接口描述"
,
required
=
false
)
public
String
apiDesc
;
public
String
apiDesc
;
...
@@ -53,9 +49,9 @@ public class ApiInterfaceReq {
...
@@ -53,9 +49,9 @@ public class ApiInterfaceReq {
@ApiModelProperty
(
value
=
"api描述"
,
required
=
false
)
@ApiModelProperty
(
value
=
"api描述"
,
required
=
false
)
public
String
apiFunction
;
public
String
apiFunction
;
@ApiModelProperty
(
value
=
"
文件Id
"
,
required
=
true
)
@ApiModelProperty
(
value
=
"
父类文件id,一级文件夹传入0
"
,
required
=
true
)
@NotNull
(
message
=
"文件id不能为空"
)
@NotNull
(
message
=
"
父类id
文件id不能为空"
)
public
Long
file
Id
;
public
Long
parent
Id
;
@ApiModelProperty
(
value
=
"项目id"
,
required
=
true
)
@ApiModelProperty
(
value
=
"项目id"
,
required
=
true
)
@NotNull
(
message
=
"项目id不能为空"
)
@NotNull
(
message
=
"项目id不能为空"
)
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/make/MakeDataBankApiReq.java
View file @
e5ac3d62
...
@@ -20,9 +20,9 @@ import java.io.Serializable;
...
@@ -20,9 +20,9 @@ import java.io.Serializable;
@ApiModel
(
"数据银行api制作"
)
@ApiModel
(
"数据银行api制作"
)
public
class
MakeDataBankApiReq
implements
Serializable
{
public
class
MakeDataBankApiReq
implements
Serializable
{
@ApiModelProperty
(
value
=
"api类型:1 实时接入 2 数据银行制作API, 3 数据银行制作数据包 6
标签查询 9自定义"
,
required
=
true
)
//@ApiModelProperty(value = "api类型:1 数据银行制作API 2 数据银行制作数据包, 3 API实时接入 6
标签查询 9自定义",required = true)
@NotNull
(
message
=
"api类型不能为空"
)
//
@NotNull(message = "api类型不能为空")
public
String
apiType
;
//
public String apiType;
@ApiModelProperty
(
value
=
"传输方式(1为HTTPS,2为HTTP)"
,
required
=
true
)
@ApiModelProperty
(
value
=
"传输方式(1为HTTPS,2为HTTP)"
,
required
=
true
)
@NotNull
(
message
=
"传输方式不能为空"
)
@NotNull
(
message
=
"传输方式不能为空"
)
...
@@ -36,6 +36,17 @@ public class MakeDataBankApiReq implements Serializable {
...
@@ -36,6 +36,17 @@ public class MakeDataBankApiReq implements Serializable {
@NotNull
(
message
=
"接入类型不能为空"
)
@NotNull
(
message
=
"接入类型不能为空"
)
public
String
joinType
;
public
String
joinType
;
@ApiModelProperty
(
value
=
"输出类型:flow 流,json json形式"
,
required
=
true
)
@NotNull
(
message
=
"输出类型不能为空"
)
public
String
outputType
;
@ApiModelProperty
(
value
=
"是否分页:"
,
required
=
false
)
//@NotNull(message = "是否分页不能为空")
public
Boolean
page
;
@ApiModelProperty
(
value
=
"请求地址"
,
required
=
false
)
public
String
apiPath
;
@ApiModelProperty
(
value
=
"接口描述"
,
required
=
false
)
@ApiModelProperty
(
value
=
"接口描述"
,
required
=
false
)
public
String
apiDesc
;
public
String
apiDesc
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/ApiDirectionService.java
View file @
e5ac3d62
...
@@ -17,10 +17,10 @@ public interface ApiDirectionService {
...
@@ -17,10 +17,10 @@ public interface ApiDirectionService {
/**
/**
* 根据类型获取API类型信息
* 根据类型获取API类型信息
* @param parent
Code
* @param parent
Key
* @return
* @return
*/
*/
List
<
ApiDirection
>
getApiType
(
String
parent
Code
);
List
<
ApiDirection
>
getApiType
(
String
parent
Key
);
/**
/**
* 查询code值信息
* 查询code值信息
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/ProducerService.java
View file @
e5ac3d62
...
@@ -93,7 +93,8 @@ public interface ProducerService {
...
@@ -93,7 +93,8 @@ public interface ProducerService {
* 获取文件列表
* 获取文件列表
* @param pageNum
* @param pageNum
* @param pageSize
* @param pageSize
* @param projectId
* @return
* @return
*/
*/
IPage
<
ApiInterfaceFile
>
getFileCatalog
(
String
pageNum
,
String
pageSize
);
IPage
<
ApiInterfaceFile
>
getFileCatalog
(
Long
projectId
,
String
pageNum
,
String
pageSize
);
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/ApiDirectionServiceImpl.java
View file @
e5ac3d62
...
@@ -29,25 +29,31 @@ public class ApiDirectionServiceImpl implements ApiDirectionService {
...
@@ -29,25 +29,31 @@ public class ApiDirectionServiceImpl implements ApiDirectionService {
private
ApiDirectionMapper
apiDirectionMapper
;
private
ApiDirectionMapper
apiDirectionMapper
;
@Override
@Override
public
List
<
ApiDirection
>
getApiType
(
String
parent
Code
)
{
public
List
<
ApiDirection
>
getApiType
(
String
parent
Key
)
{
QueryWrapper
<
ApiDirection
>
query
=
new
QueryWrapper
<>();
QueryWrapper
<
ApiDirection
>
query
=
new
QueryWrapper
<>();
query
.
eq
(
"parent"
,
parent
Code
);
//父类下的所有子类
query
.
eq
(
"parent"
,
parent
Key
);
//父类下的所有子类
query
.
eq
(
"is_enabled"
,
GeneralStatusTypeEnum
.
ENABLE
);
query
.
eq
(
"is_enabled"
,
GeneralStatusTypeEnum
.
ENABLE
);
return
apiDirectionMapper
.
selectList
(
query
);
List
<
ApiDirection
>
apiDirections
=
apiDirectionMapper
.
selectList
(
query
);
apiDirections
.
forEach
((
x
)->{
if
(
null
==
x
.
getParent
())
{
apiDirections
.
remove
(
x
.
getId
());
}
});
return
apiDirections
;
}
}
@Override
@Override
public
List
<
ApiDirection
>
getDirectionVal
(
String
key
,
String
code
)
{
public
List
<
ApiDirection
>
getDirectionVal
(
String
key
,
String
code
)
{
QueryWrapper
<
ApiDirection
>
query
=
new
QueryWrapper
<>();
QueryWrapper
<
ApiDirection
>
query
=
new
QueryWrapper
<>();
if
(
StringUtils
.
isNotBlank
(
key
)
&&
StringUtils
.
isNotBlank
(
code
)){
if
(
StringUtils
.
isNotBlank
(
key
)
&&
StringUtils
.
isNotBlank
(
code
)){
query
.
eq
(
"
key
"
,
key
);
query
.
eq
(
"
`key`
"
,
key
);
query
.
eq
(
"
code
"
,
code
);
query
.
eq
(
"
`code`
"
,
code
);
query
.
eq
(
"is_enabled"
,
GeneralStatusTypeEnum
.
ENABLE
);
query
.
eq
(
"is_enabled"
,
GeneralStatusTypeEnum
.
ENABLE
);
}
else
if
(
StringUtils
.
isNotBlank
(
code
)){
}
else
if
(
StringUtils
.
isNotBlank
(
key
)){
query
.
eq
(
"
key
"
,
key
);
query
.
eq
(
"
`key`
"
,
key
);
query
.
eq
(
"is_enabled"
,
GeneralStatusTypeEnum
.
ENABLE
);
query
.
eq
(
"is_enabled"
,
GeneralStatusTypeEnum
.
ENABLE
);
}
else
{
}
else
{
query
.
eq
(
"
code
"
,
code
);
query
.
eq
(
"
`code`
"
,
code
);
query
.
eq
(
"is_enabled"
,
GeneralStatusTypeEnum
.
ENABLE
);
query
.
eq
(
"is_enabled"
,
GeneralStatusTypeEnum
.
ENABLE
);
}
}
return
apiDirectionMapper
.
selectList
(
query
);
return
apiDirectionMapper
.
selectList
(
query
);
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/ProducerServiceImpl.java
View file @
e5ac3d62
...
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
...
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.jz.common.bean.SysUserDto
;
import
com.jz.common.bean.SysUserDto
;
import
com.jz.common.constant.RedisMessageConstant
;
import
com.jz.common.constant.RedisMessageConstant
;
import
com.jz.common.constant.ResultCode
;
import
com.jz.common.constant.ResultMsg
;
import
com.jz.common.constant.ResultMsg
;
import
com.jz.common.exception.ResponseException
;
import
com.jz.common.exception.ResponseException
;
import
com.jz.common.utils.HttpsUtils
;
import
com.jz.common.utils.HttpsUtils
;
...
@@ -80,17 +81,18 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -80,17 +81,18 @@ public class ProducerServiceImpl implements ProducerService {
/**
/**
* 获取文件列表
* 获取文件列表
*
*
@param projectId
* @param pageSize
* @param pageSize
* @param pageNum
* @param pageNum
* @return
* @return
*/
*/
@Override
@Override
public
IPage
<
ApiInterfaceFile
>
getFileCatalog
(
String
pageNum
,
String
pageSize
)
{
public
IPage
<
ApiInterfaceFile
>
getFileCatalog
(
Long
projectId
,
String
pageNum
,
String
pageSize
)
{
Integer
pageN
=
Integer
.
valueOf
(
pageNum
);
Integer
pageN
=
Integer
.
valueOf
(
pageNum
);
Integer
pageS
=
Integer
.
valueOf
(
pageSize
);
Integer
pageS
=
Integer
.
valueOf
(
pageSize
);
IPage
<
ApiInterfaceFile
>
page
=
new
Page
<>(
pageN
,
pageS
);
IPage
<
ApiInterfaceFile
>
page
=
new
Page
<>(
pageN
,
pageS
);
QueryWrapper
<
ApiInterfaceFile
>
query
=
new
QueryWrapper
<>();
QueryWrapper
<
ApiInterfaceFile
>
query
=
new
QueryWrapper
<>();
query
.
eq
(
"project_id"
,
projectId
);
query
.
eq
(
"is_deleted"
,
0
);
query
.
eq
(
"is_deleted"
,
0
);
query
.
orderByDesc
(
"create_date"
);
query
.
orderByDesc
(
"create_date"
);
return
apiInterfaceFileMapper
.
selectPage
(
page
,
query
);
return
apiInterfaceFileMapper
.
selectPage
(
page
,
query
);
...
@@ -116,16 +118,22 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -116,16 +118,22 @@ 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
)
{
List
<
ApiInterfaceFile
>
fileSource
=
apiInterfaceFileMapper
.
selectList
(
new
QueryWrapper
<
ApiInterfaceFile
>().
eq
(
"file_source"
,
"2"
));
SysUserDto
currentUser
=
getLoginUser
(
RedisMessageConstant
.
SENDTYPE_LOGIN_SYS
);
if
(
null
==
currentUser
)
{
return
Result
.
of_error
(
ResultMsg
.
USER_NOT_LOGIN
);
}
List
<
ApiInterfaceFile
>
fileSource
=
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
(
"文件夹信息异常!"
);
}
}
String
apiKey
=
""
;
String
apiKey
=
""
;
if
(
StringUtils
.
isNotBlank
(
req
.
get
Api
Type
())
if
(
StringUtils
.
isNotBlank
(
req
.
get
Join
Type
())
&&
"
2"
.
equals
(
req
.
getApi
Type
()))
{
//数据银行制作API
&&
"
10006"
.
equals
(
req
.
getJoin
Type
()))
{
//数据银行制作API
apiKey
=
RandomUtil
.
getStringRandom
(
16
);
apiKey
=
RandomUtil
.
getStringRandom
(
16
);
ApiInterface
anInterface
=
new
ApiInterface
();
ApiInterface
anInterface
=
new
ApiInterface
();
anInterface
.
setCreateUser
(
""
);
anInterface
.
setCreateUser
(
""
);
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
());
anInterface
.
setFileId
(
req
.
getFileId
());
...
@@ -140,16 +148,19 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -140,16 +148,19 @@ public class ProducerServiceImpl implements ProducerService {
if
(
resOut
==
0
||
resIn
==
0
)
{
if
(
resOut
==
0
||
resIn
==
0
)
{
throw
ResponseException
.
of_error
(
"保存信息失败!"
);
throw
ResponseException
.
of_error
(
"保存信息失败!"
);
}
}
}
else
if
(
StringUtils
.
isNotBlank
(
req
.
getApiType
())
redisUtils
.
set
(
apiKey
,
req
);
&&
"3"
.
equals
(
req
.
getApiType
()))
{
//数据银行制作数据包
}
else
if
(
StringUtils
.
isNotBlank
(
req
.
getJoinType
())
&&
"10007"
.
equals
(
req
.
getJoinType
()))
{
//数据银行制作数据包
if
(
StringUtils
.
isBlank
(
req
.
getTargetUrl
()))
{
//目标地址
if
(
StringUtils
.
isBlank
(
req
.
getTargetUrl
()))
{
//目标地址
return
Result
.
of_error
(
"目标地址为空!"
);
return
Result
.
of_error
(
"目标地址为空!"
);
}
}
ApiInterfaceReq
apiInterfaceReq
=
new
ApiInterfaceReq
();
ApiInterfaceReq
apiInterfaceReq
=
new
ApiInterfaceReq
();
apiInterfaceReq
.
setTransMode
(
req
.
getApiProtocl
());
apiInterfaceReq
.
setApiType
(
"2"
);
apiInterfaceReq
.
setTransMode
(
req
.
getApiProtocl
());
//请求方式:https http
BeanUtils
.
copyProperties
(
req
,
apiInterfaceReq
);
BeanUtils
.
copyProperties
(
req
,
apiInterfaceReq
);
Result
result
=
saveInterfaceAPi
(
apiInterfaceReq
);
Result
result
=
saveInterfaceAPi
(
apiInterfaceReq
);
apiKey
=(
String
)
result
.
getData
();
apiKey
=(
String
)
result
.
getData
();
redisUtils
.
set
(
apiKey
,
req
);
}
}
return
Result
.
of_success
(
ResultMsg
.
INSERT_SUCCESS
,
apiKey
);
return
Result
.
of_success
(
ResultMsg
.
INSERT_SUCCESS
,
apiKey
);
}
}
...
@@ -175,9 +186,9 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -175,9 +186,9 @@ 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
addBigDataMakeApi
(
MakeBigDataApiReq
req
)
{
public
Result
addBigDataMakeApi
(
MakeBigDataApiReq
req
)
{
SysUserDto
currentUser
=
(
SysUserDto
)
redisTemplate
.
opsForValue
().
get
(
"USER"
+
RedisMessageConstant
.
SENDTYPE_LOGIN_SYS
);
SysUserDto
currentUser
=
getLoginUser
(
RedisMessageConstant
.
SENDTYPE_LOGIN_SYS
);
if
(
null
==
currentUser
)
{
if
(
null
==
currentUser
)
{
return
Result
.
of_error
(
ResultMsg
.
USER_NOT_
EXIST
);
return
Result
.
of_error
(
ResultMsg
.
USER_NOT_
LOGIN
);
}
}
QueryWrapper
<
ApiOpenApiEsFields
>
queryOpenApi
=
new
QueryWrapper
<>();
QueryWrapper
<
ApiOpenApiEsFields
>
queryOpenApi
=
new
QueryWrapper
<>();
queryOpenApi
.
eq
(
"es_database"
,
req
.
getEsDatabase
());
queryOpenApi
.
eq
(
"es_database"
,
req
.
getEsDatabase
());
...
@@ -200,7 +211,7 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -200,7 +211,7 @@ public class ProducerServiceImpl implements ProducerService {
fields
.
setFieldName
(
jsonObject
.
get
(
"name"
).
toString
());
fields
.
setFieldName
(
jsonObject
.
get
(
"name"
).
toString
());
fields
.
setFieldType
(
jsonObject
.
get
(
"type"
).
toString
());
fields
.
setFieldType
(
jsonObject
.
get
(
"type"
).
toString
());
fields
.
setFieldDesc
(
jsonObject
.
get
(
"desc"
).
toString
());
fields
.
setFieldDesc
(
jsonObject
.
get
(
"desc"
).
toString
());
//
fields.setCreateUser(currentUser.getUserName());
fields
.
setCreateUser
(
currentUser
.
getUserName
());
listApiEsFields
.
add
(
fields
);
listApiEsFields
.
add
(
fields
);
}
}
//保存字段表中的字段信息
//保存字段表中的字段信息
...
@@ -213,7 +224,9 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -213,7 +224,9 @@ public class ProducerServiceImpl implements ProducerService {
if
(
null
!=
dataSource
)
{
if
(
null
!=
dataSource
)
{
redisTemplate
.
opsForValue
().
set
(
TagConstants
.
OPEN_API_HANDLER_INFO_NAMESPACE
+
redisValueOfKey
,
req
.
getHandleType
());
redisTemplate
.
opsForValue
().
set
(
TagConstants
.
OPEN_API_HANDLER_INFO_NAMESPACE
+
redisValueOfKey
,
req
.
getHandleType
());
//es相关信息
//es相关信息
redisTemplate
.
opsForValue
().
set
(
TagConstants
.
OPEN_API_ESTAG_INFO_NAMESPACE
+
redisValueOfKey
,
req
);
//redisTemplate.opsForValue().set(TagConstants.OPEN_API_ESTAG_INFO_NAMESPACE + redisValueOfKey, req);
//存入调用的基本ApiKey信息
redisTemplate
.
opsForValue
().
set
(
redisValueOfKey
,
req
);
//esjdbc 连接地址 用于接口中调用获取es数据
//esjdbc 连接地址 用于接口中调用获取es数据
redisTemplate
.
opsForValue
().
set
(
TagConstants
.
OPEN_API_ESTAG_JDBC_INFO_NAMESPACE
+
redisValueOfKey
,
dataSource
.
getJdbcUrl
());
redisTemplate
.
opsForValue
().
set
(
TagConstants
.
OPEN_API_ESTAG_JDBC_INFO_NAMESPACE
+
redisValueOfKey
,
dataSource
.
getJdbcUrl
());
}
}
...
@@ -244,21 +257,31 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -244,21 +257,31 @@ public class ProducerServiceImpl implements ProducerService {
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRED
)
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRED
)
public
Result
saveInterfaceAPi
(
ApiInterfaceReq
req
)
{
public
Result
saveInterfaceAPi
(
ApiInterfaceReq
req
)
{
SysUserDto
currentUser
=
getLoginUser
(
RedisMessageConstant
.
SENDTYPE_LOGIN_SYS
);
if
(
null
==
currentUser
)
{
return
Result
.
of_error
(
ResultMsg
.
USER_NOT_LOGIN
);
}
QueryWrapper
<
ApiInterfaceFile
>
query
=
new
QueryWrapper
<>();
QueryWrapper
<
ApiInterfaceFile
>
query
=
new
QueryWrapper
<>();
//
query.eq("project_id", req.getProjectId());
query
.
eq
(
"project_id"
,
req
.
getProjectId
());
query
.
eq
(
"
id"
,
req
.
getFile
Id
());
query
.
eq
(
"
parent_id"
,
req
.
getParent
Id
());
ApiInterfaceFile
file
=
apiInterfaceFileMapper
.
selectOne
(
query
);
ApiInterfaceFile
file
=
apiInterfaceFileMapper
.
selectOne
(
query
);
if
(
null
==
file
)
{
if
(
null
==
file
)
{
//查询父类是否存在
ApiInterfaceFile
parentId
=
apiInterfaceFileMapper
.
selectOne
(
new
QueryWrapper
<
ApiInterfaceFile
>().
eq
(
"parent_id"
,
req
.
getParentId
()));
if
(
null
==
parentId
&&
"0"
.
equals
(
req
.
getParentId
())){
file
=
new
ApiInterfaceFile
();
file
=
new
ApiInterfaceFile
();
file
.
setProjectId
(
req
.
getProjectId
());
file
.
setProjectId
(
req
.
getProjectId
());
file
.
setFileSource
(
"1"
);
//dmp
file
.
setFileSource
(
"1"
);
//dmp
file
.
setFileType
(
"1"
);
//文件夹
file
.
setParentId
(
"0"
);
file
.
setStatus
(
GeneralStatusTypeEnum
.
VALID
.
name
());
file
.
setStatus
(
GeneralStatusTypeEnum
.
VALID
.
name
());
file
.
setCreateUser
(
""
);
file
.
setCreateUser
(
""
);
file
.
setRemark
(
"创建文件夹"
);
file
.
setRemark
(
"创建文件夹"
);
if
(
apiInterfaceFileMapper
.
insert
(
file
)
==
0
){
if
(
apiInterfaceFileMapper
.
insert
(
file
)
==
0
){
throw
ResponseException
.
of_error
(
"创建文件夹失败!"
);
throw
ResponseException
.
of_error
(
"创建文件夹失败!"
);
}
}
}
else
{
throw
ResponseException
.
of
(
ResultCode
.
FAILURE
,
"父类文件信息不存在!"
);
}
}
}
//生成ApiKey
//生成ApiKey
String
apiKey
=
RandomUtil
.
getStringRandom
(
16
);
String
apiKey
=
RandomUtil
.
getStringRandom
(
16
);
...
@@ -268,7 +291,7 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -268,7 +291,7 @@ public class ProducerServiceImpl implements ProducerService {
apiInterface
.
setStatus
(
ApiStatusEnum
.
ISSUE
.
name
());
//发布
apiInterface
.
setStatus
(
ApiStatusEnum
.
ISSUE
.
name
());
//发布
apiInterface
.
setFileId
(
file
.
getId
());
apiInterface
.
setFileId
(
file
.
getId
());
BeanUtils
.
copyProperties
(
req
,
apiInterface
);
BeanUtils
.
copyProperties
(
req
,
apiInterface
);
//
apiInterface.setCreateUser(currentUser.getUserName());
apiInterface
.
setCreateUser
(
currentUser
.
getUserName
());
Long
timeout
=
Long
.
parseLong
(
req
.
getTimeout
());
Long
timeout
=
Long
.
parseLong
(
req
.
getTimeout
());
if
(
timeout
==
null
||
timeout
==
0
)
{
if
(
timeout
==
null
||
timeout
==
0
)
{
apiInterface
.
setTimeout
(
String
.
valueOf
(
defaultTimeout
));
apiInterface
.
setTimeout
(
String
.
valueOf
(
defaultTimeout
));
...
@@ -291,9 +314,9 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -291,9 +314,9 @@ public class ProducerServiceImpl implements ProducerService {
*/
*/
@Override
@Override
public
Result
saveUpdateAPiInfo
(
MakeApiSaveInfoReq
req
)
{
public
Result
saveUpdateAPiInfo
(
MakeApiSaveInfoReq
req
)
{
SysUserDto
currentUser
=
(
SysUserDto
)
redisTemplate
.
opsForValue
().
get
(
"USER"
+
RedisMessageConstant
.
SENDTYPE_LOGIN_SYS
);
SysUserDto
currentUser
=
getLoginUser
(
RedisMessageConstant
.
SENDTYPE_LOGIN_SYS
);
if
(
null
==
currentUser
)
{
if
(
null
==
currentUser
)
{
return
Result
.
of_error
(
ResultMsg
.
USER_NOT_
EXIST
);
return
Result
.
of_error
(
ResultMsg
.
USER_NOT_
LOGIN
);
}
}
ApiInterface
apiInterface
=
apiInterfaceMapper
.
selectById
(
req
.
getId
());
ApiInterface
apiInterface
=
apiInterfaceMapper
.
selectById
(
req
.
getId
());
if
(
null
==
apiInterface
)
{
if
(
null
==
apiInterface
)
{
...
@@ -337,7 +360,7 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -337,7 +360,7 @@ public class ProducerServiceImpl implements ProducerService {
}
}
apiInterface
.
setUpdateDate
(
new
Date
());
apiInterface
.
setUpdateDate
(
new
Date
());
apiInterface
.
setTimeout
(
req
.
getTimeout
());
apiInterface
.
setTimeout
(
req
.
getTimeout
());
apiInterface
.
setUpdateUser
(
""
);
apiInterface
.
setUpdateUser
(
currentUser
.
getUserName
()
);
int
result
=
apiInterfaceMapper
.
updateById
(
apiInterface
);
int
result
=
apiInterfaceMapper
.
updateById
(
apiInterface
);
if
(
result
>
0
)
{
if
(
result
>
0
)
{
return
Result
.
of_success
(
ResultMsg
.
UPDATE_SUCCESS
);
return
Result
.
of_success
(
ResultMsg
.
UPDATE_SUCCESS
);
...
@@ -487,4 +510,18 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -487,4 +510,18 @@ public class ProducerServiceImpl implements ProducerService {
}
}
return
Result
.
of_success
(
resp
);
return
Result
.
of_success
(
resp
);
}
}
/**
* 获取当前登录用户
* @param userType
* @return
*/
protected
SysUserDto
getLoginUser
(
String
userType
){
SysUserDto
currentUser
=
(
SysUserDto
)
redisTemplate
.
opsForValue
().
get
(
"USER_"
+
RedisMessageConstant
.
SENDTYPE_LOGIN_SYS
);
if
(
null
!=
currentUser
){
return
currentUser
;
}
return
null
;
}
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/request/ApiQueryService.java
View file @
e5ac3d62
package
com
.
jz
.
dm
.
service
.
request
;
package
com
.
jz
.
dm
.
service
.
request
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jz.common.utils.HttpsUtils
;
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.util.OpenApiRequest
;
import
com.jz.dm.common.util.OpenApiRequest
;
import
com.jz.dm.common.util.OpenApiResponse
;
import
com.jz.dm.common.util.OpenApiResponse
;
...
@@ -15,6 +17,8 @@ import org.springframework.stereotype.Service;
...
@@ -15,6 +17,8 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.Map
;
/**
/**
* @author ZC
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service.request
* @PACKAGE_NAME: com.jz.dm.service.request
...
@@ -39,6 +43,10 @@ public class ApiQueryService implements OpenApiService {
...
@@ -39,6 +43,10 @@ public class ApiQueryService implements OpenApiService {
@Autowired
@Autowired
private
ApiInterfaceService
apiInterfaceService
;
private
ApiInterfaceService
apiInterfaceService
;
@Autowired
private
RedisUtils
redisUtils
;
@Autowired
private
HttpsUtils
httpsUtils
;
@Override
@Override
@ApiLogAspect
(
description
=
"API请求日志"
)
@ApiLogAspect
(
description
=
"API请求日志"
)
@AccessLimit
(
limit
=
10000
,
sec
=
1
)
@AccessLimit
(
limit
=
10000
,
sec
=
1
)
...
@@ -57,6 +65,22 @@ public class ApiQueryService implements OpenApiService {
...
@@ -57,6 +65,22 @@ public class ApiQueryService implements OpenApiService {
break
;
break
;
case
"CUSTOM_QUERY"
:
//自定义查询(三方查询)
case
"CUSTOM_QUERY"
:
//自定义查询(三方查询)
break
;
break
;
case
"DATA_BANK_QUERY"
:
//数据银行查询
String
reqParams
=
parameter
.
getString
(
"reqParams"
);
if
(
StringUtils
.
isNotBlank
(
reqParams
)){
String
apiInterface
=
redisUtils
.
get
(
request
.
getAppKey
());
if
(
null
!=
apiInterface
){
//存在
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
apiInterface
);
String
requestParam
=
jsonObject
.
getString
(
"requestParam"
);
String
targetUrl
=
jsonObject
.
getString
(
"targetUrl"
);
Map
param
=
(
Map
)
JSONObject
.
parseObject
(
requestParam
);
String
respResult
=
httpsUtils
.
doGet
(
targetUrl
,
param
);
response
.
setAttribute
(
respResult
);
}
else
{
//不存在查询数据库
//apiInterfaceService.getReqTargetInfo(request.getAppKey());
}
}
break
;
case
"DATA_BAG_QUERY"
:
//数据包查询
case
"DATA_BAG_QUERY"
:
//数据包查询
break
;
break
;
default
:
default
:
...
...
jz-dm-apigateway/src/test/java/com/jz/dm/gateway/orther/TestHttpReq.java
View file @
e5ac3d62
...
@@ -39,6 +39,7 @@ public class TestHttpReq extends SpringTestCase {
...
@@ -39,6 +39,7 @@ public class TestHttpReq extends SpringTestCase {
headers
.
put
(
"Charsert"
,
"UTF-8"
);
headers
.
put
(
"Charsert"
,
"UTF-8"
);
headers
.
put
(
"Accept"
,
"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
);
headers
.
put
(
"Accept"
,
"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
);
String
response
=
httpsUtils
.
submitPost
(
baseUrlPost
,
jsonObject
,
headers
);
String
response
=
httpsUtils
.
submitPost
(
baseUrlPost
,
jsonObject
,
headers
);
System
.
out
.
println
(
response
);
System
.
out
.
println
(
response
);
}
}
}
}
jz-dm-apigateway/src/test/java/com/jz/dm/gateway/orther/TestMakeApi.java
View file @
e5ac3d62
package
com
.
jz
.
dm
.
gateway
.
orther
;
package
com
.
jz
.
dm
.
gateway
.
orther
;
import
com.jz.common.utils.WebUtils
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jz.common.utils.HttpsUtils
;
import
com.jz.dm.gateway.SpringTestCase
;
import
com.jz.dm.gateway.SpringTestCase
;
import
com.jz.dm.service.ProducerService
;
import
com.jz.dm.service.ProducerService
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -23,19 +24,21 @@ public class TestMakeApi extends SpringTestCase {
...
@@ -23,19 +24,21 @@ public class TestMakeApi extends SpringTestCase {
@Autowired
@Autowired
private
ProducerService
producerService
;
private
ProducerService
producerService
;
@Autowired
private
HttpsUtils
httpsUtils
;
@Test
@Test
public
void
testApiMake
()
{
public
void
testApiMake
()
{
Map
headers
=
new
HashMap
<
String
,
String
>();
Map
headers
=
new
HashMap
<
String
,
String
>();
headers
.
put
(
"Content-Type"
,
"application/json;charset=UTF-8"
);
headers
.
put
(
"Content-Type"
,
"application/json;charset=UTF-8"
);
headers
.
put
(
"User-Agent"
,
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36"
);
headers
.
put
(
"User-Agent"
,
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36"
);
Map
params
=
new
HashMap
<
String
,
String
>
();
JSONObject
params
=
new
JSONObject
();
params
.
put
(
"apiType"
,
"2"
);
params
.
put
(
"apiType"
,
"2"
);
params
.
put
(
"apiKey"
,
"www.q99sss9"
);
params
.
put
(
"apiKey"
,
"www.q99sss9"
);
params
.
put
(
"apiProtocl"
,
"HTTPS"
);
params
.
put
(
"apiProtocl"
,
"HTTPS"
);
params
.
put
(
"type"
,
"1"
);
params
.
put
(
"type"
,
"1"
);
try
{
try
{
String
result
=
WebUtils
.
p
ost
(
url
,
params
,
headers
);
String
result
=
httpsUtils
.
submitP
ost
(
url
,
params
,
headers
);
System
.
out
.
println
(
"接受到的结果为:"
+
result
);
System
.
out
.
println
(
"接受到的结果为:"
+
result
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
...
jz-dm-common/src/main/java/com/jz/common/constant/ResultMsg.java
View file @
e5ac3d62
...
@@ -78,9 +78,9 @@ public enum ResultMsg {
...
@@ -78,9 +78,9 @@ public enum ResultMsg {
*/
*/
INVALID_USER
(
"用户错误"
),
INVALID_USER
(
"用户错误"
),
/**
/**
* 用户
已报备
* 用户
未登录
*/
*/
USER_
REPORTED
(
"用户已报备
"
),
USER_
NOT_LOGIN
(
"用户未登录
"
),
/**
/**
* 用户名错误
* 用户名错误
...
...
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