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
7893c12f
Commit
7893c12f
authored
Dec 31, 2020
by
zhangc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改制作Api接口
parent
50aebbfb
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
81 additions
and
51 deletions
+81
-51
api_gateway.sql
database/zc/api_gateway.sql
+8
-5
GeneralStatusTypeEnum.java
...in/java/com/jz/dm/common/enums/GeneralStatusTypeEnum.java
+9
-1
GatewayController.java
...src/main/java/com/jz/dm/controller/GatewayController.java
+4
-2
ApiInterface.java
...y/src/main/java/com/jz/dm/models/domian/ApiInterface.java
+5
-0
ApiInterfaceFile.java
...c/main/java/com/jz/dm/models/domian/ApiInterfaceFile.java
+12
-6
ApiReqLog.java
...eway/src/main/java/com/jz/dm/models/domian/ApiReqLog.java
+5
-0
ApiInterfaceReq.java
.../main/java/com/jz/dm/models/req/make/ApiInterfaceReq.java
+8
-8
MakeBigDataApiReq.java
...ain/java/com/jz/dm/models/req/make/MakeBigDataApiReq.java
+3
-3
MakeCustomApiReq.java
...main/java/com/jz/dm/models/req/make/MakeCustomApiReq.java
+6
-6
MakeDataBankApiReq.java
...in/java/com/jz/dm/models/req/make/MakeDataBankApiReq.java
+5
-5
ProducerServiceImpl.java
...main/java/com/jz/dm/service/impl/ProducerServiceImpl.java
+16
-15
No files found.
database/zc/api_gateway.sql
View file @
7893c12f
...
...
@@ -10,9 +10,10 @@ CREATE TABLE `t_api_interface` (
`api_type`
varchar
(
50
)
NULL
DEFAULT
''
COMMENT
'api类型:1 实时接入 2 数据银行制作API, 3 数据银行制作数据包 6标签查询 9自定义'
,
`api_function`
varchar
(
200
)
DEFAULT
NULL
COMMENT
'接口功能'
,
`status`
varchar
(
50
)
NOT
NULL
COMMENT
'状态(DRAFT-草稿 ISSUE-发布 OUTMODED-过时 4FREEZE-冻结 EXPIRY-失效)'
,
`version`
varchar
(
20
)
DEFAULT
NULL
COMMENT
'版本号'
,
`version`
varchar
(
20
)
DEFAULT
'1.0'
COMMENT
'版本号'
,
`sign_type`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'加密方式: MD5 RSA'
,
`timeout`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'超时时间'
,
`file_id`
bigint
(
20
)
NOT
NULL
COMMENT
'文件夹id'
,
`is_test`
tinyint
(
2
)
NOT
NULL
DEFAULT
'0'
COMMENT
'是否测试数据:0 否,1 是'
,
`remark`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'备注'
,
`create_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
COMMENT
'创建时间'
,
...
...
@@ -42,18 +43,19 @@ CREATE TABLE `t_api_interface_custom` (
`update_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
ON
UPDATE
CURRENT_TIMESTAMP
COMMENT
'修改时间'
,
`update_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'更新人'
,
`is_deleted`
tinyint
(
2
)
unsigned
NOT
NULL
DEFAULT
'0'
COMMENT
'是否删除'
,
PRIMARY
KEY
(
`id`
)
,
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
ROW_FORMAT
=
DYNAMIC
COMMENT
=
'api自定义信息表'
;
#
api
api
文件表
DROP
TABLE
IF
EXISTS
`t_api_interface_file`
;
CREATE
TABLE
`t_api_interface_file`
(
`id`
bigint
(
20
)
unsigned
NOT
NULL
AUTO_INCREMENT
COMMENT
'api文件表自增ID'
,
`
api_interface_id`
bigint
(
20
)
NOT
NULL
COMMENT
'api表自增id
'
,
`
api_key`
varchar
(
200
)
NOT
NULL
COMMENT
'api唯一标识
'
,
`
project_id`
bigint
(
20
)
NOT
NULL
COMMENT
'项目编号
'
,
`
file_source`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'文件来源:,1 dmp, 2 数据银行
'
,
`file_type`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'文件类型'
,
`file_name`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'文件名称'
,
`file_en_name`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'文件英文名称'
,
`parent_id`
bigint
(
20
)
NOT
NULL
COMMENT
'父类id'
,
`status`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'VALID 有效,UNVALID 无效'
,
`remark`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'备注'
,
`create_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
COMMENT
'创建时间'
,
...
...
@@ -61,7 +63,7 @@ CREATE TABLE `t_api_interface_file` (
`update_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
ON
UPDATE
CURRENT_TIMESTAMP
COMMENT
'修改时间'
,
`update_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'更新人'
,
`is_deleted`
tinyint
(
2
)
unsigned
NOT
NULL
DEFAULT
'0'
COMMENT
'是否删除'
,
PRIMARY
KEY
(
`id`
)
,
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
ROW_FORMAT
=
DYNAMIC
COMMENT
=
'api文件表'
;
#
api
组织信息表
...
...
@@ -129,6 +131,7 @@ CREATE TABLE `t_api_req_log` (
`trans_mode`
varchar
(
20
)
DEFAULT
NULL
COMMENT
'传输方式:POST,GET'
,
`request_token`
varchar
(
64
)
DEFAULT
NULL
COMMENT
'客户请求token'
,
`request_time`
datetime
DEFAULT
NULL
COMMENT
'请求时间'
,
`remark`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'状态:SUCCEED 请求成功, FAIL 请求失败'
,
`remark`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'备注'
,
`create_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
COMMENT
'创建时间'
,
`create_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'创建人'
,
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/common/enums/GeneralStatusTypeEnum.java
View file @
7893c12f
...
...
@@ -29,7 +29,15 @@ public enum GeneralStatusTypeEnum {
/**
* 无效
*/
UN_VALID
(
"无效"
);
UN_VALID
(
"无效"
),
/**
* 成功'
*/
SUCCEED
(
"成功"
),
/**
* 失败'
*/
FAIL
(
"失败"
);
private
String
text
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/controller/GatewayController.java
View file @
7893c12f
...
...
@@ -8,6 +8,7 @@ import com.jz.dm.gateway.GatewayService;
import
com.jz.dm.models.enity.GatewayRequest
;
import
com.jz.dm.models.enity.GatewayResponse
;
import
com.jz.dm.models.enity.RequestContext
;
import
io.swagger.annotations.Api
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.CollectionUtils
;
...
...
@@ -23,7 +24,9 @@ import java.util.Map;
* 网关请求
* @author zc
*/
@RestController
(
"/api"
)
@RestController
@RequestMapping
(
"api/"
)
@Api
(
tags
=
{
"api请求controller"
})
public
class
GatewayController
{
@Autowired
...
...
@@ -69,6 +72,5 @@ public class GatewayController {
result
.
put
(
"data"
,
gatewayResponse
.
getEncryptData
());
}
}
result
.
put
(
"sign"
,
gatewayResponse
.
getSign
());
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiInterface.java
View file @
7893c12f
...
...
@@ -93,5 +93,10 @@ public class ApiInterface extends BaseObject implements Serializable {
*/
@TableField
(
"is_test"
)
private
Integer
isTest
;
/**
* 文件夹id
*/
@TableField
(
"file_id"
)
private
Long
fileId
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiInterfaceFile.java
View file @
7893c12f
...
...
@@ -25,16 +25,16 @@ public class ApiInterfaceFile extends BaseObject implements Serializable {
/**
*
api唯一标识
*
项目编号
*/
@TableField
(
"
api_key
"
)
private
String
apiKey
;
@TableField
(
"
project_id
"
)
private
String
projectId
;
/**
*
apiInterfaceId
*
文件来源:1 DMP 2 数据银行
*/
@TableField
(
"
api_interface_id
"
)
private
Long
apiInterfaceId
;
@TableField
(
"
file_source
"
)
private
String
fileSource
;
/**
* 文件类型
...
...
@@ -47,6 +47,12 @@ public class ApiInterfaceFile extends BaseObject implements Serializable {
*/
@TableField
(
"file_name"
)
private
String
fileName
;
/**
* 父类id
*/
@TableField
(
"parent_id"
)
private
String
parentId
;
/**
* 文件英文名称
*/
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiReqLog.java
View file @
7893c12f
...
...
@@ -88,4 +88,9 @@ public class ApiReqLog extends BaseObject implements Serializable {
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
requestTime
;
/**
* 请求状态: SUCCEED 成功 ,FAIL 失败
*/
@TableField
(
"status"
)
private
String
status
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/make/ApiInterfaceReq.java
View file @
7893c12f
...
...
@@ -22,15 +22,15 @@ public class ApiInterfaceReq {
@NotNull
(
message
=
"api类型不能为空"
)
public
String
apiType
;
@ApiModelProperty
(
value
=
"apiId 等价于apiKey"
,
required
=
true
)
/*
@ApiModelProperty(value = "apiId 等价于apiKey",required = true)
@NotNull(message = "apiId不能为空")
public
String
apiId
;
public String apiId;
*/
@ApiModelProperty
(
value
=
"接口描述"
,
required
=
false
)
public
String
apiDesc
;
/*
@ApiModelProperty(value = "api版本",required = false)
public
String
version
;
public String version;
*/
@ApiModelProperty
(
value
=
"传输方式"
,
required
=
true
)
@NotNull
(
message
=
"传输方式不能为空"
)
...
...
@@ -54,11 +54,11 @@ public class ApiInterfaceReq {
@ApiModelProperty
(
value
=
"列"
,
required
=
false
)
public
String
columnCode
;
@ApiModelProperty
(
value
=
"api名称"
,
required
=
false
)
/*
@ApiModelProperty(value = "api名称",required = false)
public String apiName;
@ApiModelProperty
(
value
=
"状态"
,
required
=
false
)
public
String
status
;
*/
/*
@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/MakeBigDataApiReq.java
View file @
7893c12f
...
...
@@ -27,9 +27,9 @@ public class MakeBigDataApiReq implements Serializable {
@NotNull
(
message
=
"apiType不能为空"
)
private
String
apiType
;
@ApiModelProperty
(
value
=
"apiId 等价于apiKey"
,
required
=
true
)
@NotNull
(
message
=
"apiId不能为空"
)
public
String
apiId
;
//
@ApiModelProperty(value = "apiId 等价于apiKey",required = true)
//
@NotNull(message = "apiId不能为空")
//
public String apiId;
@ApiModelProperty
(
value
=
"数据源Id"
,
required
=
true
)
@NotNull
(
message
=
"数据源Id不能为空"
)
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/make/MakeCustomApiReq.java
View file @
7893c12f
...
...
@@ -23,15 +23,15 @@ public class MakeCustomApiReq implements Serializable {
@NotNull
(
message
=
"api类型不能为空"
)
public
String
apiType
;
@ApiModelProperty
(
value
=
"apiId 等价于apiKey"
,
required
=
true
)
/*
@ApiModelProperty(value = "apiId 等价于apiKey",required = true)
@NotNull(message = "apiId不能为空")
public
String
apiId
;
public String apiId;
*/
@ApiModelProperty
(
value
=
"接口描述"
,
required
=
false
)
public
String
apiDesc
;
@ApiModelProperty
(
value
=
"api版本"
,
required
=
false
)
public
String
version
;
/*
@ApiModelProperty(value = "api版本",required = false)
public String version;
*/
@ApiModelProperty
(
value
=
"传输方式"
,
required
=
true
)
@NotNull
(
message
=
"传输方式不能为空"
)
...
...
@@ -55,8 +55,8 @@ public class MakeCustomApiReq implements Serializable {
@ApiModelProperty
(
value
=
"列"
,
required
=
false
)
public
String
columnCode
;
@ApiModelProperty
(
value
=
"状态"
,
required
=
false
)
public
String
status
;
/*
@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/MakeDataBankApiReq.java
View file @
7893c12f
...
...
@@ -24,15 +24,15 @@ public class MakeDataBankApiReq implements Serializable {
@NotNull
(
message
=
"api类型不能为空"
)
public
String
apiType
;
@ApiModelProperty
(
value
=
"apiKey 等价于apiId"
,
required
=
true
)
@NotNull
(
message
=
"apiKey不能为空"
)
public
String
apiKey
;
//
@ApiModelProperty(value = "apiKey 等价于apiId",required = true)
//
@NotNull(message = "apiKey不能为空")
//
public String apiKey;
@ApiModelProperty
(
value
=
"接口描述"
,
required
=
false
)
public
String
apiDesc
;
@ApiModelProperty
(
value
=
"api版本"
,
required
=
false
)
public
String
version
;
//
@ApiModelProperty(value = "api版本",required = false)
//
public String version;
@ApiModelProperty
(
value
=
"传输方式(1为HTTPS,2为HTTP)"
,
required
=
true
)
@NotNull
(
message
=
"传输方式不能为空"
)
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/ProducerServiceImpl.java
View file @
7893c12f
...
...
@@ -6,12 +6,14 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.jz.common.bean.SysUserDto
;
import
com.jz.common.constant.RedisMessageConstant
;
import
com.jz.common.constant.ResultMsg
;
import
com.jz.common.exception.ResponseException
;
import
com.jz.common.utils.RedisUtils
;
import
com.jz.common.utils.Result
;
import
com.jz.dm.common.constant.TagConstants
;
import
com.jz.dm.common.enums.apiInterface.ApiStatusEnum
;
import
com.jz.dm.common.util.RandomUtil
;
import
com.jz.dm.common.util.WebUtils
;
import
com.jz.dm.mapper.*
;
import
com.jz.dm.models.domian.*
;
...
...
@@ -98,16 +100,13 @@ public class ProducerServiceImpl implements ProducerService {
public
Result
addCustomApi
(
MakeCustomApiReq
req
)
{
ApiInterfaceReq
makeBigDataApiReq
=
new
ApiInterfaceReq
();
makeBigDataApiReq
.
setApiType
(
req
.
getApiType
());
makeBigDataApiReq
.
setApiId
(
req
.
getApiId
());
makeBigDataApiReq
.
setApiDesc
(
req
.
getApiDesc
());
makeBigDataApiReq
.
setVersion
(
req
.
getVersion
());
makeBigDataApiReq
.
setTransMode
(
req
.
getTransMode
());
makeBigDataApiReq
.
setType
(
req
.
getType
());
makeBigDataApiReq
.
setTargetUrl
(
req
.
getTargetUrl
());
makeBigDataApiReq
.
setTimeout
(
req
.
getTimeout
());
makeBigDataApiReq
.
setApiFunction
(
req
.
getApiFunction
());
makeBigDataApiReq
.
setColumnCode
(
req
.
getColumnCode
());
makeBigDataApiReq
.
setStatus
(
req
.
getStatus
());
return
saveInterfaceAPi
(
makeBigDataApiReq
);
}
...
...
@@ -119,12 +118,19 @@ public class ProducerServiceImpl implements ProducerService {
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRES_NEW
)
public
Result
addDataBankApiInfo
(
MakeDataBankApiReq
req
)
{
List
<
ApiInterfaceFile
>
fileSource
=
apiInterfaceFileMapper
.
selectList
(
new
QueryWrapper
<
ApiInterfaceFile
>().
eq
(
"file_source"
,
"2"
));
if
(
fileSource
.
size
()
==
0
||
fileSource
.
size
()
>=
2
){
return
Result
.
of_error
(
"文件夹信息异常!"
);
}
if
(
StringUtils
.
isNotBlank
(
req
.
getApiType
())
&&
"2"
.
equals
(
req
.
getApiType
())){
//数据银行制作API
ApiInterface
anInterface
=
new
ApiInterface
();
anInterface
.
setCreateUser
(
""
);
anInterface
.
setStatus
(
"2"
);
//发布
anInterface
.
setSignType
(
req
.
getType
());
//加密类型
anInterface
.
setVersion
(
"1.0"
);
anInterface
.
setApiKey
(
RandomUtil
.
getStringRandom
(
16
));
//apiKey
anInterface
.
setFileId
(
fileSource
.
get
(
0
).
getId
());
BeanUtils
.
copyProperties
(
req
,
anInterface
);
int
resIn
=
apiInterfaceMapper
.
insert
(
anInterface
);
ApiInterfaceCustom
interfaceCustom
=
new
ApiInterfaceCustom
();
...
...
@@ -142,15 +148,12 @@ public class ProducerServiceImpl implements ProducerService {
}
ApiInterfaceReq
makeBigDataApiReq
=
new
ApiInterfaceReq
();
makeBigDataApiReq
.
setApiType
(
req
.
getApiType
());
makeBigDataApiReq
.
setApiId
(
req
.
getApiKey
());
makeBigDataApiReq
.
setApiDesc
(
req
.
getApiDesc
());
makeBigDataApiReq
.
setVersion
(
req
.
getVersion
());
makeBigDataApiReq
.
setTransMode
(
req
.
getApiProtocl
());
makeBigDataApiReq
.
setType
(
req
.
getType
());
makeBigDataApiReq
.
setTargetUrl
(
req
.
getTargetUrl
());
makeBigDataApiReq
.
setTimeout
(
req
.
getTimeout
());
makeBigDataApiReq
.
setApiFunction
(
req
.
getApiFunction
());
makeBigDataApiReq
.
setStatus
(
"1"
);
saveInterfaceAPi
(
makeBigDataApiReq
);
}
return
Result
.
of_success
(
ResultMsg
.
INSERT_SUCCESS
);
...
...
@@ -212,7 +215,7 @@ public class ProducerServiceImpl implements ProducerService {
}
ApiSyncingDatasource
dataSource
=
apiSyncingDatasourceMapper
.
selectById
(
req
.
getEsDataSource
());
//api信息在redis中的key
String
redisValueOfKey
=
req
.
getApiId
(
);
String
redisValueOfKey
=
RandomUtil
.
getStringRandom
(
16
);
if
(
null
!=
dataSource
)
{
redisTemplate
.
opsForValue
().
set
(
TagConstants
.
OPEN_API_HANDLER_INFO_NAMESPACE
+
redisValueOfKey
,
req
.
getHandleType
());
//es相关信息
...
...
@@ -247,14 +250,12 @@ public class ProducerServiceImpl implements ProducerService {
@Override
public
Result
saveInterfaceAPi
(
ApiInterfaceReq
req
)
{
ApiInterface
apiInterface
=
new
ApiInterface
();
apiInterface
.
setApiKey
(
req
.
getApiId
());
apiInterface
.
setApiName
(
req
.
getApiName
());
apiInterface
.
setApiKey
(
RandomUtil
.
getStringRandom
(
16
));
apiInterface
.
setApiDesc
(
req
.
getApiDesc
());
apiInterface
.
setApiProtocl
(
req
.
getTransMode
());
//传输方式 https http
apiInterface
.
setTargetUrl
(
req
.
getTargetUrl
());
apiInterface
.
setStatus
(
req
.
getStatus
());
apiInterface
.
setStatus
(
"2"
);
//发布
apiInterface
.
setApiFunction
(
req
.
getApiFunction
());
apiInterface
.
setVersion
(
req
.
getVersion
());
apiInterface
.
setSignType
(
req
.
getType
());
//加密方式
apiInterface
.
setApiType
(
req
.
getApiType
());
//api类型
// apiInterface.setCreateUser(currentUser.getUserName());
...
...
@@ -282,10 +283,10 @@ public class ProducerServiceImpl implements ProducerService {
*/
@Override
public
Result
saveUpdateAPiInfo
(
MakeApiSaveInfoReq
req
)
{
//
SysUserDto currentUser = (SysUserDto)redisTemplate.opsForValue().get("user"+ RedisMessageConstant.SENDTYPE_LOGIN_SYS);
//
if (null == currentUser){
//
return Result.of_error(ResultMsg.USER_NOT_EXIST);
//
}
SysUserDto
currentUser
=
(
SysUserDto
)
redisTemplate
.
opsForValue
().
get
(
"user"
+
RedisMessageConstant
.
SENDTYPE_LOGIN_SYS
);
if
(
null
==
currentUser
){
return
Result
.
of_error
(
ResultMsg
.
USER_NOT_EXIST
);
}
ApiInterface
apiInterface
=
apiInterfaceMapper
.
selectById
(
req
.
getId
());
if
(
null
==
apiInterface
)
{
return
Result
.
of_error
(
ResultMsg
.
DATA_NOT_FOUND
);
...
...
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