Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
platform
/
platform-cdp-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 033f1a52
authored
Aug 30, 2023
by
zhouhaibao
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]代码初始化
1 parent
630d0a42
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
1924 additions
and
1 deletions
README.md
platform-cdp-api/pom.xml
platform-cdp-api/src/main/java/cn/com/glsx/cdp/api/UserCenterFeignClient.java
platform-cdp-api/src/main/java/cn/com/glsx/cdp/modules/entity/User.java
platform-cdp-api/src/main/java/cn/com/glsx/cdp/modules/mapper/UserMapper.java
platform-cdp-api/src/main/java/cn/com/glsx/cdp/modules/model/UserBO.java
platform-cdp-api/src/main/java/cn/com/glsx/cdp/modules/model/UserDTO.java
platform-cdp-api/src/main/java/cn/com/glsx/cdp/modules/model/UserSearch.java
platform-cdp-api/src/main/java/cn/com/glsx/cdp/modules/repository/IUserRepository.java
platform-cdp/pom.xml
platform-cdp/src/main/java/cn/com/glsx/Application.java
platform-cdp/src/main/java/cn/com/glsx/cdp/common/constant/Constants.java
platform-cdp/src/main/java/cn/com/glsx/cdp/config/WebConfig.java
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/BaseController.java
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/LoginController.java
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/api/UserApiController.java
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/controller/UserController.java
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/converter/UserConverter.java
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/service/UserDemoService.java
platform-cdp/src/main/resources/application.properties_standalone
platform-cdp/src/main/resources/bootstrap.properties
platform-cdp/src/main/resources/logback-spring.xml
platform-cdp/src/main/resources/mapper/UserMapper.xml
platform-cdp/src/main/webapp/WEB-INF/bin/restart.sh
platform-cdp/src/main/webapp/WEB-INF/bin/server.sh
platform-cdp/src/main/webapp/WEB-INF/bin/start.sh
platform-cdp/src/main/webapp/WEB-INF/bin/stop.sh
platform-cdp/src/test/java/cn/com/glsx/TestApplication.java
platform-cdp/src/test/java/cn/com/glsx/cn/com/glsx/TestApplication.java
platform-cdp/src/test/resources/generatorConfig.xml
pom.xml
README.md
View file @
033f1a5
平台SOP的cdp处理中心、短链处理中心
\ No newline at end of file
# glsx-rest-admin(微服务快速开发的脚手架)
## 背景&目标
当前新建项目时,配置文件往往都是从其它项目拷贝过来,拷贝时很容易踩坑,并且不容易定位问题。尤其对新人来说由于在对公司项目结构、基础中间件、配置还不了解的情况下,会浪费很多不必要的时间。故,希望通过脚手架解决此痛点,达到如下几个基本目标:
1.
统一规范工程项目&代码层次结构——约定大于配置;
2.
提升工作效率——脚手架&代码生成器&自定义插件;
3.
降低项目维护成本——易于组内成员相互协防;
另,发现当前各自创建的项目,存在如下几个现象,希望借机推进组内代码规范落地:
1.
项目&包层次结构不统一;
2.
配置文件命名、存放位置不统一;
3.
类命名不统一(有的叫entity,有的叫BO,有的叫Domain;有的叫job,有的叫crane,有的叫schedule;接口命名有的I开头,有的无I开头);
希望在项目模板(脚手架)中在每个层次环节代码中直接给予相应的Demo,以此达到规范引导作用。
## 项目介绍
基于 Spring Cloud 完整的微服务架构的一个脚手架项目
## 技术栈
> 权限认证
>
> > Jwt
> 配置中心
>
> > Alibaba nacos
> 服务注册与发现
>
> > Alibaba nacos
> 分布式链路追踪
>
> > sleuth
> >
> > zipkin
> 网关
>
> > SpringCloud Gateway
> 流量控制、熔断降级
>
> > Alibaba sentinel
> Http声名式转发
>
> > Feign
> >
> > RestTemplate
> >
> > WebClient
> 持久层
>
> > mybatis
> >
> > pagehelper
> >
> > tk-mapper
> >
> > Jpa
> 数据存储
>
> > MySQL
> >
> > Redis
> >
> > MongoDB
> 文件服务
>
> > Fastdfs
> >
> > Minio
> 消息中间件
>
> > Kafka
## 项目结构
## 模块说明

