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
86d6f621
Commit
86d6f621
authored
Jan 28, 2021
by
zhangc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加api制作相关接口,修改组织管理额相关接口
parent
7f2c7f50
Changes
36
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
36 changed files
with
710 additions
and
233 deletions
+710
-233
api_gateway.sql
database/zc/api_gateway.sql
+6
-6
GatewayResultCode.java
...c/main/java/com/jz/dm/common/enums/GatewayResultCode.java
+3
-0
AuthTypeEnum.java
...c/main/java/com/jz/dm/common/enums/auth/AuthTypeEnum.java
+1
-1
DateUtil.java
...gateway/src/main/java/com/jz/dm/common/util/DateUtil.java
+18
-0
RandomUtil.java
...teway/src/main/java/com/jz/dm/common/util/RandomUtil.java
+5
-0
ApiInterfaceController.java
...ain/java/com/jz/dm/controller/ApiInterfaceController.java
+21
-5
AuthController.java
...ay/src/main/java/com/jz/dm/controller/AuthController.java
+10
-0
ProducerController.java
...rc/main/java/com/jz/dm/controller/ProducerController.java
+26
-3
AuthFilter.java
...apigateway/src/main/java/com/jz/dm/filter/AuthFilter.java
+13
-5
ApiInterfaceMapper.java
...ay/src/main/java/com/jz/dm/mapper/ApiInterfaceMapper.java
+15
-0
ApiAuth.java
...ateway/src/main/java/com/jz/dm/models/domian/ApiAuth.java
+9
-0
ApiInterface.java
...y/src/main/java/com/jz/dm/models/domian/ApiInterface.java
+11
-14
ApiInterfaceCustom.java
...main/java/com/jz/dm/models/domian/ApiInterfaceCustom.java
+5
-2
ApiServiceApplyDto.java
...rc/main/java/com/jz/dm/models/dto/ApiServiceApplyDto.java
+44
-0
AuthUserApiReq.java
...c/main/java/com/jz/dm/models/req/auth/AuthUserApiReq.java
+2
-2
ServiceAuthReq.java
...c/main/java/com/jz/dm/models/req/auth/ServiceAuthReq.java
+30
-0
CreateFolderReq.java
...ain/java/com/jz/dm/models/req/folder/CreateFolderReq.java
+40
-0
MakeBigDataApiReq.java
...ain/java/com/jz/dm/models/req/make/MakeBigDataApiReq.java
+0
-83
OrganizationManageListQueryReq.java
...eq/organizationManage/OrganizationManageListQueryReq.java
+5
-0
ApiInterfaceReq.java
...n/java/com/jz/dm/models/req/producer/ApiInterfaceReq.java
+8
-9
MakeBigDataApiReq.java
...java/com/jz/dm/models/req/producer/MakeBigDataApiReq.java
+81
-0
MakeDataBankApiReq.java
...ava/com/jz/dm/models/req/producer/MakeDataBankApiReq.java
+1
-1
MakeRealCustomApiReq.java
...a/com/jz/dm/models/req/producer/MakeRealCustomApiReq.java
+1
-1
ServiceIssueReq.java
...n/java/com/jz/dm/models/req/producer/ServiceIssueReq.java
+31
-0
SourceConfigReq.java
...n/java/com/jz/dm/models/req/producer/SourceConfigReq.java
+1
-1
ApiInterfaceService.java
.../src/main/java/com/jz/dm/service/ApiInterfaceService.java
+14
-0
AuthService.java
...igateway/src/main/java/com/jz/dm/service/AuthService.java
+7
-0
ProducerService.java
...eway/src/main/java/com/jz/dm/service/ProducerService.java
+25
-9
ApiInterfaceServiceImpl.java
.../java/com/jz/dm/service/impl/ApiInterfaceServiceImpl.java
+35
-0
AuthServiceImpl.java
...src/main/java/com/jz/dm/service/impl/AuthServiceImpl.java
+50
-32
OrganizationManageImpl.java
...n/java/com/jz/dm/service/impl/OrganizationManageImpl.java
+3
-0
ProducerServiceImpl.java
...main/java/com/jz/dm/service/impl/ProducerServiceImpl.java
+126
-31
ApiQueryService.java
.../main/java/com/jz/dm/service/request/ApiQueryService.java
+16
-15
ApiInterfaceMapper.xml
...igateway/src/main/resources/mapper/ApiInterfaceMapper.xml
+30
-0
TestRedisUserSave.java
...test/java/com/jz/dm/gateway/orther/TestRedisUserSave.java
+1
-1
TestStr.java
...teway/src/test/java/com/jz/dm/gateway/orther/TestStr.java
+16
-12
No files found.
database/zc/api_gateway.sql
View file @
86d6f621
...
...
@@ -6,19 +6,18 @@ CREATE TABLE `t_api_interface` (
`api_name`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'api名称'
,
`api_protocl`
varchar
(
32
)
DEFAULT
NULL
COMMENT
'api请求协议:http,https'
,
`target_url`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'目标url'
,
`api_type`
varchar
(
50
)
NULL
DEFAULT
''
COMMENT
'
api类型:1 数据银行制作大数据表 2 数据银行制作数据包,3,数据银行制作自定义API 4 API实时接入 6 标签查询 9自定义
'
,
`req_
method
`
varchar
(
20
)
NULL
DEFAULT
NULL
COMMENT
'请求方式: GET, POST'
,
`api_type`
varchar
(
50
)
NULL
DEFAULT
''
COMMENT
'
接入类型:字典表对应key值
'
,
`req_
type
`
varchar
(
20
)
NULL
DEFAULT
NULL
COMMENT
'请求方式: GET, POST'
,
`api_function`
varchar
(
200
)
DEFAULT
NULL
COMMENT
'接口功能'
,
`join_type`
varchar
(
50
)
NULL
DEFAULT
NULL
COMMENT
'接入类型:字典表对应key值'
,
`status`
varchar
(
50
)
NOT
NULL
COMMENT
'状态(DRAFT-草稿 ISSUE-发布 OUTMODED-过时 4FREEZE-冻结 EXPIRY-失效)'
,
`output_type`
varchar
(
50
)
NULL
DEFAULT
'JSON'
COMMENT
'输出类型:flow 流形式输出, json格式输出'
,
`version`
varchar
(
20
)
DEFAULT
'v1.0'
COMMENT
'版本号'
,
`sign_type`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'加密方式: MD5 RSA'
,
`timeout`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'超时时间'
,
`file_id`
bigint
(
20
)
NO
T
NULL
COMMENT
'文件夹id'
,
`
req
_type`
varchar
(
20
)
DEFAULT
NULL
COMMENT
'限流类型:DAY 按天,MONTH 按月, YEAR 按年'
,
`file_id`
bigint
(
20
)
DEFAUL
T
NULL
COMMENT
'文件夹id'
,
`
limit
_type`
varchar
(
20
)
DEFAULT
NULL
COMMENT
'限流类型:DAY 按天,MONTH 按月, YEAR 按年'
,
`req_frequency`
bigint
(
20
)
DEFAULT
'100'
COMMENT
'限制次数'
,
`
api_custom_id`
bigint
(
20
)
NULL
COMMENT
'API扩展表id
'
`
is_send_bank`
tinyint
(
2
)
NULL
DEFAULT
0
COMMENT
'是否发送到数据银行: 0 false ,1 true
'
`remark`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'备注'
,
`create_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
COMMENT
'创建时间'
,
`create_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'创建人'
,
...
...
@@ -116,6 +115,7 @@ CREATE TABLE `t_api_auth` (
`auth_mode`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'授权方式:POWER_CALL_MODE 按次调用 ,RECORD_TIME_MODE 按时间调用 PERMANENT_TIME_MODE 永久有效'
,
`valid_start_time`
datetime
DEFAULT
NULL
COMMENT
'开始时间'
,
`valid_end_time`
datetime
DEFAULT
NULL
COMMENT
'结束时间'
,
`valid_expr_date`
datetime
DEFAULT
NULL
COMMENT
'有效截止时间'
,
`handler`
tinyint
(
2
)
NULL
DEFAULT
'0'
COMMENT
'处理状态:0 未处理, 1 已处理'
,
`status`
varchar
(
50
)
NOT
NULL
COMMENT
'状态(VALID-正常 UN_VALID-无效)'
,
`remark`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'备注'
,
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/common/enums/GatewayResultCode.java
View file @
86d6f621
...
...
@@ -75,6 +75,9 @@ public enum GatewayResultCode implements ResultCode {
/** 单次调用金额不足 */
CALL_AMOUNT_NOT_ENOUGH
(
"CALL_AMOUNT_NOT_ENOUGH"
,
"单次调用金额不足"
),
/** 认证API已过有效期 */
AUTH_EXCEED_TIME
(
"AUTH_EXCEED_TIME"
,
"认证API已过有效期"
),
/** 输出类型错误 */
OUTPUT_TYPE_EXCEPTION
(
"OUTPUT_TYPE_EXCEPTION"
,
"输出类型错误!"
);
/**
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/common/enums/auth/AuthTypeEnum.java
View file @
86d6f621
...
...
@@ -30,7 +30,7 @@ public enum AuthTypeEnum {
return
text
;
}
public
static
AuthTypeEnum
fromTypeName
(
String
typeName
)
{
public
static
AuthTypeEnum
from
Auth
TypeName
(
String
typeName
)
{
for
(
AuthTypeEnum
type
:
AuthTypeEnum
.
values
())
{
if
(
type
.
name
().
equals
(
typeName
))
{
return
type
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/DateUtil.java
View file @
86d6f621
...
...
@@ -43,6 +43,24 @@ public class DateUtil {
c
.
set
(
Calendar
.
SECOND
,
59
);
return
(
c
.
getTimeInMillis
()
-
System
.
currentTimeMillis
())
/
1000
;
}
/**
* 获取指定年份的时间
* @param year
* @return
*/
public
static
Date
getAssignYearDate
(
Integer
year
){
Calendar
cal
=
Calendar
.
getInstance
();
/* int year =cal.get(Calendar.YEAR)+1;
int month=cal.get(Calendar.MONTH)+1;
cal.add(Calendar.MONTH, 0);*/
//Date date = cal.getTime(); //结果
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
cal
.
set
(
Calendar
.
YEAR
,
cal
.
get
(
Calendar
.
YEAR
)+
year
);
Date
date
=
cal
.
getTime
();
System
.
out
.
println
(
sdf
.
format
(
date
));
return
date
;
}
public
static
void
main
(
String
[]
args
)
{
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
//System.out.println(calculateNowResidueTime());
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/RandomUtil.java
View file @
86d6f621
...
...
@@ -125,6 +125,11 @@ public class RandomUtil {
builder
.
append
(
userNum
);
}
coding
=
getCodeInfo
(
userId
,
coding
,
builder
,
month
,
day
,
hour
,
minute
,
second
);
}
else
{
//无内外部之分
if
(
StringUtils
.
isBlank
(
orgCode
))
{
return
""
;
}
coding
=
getCodeInfo
(
orgCode
,
coding
,
builder
,
month
,
day
,
hour
,
minute
,
second
);
}
return
coding
;
}
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/controller/ApiInterfaceController.java
View file @
86d6f621
...
...
@@ -31,7 +31,6 @@ public class ApiInterfaceController {
/**
* @Description:API列表查询
* @return: API列表
* @Author: Mr.zhang
* @Date: 2020-12-24
*/
...
...
@@ -42,7 +41,6 @@ public class ApiInterfaceController {
}
/**
* @Description:API列表查询
* @return: API列表
* @Author: Mr.zhang
* @Date: 2020-12-24
*/
...
...
@@ -53,7 +51,6 @@ public class ApiInterfaceController {
}
/**
* @Description:API详情查询
* @return: API详情查询
* @Author: Mr.zhang
* @Date: 2020-12-24
*/
...
...
@@ -64,7 +61,6 @@ public class ApiInterfaceController {
}
/**
* @Description:API删除
* @return: API删除
* @Author: Mr.zhang
* @Date: 2020-12-24
*/
...
...
@@ -75,7 +71,6 @@ public class ApiInterfaceController {
}
/**
* @Description:DMP-API删除
* @return: DMP-API删除
* @Author: Mr.zhang
* @Date: 2020-12-24
*/
...
...
@@ -86,5 +81,26 @@ public class ApiInterfaceController {
return
Mono
.
fromSupplier
(()
->
apiInterfaceService
.
dmpDeleteAuth
(
type
,
apiKey
));
}
/**
* @Description:数据修改发送状态接口
* @Author: Mr.zhang
* @Date: 2020-12-24
*/
@ApiOperation
(
"数据修改发送状态接口"
)
@GetMapping
(
value
=
"/updateSendStatus"
)
public
Mono
<
Result
>
updateApiSendStatus
(
@RequestParam
(
name
=
"apiKey"
)
String
apiKey
)
{
return
Mono
.
fromSupplier
(()
->
apiInterfaceService
.
updateApiSendStatus
(
apiKey
));
}
/**
* @Description: 已发送到数据银行API列表
* @Author: Mr.zhang
* @Date: 2020-12-24
*/
@ApiOperation
(
"已发送到数据银行API列表"
)
@GetMapping
(
value
=
"/listSendDataBank"
)
public
Mono
<
Result
>
listSendDataBank
(
@RequestParam
(
name
=
"pageNum"
,
defaultValue
=
"1"
,
required
=
false
)
String
pageNum
,
@RequestParam
(
name
=
"pageSize"
,
defaultValue
=
"20"
,
required
=
false
)
String
pageSize
)
{
return
Mono
.
fromSupplier
(()
->
apiInterfaceService
.
getSendDataBankList
(
pageNum
,
pageSize
));
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/controller/AuthController.java
View file @
86d6f621
...
...
@@ -29,6 +29,16 @@ public class AuthController {
@Autowired
private
AuthService
authService
;
/**
* @Description:服务授权列表
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation
(
"服务授权列表"
)
@PostMapping
(
value
=
"/getServiceAuthList"
)
public
Mono
<
Result
>
getServiceAuthList
(
@RequestBody
@Valid
ServiceAuthReq
req
)
{
return
Mono
.
fromSupplier
(()
->
authService
.
getServiceAuthList
(
req
));
}
/**
* @Description:商城用户API认证
* @return: 商城用户API认证
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/controller/ProducerController.java
View file @
86d6f621
package
com
.
jz
.
dm
.
controller
;
import
com.jz.common.utils.Result
;
import
com.jz.dm.models.req.CreateFolderReq
;
import
com.jz.dm.models.req.make.ApiInterfaceReq
;
import
com.jz.dm.models.req.folder.CreateFolderReq
;
import
com.jz.dm.models.req.producer.ApiInterfaceReq
;
import
com.jz.dm.models.req.producer.ServiceIssueReq
;
import
com.jz.dm.service.ProducerService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -50,6 +51,28 @@ public class ProducerController {
public
Mono
<
Result
>
createProjectFolder
(
@RequestBody
@Valid
CreateFolderReq
req
)
{
return
Mono
.
fromSupplier
(()
->
producerService
.
createProjectFolder
(
req
));
}
/**
* @Description:服务发布列表
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation
(
"服务发布列表"
)
@PostMapping
(
value
=
"/getServiceIssueList"
)
public
Mono
<
Result
>
getServiceIssueList
(
@RequestBody
@Valid
ServiceIssueReq
req
)
{
return
Mono
.
fromSupplier
(()
->
producerService
.
getServiceIssueList
(
req
));
}
/**
* @Description:服务发布/服务取消
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@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
));
}
/**
* @Description:获取APIID
* @Author: Mr.zhang
...
...
@@ -58,7 +81,7 @@ public class ProducerController {
@ApiOperation
(
"Api制作(获取ApiId)"
)
@PostMapping
(
value
=
"/getCustomApiId"
)
public
Mono
<
Result
>
getCustomApiId
()
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
producerService
.
getCustomApiId
()
));
return
Mono
.
fromSupplier
(()
->
producerService
.
getCustomApiId
(
));
}
/**
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/filter/AuthFilter.java
View file @
86d6f621
...
...
@@ -140,11 +140,18 @@ public class AuthFilter extends AbstractFilter {
*/
private
void
checkBill
(
GatewayRequest
request
,
String
authCode
,
ApiAuth
authAuth
)
throws
ParseException
{
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
Constants
.
DATE_TIME_FORMAT
);
String
formatDate
=
dateFormat
.
format
(
new
Date
());
Date
currentDate
=
dateFormat
.
parse
(
formatDate
);
switch
(
authAuth
.
getAuthMode
())
{
case
"POWER_CALL_MODE"
:
//按次调用
//查询数据银行银行余额是否充足
getDataAmountResult
(
request
);
Date
validExprDate
=
authAuth
.
getValidExprDate
();
if
(
currentDate
.
after
(
validExprDate
))
{
//超出时间
throw
new
GatewayException
(
GatewayResultCode
.
AUTH_EXCEED_TIME
);
}
try
{
//记录请求次数(每天限制请求次数)
//查询数据银行银行余额是否充足
getDataAmountResult
(
request
);
String
limitKey
=
TagConstants
.
OPEN_API_REDIS_LIMIT_KEY
+
authCode
;
Integer
reqValue
=
(
Integer
)
redisUtils
.
getObj
(
limitKey
);
long
timeOut
=
0
;
...
...
@@ -172,9 +179,6 @@ public class AuthFilter extends AbstractFilter {
}
break
;
case
"RECORD_TIME_MODE"
:
//按时间调用
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
Constants
.
DATE_TIME_FORMAT
);
String
formatDate
=
dateFormat
.
format
(
new
Date
());
Date
currentDate
=
dateFormat
.
parse
(
formatDate
);
Date
validEndTime
=
authAuth
.
getValidEndTime
();
//如果 date1 在 date2 之前,before 返回 true,否则返回 false
if
(
currentDate
.
after
(
validEndTime
))
{
//超出时间
...
...
@@ -183,6 +187,10 @@ public class AuthFilter extends AbstractFilter {
}
break
;
case
"PERMANENT_TIME_MODE"
:
//永久有效(直接跳出)
Date
validExpr
=
authAuth
.
getValidExprDate
();
if
(
currentDate
.
after
(
validExpr
))
{
//超出时间
throw
new
GatewayException
(
GatewayResultCode
.
AUTH_EXCEED_TIME
);
}
break
;
default
:
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_REQUEST
);
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/mapper/ApiInterfaceMapper.java
View file @
86d6f621
...
...
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.jz.dm.models.domian.ApiInterface
;
import
com.jz.dm.models.domian.ApiInterfaceCustom
;
import
com.jz.dm.models.dto.ApiServiceApplyDto
;
import
com.jz.dm.models.req.api.ApiInterfaceDetailReq
;
import
org.apache.ibatis.annotations.Param
;
...
...
@@ -52,5 +53,19 @@ public interface ApiInterfaceMapper extends BaseMapper<ApiInterface> {
ApiInterfaceCustom
getTestData
(
String
apiKey
);
/**
* 查询服务发布列表
* @param page
* @param query
* @return
*/
IPage
<
ApiServiceApplyDto
>
listApiIssueService
(
IPage
<
ApiServiceApplyDto
>
page
,
@Param
(
"ew"
)
Wrapper
<
ApiServiceApplyDto
>
query
);
/**
* 查询服务授权列表
* @param page
* @param query
* @return
*/
IPage
<
ApiServiceApplyDto
>
listApiAuthService
(
IPage
<
ApiServiceApplyDto
>
page
,
@Param
(
"ew"
)
Wrapper
<
ApiServiceApplyDto
>
query
);
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiAuth.java
View file @
86d6f621
...
...
@@ -97,6 +97,15 @@ public class ApiAuth extends BaseObject implements Serializable {
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
validEndTime
;
/**
* 有效截止时间
*/
@ApiModelProperty
(
"有效截止时间"
)
@TableField
(
"valid_expr_date"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
validExprDate
;
/**
* 处理状态:0 未处理, 1 已处理
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiInterface.java
View file @
86d6f621
...
...
@@ -45,7 +45,7 @@ public class ApiInterface extends BaseObject implements Serializable {
private
String
apiProtocl
;
/**
*
api类型: 1 API实时接入 2 DMP标签查询 3 数据表查询 4 三方查询'
*
接入类型:对应字典表key
*/
@TableField
(
"api_type"
)
private
String
apiType
;
...
...
@@ -55,16 +55,12 @@ public class ApiInterface extends BaseObject implements Serializable {
*/
@TableField
(
"target_url"
)
private
String
targetUrl
;
/**
* 请求方式:GET POST
*/
@TableField
(
"req_method"
)
private
String
reqMethod
;
/**
* 接入类型:对应字典表key
*/
@TableField
(
"join_type"
)
private
String
joinType
;
@TableField
(
"req_type"
)
private
String
reqType
;
/**
* '输出类型:flow 流形式输出, json格式输出',
...
...
@@ -99,8 +95,8 @@ public class ApiInterface extends BaseObject implements Serializable {
/**
* 限流类型:DAY 按天,MONTH 按月, YEAR 按年
*/
@TableField
(
"
req
_type"
)
private
String
req
Type
;
@TableField
(
"
limit
_type"
)
private
String
limit
Type
;
/**
* 限制次数
...
...
@@ -113,6 +109,7 @@ public class ApiInterface extends BaseObject implements Serializable {
@TableField
(
"timeout"
)
private
String
timeout
;
/**
* 文件夹id
*/
...
...
@@ -120,10 +117,10 @@ public class ApiInterface extends BaseObject implements Serializable {
private
Long
fileId
;
/**
* API扩展表id
*/
@TableField
(
"
api_custom_id
"
)
private
Long
apiCustomId
;
* 是否发送到数据银行
*/
@TableField
(
"
is_send_bank
"
)
private
Boolean
isSendBank
;
/*-----------------------------------保存数据库时忽略字段--------------------------------*/
/**
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiInterfaceCustom.java
View file @
86d6f621
...
...
@@ -33,8 +33,8 @@ public class ApiInterfaceCustom extends BaseObject implements Serializable {
/**
* apiInterfaceId
*/
/*
@TableField("api_interface_id")
private Long apiInterfaceId;
*/
@TableField
(
"api_interface_id"
)
private
Long
apiInterfaceId
;
/**
...
...
@@ -105,4 +105,7 @@ public class ApiInterfaceCustom extends BaseObject implements Serializable {
@TableField
(
"page_row"
)
private
Long
pageRow
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/dto/ApiServiceApplyDto.java
0 → 100644
View file @
86d6f621
package
com
.
jz
.
dm
.
models
.
dto
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.dto
* @PROJECT_NAME: jz-dm-parent
* @NAME: ApiServiceApplyDto
* @DATE: 2021-1-28/11:10
* @DAY_NAME_SHORT: 周四
* @Description:
**/
@Data
@ApiModel
(
value
=
"服务发布/授权应用类"
)
public
class
ApiServiceApplyDto
implements
Serializable
{
@ApiModelProperty
(
value
=
"apiId"
)
private
String
apiId
;
@ApiModelProperty
(
value
=
"api名称"
)
private
String
apiName
;
@ApiModelProperty
(
value
=
"api类型"
)
private
String
apiType
;
@ApiModelProperty
(
value
=
"返回类型"
)
private
String
outputType
;
@ApiModelProperty
(
value
=
"请求方式"
)
private
String
reqType
;
@ApiModelProperty
(
value
=
"最大数据量"
)
private
Long
maxRow
;
@ApiModelProperty
(
value
=
"每页行数"
)
private
Long
pageRow
;
@ApiModelProperty
(
value
=
"描述"
)
private
String
apiFunction
;
@ApiModelProperty
(
value
=
"是否发布到数据银行,0 false 1 true"
)
private
Boolean
isSendBank
;
@ApiModelProperty
(
value
=
"授权码"
)
private
String
authCode
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/auth/AuthUserApiReq.java
View file @
86d6f621
...
...
@@ -38,9 +38,9 @@ public class AuthUserApiReq implements Serializable {
@NotNull
(
message
=
"组织编码不能为空"
)
private
String
orgCode
;
/*
@ApiModelProperty(value = "授权类型:DATA_BANK_AUTH 数据银行 , DMP_AUTH 授权",required = true)
@ApiModelProperty
(
value
=
"授权类型:DATA_BANK_AUTH 数据银行 , DMP_AUTH 授权"
,
required
=
true
)
@NotNull
(
message
=
"授权类型不能为空"
)
private String authType;
*/
private
String
authType
;
@ApiModelProperty
(
value
=
"授权方式:POWER_CALL_MODE 按次调用 ,RECORD_TIME_MODE 按时间调用,PERMANENT_TIME_MODE 永久有效"
,
required
=
true
)
@NotNull
(
message
=
"授权方式不能为空"
)
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/auth/ServiceAuthReq.java
0 → 100644
View file @
86d6f621
package
com
.
jz
.
dm
.
models
.
req
.
auth
;
import
com.jz.common.bean.BasePageBean
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.req.auth
* @PROJECT_NAME: jz-dm-parent
* @NAME: ServiceAuthReq
* @DATE: 2021-1-28/11:50
* @DAY_NAME_SHORT: 周四
* @Description:
**/
@Data
@ApiModel
(
value
=
"服务授权请求体"
)
public
class
ServiceAuthReq
extends
BasePageBean
implements
Serializable
{
@ApiModelProperty
(
value
=
"文件夹id"
,
required
=
false
)
private
Long
folderId
;
@ApiModelProperty
(
value
=
"api名称"
,
required
=
false
)
private
String
apiName
;
@ApiModelProperty
(
value
=
"apiId"
,
required
=
false
)
private
String
apiId
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/folder/CreateFolderReq.java
0 → 100644
View file @
86d6f621
package
com
.
jz
.
dm
.
models
.
req
.
folder
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
org.hibernate.validator.constraints.NotBlank
;
import
java.io.Serializable
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.req
* @PROJECT_NAME: jz-dm-parent
* @NAME: CreateFolderReq
* @DATE: 2021-1-27/18:12
* @DAY_NAME_SHORT: 周三
* @Description:
**/
@Data
@ApiModel
(
"创建文件请求体"
)
public
class
CreateFolderReq
implements
Serializable
{
@ApiModelProperty
(
value
=
"项目id"
,
required
=
false
)
private
Long
projectId
;
@ApiModelProperty
(
value
=
"父类文件夹id ,创建同级不传"
,
required
=
false
)
private
Long
parentId
;
@ApiModelProperty
(
value
=
"文件夹名称"
,
required
=
true
)
@NotBlank
(
message
=
"文件夹名称不能为空!"
)
private
String
fileName
;
@ApiModelProperty
(
value
=
"文件来源:,1 API制做,2 组织创建"
,
required
=
true
)
@NotBlank
(
message
=
"文件来源不能为空"
)
private
String
fileSource
;
@ApiModelProperty
(
value
=
"创建用户"
,
required
=
false
)
private
String
createUser
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/make/MakeBigDataApiReq.java
deleted
100644 → 0
View file @
7f2c7f50
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
* @PROJECT_NAME: jz-dm-parent
* @NAME: MakeBigDataApiReq
* @DATE: 2020-12-26/13:08
* @DAY_NAME_SHORT: 周六
* @Description:
**/
@Data
@ApiModel
(
"Api制作大数据查询/标签查询请求体"
)
public
class
MakeBigDataApiReq
implements
Serializable
{
@ApiModelProperty
(
value
=
"id--更新时id不能为空"
,
required
=
false
)
private
Long
id
;
/* @ApiModelProperty(value = "数据类型:api类型:1 实时接入 2 数据银行制作API, 3 数据银行制作数据包 6标签查询 8 查询hive数据源 9自定义",required = true)
@NotNull(message = "apiType不能为空")
private String apiType;*/
@ApiModelProperty
(
value
=
"apiKey"
,
required
=
false
)
@NotNull
(
message
=
"apiKey不能为空"
)
public
String
apiKey
;
//@ApiModelProperty(value = "是否分页",required = false)
//public Boolean page;
@ApiModelProperty
(
value
=
"数据源Id"
,
required
=
true
)
@NotNull
(
message
=
"数据源Id不能为空"
)
private
String
esDataSource
;
@ApiModelProperty
(
value
=
"源库名称"
,
required
=
true
)
@NotNull
(
message
=
"源库名称不能为空"
)
private
String
esDataBase
;
@ApiModelProperty
(
value
=
"源表名称"
,
required
=
true
)
@NotNull
(
message
=
"源表名称不能为空"
)
private
String
esTable
;
@ApiModelProperty
(
value
=
"处理类型"
,
required
=
true
)
@NotNull
(
message
=
"处理类型不能为空"
)
private
String
handleType
;
@ApiModelProperty
(
value
=
"请求参数"
,
required
=
true
)
@NotNull
(
message
=
"请求参数不能为空"
)
private
String
requestParam
;
@ApiModelProperty
(
value
=
"返回参数"
,
required
=
true
)
@NotNull
(
message
=
"返回参数不能为空"
)
private
String
responseParam
;
@ApiModelProperty
(
value
=
"段列表"
,
required
=
true
)
@NotNull
(
message
=
"字段列表不能为空"
)
private
String
tableFields
;
@ApiModelProperty
(
value
=
"创建用户"
,
required
=
false
)
public
String
createUser
;
//@ApiModelProperty(value = "项目id",required = true)
//@NotNull(message="项目id不能为空")
//public Long projectId;
//@ApiModelProperty(value = "父类文件id,一级文件夹传入0",required = false)
//public Long parentId;
//
//@ApiModelProperty(value = "文件id",required = false)
//public Long fileId;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/organizationManage/OrganizationManageListQueryReq.java
View file @
86d6f621
...
...
@@ -29,4 +29,9 @@ public class OrganizationManageListQueryReq extends BasePageBean implements Seri
@ApiModelProperty
(
value
=
"组织联系人"
)
private
String
linkman
;
@ApiModelProperty
(
value
=
"组织文件夹"
)
private
Long
fileId
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/
make
/ApiInterfaceReq.java
→
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/
producer
/ApiInterfaceReq.java
View file @
86d6f621
package
com
.
jz
.
dm
.
models
.
req
.
make
;
package
com
.
jz
.
dm
.
models
.
req
.
producer
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
...
...
@@ -30,19 +30,18 @@ public class ApiInterfaceReq implements Serializable {
@ApiModelProperty
(
value
=
"Api类型:对应字典表key"
,
required
=
true
)
@NotNull
(
message
=
"Api类型不能为空"
)
public
String
join
Type
;
public
String
api
Type
;
@ApiModelProperty
(
value
=
"apiKey"
,
required
=
true
)
@NotNull
(
message
=
"apiKey不能为空"
)
public
String
apiKey
;
@ApiModelProperty
(
value
=
"目标地址"
,
required
=
true
)
@NotNull
(
message
=
"目标地址不能为空"
)
@ApiModelProperty
(
value
=
"目标地址"
,
required
=
false
)
public
String
targetUrl
;
@ApiModelProperty
(
value
=
"请求方式:GET POST"
,
required
=
true
)
@NotNull
(
message
=
"请求方式不能为空"
)
public
String
req
Method
;
public
String
req
Type
;
@ApiModelProperty
(
value
=
"超时时间"
,
required
=
true
)
@NotNull
(
message
=
"超时时间不能为空"
)
...
...
@@ -50,7 +49,7 @@ public class ApiInterfaceReq implements Serializable {
@ApiModelProperty
(
value
=
"限流类型:DAY 按天,MONTH 按月, YEAR 按年"
,
required
=
true
)
@NotNull
(
message
=
"限流类型不能为空"
)
public
String
req
Type
;
public
String
limit
Type
;
@ApiModelProperty
(
value
=
"API名称"
,
required
=
false
)
public
String
apiName
;
...
...
@@ -63,7 +62,7 @@ public class ApiInterfaceReq implements Serializable {
@ApiModelProperty
(
value
=
"文件夹Id"
,
required
=
true
)
@NotNull
(
message
=
"文件夹Id不能为空"
)
public
Long
f
older
Id
;
public
Long
f
ile
Id
;
@ApiModelProperty
(
value
=
"项目编号"
,
required
=
true
)
@NotNull
(
message
=
"项目编号不能为空"
)
...
...
@@ -106,9 +105,9 @@ public class ApiInterfaceReq implements Serializable {
@ApiModelProperty
(
value
=
"创建用户"
,
hidden
=
true
)
public
String
updateUser
;
@ApiModelProperty
(
value
=
"api类型:1.数据银行制作大数据表 "
+
/*
@ApiModelProperty(value = "api类型:1.数据银行制作大数据表 " +
"2 数据银行制作数据包,3,数据银行制作自定义API " +
"4 API实时接入 6 标签查询 9自定义",hidden = true)
public
String
apiType
;
public String apiType;
*/
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/producer/MakeBigDataApiReq.java
0 → 100644
View file @
86d6f621
package
com
.
jz
.
dm
.
models
.
req
.
producer
;
import
io.swagger.annotations.ApiModel
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.req
* @PROJECT_NAME: jz-dm-parent
* @NAME: MakeBigDataApiReq
* @DATE: 2020-12-26/13:08
* @DAY_NAME_SHORT: 周六
* @Description:
**/
@Data
@ApiModel
(
"Api制作大数据查询/标签查询请求体"
)
public
class
MakeBigDataApiReq
implements
Serializable
{
// @ApiModelProperty(value = "id--更新时id不能为空",required = false)
// private Long id;
//
///* @ApiModelProperty(value = "数据类型:api类型:1 实时接入 2 数据银行制作API, 3 数据银行制作数据包 6标签查询 8 查询hive数据源 9自定义",required = true)
// @NotNull(message = "apiType不能为空")
// private String apiType;*/
//
// @ApiModelProperty(value = "apiKey",required = false)
// @NotNull(message = "apiKey不能为空")
// public String apiKey;
//
// //@ApiModelProperty(value = "是否分页",required = false)
// //public Boolean page;
//
// @ApiModelProperty(value = "数据源Id",required = true)
// @NotNull(message = "数据源Id不能为空")
// private String esDataSource;
//
// @ApiModelProperty(value = "源库名称",required = true)
// @NotNull(message = "源库名称不能为空")
// private String esDataBase;
//
// @ApiModelProperty(value = "源表名称",required = true)
// @NotNull(message = "源表名称不能为空")
// private String esTable;
//
// @ApiModelProperty(value = "处理类型",required = true)
// @NotNull(message = "处理类型不能为空")
// private String handleType;
//
//
// @ApiModelProperty(value = "请求参数",required = true)
// @NotNull(message = "请求参数不能为空")
// private String requestParam;
//
// @ApiModelProperty(value = "返回参数",required = true)
// @NotNull(message = "返回参数不能为空")
// private String responseParam;
//
// @ApiModelProperty(value = "段列表",required = true)
// @NotNull(message = "字段列表不能为空")
// private String tableFields;
//
// @ApiModelProperty(value = "创建用户",required = false)
// public String createUser;
//
// //@ApiModelProperty(value = "项目id",required = true)
// //@NotNull(message="项目id不能为空")
// //public Long projectId;
//
// //@ApiModelProperty(value = "父类文件id,一级文件夹传入0",required = false)
// //public Long parentId;
// //
// //@ApiModelProperty(value = "文件id",required = false)
// //public Long fileId;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/
make
/MakeDataBankApiReq.java
→
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/
producer
/MakeDataBankApiReq.java
View file @
86d6f621
package
com
.
jz
.
dm
.
models
.
req
.
make
;
package
com
.
jz
.
dm
.
models
.
req
.
producer
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/
make
/MakeRealCustomApiReq.java
→
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/
producer
/MakeRealCustomApiReq.java
View file @
86d6f621
package
com
.
jz
.
dm
.
models
.
req
.
make
;
package
com
.
jz
.
dm
.
models
.
req
.
producer
;
import
io.swagger.annotations.ApiModel
;
import
lombok.Data
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/producer/ServiceIssueReq.java
0 → 100644
View file @
86d6f621
package
com
.
jz
.
dm
.
models
.
req
.
producer
;
import
com.jz.common.bean.BasePageBean
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.req.producer
* @PROJECT_NAME: jz-dm-parent
* @NAME: ServiceIssueReq
* @DATE: 2021-1-28/11:00
* @DAY_NAME_SHORT: 周四
* @Description:
**/
@Data
@ApiModel
(
value
=
"服务发布请求体"
)
public
class
ServiceIssueReq
extends
BasePageBean
implements
Serializable
{
@ApiModelProperty
(
value
=
"文件夹id"
,
required
=
false
)
private
Long
fileId
;
@ApiModelProperty
(
value
=
"api名称"
,
required
=
false
)
private
String
apiName
;
@ApiModelProperty
(
value
=
"apiId"
,
required
=
false
)
private
String
apiId
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/
make
/SourceConfigReq.java
→
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/
producer
/SourceConfigReq.java
View file @
86d6f621
package
com
.
jz
.
dm
.
models
.
req
.
make
;
package
com
.
jz
.
dm
.
models
.
req
.
producer
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/ApiInterfaceService.java
View file @
86d6f621
...
...
@@ -92,4 +92,18 @@ public interface ApiInterfaceService {
*/
ApiInterfaceCustom
getApiCustomInfo
(
Long
apiInterfaceId
);
/**
* 更新数据银行调用状态
* @param apiKey
* @return
*/
Result
updateApiSendStatus
(
String
apiKey
);
/**
* 获取已发送到数据API列表
* @param pageNum
* @param pageSize
* @return
*/
Result
getSendDataBankList
(
String
pageNum
,
String
pageSize
);
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/AuthService.java
View file @
86d6f621
...
...
@@ -84,4 +84,11 @@ public interface AuthService {
* @return
*/
Result
getAuthNameList
(
String
key
);
/**
* 获取服务授权列表
* @param req
* @return
*/
Result
getServiceAuthList
(
ServiceAuthReq
req
);
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/ProducerService.java
View file @
86d6f621
package
com
.
jz
.
dm
.
service
;
import
com.jz.common.utils.Result
;
import
com.jz.dm.models.req.CreateFolderReq
;
import
com.jz.dm.models.req.make.ApiInterfaceReq
;
import
com.jz.dm.models.req.folder.CreateFolderReq
;
import
com.jz.dm.models.req.producer.ApiInterfaceReq
;
import
com.jz.dm.models.req.producer.ServiceIssueReq
;
/**
* @author ZC
...
...
@@ -22,12 +23,7 @@ public interface ProducerService {
*/
// Result addRealCustomApi(MakeRealCustomApiReq req);
/**
* Api制作(数据查询/标签查询)
* @param req
* @return
*/
Result
addBigDataMakeApi
(
ApiInterfaceReq
req
);
/**
* 获取数据源配置
...
...
@@ -74,7 +70,12 @@ public interface ProducerService {
*/
//Result saveUpdateAPiInfo(ApiInterfaceReq req);
/**
* Api制作(数据查询/标签查询)
* @param req
* @return
*/
Result
addBigDataMakeApi
(
ApiInterfaceReq
req
);
/**
* 保存 API基本信息
* @param req
...
...
@@ -102,6 +103,21 @@ public interface ProducerService {
*/
Result
getCustomApiId
();
/**
* 获取服务发布列表
* @param req
* @return
*/
Result
getServiceIssueList
(
ServiceIssueReq
req
);
/**
* 服务发布/取消操作
* @param id
* @param optStatus
* @return
*/
Result
optionApiIssueStatus
(
Long
id
,
Boolean
optStatus
);
//Result saveObjOnRedis();
//Result getObjOnRedis();
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/ApiInterfaceServiceImpl.java
View file @
86d6f621
...
...
@@ -285,4 +285,39 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
query
.
eq
(
"is_deleted"
,
0
);
return
apiInterfaceMapper
.
selectOne
(
query
);
}
/**
* 更新APi是否发送到数据银行状态
* @param apiKey
* @return
*/
@Override
public
Result
updateApiSendStatus
(
String
apiKey
)
{
QueryWrapper
<
ApiInterface
>
queryWra
=
new
QueryWrapper
<>();
queryWra
.
eq
(
"api_key"
,
apiKey
);
queryWra
.
eq
(
"is_deleted"
,
0
);
ApiInterface
apiInterface
=
apiInterfaceMapper
.
selectOne
(
queryWra
);
if
(
null
==
apiInterface
){
return
Result
.
of_error
(
ResultMsg
.
DATA_NOT_FOUND
);
}
UpdateWrapper
<
ApiInterface
>
updateWra
=
new
UpdateWrapper
<>();
updateWra
.
set
(
"is_send_bank"
,
0
);
if
(
apiInterfaceMapper
.
update
(
null
,
updateWra
)
>
0
){
return
Result
.
of_success
(
ResultMsg
.
UPDATE_SUCCESS
);
}
return
Result
.
of_error
(
ResultMsg
.
UPDATE_FAIL
);
}
@Override
public
Result
getSendDataBankList
(
String
pageNum
,
String
pageSize
)
{
Integer
pageN
=
Integer
.
valueOf
(
pageNum
);
Integer
pageS
=
Integer
.
valueOf
(
pageSize
);
IPage
<
ApiInterface
>
page
=
new
Page
<>(
pageN
,
pageS
);
QueryWrapper
<
ApiInterface
>
query
=
new
QueryWrapper
<>();
query
.
eq
(
"is_send_bank"
,
1
);
query
.
eq
(
"status"
,
ApiStatusEnum
.
ISSUE
.
name
());
query
.
eq
(
"is_deleted"
,
0
);
return
Result
.
of_success
(
apiInterfaceMapper
.
selectPage
(
page
,
query
));
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/AuthServiceImpl.java
View file @
86d6f621
...
...
@@ -5,13 +5,11 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.jz.common.constant.ResultMsg
;
import
com.jz.common.enums.auth.AuthTypeEnum
;
import
com.jz.common.utils.Result
;
import
com.jz.dm.common.constant.Constants
;
import
com.jz.dm.common.enums.GeneralStatusTypeEnum
;
import
com.jz.dm.common.enums.apiInterface.ApiStatusEnum
;
import
com.jz.dm.common.enums.auth.AuthModeEnum
;
import
com.jz.dm.common.
enums.org.OrgStatusEnum
;
import
com.jz.dm.common.
util.DateUtil
;
import
com.jz.dm.common.util.RandomUtil
;
import
com.jz.dm.mapper.ApiAuthMapper
;
import
com.jz.dm.mapper.ApiInterfaceMapper
;
...
...
@@ -19,6 +17,7 @@ import com.jz.dm.mapper.ApiOrgMapper;
import
com.jz.dm.models.domian.ApiAuth
;
import
com.jz.dm.models.domian.ApiInterface
;
import
com.jz.dm.models.domian.ApiOrg
;
import
com.jz.dm.models.dto.ApiServiceApplyDto
;
import
com.jz.dm.models.dto.AuthInfoDto
;
import
com.jz.dm.models.req.auth.*
;
import
com.jz.dm.models.resp.AuthUserResponse
;
...
...
@@ -34,6 +33,7 @@ import javax.annotation.Resource;
import
java.util.Date
;
import
static
com
.
jz
.
dm
.
common
.
enums
.
auth
.
AuthModeEnum
.
fromTypeModeName
;
import
static
com
.
jz
.
dm
.
common
.
enums
.
auth
.
AuthTypeEnum
.
fromAuthTypeName
;
/**
* @author ZC
...
...
@@ -89,6 +89,29 @@ public class AuthServiceImpl implements AuthService {
return
Result
.
of_success
(
apiAuthMapper
.
selectAuthDetail
(
req
));
}
/**
* 获取服务授权列表
* @param req
* @return
*/
@Override
public
Result
getServiceAuthList
(
ServiceAuthReq
req
)
{
IPage
<
ApiServiceApplyDto
>
page
=
new
Page
<>(
req
.
getPageNum
(),
req
.
getPageSize
());
QueryWrapper
<
ApiServiceApplyDto
>
query
=
new
QueryWrapper
<>();
if
(
null
!=
req
.
getFolderId
()){
query
.
eq
(
"ai.file_id"
,
req
.
getFolderId
());
}
if
(
StringUtils
.
isNotBlank
(
req
.
getApiName
())){
query
.
eq
(
"ai.api_name"
,
req
.
getApiName
());
}
if
(
StringUtils
.
isNotBlank
(
req
.
getApiId
())){
query
.
eq
(
"ai.api_key"
,
req
.
getApiId
());
}
query
.
eq
(
"ai.is_deleted"
,
0
);
query
.
orderByDesc
(
"ai.create_time"
);
return
Result
.
of_success
(
apiInterfaceMapper
.
listApiAuthService
(
page
,
query
));
}
/**
* 添加dmp认证信息
*
...
...
@@ -102,20 +125,23 @@ public class AuthServiceImpl implements AuthService {
if
(
null
==
apiInterface
)
{
return
Result
.
of_error
(
"api授权信息不存在!"
);
}
if
(
ApiStatusEnum
.
DRAFT
.
name
().
equals
(
apiInterface
.
getStatus
())){
return
Result
.
of_error
(
"api未发布,无法授权"
);
}
if
(
ApiStatusEnum
.
EXPIRY
.
name
().
equals
(
apiInterface
.
getStatus
()))
{
return
Result
.
of_error
(
"api已下架,无法授权"
);
}
ApiOrg
apiOrg
=
apiOrgMapper
.
selectOne
(
new
QueryWrapper
<
ApiOrg
>().
eq
(
"org_code"
,
req
.
getOrgCode
()));
if
(
null
==
apiOrg
||
OrgStatusEnum
.
CANCEL
.
name
().
equals
(
apiOrg
))
{
if
(
null
==
apiOrg
||
!
apiOrg
.
getStatus
(
))
{
return
Result
.
of_error
(
"组织信息不存在!"
);
}
//授权验证
//
if (StringUtils.isNotBlank(req.getAuthType())){
// if (null == from
TypeName(req.getAuthType())){
//
return Result.of_error("授权类型不存在!");
//
}
//
}
if
(
StringUtils
.
isNotBlank
(
req
.
getAuthType
())){
if
(
null
==
fromAuth
TypeName
(
req
.
getAuthType
())){
return
Result
.
of_error
(
"授权类型不存在!"
);
}
}
//验证授权方式
if
(
StringUtils
.
isNotBlank
(
req
.
getAuthMode
()))
{
if
(
null
==
fromTypeModeName
(
req
.
getAuthMode
()))
{
...
...
@@ -130,7 +156,7 @@ public class AuthServiceImpl implements AuthService {
if
(
StringUtils
.
isBlank
(
apiOrg
.
getOrgCode
()))
{
return
Result
.
of_error
(
"内部授权组织编码不能为空!!"
);
}
return
saveAuthInfo
(
apiInterface
,
apiOrg
,
req
,
Constants
.
AUTH_INT
);
return
saveAuthInfo
(
apiInterface
,
apiOrg
,
req
);
}
/**
...
...
@@ -149,16 +175,19 @@ public class AuthServiceImpl implements AuthService {
if
(
ApiStatusEnum
.
SOLDOUT
.
name
().
equals
(
apiInterface
.
getStatus
()))
{
return
Result
.
of_error
(
"api已下架,无法授权"
);
}
if
(
ApiStatusEnum
.
DRAFT
.
name
().
equals
(
apiInterface
.
getStatus
())){
return
Result
.
of_error
(
"api未发布,无法授权"
);
}
ApiOrg
apiOrg
=
apiOrgMapper
.
selectOne
(
new
QueryWrapper
<
ApiOrg
>().
eq
(
"org_code"
,
req
.
getOrgCode
()));
if
(
null
==
apiOrg
||
OrgStatusEnum
.
CANCEL
.
name
().
equals
(
apiOrg
))
{
if
(
null
==
apiOrg
||
!
apiOrg
.
getStatus
(
))
{
return
Result
.
of_error
(
"组织信息不存在!"
);
}
//授权验证
//
if (StringUtils.isNotBlank(req.getAuthType())){
// if (null == from
TypeName(req.getAuthType())){
//
return Result.of_error("授权类型不存在!");
//
}
//
}
if
(
StringUtils
.
isNotBlank
(
req
.
getAuthType
())){
if
(
null
==
fromAuth
TypeName
(
req
.
getAuthType
())){
return
Result
.
of_error
(
"授权类型不存在!"
);
}
}
//验证授权方式
if
(
StringUtils
.
isNotBlank
(
req
.
getAuthMode
()))
{
if
(
null
==
fromTypeModeName
(
req
.
getAuthMode
()))
{
...
...
@@ -181,7 +210,7 @@ public class AuthServiceImpl implements AuthService {
if
(
StringUtils
.
isBlank
(
req
.
getUserId
()))
{
return
Result
.
of_error
(
"外部授权用户Id不能为空"
);
}
return
saveAuthInfo
(
apiInterface
,
apiOrg
,
req
,
Constants
.
AUTH_OUT
);
return
saveAuthInfo
(
apiInterface
,
apiOrg
,
req
);
}
/**
...
...
@@ -190,11 +219,10 @@ public class AuthServiceImpl implements AuthService {
* @param apiInterface
* @param apiOrg
* @param req
* @param orgType
* @return
*/
private
Result
saveAuthInfo
(
ApiInterface
apiInterface
,
ApiOrg
apiOrg
,
AuthUserApiReq
req
,
String
orgType
)
{
AuthUserApiReq
req
)
{
AuthUserResponse
response
=
new
AuthUserResponse
();
ApiAuth
apiAuth
=
new
ApiAuth
();
BeanUtils
.
copyProperties
(
req
,
apiAuth
);
...
...
@@ -202,21 +230,11 @@ public class AuthServiceImpl implements AuthService {
apiAuth
.
setApiOrgId
(
apiOrg
.
getId
());
apiAuth
.
setReqType
(
apiInterface
.
getReqType
());
apiAuth
.
setReqFrequency
(
apiInterface
.
getReqFrequency
());
if
(
Constants
.
AUTH_INT
.
equals
(
orgType
))
{
//内部授权
apiAuth
.
setAuthType
(
AuthTypeEnum
.
DMP_AUTH
.
name
());
}
else
{
apiAuth
.
setAuthType
(
AuthTypeEnum
.
DATA_BANK_AUTH
.
name
());
if
(!
AuthModeEnum
.
RECORD_TIME_MODE
.
name
().
equals
(
req
.
getAuthMode
())){
apiAuth
.
setValidExprDate
(
DateUtil
.
getAssignYearDate
(
99
));
//过期时间
}
//商城只有外部授权
String
authCode
=
""
;
//内部组织
if
(
StringUtils
.
isNotBlank
(
orgType
)
&&
Constants
.
AUTH_INT
.
equalsIgnoreCase
(
orgType
))
{
authCode
=
getAuthCode
(
apiOrg
.
getOrgCode
(),
""
,
Constants
.
AUTH_INT
);
//外部组织
}
else
if
(
StringUtils
.
isNotBlank
(
orgType
)
&&
Constants
.
AUTH_OUT
.
equalsIgnoreCase
(
orgType
))
{
authCode
=
getAuthCode
(
""
,
req
.
getUserId
(),
Constants
.
AUTH_OUT
);
}
String
authCode
=
getAuthCode
(
apiOrg
.
getOrgCode
(),
""
,
""
);
//生成盐值
String
salt
=
RandomUtil
.
getStringRandom
(
8
);
apiAuth
.
setAuthCode
(
authCode
);
//授权码
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/OrganizationManageImpl.java
View file @
86d6f621
...
...
@@ -60,6 +60,9 @@ public class OrganizationManageImpl implements OrganizationManageService {
if
(
StringUtils
.
isNotBlank
(
req
.
getOrgCode
()))
{
query
.
eq
(
"org_code"
,
req
.
getOrgCode
());
}
if
(
null
!=
req
.
getFileId
()){
query
.
eq
(
"org_folder_id"
,
req
.
getFileId
());
}
query
.
eq
(
"is_deleted"
,
0
);
query
.
orderByDesc
(
"create_date"
);
return
apiOrgMapper
.
selectPage
(
page
,
query
);
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/ProducerServiceImpl.java
View file @
86d6f621
This diff is collapsed.
Click to expand it.
jz-dm-apigateway/src/main/java/com/jz/dm/service/request/ApiQueryService.java
View file @
86d6f621
...
...
@@ -113,12 +113,12 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
redisReqParam
);
String
targetUrl
=
jsonObject
.
getString
(
"targetUrl"
);
String
outputType
=
jsonObject
.
getString
(
"outputType"
);
String
joinType
=
jsonObject
.
getString
(
"join
Type"
);
String
apiType
=
jsonObject
.
getString
(
"api
Type"
);
bResult
=
rangRequestTarget
(
outputType
,
targetUrl
,
paramMap
,
jsonParams
,
join
Type
,
apiInterface
,
response
);
jsonParams
,
api
Type
,
apiInterface
,
response
);
}
else
{
//不存在查询数据库
bResult
=
rangRequestTarget
(
apiInterface
.
getOutputType
(),
apiInterface
.
getTargetUrl
(),
paramMap
,
jsonParams
,
apiInterface
.
get
Join
Type
(),
apiInterface
,
response
);
apiInterface
.
getTargetUrl
(),
paramMap
,
jsonParams
,
apiInterface
.
get
Api
Type
(),
apiInterface
,
response
);
}
//调用成功请求数据银行扣款
if
(
AuthModeEnum
.
POWER_CALL_MODE
.
name
().
equals
(
apiAuth
.
getAuthMode
()))
{
...
...
@@ -148,11 +148,11 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
* @param outputType
* @param targetUrl
* @param param
* @param
join
Type
* @param
api
Type
* @param response
*/
private
boolean
rangRequestTarget
(
String
outputType
,
String
targetUrl
,
Map
<
String
,
String
>
param
,
JSONObject
jsonParams
,
String
join
Type
,
Map
<
String
,
String
>
param
,
JSONObject
jsonParams
,
String
api
Type
,
ApiInterface
apiInterface
,
OpenApiResponse
response
)
{
if
(
StringUtils
.
isBlank
(
outputType
))
{
outputType
=
ApiInfoOutTypeEnum
.
JSON
.
name
();
...
...
@@ -160,14 +160,14 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
if
(
StringUtils
.
isBlank
(
targetUrl
))
{
throw
new
GatewayException
(
GatewayResultCode
.
REQUEST_PARAM_EMPTY
);
}
if
(
StringUtils
.
isBlank
(
join
Type
))
{
if
(
StringUtils
.
isBlank
(
api
Type
))
{
throw
new
GatewayException
(
GatewayResultCode
.
API_TYPE_ERROR
);
}
if
(
"10002"
.
equals
(
joinType
)
||
"10009"
.
equals
(
join
Type
))
{
//数据表查询
if
(
"10002"
.
equals
(
apiType
)
||
"10009"
.
equals
(
api
Type
))
{
//数据表查询
return
dataTableSelect
(
outputType
,
targetUrl
,
param
,
jsonParams
,
apiInterface
,
response
);
}
else
if
(
"10004"
.
equals
(
joinType
)
||
"10008"
.
equals
(
join
Type
))
{
//三方查询
return
thirdSelect
(
targetUrl
,
apiInterface
,
response
);
}
else
if
(
"10005"
.
equals
(
joinType
)
||
"10007"
.
equals
(
join
Type
))
{
//数据包查询
}
else
if
(
"10004"
.
equals
(
apiType
)
||
"10008"
.
equals
(
api
Type
))
{
//三方查询
return
thirdSelect
(
targetUrl
,
apiInterface
,
jsonParams
,
response
);
}
else
if
(
"10005"
.
equals
(
apiType
)
||
"10007"
.
equals
(
api
Type
))
{
//数据包查询
return
dataBagDownload
(
targetUrl
,
jsonParams
,
response
);
}
else
{
throw
new
GatewayException
(
GatewayResultCode
.
API_TYPE_ERROR
);
...
...
@@ -182,11 +182,12 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
* @param response
* @return
*/
private
boolean
thirdSelect
(
String
targetUrl
,
ApiInterface
apiInterface
,
OpenApiResponse
response
)
{
private
boolean
thirdSelect
(
String
targetUrl
,
ApiInterface
apiInterface
,
JSONObject
jsonParams
,
OpenApiResponse
response
)
{
if
(
"POST"
.
equalsIgnoreCase
(
apiInterface
.
getReqType
()))
{
return
callMethodResponse
(
httpsUtils
.
submitPost
(
targetUrl
,
null
),
response
);
return
callMethodResponse
(
httpsUtils
.
submitPost
(
targetUrl
,
jsonParams
.
toString
()
),
response
);
}
else
{
return
callMethodResponse
(
httpsUtils
.
doGet
(
targetUrl
,
null
),
response
);
Map
map
=
JSONObject
.
parseObject
(
jsonParams
.
toString
(),
Map
.
class
);
return
callMethodResponse
(
httpsUtils
.
doGet
(
targetUrl
,
map
),
response
);
}
}
...
...
@@ -319,8 +320,8 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
params
.
put
(
"is_test"
,
jsonParams
.
get
(
"is_test"
));
//是否是测试
Integer
pageNum
=
jsonParams
.
getInteger
(
"page_num"
);
Integer
pageSize
=
jsonParams
.
getInteger
(
"page_size"
);
params
.
put
(
"page_size"
,
apiCustomInfo
.
getPage
Size
());
params
.
put
(
"page_num"
,
apiCustomInfo
.
getPageNum
()
);
params
.
put
(
"page_size"
,
apiCustomInfo
.
getPage
Row
());
params
.
put
(
"page_num"
,
1
);
if
(
null
!=
pageNum
)
{
params
.
put
(
"page_num"
,
pageNum
);
}
...
...
jz-dm-apigateway/src/main/resources/mapper/ApiInterfaceMapper.xml
View file @
86d6f621
...
...
@@ -43,5 +43,35 @@
AND ai.api_key =#{apiKey}
</select>
<select
id=
"listApiIssueService"
resultType=
"com.jz.dm.models.dto.ApiServiceApplyDto"
>
SELECT ai.api_key AS apiId,
ai.api_name AS apiName,
ai.api_type AS apiType,
ai.output_type AS outputType,
ai.req_type AS reqType,
ai.api_function AS apiFunction,
aic.max_row AS maxRow,
aic.page_row AS pageRow,
aic.is_send_bank AS isSendBank
FROM t_api_interface AS ai JOIN t_api_interface_custom AS aic
ON ai.id =aic.api_interface_id AND aic.is_deleted =0
${ew.customSqlSegment}
</select>
<select
id=
"listApiAuthService"
resultType=
"com.jz.dm.models.dto.ApiServiceApplyDto"
>
SELECT ai.api_key AS apiId,
ai.api_name AS apiName,
ai.api_type AS apiType,
ai.output_type AS outputType,
ai.req_type AS reqType,
ai.api_function AS apiFunction,
aic.max_row AS maxRow,
aic.page_row AS pageRow,
au.auth_code AS authCode
FROM t_api_interface AS ai
JOIN t_api_interface_custom AS aic ON ai.id =aic.api_interface_id AND aic.is_deleted =0
JOIN t_api_auth AS au ON au.api_interface_id = ai.id AND aic.is_deleted =0
${ew.customSqlSegment}
</select>
</mapper>
\ No newline at end of file
jz-dm-apigateway/src/test/java/com/jz/dm/gateway/orther/TestRedisUserSave.java
View file @
86d6f621
...
...
@@ -2,7 +2,7 @@ package com.jz.dm.gateway.orther;
import
com.jz.dm.common.util.RedisSerializableUtil
;
import
com.jz.dm.gateway.SpringTestCase
;
import
com.jz.dm.models.req.
make
.MakeDataBankApiReq
;
import
com.jz.dm.models.req.
producer
.MakeDataBankApiReq
;
import
net.sf.json.JSONObject
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
jz-dm-apigateway/src/test/java/com/jz/dm/gateway/orther/TestStr.java
View file @
86d6f621
...
...
@@ -2,10 +2,8 @@ package com.jz.dm.gateway.orther;
import
com.alibaba.fastjson.JSONObject
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -16,14 +14,20 @@ import java.util.stream.Collectors;
*/
public
class
TestStr
{
public
static
void
main
(
String
[]
args
)
{
Random
ran
=
new
Random
();
int
num
=
ran
.
nextInt
(
999999
);
String
str
=
String
.
format
(
"%06d"
,
num
);
System
.
out
.
println
(
str
);
String
stereo
=
"000101"
;
Integer
valueOf
=
Integer
.
valueOf
(
stereo
);
System
.
out
.
println
(
valueOf
);
Calendar
cal
=
Calendar
.
getInstance
();
/* int year =cal.get(Calendar.YEAR)+1;
int month=cal.get(Calendar.MONTH)+1;
cal.add(Calendar.MONTH, 0);*/
//Date date = cal.getTime(); //结果
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
cal
.
set
(
Calendar
.
YEAR
,
cal
.
get
(
Calendar
.
YEAR
)+
2
);
Date
date
=
cal
.
getTime
();
System
.
out
.
println
(
sdf
.
format
(
date
));
//String stereo = "000101";
// Integer valueOf = Integer.valueOf(stereo);
// System.out.println(valueOf);
}
public
void
resolveParameter
(){
...
...
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