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
1ef7d947
Commit
1ef7d947
authored
Jan 20, 2021
by
zhangc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
2b99b384
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
30 deletions
+46
-30
AuthFilter.java
...apigateway/src/main/java/com/jz/dm/filter/AuthFilter.java
+1
-2
OrganizationManageImpl.java
...n/java/com/jz/dm/service/impl/OrganizationManageImpl.java
+36
-24
SystemLogAspect.java
...y/src/main/java/com/jz/dm/web/aspect/SystemLogAspect.java
+9
-4
No files found.
jz-dm-apigateway/src/main/java/com/jz/dm/filter/AuthFilter.java
View file @
1ef7d947
...
@@ -8,7 +8,6 @@ import com.jz.dm.common.constant.Constants;
...
@@ -8,7 +8,6 @@ import com.jz.dm.common.constant.Constants;
import
com.jz.dm.common.enums.GatewayResultCode
;
import
com.jz.dm.common.enums.GatewayResultCode
;
import
com.jz.dm.common.enums.apiInterface.ApiStatusEnum
;
import
com.jz.dm.common.enums.apiInterface.ApiStatusEnum
;
import
com.jz.dm.common.enums.auth.AuthReqTypeEnum
;
import
com.jz.dm.common.enums.auth.AuthReqTypeEnum
;
import
com.jz.dm.common.enums.org.OrgStatusEnum
;
import
com.jz.dm.common.exception.GatewayException
;
import
com.jz.dm.common.exception.GatewayException
;
import
com.jz.dm.common.util.DateUtil
;
import
com.jz.dm.common.util.DateUtil
;
import
com.jz.dm.common.util.LogUtil
;
import
com.jz.dm.common.util.LogUtil
;
...
@@ -105,7 +104,7 @@ public class AuthFilter extends AbstractFilter {
...
@@ -105,7 +104,7 @@ public class AuthFilter extends AbstractFilter {
throw
new
GatewayException
(
GatewayResultCode
.
ORG_NOT_EXIST
);
throw
new
GatewayException
(
GatewayResultCode
.
ORG_NOT_EXIST
);
}
}
//状态检查(只限制按次请求$$ 不限制按时间请求)
//状态检查(只限制按次请求$$ 不限制按时间请求)
if
(!
OrgStatusEnum
.
NORMAL
.
name
().
equals
(
apiOrg
.
getStatus
()
))
{
if
(!
apiOrg
.
getStatus
(
))
{
throw
new
GatewayException
(
GatewayResultCode
.
ORG_STATE_EXCEPTION
);
throw
new
GatewayException
(
GatewayResultCode
.
ORG_STATE_EXCEPTION
);
}
}
checkBill
(
request
,
authCode
,
authAuth
,
apiOrg
);
checkBill
(
request
,
authCode
,
authAuth
,
apiOrg
);
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/OrganizationManageImpl.java
View file @
1ef7d947
...
@@ -89,7 +89,6 @@ public class OrganizationManageImpl implements OrganizationManageService {
...
@@ -89,7 +89,6 @@ public class OrganizationManageImpl implements OrganizationManageService {
*/
*/
@Override
@Override
public
Result
add
(
OrganizationManageAddReq
req
)
{
public
Result
add
(
OrganizationManageAddReq
req
)
{
String
coding
=
""
;
ApiOrg
apiOrg
=
new
ApiOrg
();
ApiOrg
apiOrg
=
new
ApiOrg
();
BeanUtils
.
copyProperties
(
req
,
apiOrg
);
BeanUtils
.
copyProperties
(
req
,
apiOrg
);
if
(
null
!=
req
.
getId
()){
//更新
if
(
null
!=
req
.
getId
()){
//更新
...
@@ -102,32 +101,45 @@ public class OrganizationManageImpl implements OrganizationManageService {
...
@@ -102,32 +101,45 @@ public class OrganizationManageImpl implements OrganizationManageService {
return
Result
.
of_success
(
ResultMsg
.
UPDATE_SUCCESS
);
return
Result
.
of_success
(
ResultMsg
.
UPDATE_SUCCESS
);
}
}
}
else
{
//添加
}
else
{
//添加
if
(
StringUtils
.
isNotBlank
(
req
.
getOrgName
()))
{
Result
result
=
addOrg
(
req
,
apiOrg
);
ApiOrg
orgNameInfo
=
getOrgNameInfo
(
req
.
getOrgName
());
if
(
result
!=
null
)
return
result
;
if
(
null
!=
orgNameInfo
)
{
}
return
Result
.
of_error
(
"组织名称已存在!"
);
return
Result
.
of_error
(
ResultMsg
.
FAILURE
);
}
}
}
if
(
StringUtils
.
isNotBlank
(
req
.
getOrgType
()))
{
/**
if
(
null
==
fromOrgTypeEnumName
(
req
.
getOrgType
())){
* 添加组织
return
Result
.
of_error
(
"组织类型不存在!"
);
* @param req
}
* @param apiOrg
}
* @return
if
(
StringUtils
.
isNotBlank
(
req
.
getOrgType
())
//内部组织
*/
&&
Constants
.
AUTH_INT
.
equals
(
req
.
getOrgType
()))
{
private
Result
addOrg
(
OrganizationManageAddReq
req
,
ApiOrg
apiOrg
)
{
coding
=
generateCode
(
req
.
getOrgName
(),
Constants
.
AUTH_INT
);
String
coding
=
""
;
}
else
{
if
(
StringUtils
.
isNotBlank
(
req
.
getOrgName
()))
{
coding
=
generateCode
(
req
.
getOrgName
(),
Constants
.
AUTH_OUT
);
ApiOrg
orgNameInfo
=
getOrgNameInfo
(
req
.
getOrgName
());
}
if
(
null
!=
orgNameInfo
)
{
if
(
StringUtils
.
isBlank
(
coding
))
{
return
Result
.
of_error
(
"组织名称已存在!"
);
return
Result
.
of_error
(
"生成组织编码异常!"
);
}
}
apiOrg
.
setOrgCode
(
coding
);
//组织编码
}
if
(
apiOrgMapper
.
insert
(
apiOrg
)
>
0
)
{
if
(
StringUtils
.
isNotBlank
(
req
.
getOrgType
()))
{
return
Result
.
of_success
(
ResultMsg
.
INSERT_SUCCESS
);
if
(
null
==
fromOrgTypeEnumName
(
req
.
getOrgType
())){
return
Result
.
of_error
(
"组织类型不存在!"
);
}
}
}
}
return
Result
.
of_error
(
ResultMsg
.
FAILURE
);
if
(
StringUtils
.
isNotBlank
(
req
.
getOrgType
())
//内部组织
&&
Constants
.
AUTH_INT
.
equals
(
req
.
getOrgType
()))
{
coding
=
generateCode
(
req
.
getOrgName
(),
Constants
.
AUTH_INT
);
}
else
{
coding
=
generateCode
(
req
.
getOrgName
(),
Constants
.
AUTH_OUT
);
}
if
(
StringUtils
.
isBlank
(
coding
))
{
return
Result
.
of_error
(
"生成组织编码异常!"
);
}
apiOrg
.
setOrgCode
(
coding
);
//组织编码
if
(
apiOrgMapper
.
insert
(
apiOrg
)
>
0
)
{
return
Result
.
of_success
(
ResultMsg
.
INSERT_SUCCESS
);
}
return
null
;
}
}
/**
/**
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/web/aspect/SystemLogAspect.java
View file @
1ef7d947
...
@@ -4,6 +4,7 @@ package com.jz.dm.web.aspect;
...
@@ -4,6 +4,7 @@ package com.jz.dm.web.aspect;
import
com.jz.common.utils.IpUtils
;
import
com.jz.common.utils.IpUtils
;
import
com.jz.common.utils.JsonUtils
;
import
com.jz.common.utils.JsonUtils
;
import
com.jz.common.utils.UrlUtil
;
import
com.jz.common.utils.UrlUtil
;
import
com.jz.dm.common.exception.GatewayException
;
import
com.jz.dm.mapper.ApiReqLogMapper
;
import
com.jz.dm.mapper.ApiReqLogMapper
;
import
com.jz.dm.models.domian.ApiReqLog
;
import
com.jz.dm.models.domian.ApiReqLog
;
import
com.jz.dm.service.ApiLogService
;
import
com.jz.dm.service.ApiLogService
;
...
@@ -93,8 +94,9 @@ public class SystemLogAspect {
...
@@ -93,8 +94,9 @@ public class SystemLogAspect {
com
.
alibaba
.
fastjson
.
JSONObject
jsonObject
=
com
.
alibaba
.
fastjson
.
JSONObject
.
parseObject
(
params
);
com
.
alibaba
.
fastjson
.
JSONObject
jsonObject
=
com
.
alibaba
.
fastjson
.
JSONObject
.
parseObject
(
params
);
String
paramsList
=
jsonObject
.
getString
(
"openApiParams"
);
String
paramsList
=
jsonObject
.
getString
(
"openApiParams"
);
com
.
alibaba
.
fastjson
.
JSONObject
jsonParamsList
=
com
.
alibaba
.
fastjson
.
JSONObject
.
parseObject
(
paramsList
);
com
.
alibaba
.
fastjson
.
JSONObject
jsonParamsList
=
com
.
alibaba
.
fastjson
.
JSONObject
.
parseObject
(
paramsList
);
try
{
ApiReqLog
reqLog
=
new
ApiReqLog
();
ApiReqLog
reqLog
=
new
ApiReqLog
();
JSONObject
jsonResult
=
null
;
try
{
reqLog
.
setRequestIp
(
ip
);
reqLog
.
setRequestIp
(
ip
);
reqLog
.
setApiKey
(
jsonObject
.
getString
(
"apiKey"
));
reqLog
.
setApiKey
(
jsonObject
.
getString
(
"apiKey"
));
reqLog
.
setRequestParams
(
params
);
reqLog
.
setRequestParams
(
params
);
...
@@ -112,10 +114,13 @@ public class SystemLogAspect {
...
@@ -112,10 +114,13 @@ public class SystemLogAspect {
apiReqLogMapper
.
insert
(
reqLog
);
apiReqLogMapper
.
insert
(
reqLog
);
}
}
Object
result
=
joinPoint
.
proceed
(
joinPoint
.
getArgs
());
Object
result
=
joinPoint
.
proceed
(
joinPoint
.
getArgs
());
JSONObject
jsonResult
=
JSONObject
.
fromObject
(
result
);
jsonResult
=
JSONObject
.
fromObject
(
result
);
log
.
info
(
"around响应结果为{}"
,
jsonResult
);
log
.
info
(
"around响应结果为{}"
,
jsonResult
);
apiLogService
.
updateLog
(
reqLog
.
getId
(),
jsonResult
);
apiLogService
.
updateLog
(
reqLog
.
getId
(),
jsonResult
);
}
catch
(
Throwable
throwable
)
{
}
catch
(
GatewayException
ex
)
{
log
.
info
(
"切面处理保存异常信息:{}"
,
ex
.
getMessage
());
apiLogService
.
updateLog
(
reqLog
.
getId
(),
jsonResult
);
}
catch
(
Throwable
throwable
){
throwable
.
printStackTrace
();
throwable
.
printStackTrace
();
}
}
}
}
...
...
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