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
7d0abfd9
Commit
7d0abfd9
authored
Jan 20, 2021
by
zhangc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit修改一些问题
parent
91802923
Changes
22
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
236 additions
and
68 deletions
+236
-68
api_gateway.sql
database/zc/api_gateway.sql
+5
-2
pom.xml
jz-dm-apigateway/pom.xml
+21
-1
ApiInterfaceController.java
...ain/java/com/jz/dm/controller/ApiInterfaceController.java
+1
-0
ApiLogController.java
.../src/main/java/com/jz/dm/controller/ApiLogController.java
+12
-4
AuthController.java
...ay/src/main/java/com/jz/dm/controller/AuthController.java
+11
-0
OrganizationManageController.java
...va/com/jz/dm/controller/OrganizationManageController.java
+3
-4
ApiReqLogMapper.java
...teway/src/main/java/com/jz/dm/mapper/ApiReqLogMapper.java
+11
-0
ApiOrg.java
...gateway/src/main/java/com/jz/dm/models/domian/ApiOrg.java
+5
-0
ApiReqLog.java
...eway/src/main/java/com/jz/dm/models/domian/ApiReqLog.java
+18
-4
OrganizationManageAddReq.java
...dels/req/organizationManage/OrganizationManageAddReq.java
+13
-0
ApiInterfaceService.java
.../src/main/java/com/jz/dm/service/ApiInterfaceService.java
+3
-0
ApiLogService.java
...ateway/src/main/java/com/jz/dm/service/ApiLogService.java
+7
-0
AuthService.java
...igateway/src/main/java/com/jz/dm/service/AuthService.java
+7
-0
OrganizationManageService.java
...ain/java/com/jz/dm/service/OrganizationManageService.java
+1
-2
ApiInterfaceServiceImpl.java
.../java/com/jz/dm/service/impl/ApiInterfaceServiceImpl.java
+1
-0
ApiLogServiceImpl.java
...c/main/java/com/jz/dm/service/impl/ApiLogServiceImpl.java
+27
-1
AuthServiceImpl.java
...src/main/java/com/jz/dm/service/impl/AuthServiceImpl.java
+15
-0
OrganizationManageImpl.java
...n/java/com/jz/dm/service/impl/OrganizationManageImpl.java
+34
-18
ProducerServiceImpl.java
...main/java/com/jz/dm/service/impl/ProducerServiceImpl.java
+23
-23
SystemLogAspect.java
...y/src/main/java/com/jz/dm/web/aspect/SystemLogAspect.java
+1
-1
application.yml
jz-dm-apigateway/src/main/resources/application.yml
+11
-8
ApiReqLogMapper.xml
...-apigateway/src/main/resources/mapper/ApiReqLogMapper.xml
+6
-0
No files found.
database/zc/api_gateway.sql
View file @
7d0abfd9
...
...
@@ -87,6 +87,7 @@ CREATE TABLE `t_api_org` (
`org_desc`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'组织描述'
,
`org_cn_name`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'组织英文名称'
,
`org_phone`
varchar
(
20
)
NULL
DEFAULT
NULL
COMMENT
'组织电话'
,
`linkman`
varchar
(
50
)
NULL
DEFAULT
NULL
COMMENT
'组织联系人'
`org_type`
varchar
(
20
)
NULL
DEFAULT
NULL
COMMENT
'组织类型:OUT 外部组织, IN 内部组织'
,
`status`
varchar
(
100
)
NOT
NULL
COMMENT
'状态(NORMAL-正常 FREEZE-冻结 CANCEL-注销)'
,
`org_mail`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'组织邮箱'
,
...
...
@@ -145,7 +146,9 @@ CREATE TABLE `t_api_req_log` (
`encry_mode`
varchar
(
20
)
DEFAULT
NULL
COMMENT
'加密方式:MD5,RSA'
,
`trans_mode`
varchar
(
20
)
DEFAULT
NULL
COMMENT
'传输方式:POST,GET'
,
`request_token`
varchar
(
64
)
DEFAULT
NULL
COMMENT
'客户请求token'
,
`request_time`
datetime
DEFAULT
NULL
COMMENT
'请求时间'
,
`request_consuming`
varchar
(
64
)
DEFAULT
NULL
COMMENT
'请求总耗时'
,
`request_start_time`
datetime
DEFAULT
NULL
COMMENT
'请求开始时间'
,
`request_end_time`
datetime
DEFAULT
NULL
COMMENT
'请求结束时间'
,
`status`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'状态:SUCCEED 请求成功, FAIL 请求失败'
,
`remark`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'备注'
,
`create_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
COMMENT
'创建时间'
,
...
...
jz-dm-apigateway/pom.xml
View file @
7d0abfd9
...
...
@@ -9,7 +9,6 @@
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
jz-dm-apigateway
</artifactId>
<dependencies>
<!-- spring-boot -->
<dependency>
...
...
@@ -98,6 +97,27 @@
<!-- <version>0.9.0.RELEASE</version>-->
</dependency>
<!-- 客户端需要引入 Transport 模块来与 Sentinel 控制台进行通信 -->
<dependency>
<groupId>
com.alibaba.csp
</groupId>
<artifactId>
sentinel-transport-simple-http
</artifactId>
</dependency>
<dependency>
<groupId>
com.alibaba.csp
</groupId>
<artifactId>
sentinel-parameter-flow-control
</artifactId>
</dependency>
<!-- 开启注解 -->
<dependency>
<groupId>
com.alibaba.csp
</groupId>
<artifactId>
sentinel-annotation-aspectj
</artifactId>
</dependency>
<dependency>
<groupId>
com.alibaba.csp
</groupId>
<artifactId>
sentinel-core
</artifactId>
</dependency>
<dependency>
<groupId>
net.sf.json-lib
</groupId>
<artifactId>
json-lib
</artifactId>
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/controller/ApiInterfaceController.java
View file @
7d0abfd9
...
...
@@ -85,4 +85,5 @@ public class ApiInterfaceController {
public
Mono
<
Result
>
apiTestApiInterface
(
@RequestParam
(
name
=
"apiKey"
)
String
apiKey
)
{
return
Mono
.
fromSupplier
(()
->
apiInterfaceService
.
apiTestInterface
(
apiKey
));
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/controller/ApiLogController.java
View file @
7d0abfd9
...
...
@@ -7,10 +7,7 @@ import com.jz.dm.service.ApiLogService;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
reactor.core.publisher.Mono
;
import
javax.validation.Valid
;
...
...
@@ -54,4 +51,15 @@ public class ApiLogController {
public
Mono
<
Result
>
getApiLogDetail
(
@RequestBody
@Valid
LogInfoDetailReq
req
)
{
return
Mono
.
fromSupplier
(()
->
apiLogService
.
getApiLogDetail
(
req
));
}
/**
* @Description:Api调用统计
* @return: DMP-Api调用统计
* @Author: Mr.zhang
* @Date: 2020-12-24
*/
@ApiOperation
(
"DMP-Api调用统计"
)
@GetMapping
(
value
=
"/countAPiCallStat"
)
public
Mono
<
Result
>
countAPiCallStat
(
@RequestParam
(
name
=
"date"
)
String
date
)
{
return
Mono
.
fromSupplier
(()
->
apiLogService
.
countAPiCallStat
(
date
));
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/controller/AuthController.java
View file @
7d0abfd9
...
...
@@ -73,6 +73,17 @@ public class AuthController {
public
Mono
<
Result
>
selectAuthListInfo
(
@RequestBody
@Valid
AuthListInfoReq
req
)
{
return
Mono
.
fromSupplier
(()
->
authService
.
getAuthListInfo
(
req
));
}
/**
* @Description: 授权模糊查询列表信息
* @return: 认证列表查询
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation
(
"授权模糊查询列表信息"
)
@GetMapping
(
value
=
"/getAuthNameList"
)
public
Mono
<
Result
>
getAuthNameList
(
@RequestParam
(
"key"
)
String
key
)
{
return
Mono
.
fromSupplier
(()
->
authService
.
getAuthNameList
(
key
));
}
/**
* @Description: 认证信息修改
* @return: 认证信息修改
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/controller/OrganizationManageController.java
View file @
7d0abfd9
...
...
@@ -4,7 +4,6 @@ import com.jz.common.utils.Result;
import
com.jz.dm.models.req.organizationManage.OrganizationManageAddReq
;
import
com.jz.dm.models.req.organizationManage.OrganizationManageDetailQueryReq
;
import
com.jz.dm.models.req.organizationManage.OrganizationManageListQueryReq
;
import
com.jz.dm.models.req.organizationManage.OrganizationManageUpdateReq
;
import
com.jz.dm.service.OrganizationManageService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -58,7 +57,7 @@ public class OrganizationManageController {
* @Author: Mr.zhang
* @Date: 2020-12-24
*/
@ApiOperation
(
"添加组织"
)
@ApiOperation
(
"添加
/更新
组织"
)
@PostMapping
(
value
=
"/add"
)
public
Mono
<
Result
>
add
(
@RequestBody
@Valid
OrganizationManageAddReq
req
)
{
return
Mono
.
fromSupplier
(()
->
organizationManageService
.
add
(
req
));
...
...
@@ -68,11 +67,11 @@ public class OrganizationManageController {
* @Author: Mr.zhang
* @Date: 2020-12-24
*/
@ApiOperation
(
"更新组织信息"
)
/*
@ApiOperation("更新组织信息")
@PostMapping(value = "/update")
public Mono<Result> update(@RequestBody @Valid OrganizationManageUpdateReq req) {
return Mono.fromSupplier(() -> organizationManageService.update(req));
}
}
*/
/**
* @Description:注销组织
* @Author: Mr.zhang
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/mapper/ApiReqLogMapper.java
View file @
7d0abfd9
...
...
@@ -2,8 +2,12 @@ package com.jz.dm.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.jz.dm.models.domian.ApiReqLog
;
import
com.jz.dm.models.dto.ApiCallDataDto
;
import
org.apache.ibatis.annotations.Select
;
import
java.util.Date
;
import
java.util.List
;
/**api请求日志表 mapper
* @author ybz
*/
...
...
@@ -16,4 +20,11 @@ public interface ApiReqLogMapper extends BaseMapper<ApiReqLog> {
*/
@Select
(
"SELECT * FROM t_api_req_log WHERE id =(SELECT MAX(id) FROM t_api_req_log)"
)
ApiReqLog
maxId
(
Long
id
);
/**
* 统计API调用
* @return
*/
List
<
ApiCallDataDto
>
countApiCallMonthData
(
Date
date
);
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiOrg.java
View file @
7d0abfd9
...
...
@@ -50,6 +50,11 @@ public class ApiOrg extends BaseObject implements Serializable {
*/
@TableField
(
"org_phone"
)
private
String
orgPhone
;
/**
* 组织联系人
*/
@TableField
(
"linkman"
)
private
String
linkman
;
/**
* 组织类型 OUT 外部组织 IN 内部组织
*/
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiReqLog.java
View file @
7d0abfd9
...
...
@@ -90,13 +90,27 @@ public class ApiReqLog implements Serializable {
private
String
requestToken
;
/**
* 请求
时间
* 请求
总耗时
*/
@ApiModelProperty
(
"请求时间"
)
@TableField
(
"request_time"
)
@ApiModelProperty
(
"请求总耗时"
)
@TableField
(
"request_consuming"
)
private
Double
requestConsuming
;
/**
* 请求开始时间
*/
@ApiModelProperty
(
"请求开始时间"
)
@TableField
(
"request_start_time"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
requestStartTime
;
/**
* 请求结束时间
*/
@ApiModelProperty
(
"请求结束时间"
)
@TableField
(
"request_end_time"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
requestTime
;
private
Date
request
End
Time
;
/**
* 请求状态: SUCCEED 成功 ,FAIL 失败
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/organizationManage/OrganizationManageAddReq.java
View file @
7d0abfd9
...
...
@@ -40,9 +40,22 @@ public class OrganizationManageAddReq implements Serializable {
@ApiModelProperty
(
value
=
"组织电话"
,
required
=
false
)
private
String
orgPhone
;
@ApiModelProperty
(
value
=
"组织联系人"
,
required
=
false
)
private
String
linkman
;
@ApiModelProperty
(
value
=
"备注"
,
required
=
false
)
private
String
remark
;
@ApiModelProperty
(
value
=
"创建用户"
,
required
=
false
)
private
String
createUser
;
@ApiModelProperty
(
value
=
"创建用户"
,
required
=
false
)
private
String
updateUser
;
@ApiModelProperty
(
value
=
"id ----更新时必传"
,
required
=
false
)
private
Long
id
;
@ApiModelProperty
(
value
=
"状态(true-正常 false-注销----更新时传"
,
required
=
false
)
private
Boolean
status
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/ApiInterfaceService.java
View file @
7d0abfd9
...
...
@@ -82,4 +82,7 @@ public interface ApiInterfaceService {
* @return
*/
Result
apiTestInterface
(
String
apiKey
);
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/ApiLogService.java
View file @
7d0abfd9
...
...
@@ -43,4 +43,11 @@ public interface ApiLogService {
* @param jsonObject
*/
void
updateLog
(
Long
id
,
JSONObject
jsonObject
);
/**
* 统计API调用数据
* @param date
* @return
*/
Result
countAPiCallStat
(
String
date
);
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/AuthService.java
View file @
7d0abfd9
...
...
@@ -77,4 +77,11 @@ public interface AuthService {
* @return
*/
int
updateApiAuthStatus
(
ApiAuth
apiAuth
);
/**
* 根据名称/组织编号摸索查询
* @param key
* @return
*/
Result
getAuthNameList
(
String
key
);
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/OrganizationManageService.java
View file @
7d0abfd9
...
...
@@ -6,7 +6,6 @@ import com.jz.dm.models.domian.ApiOrg;
import
com.jz.dm.models.req.organizationManage.OrganizationManageAddReq
;
import
com.jz.dm.models.req.organizationManage.OrganizationManageDetailQueryReq
;
import
com.jz.dm.models.req.organizationManage.OrganizationManageListQueryReq
;
import
com.jz.dm.models.req.organizationManage.OrganizationManageUpdateReq
;
/**
* @author ZC
...
...
@@ -44,7 +43,7 @@ public interface OrganizationManageService {
* @param req
* @return
*/
Result
update
(
OrganizationManageUpdateReq
req
);
//
Result update(OrganizationManageUpdateReq req);
/**
* 根据id注销组织
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/ApiInterfaceServiceImpl.java
View file @
7d0abfd9
...
...
@@ -226,6 +226,7 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
}
/**
* 获取用户授权信息
*
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/ApiLogServiceImpl.java
View file @
7d0abfd9
...
...
@@ -19,6 +19,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.text.SimpleDateFormat
;
import
java.util.Calendar
;
import
java.util.Date
;
/**
...
...
@@ -34,6 +36,7 @@ import java.util.Date;
@Slf4j
public
class
ApiLogServiceImpl
implements
ApiLogService
{
@Resource
private
ApiReqLogMapper
apiReqLogMapper
;
// 加锁
...
...
@@ -77,7 +80,22 @@ public class ApiLogServiceImpl implements ApiLogService {
public
void
insetLogInfo
(
ApiReqLog
reqLog
)
{
apiReqLogMapper
.
insert
(
reqLog
);
}
/**
* api计量统计
* @param date
* @return
*/
@Override
public
Result
countAPiCallStat
(
String
date
)
{
Date
dateParam
=
null
;
try
{
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"YYYY-MM"
);
dateParam
=
dateFormat
.
parse
(
date
);
}
catch
(
Exception
ex
){
log
.
error
(
"时间转换异常:{}"
,
ex
.
getMessage
());
}
return
Result
.
of_success
(
apiReqLogMapper
.
countApiCallMonthData
(
dateParam
));
}
/**
* 根据id更新日志
...
...
@@ -98,6 +116,12 @@ public class ApiLogServiceImpl implements ApiLogService {
}
update
.
set
(
"response_params"
,
jsonObject
.
toString
());
update
.
set
(
"update_date"
,
new
Date
());
update
.
set
(
"request_end_time"
,
new
Date
());
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
apiReqLog
.
getRequestStartTime
());
Long
time
=
System
.
currentTimeMillis
()
-
calendar
.
getTimeInMillis
()
/
1000
;
double
timeConsuming
=
time
.
doubleValue
();
update
.
set
(
"request_consuming"
,
timeConsuming
);
update
.
eq
(
"id"
,
id
);
if
(
apiReqLogMapper
.
update
(
null
,
update
)
==
0
){
log
.
info
(
"~~~~~~~~~~~更新日志信息失败~~~~~~~~"
);
...
...
@@ -109,4 +133,6 @@ public class ApiLogServiceImpl implements ApiLogService {
log
.
error
(
"更新日志返回信息异常:{}"
,
ex
.
getMessage
());
}
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/AuthServiceImpl.java
View file @
7d0abfd9
...
...
@@ -346,6 +346,21 @@ public class AuthServiceImpl implements AuthService {
return
apiAuthMapper
.
update
(
null
,
update
);
}
/**
* 模糊查询/
* @param key
* @return
*/
@Override
public
Result
getAuthNameList
(
String
key
)
{
QueryWrapper
<
ApiOrg
>
query
=
new
QueryWrapper
<>();
if
(
StringUtils
.
isNotBlank
(
key
)){
query
.
and
(
wrapper
->
wrapper
.
like
(
"org_name"
,
key
)
.
or
().
like
(
"org_code"
,
key
));
}
return
Result
.
of_success
(
apiOrgMapper
.
selectList
(
query
));
}
private
ApiInterface
getInterface
(
String
apiKey
)
{
QueryWrapper
<
ApiInterface
>
queryInface
=
new
QueryWrapper
<>();
queryInface
.
last
(
"where is_deleted=0 and api_key ='"
+
apiKey
+
"'"
);
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/OrganizationManageImpl.java
View file @
7d0abfd9
...
...
@@ -14,7 +14,6 @@ import com.jz.dm.models.domian.ApiOrg;
import
com.jz.dm.models.req.organizationManage.OrganizationManageAddReq
;
import
com.jz.dm.models.req.organizationManage.OrganizationManageDetailQueryReq
;
import
com.jz.dm.models.req.organizationManage.OrganizationManageListQueryReq
;
import
com.jz.dm.models.req.organizationManage.OrganizationManageUpdateReq
;
import
com.jz.dm.service.OrganizationManageService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -24,7 +23,6 @@ import org.springframework.stereotype.Service;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
static
com
.
jz
.
dm
.
common
.
enums
.
org
.
OrgStatusEnum
.
fromTypeName
;
import
static
com
.
jz
.
dm
.
common
.
enums
.
org
.
OrgTypeEnum
.
fromOrgTypeEnumName
;
/**
...
...
@@ -102,6 +100,23 @@ public class OrganizationManageImpl implements OrganizationManageService {
String
coding
=
""
;
ApiOrg
apiOrg
=
new
ApiOrg
();
BeanUtils
.
copyProperties
(
req
,
apiOrg
);
//更新
if
(
null
!=
req
.
getId
()){
ApiOrg
org
=
apiOrgMapper
.
selectById
(
req
.
getId
());
if
(
null
==
org
){
return
Result
.
of_error
(
ResultMsg
.
DATA_NOT_EXIST
);
}
if
(
req
.
getStatus
()){
org
.
setStatus
(
OrgStatusEnum
.
NORMAL
.
name
());
}
else
{
org
.
setStatus
(
OrgStatusEnum
.
CANCEL
.
name
());
}
org
.
setUpdateDate
(
new
Date
());
if
(
apiOrgMapper
.
updateById
(
apiOrg
)
>
0
){
return
Result
.
of_success
(
ResultMsg
.
UPDATE_SUCCESS
);
}
//添加
}
else
{
if
(
StringUtils
.
isNotBlank
(
req
.
getOrgType
())
//内部组织
&&
Constants
.
AUTH_INT
.
equals
(
req
.
getOrgType
()))
{
coding
=
generateCode
(
req
.
getOrgName
(),
Constants
.
AUTH_INT
);
...
...
@@ -116,7 +131,8 @@ public class OrganizationManageImpl implements OrganizationManageService {
if
(
apiOrgMapper
.
insert
(
apiOrg
)
>
0
)
{
return
Result
.
of_success
(
ResultMsg
.
INSERT_SUCCESS
);
}
return
Result
.
of_error
(
ResultMsg
.
INSERT_FAIL
);
}
return
Result
.
of_error
(
ResultMsg
.
FAILURE
);
}
/**
...
...
@@ -144,7 +160,7 @@ public class OrganizationManageImpl implements OrganizationManageService {
* @param req
* @return
*/
@Override
/*
@Override
public Result update(OrganizationManageUpdateReq req) {
ApiOrg apiOrg = apiOrgMapper.selectById(req.getId());
if (null == apiOrg) {
...
...
@@ -166,7 +182,7 @@ public class OrganizationManageImpl implements OrganizationManageService {
return Result.of_success(ResultMsg.UPDATE_SUCCESS);
}
return Result.of_success(ResultMsg.UPDATE_FAIL);
}
}
*/
/**
* 注销组织
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/ProducerServiceImpl.java
View file @
7d0abfd9
...
...
@@ -12,7 +12,6 @@ import com.jz.common.utils.HttpsUtils;
import
com.jz.common.utils.Md5
;
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.GeneralStatusTypeEnum
;
import
com.jz.dm.common.enums.apiInterface.ApiInfoOutTypeEnum
;
import
com.jz.dm.common.enums.apiInterface.ApiStatusEnum
;
...
...
@@ -156,17 +155,18 @@ public class ProducerServiceImpl implements ProducerService {
if
(
fileSource
.
size
()
==
0
||
fileSource
.
size
()
>=
2
)
{
return
Result
.
of_error
(
"文件夹信息异常!"
);
}
if
(
StringUtils
.
isNotBlank
(
req
.
getOutputType
())
&&
(!
req
.
getOutputType
().
contains
(
ApiInfoOutTypeEnum
.
JSON
.
name
())
||
!
req
.
getOutputType
().
contains
(
ApiInfoOutTypeEnum
.
FLOW
.
name
()
)))
{
if
(
StringUtils
.
isNotBlank
(
req
.
getOutputType
())
)
{
if
(!
req
.
getOutputType
().
contains
(
ApiInfoOutTypeEnum
.
JSON
.
name
())
||
!
req
.
getOutputType
().
contains
(
ApiInfoOutTypeEnum
.
FLOW
.
name
(
)))
{
return
Result
.
of_error
(
"输出类型不存在!"
);
}
}
if
(
StringUtils
.
isNotBlank
(
req
.
getReqType
()))
{
if
(
null
==
fromAuthReqTypeEnum
(
req
.
getReqType
()))
{
return
Result
.
of_error
(
"限流类型不存在!"
);
}
}
String
signStr
=
dataBankToken
+
req
.
getJoinType
()
+
System
.
currentTimeMillis
()
;
String
signStr
=
dataBankToken
+
req
.
getJoinType
();
String
signResult
=
Md5
.
encrypt
(
signStr
,
""
);
if
(!
signResult
.
equals
(
req
.
getSign
()))
{
return
Result
.
of_error
(
"签名错误!"
);
...
...
@@ -199,9 +199,9 @@ public class ProducerServiceImpl implements ProducerService {
ApiInterface
apiInterface
=
saveApiInterFace
(
req
,
apiKey
,
apiType
);
saveApiInterFaceCustom
(
req
,
apiKey
,
apiInterface
.
getId
());
JSONObject
object
=
new
JSONObject
();
object
.
put
(
"targetUrl"
,
req
.
getTargetUrl
());
object
.
put
(
"outputType"
,
req
.
getOutputType
());
saveObjOnRedis
(
apiInterface
.
getApiKey
(),
object
);
object
.
put
(
"targetUrl"
,
req
.
getTargetUrl
());
object
.
put
(
"outputType"
,
req
.
getOutputType
());
saveObjOnRedis
(
apiInterface
.
getApiKey
(),
object
);
}
/**
...
...
@@ -300,12 +300,12 @@ public class ProducerServiceImpl implements ProducerService {
if
(
CollectionUtils
.
isNotEmpty
(
listApiEsFields
))
{
apiOpenApiEsFieldsMapper
.
insetBatch
(
listApiEsFields
);
}
//调用dmp接口获取数据库连接信息
/*
//调用dmp接口获取数据库连接信息
ApiSyncingDatasource dataSource = apiSyncingDatasourceMapper.selectById(req.getEsDataSource());
if (null != dataSource) {
//esjdbc 连接地址 用于接口中调用获取es数据
redisUtils.set(TagConstants.OPEN_API_ESTAG_JDBC_INFO_NAMESPACE + apiInterface.getApiKey(), dataSource.getJdbcUrl());
}
}
*/
int
result
=
0
;
ApiInterfaceCustom
interfaceCustom
=
new
ApiInterfaceCustom
();
if
(
null
!=
req
.
getId
()
&&
!
""
.
equals
(
req
.
getId
()))
{
//更新
...
...
@@ -367,9 +367,9 @@ public class ProducerServiceImpl implements ProducerService {
throw
ResponseException
.
of_error
(
"保存Api信息失败!"
);
}
JSONObject
object
=
new
JSONObject
();
object
.
put
(
"targetUrl"
,
req
.
getTargetUrl
());
object
.
put
(
"outputType"
,
ApiInfoOutTypeEnum
.
JSON
.
name
());
saveObjOnRedis
(
apiInterface
.
getApiKey
(),
object
);
object
.
put
(
"targetUrl"
,
req
.
getTargetUrl
());
object
.
put
(
"outputType"
,
ApiInfoOutTypeEnum
.
JSON
.
name
());
saveObjOnRedis
(
apiInterface
.
getApiKey
(),
object
);
return
Result
.
of_success
(
ResultMsg
.
INSERT_SUCCESS
,
apiKey
);
}
...
...
@@ -386,12 +386,12 @@ public class ProducerServiceImpl implements ProducerService {
}
try
{
String
paramKey
=
redisUtils
.
get
(
apiKey
);
if
(
null
!=
paramKey
){
if
(
null
!=
paramKey
)
{
redisUtils
.
del
(
apiKey
);
}
redisUtils
.
set
(
apiKey
,
params
.
toString
());
}
catch
(
Exception
ex
)
{
log
.
error
(
"缓存api制作数据异常:{}"
,
ex
.
getMessage
());
log
.
error
(
"缓存api制作数据异常:{}"
,
ex
.
getMessage
());
ex
.
printStackTrace
();
}
}
...
...
@@ -505,9 +505,9 @@ public class ProducerServiceImpl implements ProducerService {
return
Result
.
of_success
(
ResultMsg
.
UPDATE_SUCCESS
);
}
JSONObject
object
=
new
JSONObject
();
object
.
put
(
"targetUrl"
,
req
.
getTargetUrl
());
object
.
put
(
"outputType"
,
ApiInfoOutTypeEnum
.
JSON
.
name
());
saveObjOnRedis
(
apiInterface
.
getApiKey
(),
object
);
object
.
put
(
"targetUrl"
,
req
.
getTargetUrl
());
object
.
put
(
"outputType"
,
ApiInfoOutTypeEnum
.
JSON
.
name
());
saveObjOnRedis
(
apiInterface
.
getApiKey
(),
object
);
return
Result
.
of_success
(
ResultMsg
.
UPDATE_FAIL
);
}
...
...
@@ -707,9 +707,9 @@ public class ProducerServiceImpl implements ProducerService {
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(bankApiReq);
redisUtils.set("apiKeyTest", jsonObject, 300);*/
JSONObject
object
=
new
JSONObject
();
object
.
put
(
"targetUrl"
,
"www.baidu.common"
);
object
.
put
(
"outputType"
,
ApiInfoOutTypeEnum
.
JSON
.
name
());
saveObjOnRedis
(
"apiKeyTest002"
,
object
);
object
.
put
(
"targetUrl"
,
"www.baidu.common"
);
object
.
put
(
"outputType"
,
ApiInfoOutTypeEnum
.
JSON
.
name
());
saveObjOnRedis
(
"apiKeyTest002"
,
object
);
return
Result
.
ok
();
}
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/web/aspect/SystemLogAspect.java
View file @
7d0abfd9
...
...
@@ -105,7 +105,7 @@ public class SystemLogAspect {
reqLog
.
setEncryMode
(
"MD5"
);
//加密方式暂时写死MD5
reqLog
.
setTransMode
(
request
.
getMethod
());
//传输方式 GET POST
reqLog
.
setRequestToken
(
jsonParamsList
.
getString
(
"authCode"
));
reqLog
.
setRequestTime
(
new
Date
());
reqLog
.
setRequest
Start
Time
(
new
Date
());
reqLog
.
setRemark
(
getServiceMethodDescription
(
joinPoint
));
log
.
info
(
"请求参数:"
,
reqLog
);
if
(
null
!=
reqLog
)
{
...
...
jz-dm-apigateway/src/main/resources/application.yml
View file @
7d0abfd9
...
...
@@ -21,13 +21,16 @@ spring:
profiles
:
active
:
test
#默认使用的配置文件
cloud
:
sentinel
:
#sentinel 限流框架配置
sentinel
:
transport
:
# 项目本地会启动一个服务的端口号,默认8719,用于与sentinel-dashboard通讯
port
:
8719
# sentinel-dashboard服务地址 # sentinel-dashboard-1.6.0 的访问路径 ,
#启动方式java -jar sentinel-dashboard-1.6.0.jar --server.port=9090
dashboard
:
localhost:9090
dashboard
:
localhost:8080
heartbeat-interval-ms
:
500
# 项目本地会启动一个服务的端口号,默认8719,用于与sentinel-dashboard通讯
port
:
8719
#服务器ip
clientIp
:
192.168.1.114
filter
:
# 需要进行限流监控的接口,多个匹配用逗号隔开
url-patterns
:
/*
...
...
@@ -35,7 +38,7 @@ spring:
# 触发限流后重定向的页面
block-page
:
/sentinel/block
#取消Sentinel控制台懒加载
#
eager: true
eager
:
true
# ====================MybatisPlus====================
mybatis-plus
:
...
...
jz-dm-apigateway/src/main/resources/mapper/ApiReqLogMapper.xml
View file @
7d0abfd9
...
...
@@ -7,5 +7,11 @@
request_token, request_time, remark, create_date, create_user,
update_date, update_user, is_deleted
</sql>
<select
id=
"countApiCallMonthData"
resultType=
"com.jz.dm.models.dto.ApiCallDataDto"
>
SELECT COUNT(1) AS callLimit,
SUM(request_consuming) AS timeStat
FROM t_api_req_log
WHERE DATE_FORMAT(create_date,'%Y:%m')=DATE_FORMAT(#{date},'%Y:%m')
</select>
</mapper>
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