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
986c9500
Commit
986c9500
authored
Jan 01, 2021
by
zhangc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化部分代码
parent
7893c12f
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
265 additions
and
9 deletions
+265
-9
api_gateway.sql
database/zc/api_gateway.sql
+18
-1
ApiStatusEnum.java
...va/com/jz/dm/common/enums/apiInterface/ApiStatusEnum.java
+8
-0
AuthModeEnum.java
...c/main/java/com/jz/dm/common/enums/auth/AuthModeEnum.java
+9
-0
AuthTypeEnum.java
...c/main/java/com/jz/dm/common/enums/auth/AuthTypeEnum.java
+9
-0
DirectionTypeEnum.java
...a/com/jz/dm/common/enums/direction/DirectionTypeEnum.java
+26
-0
ApiDirectionController.java
...ain/java/com/jz/dm/controller/ApiDirectionController.java
+42
-0
ApiDirectionMapper.java
...ay/src/main/java/com/jz/dm/mapper/ApiDirectionMapper.java
+13
-0
ApiDirection.java
...y/src/main/java/com/jz/dm/models/domian/ApiDirection.java
+69
-0
ApiDirectionService.java
.../src/main/java/com/jz/dm/service/ApiDirectionService.java
+24
-0
ApiDirectionServiceImpl.java
.../java/com/jz/dm/service/impl/ApiDirectionServiceImpl.java
+36
-0
ApiLogServiceImpl.java
...c/main/java/com/jz/dm/service/impl/ApiLogServiceImpl.java
+1
-7
SystemLogAspect.java
...y/src/main/java/com/jz/dm/web/aspect/SystemLogAspect.java
+4
-1
ApiDirectionlMapper.xml
...gateway/src/main/resources/mapper/ApiDirectionlMapper.xml
+6
-0
No files found.
database/zc/api_gateway.sql
View file @
986c9500
...
...
@@ -244,4 +244,21 @@ CREATE TABLE `t_api_syncing_datasource_type` (
`update_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'更新人'
,
`is_deleted`
tinyint
(
2
)
unsigned
NOT
NULL
DEFAULT
'0'
COMMENT
'是否删除'
,
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
1
DEFAULT
CHARSET
=
utf8mb4
ROW_FORMAT
=
DYNAMIC
COMMENT
=
'api数据源类型信息表'
;
\ No newline at end of file
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
1
DEFAULT
CHARSET
=
utf8mb4
ROW_FORMAT
=
DYNAMIC
COMMENT
=
'api数据源类型信息表'
;
#
字典表
DROP
TABLE
IF
EXISTS
`t_api_direction`
;
CREATE
TABLE
`t_api_direction`
(
`id`
bigint
(
20
)
unsigned
NOT
NULL
AUTO_INCREMENT
COMMENT
'自增ID'
,
`key`
varchar
(
64
)
DEFAULT
NULL
COMMENT
'字典key'
,
`value`
varchar
(
64
)
DEFAULT
NULL
COMMENT
'字典value'
,
`code`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'字典编码'
,
`parent`
varchar
(
32
)
DEFAULT
NULL
COMMENT
'父节点'
,
`direction_type`
varchar
(
32
)
DEFAULT
NULL
COMMENT
'字典类型'
,
`level`
int
(
10
)
DEFAULT
NULL
COMMENT
'等级'
,
`is_enabled`
char
(
1
)
DEFAULT
NULL
COMMENT
'是否启用'
,
`create_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
COMMENT
'创建时间'
,
`create_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'创建人'
,
`is_deleted`
tinyint
(
2
)
unsigned
NOT
NULL
DEFAULT
'0'
COMMENT
'是否删除'
,
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
1
DEFAULT
CHARSET
=
utf8mb4
ROW_FORMAT
=
DYNAMIC
COMMENT
=
'api字典表信息表'
;
\ No newline at end of file
jz-dm-apigateway/src/main/java/com/jz/dm/common/enums/apiInterface/ApiStatusEnum.java
View file @
986c9500
...
...
@@ -42,4 +42,12 @@ public enum ApiStatusEnum {
return
text
;
}
public
static
ApiStatusEnum
fromTypeName
(
String
typeName
)
{
for
(
ApiStatusEnum
type
:
ApiStatusEnum
.
values
())
{
if
(
type
.
name
().
equals
(
typeName
))
{
return
type
;
}
}
return
null
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/enums/auth/AuthModeEnum.java
View file @
986c9500
...
...
@@ -34,4 +34,13 @@ public enum AuthModeEnum {
public
String
getText
()
{
return
text
;
}
public
static
AuthModeEnum
fromTypeName
(
String
typeName
)
{
for
(
AuthModeEnum
type
:
AuthModeEnum
.
values
())
{
if
(
type
.
name
().
equals
(
typeName
))
{
return
type
;
}
}
return
null
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/enums/auth/AuthTypeEnum.java
View file @
986c9500
...
...
@@ -29,4 +29,13 @@ public enum AuthTypeEnum {
public
String
getText
()
{
return
text
;
}
public
static
AuthTypeEnum
fromTypeName
(
String
typeName
)
{
for
(
AuthTypeEnum
type
:
AuthTypeEnum
.
values
())
{
if
(
type
.
name
().
equals
(
typeName
))
{
return
type
;
}
}
return
null
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/enums/direction/DirectionTypeEnum.java
0 → 100644
View file @
986c9500
package
com
.
jz
.
dm
.
common
.
enums
.
direction
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.common.enums
* @PROJECT_NAME: jz-dm-parent
* @NAME: DirectionTypeEnum
* @DATE: 2020-12-31/18:39
* @DAY_NAME_SHORT: 周四
* @Description:
**/
public
enum
DirectionTypeEnum
{
/**
* API类型
*/
API_TYPE
;
public
static
DirectionTypeEnum
fromTypeName
(
String
typeName
)
{
for
(
DirectionTypeEnum
type
:
DirectionTypeEnum
.
values
())
{
if
(
type
.
name
().
equals
(
typeName
))
{
return
type
;
}
}
return
null
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/controller/ApiDirectionController.java
0 → 100644
View file @
986c9500
package
com
.
jz
.
dm
.
controller
;
import
com.jz.common.utils.Result
;
import
com.jz.dm.service.ApiDirectionService
;
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.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
reactor.core.publisher.Mono
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.controller
* @PROJECT_NAME: jz-dm-parent
* @NAME: ApiLogController
* @DATE: 2020-12-25/14:25
* @DAY_NAME_SHORT: 周五
* @Description:
**/
@RestController
@RequestMapping
(
"api/direction"
)
@Api
(
tags
=
"API字典信息Controller"
)
public
class
ApiDirectionController
{
@Autowired
private
ApiDirectionService
apiDirectionService
;
/**
* @Description:api类型列表
* @return: api类型列表
* @Author: Mr.zhang
* @Date: 2020-12-24
*/
@ApiOperation
(
"api类型列表"
)
@PostMapping
(
value
=
"/getApiTypeList"
)
public
Mono
<
Result
>
getApiTypeList
(
@RequestParam
(
name
=
"type"
)
String
type
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
apiDirectionService
.
getApiType
(
type
)));
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/mapper/ApiDirectionMapper.java
0 → 100644
View file @
986c9500
package
com
.
jz
.
dm
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.jz.dm.models.domian.ApiDirection
;
/**api授权信息表 mapper
* @author zc
*
*/
public
interface
ApiDirectionMapper
extends
BaseMapper
<
ApiDirection
>
{
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiDirection.java
0 → 100644
View file @
986c9500
package
com
.
jz
.
dm
.
models
.
domian
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.jz.dm.common.base.BaseObject
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.NoArgsConstructor
;
import
lombok.experimental.Accessors
;
import
java.io.Serializable
;
/**
* @Description:
* @Author: Mr.zhang
* @Date: 2020-12-23
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@TableName
(
"t_api_direction"
)
public
class
ApiDirection
extends
BaseObject
implements
Serializable
{
/**
* 字典key
*/
@TableField
(
"key"
)
private
String
key
;
/**
* 字典value
*/
@TableField
(
"value"
)
private
String
value
;
/**
* 字典编码
*/
@TableField
(
"code"
)
private
String
code
;
/**
* 父节点
*/
@TableField
(
"parent"
)
private
String
parent
;
/**
* 字典类型
*/
@TableField
(
"direction_type"
)
private
String
directionType
;
/**
* is_enabled
*/
@TableField
(
"level"
)
private
Integer
level
;
/**
* 是否启用:UNABLE 停用,ENABLE 启用
*/
@TableField
(
"is_enabled"
)
private
String
isEnabled
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/ApiDirectionService.java
0 → 100644
View file @
986c9500
package
com
.
jz
.
dm
.
service
;
import
com.jz.dm.models.domian.ApiDirection
;
import
java.util.List
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service.impl
* @PROJECT_NAME: jz-dm-parent
* @NAME: ApiDirectionService
* @DATE: 2020-12-31/18:00
* @DAY_NAME_SHORT: 周四
* @Description:
**/
public
interface
ApiDirectionService
{
/**
* 根据类型获取API类型信息
* @param type
* @return
*/
List
<
ApiDirection
>
getApiType
(
String
type
);
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/ApiDirectionServiceImpl.java
0 → 100644
View file @
986c9500
package
com
.
jz
.
dm
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.jz.dm.mapper.ApiDirectionMapper
;
import
com.jz.dm.models.domian.ApiDirection
;
import
com.jz.dm.service.ApiDirectionService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.List
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service.impl
* @PROJECT_NAME: jz-dm-parent
* @NAME: ApiDirectionServiceImpl
* @DATE: 2020-12-31/18:01
* @DAY_NAME_SHORT: 周四
* @Description:
**/
@Service
(
"apiDirectionService"
)
@Slf4j
public
class
ApiDirectionServiceImpl
implements
ApiDirectionService
{
@Resource
private
ApiDirectionMapper
apiDirectionMapper
;
@Override
public
List
<
ApiDirection
>
getApiType
(
String
type
)
{
QueryWrapper
<
ApiDirection
>
query
=
new
QueryWrapper
<>();
query
.
eq
(
"direction_type"
,
type
);
query
.
eq
(
"is_enabled"
,
0
);
return
apiDirectionMapper
.
selectList
(
query
);
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/ApiLogServiceImpl.java
View file @
986c9500
...
...
@@ -76,14 +76,12 @@ public class ApiLogServiceImpl implements ApiLogService {
*/
@Override
public
void
updateLog
(
Long
id
,
JSONObject
jsonObject
)
{
//if (!lock.tryLock("apiLog")){
// return;
//}
try
{
ApiReqLog
apiReqLog
=
apiReqLogMapper
.
maxId
(
id
);
if
(
null
!=
apiReqLog
){
ApiReqLog
reqLog
=
new
ApiReqLog
();
reqLog
.
setId
(
apiReqLog
.
getId
());
reqLog
.
setStatus
(
apiReqLog
.
getStatus
());
reqLog
.
setResponseParams
(
jsonObject
.
toString
());
reqLog
.
setUpdateDate
(
new
Date
());
apiReqLogMapper
.
updateById
(
reqLog
);
...
...
@@ -93,9 +91,5 @@ public class ApiLogServiceImpl implements ApiLogService {
}
catch
(
Exception
ex
){
log
.
error
(
"更新日志返回信息异常:{}"
,
ex
.
getMessage
());
}
//finally {
// lock.unlock("apiLog");
//}
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/web/aspect/SystemLogAspect.java
View file @
986c9500
...
...
@@ -5,6 +5,7 @@ import com.jz.common.utils.IpUtils;
import
com.jz.common.utils.JsonUtils
;
import
com.jz.common.utils.UrlUtil
;
import
com.jz.dm.common.util.SignType
;
import
com.jz.dm.mapper.ApiReqLogMapper
;
import
com.jz.dm.models.domian.ApiReqLog
;
import
com.jz.dm.service.ApiLogService
;
import
com.jz.dm.web.annotation.ApiLogAspect
;
...
...
@@ -46,6 +47,8 @@ public class SystemLogAspect {
@Resource
private
ApiLogService
apiLogService
;
@Resource
private
ApiReqLogMapper
apiReqLogMapper
;
/* //前置通知切入点
@Pointcut("@annotation(com.jz.dm.web.annotation.ApiLogAspect)")
...
...
@@ -98,7 +101,7 @@ public class SystemLogAspect {
reqLog
.
setRemark
(
getServiceMethodDescription
(
joinPoint
));
System
.
out
.
println
(
reqLog
);
if
(
null
!=
reqLog
)
{
api
LogService
.
insetLogInfo
(
reqLog
);
api
ReqLogMapper
.
insert
(
reqLog
);
}
Object
result
=
joinPoint
.
proceed
(
joinPoint
.
getArgs
());
JSONObject
jsonObject
=
JSONObject
.
fromObject
(
result
);
...
...
jz-dm-apigateway/src/main/resources/mapper/ApiDirectionlMapper.xml
0 → 100644
View file @
986c9500
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.jz.dm.mapper.ApiDirectionMapper"
>
</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