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
03a1b37f
Commit
03a1b37f
authored
Feb 01, 2021
by
zhangc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
df27bbc5
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
166 additions
and
14 deletions
+166
-14
pom.xml
jz-dm-apigateway/pom.xml
+14
-0
MybatisPlusConfig.java
...way/src/main/java/com/jz/dm/config/MybatisPlusConfig.java
+7
-0
WebAppConfigurer.java
...eway/src/main/java/com/jz/dm/config/WebAppConfigurer.java
+3
-0
GatewayController.java
...src/main/java/com/jz/dm/controller/GatewayController.java
+4
-2
DefaultOpenApiDispatcher.java
...main/java/com/jz/dm/gateway/DefaultOpenApiDispatcher.java
+4
-3
OpenApiService.java
...teway/src/main/java/com/jz/dm/gateway/OpenApiService.java
+2
-2
MybatisPlusGenerate.java
...src/main/java/com/jz/dm/generate/MybatisPlusGenerate.java
+127
-0
GatewayRequest.java
.../src/main/java/com/jz/dm/models/enity/GatewayRequest.java
+2
-2
SendDataReq.java
...eway/src/main/java/com/jz/dm/models/resp/SendDataReq.java
+0
-2
ApiQueryService.java
.../main/java/com/jz/dm/service/request/ApiQueryService.java
+2
-2
ApiQueryTestService.java
...n/java/com/jz/dm/service/request/ApiQueryTestService.java
+1
-1
No files found.
jz-dm-apigateway/pom.xml
View file @
03a1b37f
...
@@ -136,6 +136,20 @@
...
@@ -136,6 +136,20 @@
<groupId>
org.springframework.session
</groupId>
<groupId>
org.springframework.session
</groupId>
<artifactId>
spring-session-data-redis
</artifactId>
<artifactId>
spring-session-data-redis
</artifactId>
</dependency>
</dependency>
<!-- 代码自动生成依赖 begin -->
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatis-plus-generator
</artifactId>
<version>
3.4.1
</version>
</dependency>
<!-- velocity -->
<dependency>
<groupId>
org.apache.velocity
</groupId>
<artifactId>
velocity-engine-core
</artifactId>
<version>
2.0
</version>
</dependency>
<!-- 代码自动生成依赖 end-->
</dependencies>
</dependencies>
<build>
<build>
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/config/MybatisPlusConfig.java
View file @
03a1b37f
...
@@ -27,6 +27,13 @@ public class MybatisPlusConfig {
...
@@ -27,6 +27,13 @@ public class MybatisPlusConfig {
paginationInterceptor
.
setLimit
(
500
);
paginationInterceptor
.
setLimit
(
500
);
// 开启 count 的 join 优化,只针对部分 left join
// 开启 count 的 join 优化,只针对部分 left join
paginationInterceptor
.
setCountSqlParser
(
new
JsqlParserCountOptimize
(
true
));
paginationInterceptor
.
setCountSqlParser
(
new
JsqlParserCountOptimize
(
true
));
return
paginationInterceptor
;
return
paginationInterceptor
;
}
}
/* @Bean
public MybatisPlusInterceptor mybatisPlusInterceptor(){
MybatisPlusInterceptor plusInterceptor =new MybatisPlusInterceptor();
// plusInterceptor.addInnerInterceptor();
return plusInterceptor;
}*/
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/config/WebAppConfigurer.java
View file @
03a1b37f
package
com
.
jz
.
dm
.
config
;
package
com
.
jz
.
dm
.
config
;
import
com.jz.dm.web.interceptor.AccessLimitInterceptor
;
import
com.jz.dm.web.interceptor.AccessLimitInterceptor
;
import
com.jz.dm.web.request.ApiGatewayRequestInterceptor
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.servlet.config.annotation.InterceptorRegistry
;
import
org.springframework.web.servlet.config.annotation.InterceptorRegistry
;
...
@@ -29,6 +30,8 @@ public class WebAppConfigurer extends WebMvcConfigurerAdapter {
...
@@ -29,6 +30,8 @@ public class WebAppConfigurer extends WebMvcConfigurerAdapter {
"/**/*.js"
,
//js静态资源
"/**/*.js"
,
//js静态资源
"/**/*.css"
//css静态资源
"/**/*.css"
//css静态资源
);
);
}
}
@Bean
@Bean
public
AccessLimitInterceptor
getAccessLimitInterceptor
()
{
public
AccessLimitInterceptor
getAccessLimitInterceptor
()
{
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/controller/GatewayController.java
View file @
03a1b37f
...
@@ -9,6 +9,7 @@ import com.jz.dm.models.enity.GatewayRequest;
...
@@ -9,6 +9,7 @@ import com.jz.dm.models.enity.GatewayRequest;
import
com.jz.dm.models.enity.GatewayResponse
;
import
com.jz.dm.models.enity.GatewayResponse
;
import
com.jz.dm.models.enity.RequestContext
;
import
com.jz.dm.models.enity.RequestContext
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
...
@@ -35,17 +36,18 @@ public class GatewayController {
...
@@ -35,17 +36,18 @@ public class GatewayController {
//@RequestMapping(value = "/gateway", consumes = "application/json")
//@RequestMapping(value = "/gateway", consumes = "application/json")
@PostMapping
(
value
=
"/gateway"
,
consumes
=
"application/json"
)
@PostMapping
(
value
=
"/gateway"
,
consumes
=
"application/json"
)
@ApiOperation
(
value
=
"Api请求接口"
)
public
String
gateway
(
@RequestBody
String
json
,
HttpServletRequest
httpServletRequest
,
public
String
gateway
(
@RequestBody
String
json
,
HttpServletRequest
httpServletRequest
,
HttpServletResponse
httpServletResponse
)
{
HttpServletResponse
httpServletResponse
)
{
GatewayRequest
gatewayRequest
=
JSON
.
parseObject
(
json
,
GatewayRequest
.
class
);
GatewayRequest
gatewayRequest
=
JSON
.
parseObject
(
json
,
GatewayRequest
.
class
);
return
doGateway
(
gatewayRequest
,
httpServletRequest
,
httpServletResponse
);
return
doGateway
(
gatewayRequest
,
httpServletRequest
,
httpServletResponse
);
}
}
@RequestMapping
(
value
=
"/gateway"
)
/*
@RequestMapping(value = "/gateway")
public String gateway(GatewayRequest gatewayRequest, HttpServletRequest httpServletRequest,
public String gateway(GatewayRequest gatewayRequest, HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) {
HttpServletResponse httpServletResponse) {
return doGateway(gatewayRequest, httpServletRequest, httpServletResponse);
return doGateway(gatewayRequest, httpServletRequest, httpServletResponse);
}
}
*/
private
String
doGateway
(
GatewayRequest
gatewayRequest
,
HttpServletRequest
httpServletRequest
,
private
String
doGateway
(
GatewayRequest
gatewayRequest
,
HttpServletRequest
httpServletRequest
,
HttpServletResponse
httpServletResponse
)
{
HttpServletResponse
httpServletResponse
)
{
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/gateway/DefaultOpenApiDispatcher.java
View file @
03a1b37f
...
@@ -45,7 +45,8 @@ public class DefaultOpenApiDispatcher implements OpenApiDispatcher {
...
@@ -45,7 +45,8 @@ public class DefaultOpenApiDispatcher implements OpenApiDispatcher {
@Resource
@Resource
public
void
setOpenApiServices
(
List
<
OpenApiService
>
openApiServiceList
)
{
public
void
setOpenApiServices
(
List
<
OpenApiService
>
openApiServiceList
)
{
for
(
OpenApiService
openApiService
:
openApiServiceList
)
{
for
(
OpenApiService
openApiService
:
openApiServiceList
)
{
String
openApiServiceKey
=
getOpenApiServiceKey
(
openApiService
.
getOpenApiMethod
(),
openApiService
.
getOpenApiVersion
());
String
openApiServiceKey
=
getOpenApiServiceKey
(
openApiService
.
getOpenApiMethod
(),
openApiService
.
getOpenApiVersion
());
openApiServices
.
put
(
openApiServiceKey
,
openApiService
);
openApiServices
.
put
(
openApiServiceKey
,
openApiService
);
}
}
}
}
...
@@ -58,8 +59,8 @@ public class DefaultOpenApiDispatcher implements OpenApiDispatcher {
...
@@ -58,8 +59,8 @@ public class DefaultOpenApiDispatcher implements OpenApiDispatcher {
@Override
@Override
public
String
doDispatch
(
DispatchContext
context
)
{
public
String
doDispatch
(
DispatchContext
context
)
{
OpenApiResponse
response
=
new
OpenApiResponse
();
OpenApiResponse
response
=
new
OpenApiResponse
();
String
openApiServiceKey
=
getOpenApiServiceKey
(
context
.
getOpenApiMethod
(),
String
openApiServiceKey
=
getOpenApiServiceKey
(
context
.
getOpenApiMethod
(),
context
.
getOpenApiVersion
());
context
.
getOpenApiVersion
());
OpenApiService
openApiService
=
openApiServices
.
get
(
openApiServiceKey
);
OpenApiService
openApiService
=
openApiServices
.
get
(
openApiServiceKey
);
if
(
openApiService
==
null
)
{
if
(
openApiService
==
null
)
{
response
.
setCode
(
OpenApiResultCode
.
ILLEGAL_INTERFACE
.
getCode
());
response
.
setCode
(
OpenApiResultCode
.
ILLEGAL_INTERFACE
.
getCode
());
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/gateway/OpenApiService.java
View file @
03a1b37f
...
@@ -16,10 +16,10 @@ public interface OpenApiService {
...
@@ -16,10 +16,10 @@ public interface OpenApiService {
* @return
* @return
*/
*/
public
String
getOpenApiMethod
();
public
String
getOpenApiMethod
();
/**
/**
* 获取openapi接口版本
* 获取openapi接口版本
*
*
* @return
* @return
*/
*/
public
String
getOpenApiVersion
();
public
String
getOpenApiVersion
();
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/generate/MybatisPlusGenerate.java
0 → 100644
View file @
03a1b37f
package
com
.
jz
.
dm
.
generate
;
import
com.baomidou.mybatisplus.annotation.DbType
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.core.exceptions.MybatisPlusException
;
import
com.baomidou.mybatisplus.generator.AutoGenerator
;
import
com.baomidou.mybatisplus.generator.config.DataSourceConfig
;
import
com.baomidou.mybatisplus.generator.config.GlobalConfig
;
import
com.baomidou.mybatisplus.generator.config.PackageConfig
;
import
com.baomidou.mybatisplus.generator.config.StrategyConfig
;
import
com.baomidou.mybatisplus.generator.config.rules.DateType
;
import
com.baomidou.mybatisplus.generator.config.rules.NamingStrategy
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.Scanner
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.generate
* @PROJECT_NAME: jz-dm-parent
* @NAME: MybatisPlusGenerate
* @DATE: 2021-1-30/12:43
* @DAY_NAME_SHORT: 周六
* @Description:
**/
public
class
MybatisPlusGenerate
{
public
static
void
main
(
String
[]
args
)
{
//1. 全局配置
GlobalConfig
config
=
new
GlobalConfig
();
// 是否支持AR模式
config
.
setActiveRecord
(
true
)
// 作者
.
setAuthor
(
"ZC"
)
// 生成路径,最好使用绝对路径,window路径是不一样的
//TODO TODO TODO TODO
.
setOutputDir
(
"/Users/xdclass/Desktop/demo/src/main/java"
)
// 文件覆盖
.
setFileOverride
(
true
)
// 主键策略
.
setIdType
(
IdType
.
AUTO
)
.
setDateType
(
DateType
.
ONLY_DATE
)
// 设置生成的service接口的名字的首字母是否为I,默认Service是以I开头的
.
setServiceName
(
"%sService"
)
//实体类结尾名称
.
setEntityName
(
"%sDO"
)
//生成基本的resultMap
.
setBaseResultMap
(
true
)
//不使用AR模式
.
setActiveRecord
(
false
)
//生成基本的SQL片段
.
setBaseColumnList
(
true
);
//2. 数据源配置
DataSourceConfig
dsConfig
=
new
DataSourceConfig
();
// 设置数据库类型
dsConfig
.
setDbType
(
DbType
.
MYSQL
)
.
setDriverName
(
"com.mysql.cj.jdbc.Driver"
)
//TODO TODO TODO TODO
.
setUrl
(
"jdbc:mysql://127.0.0.1:3306/xd_shop?useSSL=false"
)
.
setUsername
(
"root"
)
.
setPassword
(
"xdclass.net"
);
//3. 策略配置globalConfiguration中
StrategyConfig
stConfig
=
new
StrategyConfig
();
//全局大写命名
stConfig
.
setCapitalMode
(
true
)
// 数据库表映射到实体的命名策略
.
setNaming
(
NamingStrategy
.
underline_to_camel
)
//使用lombok
.
setEntityLombokModel
(
true
)
//使用restcontroller注解
.
setRestControllerStyle
(
true
)
// 生成的表, 支持多表一起生成,以数组形式填写
//TODO TODO TODO TODO 两个方式,直接写,或者使用命令行输入
.
setInclude
(
"product"
,
"banner"
,
"address"
,
"coupon"
,
"product_order"
);
//.setInclude(scanner("表名,多个英文逗号分割").split(","));
//TODO TODO TODO TODO
//4. 包名策略配置(生成的项目包名)
PackageConfig
pkConfig
=
new
PackageConfig
();
pkConfig
.
setParent
(
"net.xdclass.shopmanager"
)
.
setMapper
(
"mapper"
)
.
setService
(
"service"
)
.
setController
(
"controller"
)
.
setEntity
(
"model"
)
.
setXml
(
"mapper"
);
//5. 整合配置
AutoGenerator
ag
=
new
AutoGenerator
();
ag
.
setGlobalConfig
(
config
)
.
setDataSource
(
dsConfig
)
.
setStrategy
(
stConfig
)
.
setPackageInfo
(
pkConfig
);
//6. 执行操作
ag
.
execute
();
System
.
out
.
println
(
"======= 小滴课堂 Done 相关代码生成完毕 ========"
);
}
/**
* <p>
* 读取控制台内容
* </p>
*/
public
static
String
scanner
(
String
tip
)
{
Scanner
scanner
=
new
Scanner
(
System
.
in
);
StringBuilder
help
=
new
StringBuilder
();
help
.
append
(
"请输入"
+
tip
+
":"
);
System
.
out
.
println
(
help
.
toString
());
if
(
scanner
.
hasNext
())
{
String
ipt
=
scanner
.
next
();
if
(
StringUtils
.
isNotBlank
(
ipt
))
{
return
ipt
;
}
}
throw
new
MybatisPlusException
(
"请输入正确的"
+
tip
+
"!"
);
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/enity/GatewayRequest.java
View file @
03a1b37f
...
@@ -87,14 +87,14 @@ public class GatewayRequest implements Serializable {
...
@@ -87,14 +87,14 @@ public class GatewayRequest implements Serializable {
return
extAttributes
;
return
extAttributes
;
}
}
/**
/**
* @see Object#toString()
* @see Object#toString()
*/
*/
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"GatewayRequest [appKey="
+
apiKey
+
", method="
+
method
+
", format="
+
format
return
"GatewayRequest [appKey="
+
apiKey
+
", method="
+
method
+
", format="
+
format
+
", signType="
+
signType
+
", sign="
+
sign
+
", signType="
+
signType
+
", sign="
+
sign
+
", timestamp="
+
timestamp
+
", version="
+
version
+
", timestamp="
+
timestamp
+
", params="
+
params
+
", extAttributes="
+
", params="
+
params
+
", extAttributes="
+
extAttributes
+
"]"
;
+
extAttributes
+
"]"
;
}
}
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/resp/SendDataReq.java
View file @
03a1b37f
...
@@ -3,7 +3,6 @@ package com.jz.dm.models.resp;
...
@@ -3,7 +3,6 @@ package com.jz.dm.models.resp;
import
com.jz.common.bean.BasePageBean
;
import
com.jz.common.bean.BasePageBean
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.io.Serializable
;
...
@@ -19,7 +18,6 @@ import java.io.Serializable;
...
@@ -19,7 +18,6 @@ import java.io.Serializable;
**/
**/
@Data
@Data
@ApiModel
@ApiModel
@Builder
public
class
SendDataReq
extends
BasePageBean
implements
Serializable
{
public
class
SendDataReq
extends
BasePageBean
implements
Serializable
{
@ApiModelProperty
(
value
=
"关键词"
)
@ApiModelProperty
(
value
=
"关键词"
)
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/request/ApiQueryService.java
View file @
03a1b37f
...
@@ -47,12 +47,12 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
...
@@ -47,12 +47,12 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
@Override
@Override
public
String
getOpenApiMethod
()
{
public
String
getOpenApiMethod
()
{
return
"query"
;
return
"
data.
query"
;
}
}
@Override
@Override
public
String
getOpenApiVersion
()
{
public
String
getOpenApiVersion
()
{
return
"
v
1.0.0"
;
return
"1.0.0"
;
}
}
@Autowired
@Autowired
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/request/ApiQueryTestService.java
View file @
03a1b37f
...
@@ -41,7 +41,7 @@ public class ApiQueryTestService extends ApiParamVerify implements OpenApiServic
...
@@ -41,7 +41,7 @@ public class ApiQueryTestService extends ApiParamVerify implements OpenApiServic
@Override
@Override
public
String
getOpenApiVersion
()
{
public
String
getOpenApiVersion
()
{
return
"v1.0.
0
"
;
return
"v1.0.
2
"
;
}
}
@Autowired
@Autowired
...
...
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