## 项目涉及服务组件
#### 1. nacos
Nacos是一个更易于构建云原生应用的动态服务发现、配置管理和服务管理平台。Nacos 支持几乎所有主流类型的服务的发现、配置和管理:
*
Kubernetes Service
*
gRPC & Dubbo RPC Service
*
Spring Cloud RESTful Service
官网:https://nacos.io/
github:https://github.com/alibaba/nacos/releases
```
sh
sh startup.sh -m standalone
```
开发环境部署地址:/data/nacos
开发环境访问地址:http://192.168.0.63:8858/nacos/
账号密码:nacos/nacos
#### 2. zipkin
官网:https://zipkin.io/
github:https://github.com/openzipkin/zipkin
https://dl.bintray.com/openzipkin/maven/io/zipkin/java/zipkin-server/2.12.9/
```
sh
nohup java -jar zipkin-server-2.12.9-exec.jar &
```
关于zipkin的基本使用请查看其他文章或者自行百度
开发部署:http://192.168.0.63:9411/zipkin/
开发环境部署地址:/data/zipkin
开发环境访问地址:http://192.168.0.63:9411/zipkin/
#### 3. sentinel-dashboard
github:https://github.com/alibaba/Sentinel
```
sh
nohup java -Dserver.port
=
8718 -Dcsp.sentinel.dashboard.server
=
localhost:8718 -Dproject.name
=
sentinel-dashboard -Dcsp.sentinel.api.port
=
8719 -jar sentinel-dashboard-1.8.0.jar &
```
开发环境部署地址:/data/sentinel
开发环境访问地址:http://192.168.0.63:8718/#/login
账号密码:sentinel/sentinel
!
[
](https://upload-images.jianshu.io/upload_images/5417792-ae78d6da78d48b31.png)
#### 4. spring-cloud-gateway-server
svn地址:svn://192.168.3.233/frms/code/glsx-archetype/glsx-archetype/glsx-archetype-parent/glsx-rest-admin-gateway-server
!
[
](https://img-blog.csdnimg.cn/20191208161419451.png)
#### 4. spring-boot-admin-server
svn地址:svn://192.168.3.233/frms/code/glsx-archetype/glsx-archetype/glsx-archetype-parent/glsx-rest-admin-monitor-server
!
[
](https://oscimg.oschina.net/oscnet/up-a38e9bb6b0d08cccf3ab9c6c99b4b398650.png)
开发环境部署地址:/data/webserver/glsx-rest-admin-monitor-server-1.0-SNAPSHOT
开发环境访问地址:http://192.168.0.63:8769/applications
## 脚手架项目运行调试
#### SVN地址
svn地址:svn://192.168.3.233/frms/code/glsx-archetype/glsx-archetype/glsx-archetype-parent/glsx-rest-admin
[
脑图
](
https://www.kdocs.cn/view/l/cDUsOKQht?
"项目引用框架结构"
)
### 添加配置中心
1.
打开nacos的管理中心(http://192.168.0.63:8858/nacos/#/login)
2.
新增data-id为${prefix}-${spring.profile.active}.${file-extension}
*
prefix 默认为 spring.application.name 的值,也可以通过配置项 spring.cloud.nacos.config.prefix来配置。
*
spring.profile.active 即为当前环境对应的 profile,详情可以参考 Spring Boot文档。注意:当 spring.profile.active 为空时,对应的连接符 - 也将不存在,dataId 的拼接格式变成 prefix.{file-extension}
*
file-extension 为配置内容的数据格式,可以通过配置项 spring.cloud.nacos.config.file-extension 来配置。目前只支持 properties 和 yaml 类型。
关于配置格式,通俗的讲,即为file-extension。如配置格式选择properties格式,则DataId后缀必须为properties(注意yaml,可写为yml,与yaml同义,但与bootstrap配置中的file-extension必须一致),配置内容也必须按照properties格式编写。
<pre>
<code>
server.port=8828
server.servlet.context-path=/${spring.application.name}
</code>
</pre>
[
rest-admin-dev.properties
](
http://192.168.0.63:8858/nacos/v1/cs/configs?dataId=glsx-rest-admin-dev.properties&group=DEV_GROUP
"脚手架项目配置"
)
3.
执行Application.main()启动项目
### 修改网关服务网关配置
<pre>
<code>
#glsx-rest-admin
spring.cloud.gateway.routes
[
0
]
.id=glsx-rest-admin
spring.cloud.gateway.routes
[
0
]
.uri=lb://glsx-rest-admin
spring.cloud.gateway.routes
[
0
]
.predicates
[
0
]
=Path=/glsx-rest-admin/
**
spring.cloud.gateway.routes
[
0
]
.filters
[
0
]
=StripPrefix=0
</code>
</pre>
[
rest-admin-gateway-dev.properties
](
http://192.168.0.63:8858/nacos/v1/cs/configs?dataId=glsx-rest-admin-gateway-dev.properties&group=DEV_GROUP
"网关服务配置"
)
##脚手架
##脚手架生成 https://github.com/artpoplsh/blog/issues/1
命令行方式
mvn archetype:generate
\
-DarchetypeGroupId=com.xxx
\
-DarchetypeArtifactId=archetype-spring-boot
\
-DarchetypeVersion=1.0.0
\
-DgroupId=com.xxx
\
-DartifactId=demo-archetype-generate
\
-Dversion=1.0.0
\
-DarchetypeCatalog=internal
\
-X
a. 构建脚手架命令
<pre><code>
cd glsx-archetype-parent
\r
est-admin-archetype
</code></pre>
<pre><code>
mvn archetype:create-from-project -DpropertyFile=archetype
</code></pre>
b. 安装脚手架命令
<pre><code>
cd target
\g
enerated-sources
\a
rchetype
mvn clean install
</code></pre>
c. 发布
<pre><code>
mvn deploy
</code></pre>
groupId:上传到私服的groupId
<br>
artifactId:上传到私服的artifactId
<br>
version:上传到私服的version
<br>
file:jar包的本地路径
<br>
url: 你的maven私服地址
<br>
repositoryId:setting.xml配置的server id
jar复制到非仓库目录,不然可能会发布失败
OR
<pre>
本地私服:
<code>
mvn deploy:deploy-file -DgroupId=cn.com.glsx -DartifactId=rest-admin-archetype-archetype -Dversion=1.0.0-SNAPSHOT -Dpackaging=jar -Dfile=rest-admin-archetype-archetype-1.0.0-SNAPSHOT.jar -Durl=http://127.0.0.1:8081/repository/maven-snapshots -DrepositoryId=nexus-snapshots
</code>
</pre>
<pre>
公司私服:
<code>
mvn deploy:deploy-file -DgroupId=cn.com.glsx -DartifactId=rest-admin-archetype-archetype -Dversion=1.0.0-SNAPSHOT -Dpackaging=jar -Dfile=rest-admin-archetype-archetype-1.0.0-SNAPSHOT.jar -Durl=http://192.168.3.233/nexus/content/repositories/snapshots -DrepositoryId=nexus-snapshots
</code>
</pre>
d.使用脚手架
```
xml
<groupId>
cn.com.glsx
</groupId>
<artifactId>
rest-admin-archetype-archetype
</artifactId>
<version>
1.0.0-SNAPSHOT
</version>
platform-cdp-api/pom.xml
0 → 100644
View file @
033f1a5
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<groupId>
cn.com.glsx
</groupId>
<artifactId>
platform-cdp-server
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<packaging>
jar
</packaging>
<artifactId>
platform-cdp-api
</artifactId>
<description>
Microservice Scaffolding Api Base on Spring Cloud
</description>
<dependencies>
<!-- mybatis -->
<dependency>
<groupId>
com.glsx
</groupId>
<artifactId>
rest-admin-mybatis
</artifactId>
</dependency>
<!-- feign -->
<dependency>
<groupId>
com.glsx
</groupId>
<artifactId>
rest-admin-feign
</artifactId>
</dependency>
</dependencies>
</project>
platform-cdp-api/src/main/java/cn/com/glsx/cdp/api/UserCenterFeignClient.java
0 → 100644
View file @
033f1a5
package
cn
.
com
.
glsx
.
cdp
.
api
;
import
cn.com.glsx.cdp.modules.model.UserDTO
;
import
com.glsx.plat.core.web.Result
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestParam
;
/**
* @author payu
*/
@FeignClient
(
name
=
"rest-admin"
,
contextId
=
"usercenter"
,
path
=
"/api/user/"
,
decode404
=
true
)
public
interface
UserCenterFeignClient
{
/**
* 一、FeignClients使用注意事项:
* 1. @EnableFeignClients 默认扫描 xxxxApplication启动入口 所在包路径下的 @FeignClient bean,若无法扫描到, 可以在使用Feign调用外部模块的api时候,
* 需要在引用服务中 xxxxApplication 中的 `@EnableFeignClients(basePackages = "cn.tendyron.customer")` 添加外部包需要扫描FeignClient的路径,否则无法注入bean
* 2. @FeignClient 声明的类,使用 spring.application.name 作为 name配置 @FeignClient(name="xxxx"),如果想保留 context-path , 则需要配置 path 属性 ,如:@FeignClient(name="xxxx" , path="xxxx(context-path)")
* 3. @FeignClient 接口对应的实现类,需要使用 @RestController注解 声明
* 4. mapper注解不支持 : @GetMapping,@PostMapping , 参数要加 @RequestParam(“xxx”)
* 5. FeignClient 调用,实质是httpClient调用 ,若我们暴露的接口api,声明了对应的 http mapper 信息,在调用方调用时候,通过代理 发起了 http请求,到服务提供方对应的http服务上去,所以在服务提供方的接口,可以使用 @RestController
* 来声明接口的 实现,否则调用方无法找到 http 对应的路径,会报404 ;
* 或者 根据 api 声明的http 信息,构建一个 Controller ,再来调用接口的实现类,但是这样不太方便;
* 6.FeignClient是一个“客户端”,它是用来发起请求的,不是提供服务的。
*
*
* 二、fallback 几种模式:
* 1.EchoCenterFeignServiceFallback.class 直接fallback,获取不到HTTP请求错误状态码和信息
* 2.EchoCenterFeignFactory.class 特定类型工厂模式
* 3.FunFallbackFactory 使用统一的工厂模式处理
*
*
* 三、性能问题
* 1.Feign是一个http请求调用的轻量级框架,基于http协议,性能不如rpc
* 2.可以为Feign配置连接池,配合使用okhttp等
*/
/**
* 测试Feign Get ,普通处理
* 注意: @RequestParam("xx") 注解一定要写,而且属性名xx不能省略
*/
@GetMapping
(
"/echo"
)
String
echo
(
@RequestParam
String
message
);
@GetMapping
(
value
=
"/info/{id}"
)
UserDTO
info
(
@PathVariable
(
"id"
)
Long
id
);
@GetMapping
(
value
=
"/info/{id}"
)
Result
<
UserDTO
>
info2
(
@PathVariable
(
"id"
)
Long
id
);
}
platform-cdp-api/src/main/java/cn/com/glsx/cdp/modules/entity/User.java
0 → 100644
View file @
033f1a5
package
cn
.
com
.
glsx
.
cdp
.
modules
.
entity
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.glsx.plat.mybatis.base.BaseEntity
;
import
lombok.Data
;
import
lombok.experimental.Accessors
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
@Accessors
(
chain
=
true
)
@Data
@Entity
@Table
(
name
=
"t_user"
)
public
class
User
extends
BaseEntity
{
/**
* 帐号
*/
@Column
(
name
=
"account"
,
length
=
64
)
private
String
account
;
/**
* 密码
*/
@JsonIgnore
@Column
(
name
=
"password"
,
length
=
128
)
private
String
password
;
/**
* 用户名
*/
@Column
(
name
=
"username"
,
length
=
64
)
private
String
username
;
/**
* (真实)姓名
*/
@Column
(
name
=
"realname"
,
length
=
64
)
private
String
realname
;
/**
* 手机号
*/
@Column
(
name
=
"phone"
,
length
=
20
)
private
String
phone
;
/**
* 头像链接
*/
@Column
(
name
=
"avatar"
,
length
=
150
)
private
String
avatar
;
/**
* 加密盐
*/
private
String
salt
;
}
platform-cdp-api/src/main/java/cn/com/glsx/cdp/modules/mapper/UserMapper.java
0 → 100644
View file @
033f1a5
package
cn
.
com
.
glsx
.
cdp
.
modules
.
mapper
;
import
cn.com.glsx.cdp.modules.entity.User
;
import
cn.com.glsx.cdp.modules.model.UserSearch
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
@Mapper
public
interface
UserMapper
extends
CommonBaseMapper
<
User
>
{
List
<
User
>
selectList
(
UserSearch
search
);
User
selectById
(
@Param
(
"id"
)
Long
id
);
void
logicDeleteById
(
@Param
(
"id"
)
Long
id
);
}
\ No newline at end of file
platform-cdp-api/src/main/java/cn/com/glsx/cdp/modules/model/UserBO.java
0 → 100644
View file @
033f1a5
package
cn
.
com
.
glsx
.
cdp
.
modules
.
model
;
import
lombok.Data
;
import
javax.validation.constraints.NotBlank
;
/**
* @author payu
*/
@Data
public
class
UserBO
{
private
Long
id
;
@NotBlank
private
String
account
;
@NotBlank
private
String
password
;
@NotBlank
private
String
username
;
private
String
realName
;
private
String
phone
;
private
String
avatar
;
private
String
remark
;
private
Long
[]
roleIds
;
}
platform-cdp-api/src/main/java/cn/com/glsx/cdp/modules/model/UserDTO.java
0 → 100644
View file @
033f1a5
package
cn
.
com
.
glsx
.
cdp
.
modules
.
model
;
import
lombok.Data
;
/**
* @author payu
*/
@Data
public
class
UserDTO
{
private
Long
id
;
private
String
account
;
private
String
username
;
private
String
realname
;
private
String
password
;
private
String
phone
;
private
String
remark
;
private
Long
[]
roleIds
;
}
platform-cdp-api/src/main/java/cn/com/glsx/cdp/modules/model/UserSearch.java
0 → 100644
View file @
033f1a5
package
cn
.
com
.
glsx
.
cdp
.
modules
.
model
;
import
cn.hutool.db.Page
;
import
lombok.Data
;
/**
* @author payu
*/
@Data
public
class
UserSearch
extends
Page
{
private
String
term
;
}
platform-cdp-api/src/main/java/cn/com/glsx/cdp/modules/repository/IUserRepository.java
0 → 100644
View file @
033f1a5
package
cn
.
com
.
glsx
.
cdp
.
modules
.
repository
;
//package com.glsx.vasp.modules.repository;
//
//import com.glsx.vasp.modules.entity.User;
//import java.io.Serializable;
//
///**
// * UserRepository JPA
// */
//public interface IUserRepository extends BaseRepository<User, Long>, Serializable {
//
// User findByUsername(String username);
//
//}
platform-cdp/pom.xml
0 → 100644
View file @
033f1a5
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<groupId>
cn.com.glsx
</groupId>
<artifactId>
platform-cdp-server
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<packaging>
war
</packaging>
<description>
Microservice Scaffolding Project Base on Spring Cloud
</description>
<artifactId>
platform-cdp
</artifactId>
<dependencies>
<!-- 运行环境上下文 -->
<dependency>
<groupId>
com.glsx
</groupId>
<artifactId>
rest-admin-context
</artifactId>
</dependency>
<!-- 接入微服务组件联盟 配置、注册、网关、链路、监控等 ,单体应用无需引入(logback-spring.xml与logstash相关内容需要注释掉)-->
<dependency>
<groupId>
com.glsx
</groupId>
<artifactId>
rest-admin-alliance
</artifactId>
</dependency>
<dependency>
<groupId>
com.glsx
</groupId>
<artifactId>
rest-admin-swagger3
</artifactId>
</dependency>
<dependency>
<groupId>
com.glsx
</groupId>
<artifactId>
rest-admin-dubbo
</artifactId>
</dependency>
<!-- local api -->
<dependency>
<groupId>
cn.com.glsx
</groupId>
<artifactId>
platform-cdp-api
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<!-- rest api -->
<dependency>
<groupId>
com.glsx
</groupId>
<artifactId>
rest-service-echocenter-api
</artifactId>
<version>
2.0.0-SNAPSHOT
</version>
</dependency>
<!-- dubbo api -->
<dependency>
<groupId>
cn.com.glsx.scrm
</groupId>
<artifactId>
rpc-scrm-proxy-api
</artifactId>
<version>
3.7.0-SNAPSHOT
</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>
3.8.1
</version>
<configuration>
<encoding>
UTF-8
</encoding>
<annotationProcessorPaths>
<path>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<version>
${lombok.version}
</version>
</path>
<path>
<groupId>
org.mapstruct
</groupId>
<artifactId>
mapstruct-processor
</artifactId>
<version>
${org.mapstruct.version}
</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-deploy-plugin
</artifactId>
<version>
3.0.0-M2
</version>
<configuration>
<skip>
true
</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
platform-cdp/src/main/java/cn/com/glsx/Application.java
0 → 100644
View file @
033f1a5
package
cn
.
com
.
glsx
;
import
com.glsx.plat.context.EnableRestAdmin
;
import
org.apache.dubbo.config.spring.context.annotation.EnableDubbo
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
import
javax.annotation.PostConstruct
;
import
java.util.TimeZone
;
import
static
java
.
time
.
ZoneId
.
of
;
import
static
java
.
util
.
TimeZone
.
getTimeZone
;
/**
* @author payu
*/
@EnableDubbo
@EnableRestAdmin
@EnableDiscoveryClient
@EnableFeignClients
(
basePackages
=
{
"cn.com.glsx.*.api"
})
@SpringBootApplication
public
class
Application
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
Application
.
class
,
args
);
}
@PostConstruct
void
started
()
{
TimeZone
.
setDefault
(
getTimeZone
(
of
(
"Asia/Shanghai"
)));
}
}
platform-cdp/src/main/java/cn/com/glsx/cdp/common/constant/Constants.java
0 → 100644
View file @
033f1a5
package
cn
.
com
.
glsx
.
cdp
.
common
.
constant
;
import
com.glsx.plat.core.constant.BasicConstants
;
/**
* 〈一句话功能简述〉<br>
* 公共常量类
*
* @author liuyf
* @since 1.0.0
*/
public
final
class
Constants
extends
BasicConstants
{
public
final
static
String
SERVER_NAME
=
"glsx_rest_admin"
;
}
platform-cdp/src/main/java/cn/com/glsx/cdp/config/WebConfig.java
0 → 100644
View file @
033f1a5
package
cn
.
com
.
glsx
.
cdp
.
config
;
import
com.glsx.plat.context.properties.UploadProperties
;
import
com.glsx.plat.jwt.base.ComJwtUser
;
import
com.glsx.plat.web.interceptor.LogInterceptor
;
import
com.glsx.plat.web.interceptor.VisitInterceptor
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.servlet.config.annotation.InterceptorRegistry
;
import
org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
javax.annotation.Resource
;
/**
* @author liuyf
* @Title WebConfig.java
* @Description 系统的配置相关文件,如拦截器,过滤器,跨域等
* @date 2019年7月18日 下午4:45:06
*/
@Configuration
public
class
WebConfig
implements
WebMvcConfigurer
{
@Resource
private
UploadProperties
uploadProperties
;
/**
* 基于MDC的简单的日志链路
*/
@Resource
private
LogInterceptor
logInterceptor
;
/**
* 基于jwt的token认证
*/
@Resource
private
VisitInterceptor
<
ComJwtUser
>
visitInterceptor
;
/**
* 静态资源
*
* @param registry
*/
@Override
public
void
addResourceHandlers
(
ResourceHandlerRegistry
registry
)
{
registry
.
addResourceHandler
(
"/**"
)
.
addResourceLocations
(
"classpath:/META-INF/resources/"
)
.
addResourceLocations
(
"classpath:/resources/"
)
.
addResourceLocations
(
"classpath:/static/"
)
.
addResourceLocations
(
"classpath:/public/"
)
.
addResourceLocations
(
"/dist/"
);
//本地文件
registry
.
addResourceHandler
(
"/files/**"
).
addResourceLocations
(
"file://"
+
uploadProperties
.
getBasePath
());
//swagger3
registry
.
addResourceHandler
(
"/swagger-ui/**"
).
addResourceLocations
(
"classpath:/META-INF/resources/webjars/springfox-swagger-ui/"
);
}
@Override
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
//1.加入的顺序就是拦截器执行的顺序,
//2.按顺序执行所有拦截器的preHandle
//3.所有的preHandle 执行完再执行全部postHandle 最后是postHandle
registry
.
addInterceptor
(
visitInterceptor
)
.
addPathPatterns
(
"/**"
)
.
excludePathPatterns
(
"/"
)
.
excludePathPatterns
(
"/login"
)
.
excludePathPatterns
(
"/actuator/**"
)
.
excludePathPatterns
(
"/api/**"
)
.
excludePathPatterns
(
uploadProperties
.
getFilepath
())
.
excludePathPatterns
(
"/swagger-resources/**"
,
"/swagger-ui/**"
,
"/v3/**"
,
"/doc.html"
);
registry
.
addInterceptor
(
logInterceptor
).
addPathPatterns
(
"/**"
);
}
}
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/BaseController.java
0 → 100644
View file @
033f1a5
package
cn
.
com
.
glsx
.
cdp
.
modules
;
import
cn.com.glsx.cdp.modules.service.UserDemoService
;
import
com.glsx.plat.core.web.R
;
import
com.glsx.plat.web.controller.AbstractController
;
import
cn.com.glsx.cdp.modules.entity.User
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.validation.BindException
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
/**
* @author liuyf
* @Title BaseController.java
* @Package com.glsx.vasp.controller
* @Description
* @date 2019年10月24日 下午2:24:00
*/
@RestController
public
class
BaseController
extends
AbstractController
{
@Resource
private
UserDemoService
userDemoService
;
/**
* 这个给Spring Boot Admin探测用
*
* @return
*/
@GetMapping
(
value
=
"/"
)
public
R
index
()
{
return
R
.
ok
(
"You get it!"
);
}
/**
* 从session中获取当前用户
*
* @return
*/
@Override
public
User
getSessionUser
()
{
User
user
=
userDemoService
.
getByToken
();
if
(
user
==
null
||
StringUtils
.
isBlank
(
user
.
getPhone
()))
{
return
null
;
}
return
user
;
}
@Override
public
Long
getUserId
()
{
User
user
=
getSessionUser
();
if
(
user
!=
null
)
{
return
user
.
getId
();
}
return
null
;
}
@Override
public
String
getAccount
()
{
User
user
=
getSessionUser
();
if
(
user
!=
null
)
{
return
user
.
getUsername
();
}
return
null
;
}
/**
* 参数校验
*
* @param bindingResult
* @throws BindException
*/
protected
void
checkDTOParams
(
BindingResult
bindingResult
)
throws
BindException
{
if
(
bindingResult
.
hasErrors
())
{
throw
new
BindException
(
bindingResult
);
}
}
}
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/LoginController.java
0 → 100644
View file @
033f1a5
package
cn
.
com
.
glsx
.
cdp
.
modules
;
import
cn.com.glsx.cdp.modules.entity.User
;
import
cn.com.glsx.cdp.modules.service.UserDemoService
;
import
com.glsx.plat.common.annotation.SysLog
;
import
com.glsx.plat.core.web.R
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @author payu
*/
@Slf4j
@Tag
(
name
=
"登录登出(Demo)"
)
@RestController
public
class
LoginController
{
@Resource
private
UserDemoService
userDemoService
;
/**
* 登录
*/
@SysLog
@Operation
(
summary
=
"登录接口"
,
description
=
"登录接口"
)
@PostMapping
(
value
=
"/login"
)
public
R
login
(
@RequestParam
String
account
,
@RequestParam
String
code
)
{
// User user = userService.findByPhone(account);
User
user
=
new
User
();
user
.
setPhone
(
account
);
String
token
=
userDemoService
.
createToken
(
user
);
Map
<
String
,
Object
>
rtnMap
=
new
HashMap
<>();
rtnMap
.
put
(
"token"
,
token
);
rtnMap
.
put
(
"user"
,
user
);
return
R
.
ok
().
data
(
rtnMap
);
}
}
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/api/UserApiController.java
0 → 100644
View file @
033f1a5
package
cn
.
com
.
glsx
.
cdp
.
modules
.
api
;
import
cn.com.glsx.cdp.api.UserCenterFeignClient
;
import
cn.com.glsx.cdp.modules.converter.UserConverter
;
import
cn.com.glsx.cdp.modules.entity.User
;
import
cn.com.glsx.cdp.modules.model.UserDTO
;
import
cn.com.glsx.cdp.modules.service.UserDemoService
;
import
cn.com.glsx.echocenter.api.EchoCenterFeignClient
;
import
com.glsx.plat.core.annotation.ResponseResultBody
;
import
com.glsx.plat.core.web.Result
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
/**
* 微服务应用在网关中处理统一返回体
*
* @author payu
*/
@Slf4j
@Tag
(
name
=
"用户开放接口(Demo)"
)
@RestController
@RequestMapping
(
value
=
"/api/user"
)
@ResponseResultBody
public
class
UserApiController
implements
UserCenterFeignClient
{
@Resource
private
UserDemoService
userDemoService
;
@Resource
private
EchoCenterFeignClient
echoCenterFeignClient
;
@Operation
(
summary
=
"FeignClient调用"
)
@Override
@GetMapping
(
"/echo"
)
public
String
echo
(
@RequestParam
String
message
)
{
String
echo
=
echoCenterFeignClient
.
echo
(
message
);
return
echo
;
}
@Operation
(
summary
=
"本地调用"
)
@GetMapping
(
value
=
"/info/{id}"
)
public
UserDTO
info
(
@PathVariable
(
"id"
)
Long
id
)
{
User
user
=
userDemoService
.
getById
(
id
);
UserDTO
result
=
UserConverter
.
INSTANCE
.
do2dto
(
user
);
return
result
;
}
@Operation
(
summary
=
"本地调用"
)
@Override
@GetMapping
(
value
=
"/info2/{id}"
)
public
Result
<
UserDTO
>
info2
(
@PathVariable
(
"id"
)
Long
id
)
{
User
user
=
userDemoService
.
getById
(
id
);
UserDTO
result
=
UserConverter
.
INSTANCE
.
do2dto
(
user
);
return
Result
.
success
(
result
);
}
}
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/controller/UserController.java
0 → 100644
View file @
033f1a5
package
cn
.
com
.
glsx
.
cdp
.
modules
.
controller
;
import
cn.com.glsx.cdp.modules.BaseController
;
import
cn.com.glsx.cdp.modules.converter.UserConverter
;
import
cn.com.glsx.cdp.modules.entity.User
;
import
cn.com.glsx.cdp.modules.model.UserBO
;
import
cn.com.glsx.cdp.modules.model.UserDTO
;
import
cn.com.glsx.cdp.modules.model.UserSearch
;
import
cn.com.glsx.cdp.modules.service.UserDemoService
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
com.glsx.plat.context.utils.validator.AssertUtils
;
import
com.glsx.plat.core.annotation.ResponseResultBody
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
/**
* 单体应用Controller处理统一返回体
*
* @author payu
*/
@Slf4j
@Tag
(
name
=
"用户接口(Demo)"
)
@RestController
@RequestMapping
(
value
=
"/user"
)
@ResponseResultBody
public
class
UserController
extends
BaseController
{
@Autowired
private
UserDemoService
userDemoService
;
@Operation
(
summary
=
"分页查询用户"
,
description
=
"分页查询用户"
)
@GetMapping
(
"/search"
)
public
PageInfo
<
UserDTO
>
search
(
UserSearch
search
)
{
PageHelper
.
startPage
(
search
.
getPageNumber
(),
search
.
getPageSize
());
PageInfo
<
UserDTO
>
list
=
userDemoService
.
search
(
search
);
return
list
;
}
@Operation
(
summary
=
"新增用户"
,
description
=
"分页查询用户"
)
@PostMapping
(
value
=
"/add"
)
public
UserDTO
add
(
@RequestBody
@Validated
UserBO
userBO
)
{
User
user
=
UserConverter
.
INSTANCE
.
bo2do
(
userBO
);
User
savedUser
=
userDemoService
.
addUser
(
user
);
UserDTO
result
=
UserConverter
.
INSTANCE
.
do2dto
(
savedUser
);
return
result
;
}
@Operation
(
summary
=
"编辑用户"
,
description
=
"分页查询用户"
)
@PostMapping
(
value
=
"/edit"
)
public
Integer
edit
(
@RequestBody
@Validated
UserBO
userBO
)
{
AssertUtils
.
isNull
(
userBO
.
getId
(),
"ID不能为空"
);
User
user
=
UserConverter
.
INSTANCE
.
bo2do
(
userBO
);
int
editCnt
=
userDemoService
.
editUser
(
user
);
return
editCnt
;
}
@Operation
(
summary
=
"用户详情"
,
description
=
"查询用户详情"
)
@GetMapping
(
value
=
"/info/{id}"
)
public
UserDTO
info
(
@PathVariable
(
"id"
)
Long
id
)
{
User
user
=
userDemoService
.
getById
(
id
);
UserDTO
userDTO
=
UserConverter
.
INSTANCE
.
do2dto
(
user
);
return
userDTO
;
}
}
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/converter/UserConverter.java
0 → 100644
View file @
033f1a5
package
cn
.
com
.
glsx
.
cdp
.
modules
.
converter
;
import
cn.com.glsx.cdp.modules.model.UserBO
;
import
cn.com.glsx.cdp.modules.model.UserDTO
;
import
cn.com.glsx.cdp.modules.entity.User
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.Mapping
;
import
org.mapstruct.Mappings
;
import
org.mapstruct.factory.Mappers
;
/**
* 解耦dao与api的实体映射
* 字段名不一样,用@Mapping来处理
* https://github.com/mapstruct/mapstruct-examples
*
* @author payu
*/
@Mapper
public
interface
UserConverter
{
UserConverter
INSTANCE
=
Mappers
.
getMapper
(
UserConverter
.
class
);
UserDTO
do2dto
(
User
user
);
User
dto2do
(
UserDTO
userDTO
);
@Mappings
(
@Mapping
(
source
=
"realname"
,
target
=
"realName"
))
UserBO
do2bo
(
User
user
);
@Mappings
(
@Mapping
(
source
=
"realName"
,
target
=
"realname"
))
User
bo2do
(
UserBO
userBO
);
}
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/service/UserDemoService.java
0 → 100644
View file @
033f1a5
package
cn
.
com
.
glsx
.
cdp
.
modules
.
service
;
import
cn.com.glsx.cdp.modules.converter.UserConverter
;
import
cn.com.glsx.cdp.modules.entity.User
;
import
cn.com.glsx.cdp.modules.mapper.UserMapper
;
import
cn.com.glsx.cdp.modules.model.UserDTO
;
import
cn.com.glsx.cdp.modules.model.UserSearch
;
import
com.github.pagehelper.PageInfo
;
import
com.glsx.plat.common.utils.ObjectUtils
;
import
com.glsx.plat.common.utils.StringUtils
;
import
com.glsx.plat.exception.ResultException
;
import
com.glsx.plat.exception.SystemMessage
;
import
com.glsx.plat.jwt.base.ComJwtUser
;
import
com.glsx.plat.jwt.util.JwtUtils
;
import
com.glsx.plat.common.utils.SessionUtils
;
import
org.apache.commons.beanutils.BeanUtils
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.Assert
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author liuyf
* @desc 用户信息
* @date 2019年10月24日 下午2:37:40
*/
@Service
public
class
UserDemoService
{
@Resource
private
StringRedisTemplate
stringRedisTemplate
;
@Resource
private
JwtUtils
jwtUtils
;
@Resource
private
UserMapper
userMapper
;
public
User
getById
(
Long
id
)
{
return
userMapper
.
selectById
(
id
);
}
public
PageInfo
<
UserDTO
>
search
(
UserSearch
search
)
{
List
<
User
>
userList
=
userMapper
.
selectList
(
search
);
List
<
UserDTO
>
list
=
new
ArrayList
<>(
userList
.
size
());
userList
.
forEach
(
u
->
list
.
add
(
UserConverter
.
INSTANCE
.
do2dto
(
u
)));
return
new
PageInfo
<>(
list
);
}
public
PageInfo
<
UserDTO
>
search
(
Map
<
String
,
Object
>
params
)
{
UserSearch
search
=
new
UserSearch
();
try
{
BeanUtils
.
populate
(
search
,
params
);
}
catch
(
Exception
e
)
{
return
new
PageInfo
<>(
new
ArrayList
<>());
}
return
search
(
search
);
}
public
User
addUser
(
User
user
)
{
String
password
=
user
.
getPassword
();
// uuid获取随机字符串,作为盐值。
String
salt
=
StringUtils
.
generateRandomCode
(
false
,
4
);
//add Salt to password
//user.getCredentialsSalt
//SimpleHash hash = new SimpleHash(hcm.getHashAlgorithmName(), password, salt, hcm.getHashIterations());
//重新赋值
user
.
setSalt
(
salt
);
user
.
setPassword
(
password
);
//user.setEnableStatus(SysConstants.EnableStatus.enable.getCode());
user
.
setCreatedDate
(
new
Date
());
userMapper
.
insertUseGeneratedKeys
(
user
);
return
user
;
}
public
int
editUser
(
User
user
)
{
String
password
=
user
.
getPassword
();
//todo 更新入库
return
0
;
}
public
String
createToken
(
User
user
)
{
Assert
.
notNull
(
user
,
"获取当前用户信息失败"
);
String
uuid
=
cn
.
hutool
.
core
.
lang
.
UUID
.
randomUUID
().
toString
(
true
);
//JWT 随机ID,做为验证的key
String
jwtId
=
jwtUtils
.
getApplication
()
+
":"
+
jwtUtils
.
JWT_SESSION_PREFIX
+
uuid
+
"_"
+
user
.
getAccount
();
ComJwtUser
jwtUser
=
new
ComJwtUser
();
jwtUser
.
setJwtId
(
jwtId
);
jwtUser
.
setUserId
(
String
.
valueOf
(
user
.
getId
()));
jwtUser
.
setAccount
(
user
.
getPhone
());
jwtUser
.
setApplication
(
jwtUtils
.
getApplication
());
Map
<
String
,
String
>
userMap
=
(
Map
<
String
,
String
>)
ObjectUtils
.
objectToMap
(
jwtUser
);
return
jwtUtils
.
createCachedToken
(
jwtId
,
userMap
);
}
/**
* 根据Token获取Customer
*/
public
User
getByToken
()
{
String
token
=
SessionUtils
.
request
().
getHeader
(
HttpHeaders
.
AUTHORIZATION
);
if
(
StringUtils
.
isNullOrEmpty
(
token
))
{
throw
ResultException
.
create
(
SystemMessage
.
ILLEGAL_ACCESS
.
getCode
(),
"登录已失效"
);
}
//解析token,反转成JwtUser对象
Map
<
String
,
Object
>
userMap
=
jwtUtils
.
parseClaim
(
token
);
ComJwtUser
jwtUser
=
null
;
try
{
jwtUser
=
(
ComJwtUser
)
ObjectUtils
.
mapToObject
(
userMap
,
ComJwtUser
.
class
);
}
catch
(
Exception
e
)
{
throw
ResultException
.
create
(
SystemMessage
.
ILLEGAL_ACCESS
.
getCode
(),
"登录已失效"
);
}
User
user
=
new
User
();
user
.
setId
(
Long
.
valueOf
(
jwtUser
.
getUserId
()));
user
.
setPhone
(
jwtUser
.
getAccount
());
return
user
;
}
}
platform-cdp/src/main/resources/application.properties_standalone
0 → 100644
View file @
033f1a5
spring.application.name=admin
logging.path=/data/java_log/jetty/${spring.application.name}/${spring.application.name}.log
#server
server.port=8202
server.servlet.context-path=/${spring.application.name}
server.servlet.session.timeout=2592000
server.max-http-header-size=8192
server.tomcat.uri-encoding=UTF-8
server.tomcat.max-threads=1000
server.tomcat.min-spare-threads=30s
server.tomcat.basedir=/temp
#database
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://192.168.0.39:3306/gecc?serverTimeZone=Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false
spring.datasource.username=root
spring.datasource.password=123456
# Hikari will use the above plus the following to setup connection pooling
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.hikari.minimum-idle=5
spring.datasource.hikari.maximum-pool-size=15
spring.datasource.hikari.auto-commit=true
spring.datasource.hikari.idle-timeout=30000
spring.datasource.hikari.pool-name=DatebookHikariCP
spring.datasource.hikari.max-lifetime=1800000
spring.datasource.hikari.connection-timeout=30000
spring.datasource.hikari.connection-test-query=SELECT 1
spring.data.redis.repositories.enabled = false
#redis config
spring.redis.host=192.168.0.39
spring.redis.port=6379
spring.redis.password=hhxredis
spring.redis.database=1
spring.redis.timeout=200000
#jwt config
jwt.config.header=Authorization
jwt.config.ttl=7200
jwt.config.key=5371f568a45e5ab1f442c38e0932aef24447139c
\ No newline at end of file
platform-cdp/src/main/resources/bootstrap.properties
0 → 100644
View file @
033f1a5
spring.application.name
=
platform-cdp
logging.path
=
/data/java_log/jetty/${spring.application.name}/${spring.application.name}.log
spring.cloud.nacos.config.server-
addr
=
192.168.0.63:8868
spring.cloud.nacos.config.group
=
PLATFORM_GROUP
spring.cloud.nacos.config.prefix
=
${spring.application.name}
spring.profiles.active
=
dev
spring.cloud.nacos.config.file-
extension
=
properties
spring.cloud.nacos.config.shared-configs[0].data-
id
=
platform-microservice-share.properties
spring.cloud.nacos.config.shared-configs[0]
.group
=
${spring.cloud.nacos.config.group}
spring.cloud.nacos.config.shared-configs[0]
.refresh
=
true
spring.cloud.nacos.config.shared-configs[1]
.group
=
${spring.cloud.nacos.config.group}
spring.cloud.nacos.config.shared-configs[1].data-
id
=
platform-share-dev.properties
spring.cloud.nacos.config.shared-configs[1]
.refresh
=
true
\ No newline at end of file
platform-cdp/src/main/resources/logback-spring.xml
0 → 100644
View file @
033f1a5
<?xml version="1.0" encoding="UTF-8" ?>
<!--
说明:
1. 文件的命名和加载顺序有关
logback.xml早于application.yml加载,logback-spring.xml晚于application.yml加载
如果logback配置需要使用application.yml中的属性,需要命名为logback-spring.xml
2. logback使用application.yml中的属性
使用springProperty才可使用application.yml中的值 可以设置默认值
如果非要用yaml文件,那么只能使用绝对路径,例如:
logback-spring.xml引入文件:
<property file="${HOME}/configuration/application.yaml"/>
-->
<configuration
scan=
"true"
scanPeriod=
"60 seconds"
debug=
"false"
>
<include
resource=
"org/springframework/boot/logging/logback/defaults.xml"
/>
<property
resource=
"bootstrap.properties"
/>
<property
name=
"APP_NAME"
value=
"${spring.application.name}"
/>
<!-- 生成日志文件目录 -->
<property
name=
"LOG_FILE"
value=
"${logging.path}"
/>
<contextName>
${APP_NAME}
</contextName>
<turboFilter
class=
"com.glsx.plat.common.loggin.BootTurboFilter"
>
<Marker>
${APP_NAME}
</Marker>
</turboFilter>
<!-- 彩色日志 -->
<!-- 彩色日志依赖的渲染类 -->
<!-- <conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />-->
<!-- <conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />-->
<!-- <conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />-->
<!-- 配置日志输出参数,彩色日志格式 -->
<property
name=
"CONSOLE_LOG_PATTERN"
value=
"%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"
/>
<!-- 控制台打印日志 -->
<appender
name=
"console"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<filter
class=
"ch.qos.logback.classic.filter.ThresholdFilter"
>
<!-- Minimum logging level to be presented in the console logs-->
<level>
INFO
</level>
</filter>
<encoder>
<pattern>
${CONSOLE_LOG_PATTERN}
</pattern>
<charset>
utf8
</charset>
</encoder>
</appender>
<!-- 日志定时生成压缩文件 -->
<appender
name=
"flatfile"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<file>
${LOG_FILE}
</file>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<fileNamePattern>
${LOG_FILE}.%d{yyyy-MM-dd}.gz
</fileNamePattern>
<maxHistory>
7
</maxHistory>
</rollingPolicy>
<encoder>
<pattern>
${CONSOLE_LOG_PATTERN}
</pattern>
<charset>
utf8
</charset>
</encoder>
</appender>
<!-- 日志进行格式化 -->
<!-- <appender name="logstash" class="ch.qos.logback.core.rolling.RollingFileAppender">-->
<!-- <file>${LOG_FILE}.json</file>-->
<!-- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">-->
<!-- <fileNamePattern>${LOG_FILE}.json.%d{yyyy-MM-dd}.gz</fileNamePattern>-->
<!-- <maxHistory>7</maxHistory>-->
<!-- </rollingPolicy>-->
<!-- <encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">-->
<!-- <providers>-->
<!-- <timestamp>-->
<!-- <timeZone>UTC</timeZone>-->
<!-- </timestamp>-->
<!-- <pattern>-->
<!-- <pattern>-->
<!-- {-->
<!-- "severity": "%level",-->
<!-- "service": "${APP_NAME:-}",-->
<!-- "trace": "%X{X-B3-TraceId:-}",-->
<!-- "span": "%X{X-B3-SpanId:-}",-->
<!-- "parent": "%X{X-B3-ParentSpanId:-}",-->
<!-- "exportable": "%X{X-Span-Export:-}",-->
<!-- "pid": "${PID:-}",-->
<!-- "thread": "%thread",-->
<!-- "class": "%logger{40}",-->
<!-- "rest": "%message"-->
<!-- }-->
<!-- </pattern>-->
<!-- </pattern>-->
<!-- </providers>-->
<!-- </encoder>-->
<!-- </appender>-->
<root
level=
"INFO"
>
<appender-ref
ref=
"console"
/>
<appender-ref
ref=
"flatfile"
/>
<!-- uncomment this to have also JSON logs -->
<!-- <appender-ref ref="logstash"/>-->
</root>
</configuration>
\ No newline at end of file
platform-cdp/src/main/resources/mapper/UserMapper.xml
0 → 100644
View file @
033f1a5
<?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=
"cn.com.glsx.cdp.modules.mapper.UserMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"cn.com.glsx.cdp.modules.entity.User"
>
<id
column=
"id"
jdbcType=
"INTEGER"
property=
"id"
/>
<result
column=
"account"
jdbcType=
"VARCHAR"
property=
"account"
/>
<result
column=
"password"
jdbcType=
"VARCHAR"
property=
"password"
/>
<result
column=
"username"
jdbcType=
"VARCHAR"
property=
"username"
/>
<result
column=
"realname"
jdbcType=
"VARCHAR"
property=
"realname"
/>
<result
column=
"phone"
jdbcType=
"VARCHAR"
property=
"phone"
/>
<result
column=
"avatar"
jdbcType=
"VARCHAR"
property=
"avatar"
/>
<result
column=
"salt"
jdbcType=
"VARCHAR"
property=
"salt"
/>
<result
column=
"del_flag"
jdbcType=
"TINYINT"
property=
"delFlag"
/>
<result
column=
"created_date"
jdbcType=
"TIMESTAMP"
property=
"createdDate"
/>
<result
column=
"created_by"
jdbcType=
"INTEGER"
property=
"createdBy"
/>
<result
column=
"updated_date"
jdbcType=
"TIMESTAMP"
property=
"updatedDate"
/>
<result
column=
"updated_by"
jdbcType=
"INTEGER"
property=
"updatedBy"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
id, account, password, username, realname, phone, avatar, salt,
del_flag, created_date, created_by, updated_date, updated_by
</sql>
<select
id=
"selectList"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_user
where del_flag = 0
</select>
<select
id=
"selectById"
parameterType=
"java.lang.Integer"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_user
where del_flag = 0
and id = #{id}
</select>
<update
id=
"logicDeleteById"
parameterType=
"java.lang.Long"
>
update t_user
set del_flag = -1
where id = #{id}
</update>
</mapper>
\ No newline at end of file
platform-cdp/src/main/webapp/WEB-INF/bin/restart.sh
0 → 100644
View file @
033f1a5
#!/bin/bash
cd
`
dirname
$0
`
./stop.sh
if
[
!
$?
-eq 2
]
;
then
./start.sh
fi
\ No newline at end of file
platform-cdp/src/main/webapp/WEB-INF/bin/server.sh
0 → 100644
View file @
033f1a5
#!/bin/bash
cd
`
dirname
$0
`
if
[
"
$1
"
=
"start"
]
;
then
ENV
=
$2
if
[
-z
"
$ENV
"
]
;
then
echo
"ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo
"app exit"
exit
1
fi
./start.sh
$ENV
else
if
[
"
$1
"
=
"stop"
]
;
then
./stop.sh
else
if
[
"
$1
"
=
"debug"
]
;
then
ENV
=
$2
if
[
-z
"
$ENV
"
]
;
then
echo
"ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo
"app exit"
exit
1
fi
./start.sh
$ENV
debug
else
if
[
"
$1
"
=
"restart"
]
;
then
ENV
=
$2
if
[
-z
"
$ENV
"
]
;
then
echo
"ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo
"app exit"
exit
1
fi
./restart.sh
$ENV
else
if
[
"
$1
"
=
"dump"
]
;
then
./dump.sh
else
echo
"ERROR: Please input argument: start or stop or debug or restart or dump"
exit
1
fi
fi
fi
fi
fi
platform-cdp/src/main/webapp/WEB-INF/bin/start.sh
0 → 100644
View file @
033f1a5
#!/bin/bash
####################################
# #
# General shell v1.0.0.1 #
# #
# #
####################################
###########init variable#############
JAVA_HOME
=
"/app/soft/jdk1.8.0_144"
SERVER_PORT
=
"8820"
DUBBO_PORT
=
""
JMX_ARG
=
"-Xmx1024m -Xms512m -Xmn256m"
MAIN
=
"cn.com.glsx.Application"
SERVER_NAME
=
"rest-admin"
###########end#######################
PID_DIR
=
"/app/soft/java_project/pids"
cd
`
dirname
$0
`
BIN_DIR
=
`
pwd
`
cd
..
if
[
-d
"classes"
]
;
then
CONF_DIR
=
"
$(
pwd
)
/classes"
LIB_DIR
=
"
$(
pwd
)
/lib"
elif
[
-d
"conf"
]
;
then
CONF_DIR
=
"
$(
pwd
)
/conf"
LIB_DIR
=
"
$(
pwd
)
/lib"
fi
LIB_JARS
=
`
ls
$LIB_DIR
|grep .jar|awk
'{print "'
$LIB_DIR
'/"$0}'
|tr
"
\n
"
":"
`
export
CLASSPATH
=
$CONF_DIR
:
$LIB_JARS
if
[
-z
"
$CONF_DIR
"
]
;
then
echo
"Configure dir not found"
exit
1
fi
PIDS
=
`
ps --no-heading -C java -f --width 1000 | grep
"
$CONF_DIR
"
|awk
'{print $2}'
`
if
[
-n
"
$PIDS
"
]
;
then
echo
"ERROR: The app is already started!"
echo
"PID:
$PIDS
"
exit
1
fi
if
[
! -d
"
$PID_DIR
"
]
;
then
mkdir -p
$PID_DIR
fi
CHECK_PORT
=
$2
if
[
-n
"
$SERVER_PORT
"
]
;
then
SERVER_PORT_COUNT
=
`
netstat -tln | grep -w
$SERVER_PORT
| wc -l
`
if
[
$SERVER_PORT_COUNT
-gt 0
]
;
then
echo
"ERROR: The port
$SERVER_PORT
is already used!"
exit
1
fi
fi
if
[
-n
"
$DUBBO_PORT
"
]
;
then
DUBBO_PORT_COUNT
=
`
netstat -tln | grep -w
$DUBBO_PORT
| wc -l
`
if
[
$DUBBO_PORT_COUNT
-gt 0
]
;
then
echo
"ERROR: The port
$DUBBO_PORT
already used!"
exit
1
fi
fi
if
[[
-z
"
$SERVER_PORT
"
&&
-z
"
$DUBBO_PORT
"
]]
;
then
CHECK_PORT
=
"skip"
fi
LOG_FILE
=
"/data/java_log/jetty/
${
SERVER_NAME
}
/
${
SERVER_NAME
}
.log"
LOG_DIR
=
`
dirname
$LOG_FILE
`
if
[
! -d
$LOG_DIR
]
;
then
mkdir -p
$LOG_DIR
fi
############java args #######
#JAVA_OPTS="$PINPOINT -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Ddubbo.registry.file=/home/jdkapp/.dubbo/${SERVER_NAME}.cache"
JAVA_OPTS
=
"
$PINPOINT
-Djava.awt.headless=true -Djava.net.preferIPv4Stack=true"
#JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true"
JAVA_DEBUG_OPTS
=
""
if
[
"
$2
"
=
"debug"
]
;
then
JAVA_DEBUG_OPTS
=
" -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n "
fi
JAVA_JMX_OPTS
=
""
if
[
"
$2
"
=
"jmx"
]
;
then
JAVA_JMX_OPTS
=
" -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false "
fi
BITS
=
`
file
$JAVA_HOME
/bin/java | grep 64-bit
`
if
[
-n
"
$BITS
"
]
;
then
if
[
-n
"
$JMX_ARG
"
]
;
then
JAVA_MEM_OPTS
=
"-server
$JMX_ARG
-XX:PermSize=128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70"
else
JAVA_MEM_OPTS
=
" -server -Xmx1g -Xms1g -Xmn256m -XX:PermSize=128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 "
fi
else
JAVA_MEM_OPTS
=
" -server -Xms1024m -Xmx1024m -XX:PermSize=128m -XX:SurvivorRatio=2 -XX:+UseParallelGC "
fi
echo
-e
"Starting
$SERVER_NAME
\c
"
nohup
$JAVA_HOME
/bin/java
$JAVA_OPTS
$JAVA_MEM_OPTS
$JAVA_DEBUG_OPTS
$JAVA_JMX_OPTS
-DCLASS_DIR
=
$CONF_DIR
:
$LIB_DIR
$MAIN
> /dev/null 2>&1 &
PIDS
=
$!
if
[
"
$CHECK_PORT
"
!
=
"skip"
]
;
then
COUNT
=
0
ERROR
=
0
TIME_OUT
=
60
ctime
=
`
date +
"%s"
`
while
[
$COUNT
-lt 1
]
;
do
ctime2
=
`
date +
"%s"
`
echo
-e
".
\c
"
sleep 1
#PIDS=`ps --no-heading -C java -f --width 1000 | grep "$CONF_DIR" | awk '{print $2}'`
RESULT
=
`
ps --no-heading -p
$PIDS
`
if
[
-n
"
$RESULT
"
]
;
then
if
[
-n
"
$DUBBO_PORT
"
]
;
then
#COUNT=`echo status | nc 127.0.0.1 $DUBBO_PORT -i 1 | grep -c OK`
COUNT
=
`
/usr/sbin/ss -lpn | grep
"
${
DUBBO_PORT
}
.*
$PIDS
"
| wc -l
`
else
if
[
-n
"
$SERVER_PORT
"
]
;
then
#COUNT=`netstat -ntl | grep -w $SERVER_PORT | wc -l`
COUNT
=
`
/usr/sbin/ss -lpn | grep
"
${
SERVER_PORT
}
.*
$PIDS
"
| wc -l
`
fi
fi
if
[
$COUNT
-gt 0
]
;
then
echo
$PIDS
>
$PID_DIR
/
${
SERVER_NAME
}
.pid
break
fi
dtime
=
$((
ctime2
-
ctime
))
if
[
"
$dtime
"
-ge
"
$TIME_OUT
"
]
;
then
echo
$PIDS
>
$PID_DIR
/
${
SERVER_NAME
}
.pid
echo
-e
"
\n
check port status timeout"
exit
1
fi
else
ERROR
=
$((
ERROR
+
1
))
if
[
"
$ERROR
"
-gt 3
]
;
then
echo
-e
"
\n
Program startup failed"
exit
2
fi
fi
done
fi
#服务检测与注册
if
[[
"x
$SERVER_PORT
"
!
=
"x"
&&
-f ./bin/check.sh
]]
then
./bin/check.sh
$SERVER_NAME
$SERVER_PORT
$PIDS
&
fi
echo
"PID:
$PIDS
"
echo
"LOGFILE:
$LOG_FILE
"
\ No newline at end of file
platform-cdp/src/main/webapp/WEB-INF/bin/stop.sh
0 → 100644
View file @
033f1a5
#!/bin/bash
####################################
# #
# General shell v1.0.0.1 #
# #
# #
####################################
SERVER_NAME
=
"rest-admin"
PID_DIR
=
"/app/soft/java_project/pids"
cd
`
dirname
$0
`
BIN_DIR
=
`
pwd
`
cd
..
if
[
-d
"classes"
]
;
then
CONF_DIR
=
"
$(
pwd
)
/classes"
elif
[
-d
"conf"
]
;
then
CONF_DIR
=
"
$(
pwd
)
/conf"
fi
#if [ -f "$PID_DIR/${SERVER_NAME}.pid" ];then
# PID=`cat $PID_DIR/${SERVER_NAME}.pid`
#else
PID
=
`
ps --no-heading -C java -f --width 1000 | grep
"
$CONF_DIR
"
|awk
'{print $2}'
`
#fi
if
[
-z
"
$PID
"
]
;
then
echo
"The program is not running"
exit
1
fi
pcount
=
`
ps --no-heading -p
$PID
| wc -l
`
if
[
"
$pcount
"
-ne 1
]
;
then
echo
"ERROR:
$SERVER_NAME
does not started!"
exit
1
fi
echo
-e
"Stopping
$SERVER_NAME
...
\c
"
kill
$PID
> /dev/null 2>&1
COUNT
=
0
ctime
=
`
date +
"%s"
`
while
[
$COUNT
-lt 1
]
;
do
echo
-e
".
\c
"
sleep 1
COUNT
=
1
PID_EXIST
=
`
ps --no-heading -p
$PID
`
if
[
-n
"
$PID_EXIST
"
]
;
then
ctime2
=
`
date +
"%s"
`
dtime
=
$((
ctime2
-
ctime
))
if
[
"
$dtime
"
-ge 10
]
;
then
echo
-e
"
\n
stop program timeout, use kill -9
$PID
"
kill
-9
$PID
>/dev/null 2>&1
if
[
!
$?
-eq 0
]
;
then
echo
"No permissions"
exit
2
else
rm -rf
$PID_DIR
/
${
SERVER_NAME
}
.pid
fi
fi
COUNT
=
0
continue
fi
done
echo
"OK!"
rm -rf
$PID_DIR
/
${
SERVER_NAME
}
.pid
\ No newline at end of file
platform-cdp/src/test/java/cn/com/glsx/TestApplication.java
0 → 100644
View file @
033f1a5
//package cn.com.glsx;
//
//import com.glsx.microservice.api.EchoCenterFeignService;
//import com.glsx.plat.core.web.R;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.SpringApplication;
//import org.springframework.boot.autoconfigure.SpringBootApplication;
//import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
//import org.springframework.cloud.client.loadbalancer.LoadBalanced;
//import org.springframework.context.annotation.Bean;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RestController;
//import org.springframework.web.client.RestTemplate;
//
//import javax.annotation.Resource;
//
///**
// * 测试spring cloud 服务调用方式
// */
//@EnableDiscoveryClient
//@SpringBootApplication
//public class TestApplication {
//
// public static void main(String[] args) {
// SpringApplication.run(TestApplication.class, args);
// }
//
// @Slf4j
// @RestController
// static class TestController {
//
// @Autowired
// RestTemplate restTemplate;
//
// @Resource
// private EchoCenterFeignService echoCenterFeignService;
//
//// @Autowired
//// private WebClient.Builder webClientBuilder;
//
// @GetMapping("/test1")
// public String test1() {
// String result = restTemplate.getForObject("http://192.168.0.63:8829/rest-echo-center/echo/didi", String.class);
// return "Return : " + result;
// }
//
//// @GetMapping("/test")
//// public Mono<String> test() {
//// Mono<String> result = webClientBuilder.build()
//// .get()
//// .uri("http://alibaba-nacos-discovery-server/hello?name=didi")
//// .retrieve()
//// .bodyToMono(String.class);
//// return result;
//// }
//
// @GetMapping("/test3")
// public R test3() {
// String result = echoCenterFeignService.echo("this is a test!");
// return R.ok().data(result);
// }
// }
//
// @Bean
// @LoadBalanced
// public RestTemplate restTemplate() {
// return new RestTemplate();
// }
//
//// @Bean
//// @LoadBalanced
//// public WebClient.Builder loadBalancedWebClientBuilder() {
//// return WebClient.builder();
//// }
//
//}
\ No newline at end of file
platform-cdp/src/test/java/cn/com/glsx/cn/com/glsx/TestApplication.java
0 → 100644
View file @
033f1a5
//package cn.com.glsx;
//
//import com.glsx.microservice.api.EchoCenterFeignService;
//import com.glsx.plat.core.web.R;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.SpringApplication;
//import org.springframework.boot.autoconfigure.SpringBootApplication;
//import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
//import org.springframework.cloud.client.loadbalancer.LoadBalanced;
//import org.springframework.context.annotation.Bean;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RestController;
//import org.springframework.web.client.RestTemplate;
//
//import javax.annotation.Resource;
//
///**
// * 测试spring cloud 服务调用方式
// */
//@EnableDiscoveryClient
//@SpringBootApplication
//public class TestApplication {
//
// public static void main(String[] args) {
// SpringApplication.run(TestApplication.class, args);
// }
//
// @Slf4j
// @RestController
// static class TestController {
//
// @Autowired
// RestTemplate restTemplate;
//
// @Resource
// private EchoCenterFeignService echoCenterFeignService;
//
//// @Autowired
//// private WebClient.Builder webClientBuilder;
//
// @GetMapping("/test1")
// public String test1() {
// String result = restTemplate.getForObject("http://192.168.0.63:8829/rest-echo-center/echo/didi", String.class);
// return "Return : " + result;
// }
//
//// @GetMapping("/test")
//// public Mono<String> test() {
//// Mono<String> result = webClientBuilder.build()
//// .get()
//// .uri("http://alibaba-nacos-discovery-server/hello?name=didi")
//// .retrieve()
//// .bodyToMono(String.class);
//// return result;
//// }
//
// @GetMapping("/test3")
// public R test3() {
// String result = echoCenterFeignService.echo("this is a test!");
// return R.ok().data(result);
// }
// }
//
// @Bean
// @LoadBalanced
// public RestTemplate restTemplate() {
// return new RestTemplate();
// }
//
//// @Bean
//// @LoadBalanced
//// public WebClient.Builder loadBalancedWebClientBuilder() {
//// return WebClient.builder();
//// }
//
//}
\ No newline at end of file
platform-cdp/src/test/resources/generatorConfig.xml
0 → 100644
View file @
033f1a5
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE generatorConfiguration PUBLIC
"-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<!-- 配置生成器 -->
<generatorConfiguration>
<!--classPathEntry:数据库的JDBC驱动,换成你自己的驱动位置 可选 -->
<!-- <classPathEntry location="F://jdbc//mysql-connector-java-8.0.18.jar"/>-->
<!-- 一个数据库一个context -->
<context
id=
"DB2Tables"
targetRuntime=
"Mybatis3"
>
<!-- 自动识别数据库关键字,默认false,如果设置为true,根据SqlReservedWords中定义的关键字列表;一般保留默认值,遇到数据库关键字(Java关键字),使用columnOverride覆盖 -->
<property
name=
"autoDelimitKeywords"
value=
"true"
/>
<!-- 生成的Java文件的编码 -->
<property
name=
"javaFileEncoding"
value=
"utf-8"
/>
<!-- beginningDelimiter和endingDelimiter:指明数据库的用于标记数据库对象名的符号,比如ORACLE就是双引号,MYSQL默认是`反引号; -->
<property
name=
"beginningDelimiter"
value=
"`"
/>
<property
name=
"endingDelimiter"
value=
"`"
/>
<!-- 格式化java代码 -->
<property
name=
"javaFormatter"
value=
"org.mybatis.generator.api.dom.DefaultJavaFormatter"
/>
<!-- 格式化XML代码 -->
<property
name=
"xmlFormatter"
value=
"org.mybatis.generator.api.dom.DefaultXmlFormatter"
/>
<plugin
type=
"org.mybatis.generator.plugins.SerializablePlugin"
/>
<plugin
type=
"org.mybatis.generator.plugins.ToStringPlugin"
/>
<!-- 配置 tk.mybatis 插件 -->
<plugin
type=
"tk.mybatis.mapper.generator.MapperPlugin"
>
<property
name=
"mappers"
value=
"com.glsx.plat.mybatis.mapper.CommonBaseMapper"
/>
</plugin>
<!--配置生成注释信息,最多配置一个 -->
<commentGenerator>
<!-- 阻止生成注释包含时间戳 默认为false -->
<property
name=
"suppressDate"
value=
"true"
/>
<!-- 注释是否添加数据库表的备注信息 默认为false -->
<property
name=
"addRemarkComments"
value=
"true"
/>
</commentGenerator>
<!-- jdbc连接-->
<jdbcConnection
driverClass=
"com.mysql.cj.jdbc.Driver"
connectionURL=
"jdbc:mysql://192.168.0.39:3306/seata_storage?serverTimeZone=Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false"
userId=
"root"
password=
"123456"
>
<!--防止生成其他库同名表-->
<property
name=
"nullCatalogMeansCurrent"
value=
"true"
/>
</jdbcConnection>
<!-- 类型转换 -->
<javaTypeResolver>
<!-- 是否使用bigDecimal, false可自动转化以下类型(Long, Integer, Short, etc.) -->
<property
name=
"forceBigDecimals"
value=
"false"
/>
</javaTypeResolver>
<!-- 生成实体类地址 -->
<javaModelGenerator
targetPackage=
"cn.com.payu.modules.entity"
targetProject=
"src/main/java"
>
<!-- 是否让schema作为包的后缀 -->
<property
name=
"enableSubPackages"
value=
"true"
/>
<!-- 从数据库返回的值去掉前后空格 -->
<property
name=
"trimStrings"
value=
"true"
/>
</javaModelGenerator>
<!-- 生成mapper.xml文件存放地址 -->
<sqlMapGenerator
targetPackage=
"mapper"
targetProject=
"src/main/resources"
>
<property
name=
"enableSubPackages"
value=
"true"
/>
</sqlMapGenerator>
<!-- 生成接口dao type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象 type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象 type="XMLMAPPER",生成SQLMap XML文件和独立的Mapper接口 -->
<javaClientGenerator
targetPackage=
"cn.com.payu.modules.mapper"
targetProject=
"src/main/java"
type=
"XMLMAPPER"
>
<property
name=
"enableSubPackages"
value=
"false"
/>
</javaClientGenerator>
<!-- table可以有多个,每个数据库中的表都可以写一个table,tableName表示要匹配的数据库表,也可以在tableName属性中通过使用%通配符来匹配所有数据库表,只有匹配的表才会自动生成文件 enableSelectByPrimaryKey相应的配置表示是否生成相应的接口 -->
<table
tableName=
"t_storage"
domainObjectName=
"Storage"
enableCountByExample=
"false"
enableUpdateByExample=
"false"
enableDeleteByExample=
"false"
enableSelectByExample=
"false"
selectByExampleQueryId=
"false"
/>
</context>
</generatorConfiguration>
\ No newline at end of file
pom.xml
0 → 100644
View file @
033f1a5
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<groupId>
com.glsx
</groupId>
<artifactId>
rest-admin-framework
</artifactId>
<version>
2.0.0-SNAPSHOT
</version>
</parent>
<groupId>
cn.com.glsx
</groupId>
<artifactId>
platform-cdp-server
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<modelVersion>
4.0.0
</modelVersion>
<packaging>
pom
</packaging>
<description>
Microservice Scaffolding project for Spring Boot
</description>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
<maven.compiler.source>
1.8
</maven.compiler.source>
<maven.compiler.target>
1.8
</maven.compiler.target>
</properties>
<build>
<resources>
<resource>
<directory>
src/main/java
</directory>
<excludes>
<exclude>
**/*.java
</exclude>
</excludes>
</resource>
<resource>
<directory>
src/main/resources
</directory>
<includes>
<include>
**/*.*
</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>
org.mybatis.generator
</groupId>
<artifactId>
mybatis-generator-maven-plugin
</artifactId>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-archetype-plugin
</artifactId>
<version>
3.2.0
</version>
</plugin>
</plugins>
</build>
<modules>
<module>
platform-cdp
</module>
<module>
platform-cdp-api
</module>
</modules>
</project>
Write
Preview
Markdown
is supported
Attach a file
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 post a comment