parent
c346794248
commit
cccf0a2ba2
|
@ -0,0 +1,46 @@
|
|||
######################################################################
|
||||
# Build Tools
|
||||
|
||||
.gradle
|
||||
/build/
|
||||
!gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
|
||||
######################################################################
|
||||
# IDE
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### JRebel ###
|
||||
rebel.xml
|
||||
### NetBeans ###
|
||||
nbproject/private/
|
||||
build/*
|
||||
nbbuild/
|
||||
dist/
|
||||
nbdist/
|
||||
.nb-gradle/
|
||||
|
||||
######################################################################
|
||||
# Others
|
||||
*.log
|
||||
*.xml.versionsBackup
|
||||
*.swp
|
||||
|
||||
!*/build/*.java
|
||||
!*/build/*.html
|
||||
!*/build/*.xml
|
|
@ -0,0 +1,131 @@
|
|||
<p align="center">
|
||||
<img alt="logo" src="https://oscimg.oschina.net/oscnet/up-b99b286755aef70355a7084753f89cdb7c9.png">
|
||||
</p>
|
||||
<h1 align="center" style="margin: 30px 0 30px; font-weight: bold;">RuoYi v3.6.3</h1>
|
||||
<h4 align="center">基于 Vue/Element UI 和 Spring Boot/Spring Cloud & Alibaba 前后端分离的分布式微服务架构</h4>
|
||||
<p align="center">
|
||||
<a href="https://gitee.com/y_project/RuoYi-Cloud/stargazers"><img src="https://gitee.com/y_project/RuoYi-Cloud/badge/star.svg?theme=dark"></a>
|
||||
<a href="https://gitee.com/y_project/RuoYi-Cloud"><img src="https://img.shields.io/badge/RuoYi-v3.6.3-brightgreen.svg"></a>
|
||||
<a href="https://gitee.com/y_project/RuoYi-Cloud/blob/master/LICENSE"><img src="https://img.shields.io/github/license/mashape/apistatus.svg"></a>
|
||||
</p>
|
||||
|
||||
## 平台简介
|
||||
|
||||
若依是一套全部开源的快速开发平台,毫无保留给个人及企业免费使用。
|
||||
|
||||
* 采用前后端分离的模式,微服务版本前端(基于 [RuoYi-Vue](https://gitee.com/y_project/RuoYi-Vue))。
|
||||
* 后端采用Spring Boot、Spring Cloud & Alibaba。
|
||||
* 注册中心、配置中心选型Nacos,权限认证使用Redis。
|
||||
* 流量控制框架选型Sentinel,分布式事务选型Seata。
|
||||
* 提供了技术栈([Vue3](https://v3.cn.vuejs.org) [Element Plus](https://element-plus.org/zh-CN) [Vite](https://cn.vitejs.dev))版本[RuoYi-Cloud-Vue3](https://github.com/yangzongzhuan/RuoYi-Cloud-Vue3),保持同步更新。
|
||||
* 如需不分离应用,请移步 [RuoYi](https://gitee.com/y_project/RuoYi),如需分离应用,请移步 [RuoYi-Vue](https://gitee.com/y_project/RuoYi-Vue)
|
||||
* 阿里云折扣场:[点我进入](http://aly.muyu.vip),腾讯云秒杀场:[点我进入](http://txy.muyu.vip)
|
||||
* 阿里云优惠券:[点我领取](https://www.aliyun.com/minisite/goods?userCode=brki8iof&share_source=copy_link),腾讯云优惠券:[点我领取](https://cloud.tencent.com/redirect.php?redirect=1025&cps_key=198c8df2ed259157187173bc7f4f32fd&from=console)
|
||||
|
||||
#### 友情链接 [若依/RuoYi-Cloud](https://gitee.com/zhangmrit/muyu-cloud) Ant Design版本。
|
||||
|
||||
## 系统模块
|
||||
|
||||
~~~
|
||||
com.muyu
|
||||
├── muyu-ui // 前端框架 [80]
|
||||
├── muyu-gateway // 网关模块 [8080]
|
||||
├── muyu-auth // 认证中心 [9200]
|
||||
├── muyu-api // 接口模块
|
||||
│ └── muyu-api-system // 系统接口
|
||||
├── muyu-common // 通用模块
|
||||
│ └── muyu-common-core // 核心模块
|
||||
│ └── muyu-common-datascope // 权限范围
|
||||
│ └── muyu-common-datasource // 多数据源
|
||||
│ └── muyu-common-log // 日志记录
|
||||
│ └── muyu-common-redis // 缓存服务
|
||||
│ └── muyu-common-seata // 分布式事务
|
||||
│ └── muyu-common-security // 安全模块
|
||||
│ └── muyu-common-swagger // 系统接口
|
||||
├── muyu-modules // 业务模块
|
||||
│ └── muyu-system // 系统模块 [9201]
|
||||
│ └── muyu-gen // 代码生成 [9202]
|
||||
│ └── muyu-job // 定时任务 [9203]
|
||||
│ └── muyu-file // 文件服务 [9300]
|
||||
├── muyu-visual // 图形化管理模块
|
||||
│ └── muyu-visual-monitor // 监控中心 [9100]
|
||||
├──pom.xml // 公共依赖
|
||||
~~~
|
||||
|
||||
## 架构图
|
||||
|
||||
<img src="https://oscimg.oschina.net/oscnet/up-82e9722ecb846786405a904bafcf19f73f3.png"/>
|
||||
|
||||
## 内置功能
|
||||
|
||||
1. 用户管理:用户是系统操作者,该功能主要完成系统用户配置。
|
||||
2. 部门管理:配置系统组织机构(公司、部门、小组),树结构展现支持数据权限。
|
||||
3. 岗位管理:配置系统用户所属担任职务。
|
||||
4. 菜单管理:配置系统菜单,操作权限,按钮权限标识等。
|
||||
5. 角色管理:角色菜单权限分配、设置角色按机构进行数据范围权限划分。
|
||||
6. 字典管理:对系统中经常使用的一些较为固定的数据进行维护。
|
||||
7. 参数管理:对系统动态配置常用参数。
|
||||
8. 通知公告:系统通知公告信息发布维护。
|
||||
9. 操作日志:系统正常操作日志记录和查询;系统异常信息日志记录和查询。
|
||||
10. 登录日志:系统登录日志记录查询包含登录异常。
|
||||
11. 在线用户:当前系统中活跃用户状态监控。
|
||||
12. 定时任务:在线(添加、修改、删除)任务调度包含执行结果日志。
|
||||
13. 代码生成:前后端代码的生成(java、html、xml、sql)支持CRUD下载 。
|
||||
14. 系统接口:根据业务代码自动生成相关的api接口文档。
|
||||
15. 服务监控:监视当前系统CPU、内存、磁盘、堆栈等相关信息。
|
||||
16. 在线构建器:拖动表单元素生成相应的HTML代码。
|
||||
17. 连接池监视:监视当前系统数据库连接池状态,可进行分析SQL找出系统性能瓶颈。
|
||||
|
||||
## 在线体验
|
||||
|
||||
- admin/admin123
|
||||
- 陆陆续续收到一些打赏,为了更好的体验已用于演示服务器升级。谢谢各位小伙伴。
|
||||
|
||||
演示地址:http://muyu.vip
|
||||
文档地址:http://doc.muyu.vip
|
||||
|
||||
## 演示图
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/cd1f90be5f2684f4560c9519c0f2a232ee8.jpg"/></td>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/1cbcf0e6f257c7d3a063c0e3f2ff989e4b3.jpg"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/up-8074972883b5ba0622e13246738ebba237a.png"/></td>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/up-9f88719cdfca9af2e58b352a20e23d43b12.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/up-39bf2584ec3a529b0d5a3b70d15c9b37646.png"/></td>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/up-4148b24f58660a9dc347761e4cf6162f28f.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/up-b2d62ceb95d2dd9b3fbe157bb70d26001e9.png"/></td>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/up-d67451d308b7a79ad6819723396f7c3d77a.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/5e8c387724954459291aafd5eb52b456f53.jpg"/></td>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/644e78da53c2e92a95dfda4f76e6d117c4b.jpg"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/up-8370a0d02977eebf6dbf854c8450293c937.png"/></td>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/up-49003ed83f60f633e7153609a53a2b644f7.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/up-d4fe726319ece268d4746602c39cffc0621.png"/></td>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/up-c195234bbcd30be6927f037a6755e6ab69c.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/up-ece3fd37a3d4bb75a3926e905a3c5629055.png"/></td>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/up-92ffb7f3835855cff100fa0f754a6be0d99.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/up-ff9e3066561574aca73005c5730c6a41f15.png"/></td>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/up-5e4daac0bb59612c5038448acbcef235e3a.png"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
## 若依微服务交流群
|
||||
|
||||
QQ群: [](https://jq.qq.com/?_wv=1027&k=yqInfq0S) [](https://jq.qq.com/?_wv=1027&k=Oy1mb3p8) [](https://jq.qq.com/?_wv=1027&k=rvxkJtXK) [](https://jq.qq.com/?_wv=1027&k=0Ck3PvTe) [](https://jq.qq.com/?_wv=1027&k=FnHHP4TT) [](https://jq.qq.com/?_wv=1027&k=qdT1Ojpz) [](https://jq.qq.com/?_wv=1027&k=nw3OiyXs) [](https://jq.qq.com/?_wv=1027&k=kiU5WDls) [](https://jq.qq.com/?_wv=1027&k=MtBy6YfT) [](https://jq.qq.com/?_wv=1027&k=FqImHgH2) [](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=G4jZ4EtdT50PhnMBudTnEwgonxkXOscJ&authKey=FkGHYfoTKlGE6wHdKdjH9bVoOgQjtLP9WM%2Fj7pqGY1msoqw9uxDiBo39E2mLgzYg&noverify=0&group_code=128355254) [](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=irnwcXhbLOQEv1g-TwGifjNTA_f4wZiA&authKey=4bpzEwhcUY%2FvsPDHvzYn6xfoS%2FtOArvZ%2BGXzfr7O0%2FEqLfkKA%2BuCDXlzHIFg8t93&noverify=0&group_code=179219821) 点击按钮入群。
|
|
@ -0,0 +1,14 @@
|
|||
@echo off
|
||||
echo.
|
||||
echo [<5B><>Ϣ] ʹ<><CAB9>Jar<61><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Auth<74><68><EFBFBD>̡<EFBFBD>
|
||||
echo.
|
||||
|
||||
cd %~dp0
|
||||
cd ../muyu-auth/target
|
||||
|
||||
set JAVA_OPTS=-Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m
|
||||
|
||||
java -Dfile.encoding=utf-8 %JAVA_OPTS% -jar muyu-auth.jar
|
||||
|
||||
cd bin
|
||||
pause
|
|
@ -0,0 +1,14 @@
|
|||
@echo off
|
||||
echo.
|
||||
echo [<5B><>Ϣ] ʹ<><CAB9>Jar<61><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Gateway<61><79><EFBFBD>̡<EFBFBD>
|
||||
echo.
|
||||
|
||||
cd %~dp0
|
||||
cd ../muyu-gateway/target
|
||||
|
||||
set JAVA_OPTS=-Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m
|
||||
|
||||
java -Dfile.encoding=utf-8 %JAVA_OPTS% -jar muyu-gateway.jar
|
||||
|
||||
cd bin
|
||||
pause
|
|
@ -0,0 +1,14 @@
|
|||
@echo off
|
||||
echo.
|
||||
echo [<5B><>Ϣ] ʹ<><CAB9>Jar<61><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Modules-File<6C><65><EFBFBD>̡<EFBFBD>
|
||||
echo.
|
||||
|
||||
cd %~dp0
|
||||
cd ../muyu-modules/muyu-file/target
|
||||
|
||||
set JAVA_OPTS=-Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m
|
||||
|
||||
java -Dfile.encoding=utf-8 %JAVA_OPTS% -jar muyu-modules-file.jar
|
||||
|
||||
cd bin
|
||||
pause
|
|
@ -0,0 +1,14 @@
|
|||
@echo off
|
||||
echo.
|
||||
echo [<5B><>Ϣ] ʹ<><CAB9>Jar<61><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Modules-Gen<65><6E><EFBFBD>̡<EFBFBD>
|
||||
echo.
|
||||
|
||||
cd %~dp0
|
||||
cd ../muyu-modules/muyu-gen/target
|
||||
|
||||
set JAVA_OPTS=-Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m
|
||||
|
||||
java -Dfile.encoding=utf-8 %JAVA_OPTS% -jar muyu-modules-gen.jar
|
||||
|
||||
cd bin
|
||||
pause
|
|
@ -0,0 +1,14 @@
|
|||
@echo off
|
||||
echo.
|
||||
echo [<5B><>Ϣ] ʹ<><CAB9>Jar<61><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Modules-Job<6F><62><EFBFBD>̡<EFBFBD>
|
||||
echo.
|
||||
|
||||
cd %~dp0
|
||||
cd ../muyu-modules/muyu-job/target
|
||||
|
||||
set JAVA_OPTS=-Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m
|
||||
|
||||
java -Dfile.encoding=utf-8 %JAVA_OPTS% -jar muyu-modules-job.jar
|
||||
|
||||
cd bin
|
||||
pause
|
|
@ -0,0 +1,14 @@
|
|||
@echo off
|
||||
echo.
|
||||
echo [<5B><>Ϣ] ʹ<><CAB9>Jar<61><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Modules-System<65><6D><EFBFBD>̡<EFBFBD>
|
||||
echo.
|
||||
|
||||
cd %~dp0
|
||||
cd ../muyu-modules/muyu-system/target
|
||||
|
||||
set JAVA_OPTS=-Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m
|
||||
|
||||
java -Dfile.encoding=utf-8 %JAVA_OPTS% -jar muyu-modules-system.jar
|
||||
|
||||
cd bin
|
||||
pause
|
|
@ -0,0 +1,14 @@
|
|||
@echo off
|
||||
echo.
|
||||
echo [<5B><>Ϣ] ʹ<><CAB9>Jar<61><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Monitor<6F><72><EFBFBD>̡<EFBFBD>
|
||||
echo.
|
||||
|
||||
cd %~dp0
|
||||
cd ../muyu-visual/muyu-monitor/target
|
||||
|
||||
set JAVA_OPTS=-Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m
|
||||
|
||||
java -Dfile.encoding=utf-8 %JAVA_OPTS% -jar muyu-visual-monitor.jar
|
||||
|
||||
cd bin
|
||||
pause
|
|
@ -0,0 +1,41 @@
|
|||
#!/bin/sh
|
||||
|
||||
# 复制项目的文件到对应docker路径,便于一键生成镜像。
|
||||
usage() {
|
||||
echo "Usage: sh copy.sh"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
# copy sql
|
||||
echo "begin copy sql "
|
||||
cp ../sql/ry_20230706.sql ./mysql/db
|
||||
cp ../sql/ry_config_20220929.sql ./mysql/db
|
||||
|
||||
# copy html
|
||||
echo "begin copy html "
|
||||
cp -r ../muyu-ui/dist/** ./nginx/html/dist
|
||||
|
||||
|
||||
# copy jar
|
||||
echo "begin copy muyu-gateway "
|
||||
cp ../muyu-gateway/target/muyu-gateway.jar ./muyu/gateway/jar
|
||||
|
||||
echo "begin copy muyu-auth "
|
||||
cp ../muyu-auth/target/muyu-auth.jar ./muyu/auth/jar
|
||||
|
||||
echo "begin copy muyu-visual "
|
||||
cp ../muyu-visual/muyu-monitor/target/muyu-visual-monitor.jar ./muyu/visual/monitor/jar
|
||||
|
||||
echo "begin copy muyu-modules-system "
|
||||
cp ../muyu-modules/muyu-system/target/muyu-modules-system.jar ./muyu/modules/system/jar
|
||||
|
||||
echo "begin copy muyu-modules-file "
|
||||
cp ../muyu-modules/muyu-file/target/muyu-modules-file.jar ./muyu/modules/file/jar
|
||||
|
||||
echo "begin copy muyu-modules-job "
|
||||
cp ../muyu-modules/muyu-job/target/muyu-modules-job.jar ./muyu/modules/job/jar
|
||||
|
||||
echo "begin copy muyu-modules-gen "
|
||||
cp ../muyu-modules/muyu-gen/target/muyu-modules-gen.jar ./muyu/modules/gen/jar
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
#!/bin/sh
|
||||
|
||||
# 使用说明,用来提示输入参数
|
||||
usage() {
|
||||
echo "Usage: sh 执行脚本.sh [port|base|modules|stop|rm]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# 开启所需端口
|
||||
port(){
|
||||
firewall-cmd --add-port=80/tcp --permanent
|
||||
firewall-cmd --add-port=8080/tcp --permanent
|
||||
firewall-cmd --add-port=8848/tcp --permanent
|
||||
firewall-cmd --add-port=9848/tcp --permanent
|
||||
firewall-cmd --add-port=9849/tcp --permanent
|
||||
firewall-cmd --add-port=6379/tcp --permanent
|
||||
firewall-cmd --add-port=3306/tcp --permanent
|
||||
firewall-cmd --add-port=9100/tcp --permanent
|
||||
firewall-cmd --add-port=9200/tcp --permanent
|
||||
firewall-cmd --add-port=9201/tcp --permanent
|
||||
firewall-cmd --add-port=9202/tcp --permanent
|
||||
firewall-cmd --add-port=9203/tcp --permanent
|
||||
firewall-cmd --add-port=9300/tcp --permanent
|
||||
service firewalld restart
|
||||
}
|
||||
|
||||
# 启动基础环境(必须)
|
||||
base(){
|
||||
docker-compose up -d muyu-mysql muyu-redis muyu-nacos
|
||||
}
|
||||
|
||||
# 启动程序模块(必须)
|
||||
modules(){
|
||||
docker-compose up -d muyu-nginx muyu-gateway muyu-auth muyu-modules-system
|
||||
}
|
||||
|
||||
# 关闭所有环境/模块
|
||||
stop(){
|
||||
docker-compose stop
|
||||
}
|
||||
|
||||
# 删除所有环境/模块
|
||||
rm(){
|
||||
docker-compose rm
|
||||
}
|
||||
|
||||
# 根据输入参数,选择执行对应方法,不输入则执行使用说明
|
||||
case "$1" in
|
||||
"port")
|
||||
port
|
||||
;;
|
||||
"base")
|
||||
base
|
||||
;;
|
||||
"modules")
|
||||
modules
|
||||
;;
|
||||
"stop")
|
||||
stop
|
||||
;;
|
||||
"rm")
|
||||
rm
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
|
@ -0,0 +1,140 @@
|
|||
version : '3.8'
|
||||
services:
|
||||
muyu-nacos:
|
||||
container_name: muyu-nacos
|
||||
image: nacos/nacos-server
|
||||
build:
|
||||
context: ./nacos
|
||||
environment:
|
||||
- MODE=standalone
|
||||
volumes:
|
||||
- ./nacos/logs/:/home/nacos/logs
|
||||
- ./nacos/conf/application.properties:/home/nacos/conf/application.properties
|
||||
ports:
|
||||
- "8848:8848"
|
||||
- "9848:9848"
|
||||
- "9849:9849"
|
||||
depends_on:
|
||||
- muyu-mysql
|
||||
muyu-mysql:
|
||||
container_name: muyu-mysql
|
||||
image: mysql:5.7
|
||||
build:
|
||||
context: ./mysql
|
||||
ports:
|
||||
- "3306:3306"
|
||||
volumes:
|
||||
- ./mysql/conf:/etc/mysql/conf.d
|
||||
- ./mysql/logs:/logs
|
||||
- ./mysql/data:/var/lib/mysql
|
||||
command: [
|
||||
'mysqld',
|
||||
'--innodb-buffer-pool-size=80M',
|
||||
'--character-set-server=utf8mb4',
|
||||
'--collation-server=utf8mb4_unicode_ci',
|
||||
'--default-time-zone=+8:00',
|
||||
'--lower-case-table-names=1'
|
||||
]
|
||||
environment:
|
||||
MYSQL_DATABASE: 'ry-cloud'
|
||||
MYSQL_ROOT_PASSWORD: password
|
||||
muyu-redis:
|
||||
container_name: muyu-redis
|
||||
image: redis
|
||||
build:
|
||||
context: ./redis
|
||||
ports:
|
||||
- "6379:6379"
|
||||
volumes:
|
||||
- ./redis/conf/redis.conf:/home/muyu/redis/redis.conf
|
||||
- ./redis/data:/data
|
||||
command: redis-server /home/muyu/redis/redis.conf
|
||||
muyu-nginx:
|
||||
container_name: muyu-nginx
|
||||
image: nginx
|
||||
build:
|
||||
context: ./nginx
|
||||
ports:
|
||||
- "80:80"
|
||||
volumes:
|
||||
- ./nginx/html/dist:/home/muyu/projects/muyu-ui
|
||||
- ./nginx/conf/nginx.conf:/etc/nginx/nginx.conf
|
||||
- ./nginx/logs:/var/log/nginx
|
||||
- ./nginx/conf.d:/etc/nginx/conf.d
|
||||
depends_on:
|
||||
- muyu-gateway
|
||||
links:
|
||||
- muyu-gateway
|
||||
muyu-gateway:
|
||||
container_name: muyu-gateway
|
||||
build:
|
||||
context: ./muyu/gateway
|
||||
dockerfile: dockerfile
|
||||
ports:
|
||||
- "8080:8080"
|
||||
depends_on:
|
||||
- muyu-redis
|
||||
links:
|
||||
- muyu-redis
|
||||
muyu-auth:
|
||||
container_name: muyu-auth
|
||||
build:
|
||||
context: ./muyu/auth
|
||||
dockerfile: dockerfile
|
||||
ports:
|
||||
- "9200:9200"
|
||||
depends_on:
|
||||
- muyu-redis
|
||||
links:
|
||||
- muyu-redis
|
||||
muyu-modules-system:
|
||||
container_name: muyu-modules-system
|
||||
build:
|
||||
context: ./muyu/modules/system
|
||||
dockerfile: dockerfile
|
||||
ports:
|
||||
- "9201:9201"
|
||||
depends_on:
|
||||
- muyu-redis
|
||||
- muyu-mysql
|
||||
links:
|
||||
- muyu-redis
|
||||
- muyu-mysql
|
||||
muyu-modules-gen:
|
||||
container_name: muyu-modules-gen
|
||||
build:
|
||||
context: ./muyu/modules/gen
|
||||
dockerfile: dockerfile
|
||||
ports:
|
||||
- "9202:9202"
|
||||
depends_on:
|
||||
- muyu-mysql
|
||||
links:
|
||||
- muyu-mysql
|
||||
muyu-modules-job:
|
||||
container_name: muyu-modules-job
|
||||
build:
|
||||
context: ./muyu/modules/job
|
||||
dockerfile: dockerfile
|
||||
ports:
|
||||
- "9203:9203"
|
||||
depends_on:
|
||||
- muyu-mysql
|
||||
links:
|
||||
- muyu-mysql
|
||||
muyu-modules-file:
|
||||
container_name: muyu-modules-file
|
||||
build:
|
||||
context: ./muyu/modules/file
|
||||
dockerfile: dockerfile
|
||||
ports:
|
||||
- "9300:9300"
|
||||
volumes:
|
||||
- ./muyu/uploadPath:/home/muyu/uploadPath
|
||||
muyu-visual-monitor:
|
||||
container_name: muyu-visual-monitor
|
||||
build:
|
||||
context: ./muyu/visual/monitor
|
||||
dockerfile: dockerfile
|
||||
ports:
|
||||
- "9100:9100"
|
|
@ -0,0 +1,15 @@
|
|||
# 基础镜像
|
||||
FROM openjdk:8-jre
|
||||
# author
|
||||
MAINTAINER muyu
|
||||
|
||||
# 挂载目录
|
||||
VOLUME /home/muyu
|
||||
# 创建目录
|
||||
RUN mkdir -p /home/muyu
|
||||
# 指定路径
|
||||
WORKDIR /home/muyu
|
||||
# 复制jar文件到路径
|
||||
COPY ./jar/muyu-auth.jar /home/muyu/muyu-auth.jar
|
||||
# 启动认证服务
|
||||
ENTRYPOINT ["java","-jar","muyu-auth.jar"]
|
|
@ -0,0 +1 @@
|
|||
存放认证中心打包好的jar文件,用于docker启动应用。
|
|
@ -0,0 +1,15 @@
|
|||
# 基础镜像
|
||||
FROM openjdk:8-jre
|
||||
# author
|
||||
MAINTAINER muyu
|
||||
|
||||
# 挂载目录
|
||||
VOLUME /home/muyu
|
||||
# 创建目录
|
||||
RUN mkdir -p /home/muyu
|
||||
# 指定路径
|
||||
WORKDIR /home/muyu
|
||||
# 复制jar文件到路径
|
||||
COPY ./jar/muyu-gateway.jar /home/muyu/muyu-gateway.jar
|
||||
# 启动网关服务
|
||||
ENTRYPOINT ["java","-jar","muyu-gateway.jar"]
|
|
@ -0,0 +1 @@
|
|||
存放网关模块打包好的jar文件,用于docker启动应用。
|
|
@ -0,0 +1,15 @@
|
|||
# 基础镜像
|
||||
FROM openjdk:8-jre
|
||||
# author
|
||||
MAINTAINER muyu
|
||||
|
||||
# 挂载目录
|
||||
VOLUME /home/muyu
|
||||
# 创建目录
|
||||
RUN mkdir -p /home/muyu
|
||||
# 指定路径
|
||||
WORKDIR /home/muyu
|
||||
# 复制jar文件到路径
|
||||
COPY ./jar/muyu-modules-file.jar /home/muyu/muyu-modules-file.jar
|
||||
# 启动文件服务
|
||||
ENTRYPOINT ["java","-jar","muyu-modules-file.jar"]
|
|
@ -0,0 +1 @@
|
|||
存放文件服务打包好的jar文件,用于docker启动应用。
|
|
@ -0,0 +1,15 @@
|
|||
# 基础镜像
|
||||
FROM openjdk:8-jre
|
||||
# author
|
||||
MAINTAINER muyu
|
||||
|
||||
# 挂载目录
|
||||
VOLUME /home/muyu
|
||||
# 创建目录
|
||||
RUN mkdir -p /home/muyu
|
||||
# 指定路径
|
||||
WORKDIR /home/muyu
|
||||
# 复制jar文件到路径
|
||||
COPY ./jar/muyu-modules-gen.jar /home/muyu/muyu-modules-gen.jar
|
||||
# 启动代码生成服务
|
||||
ENTRYPOINT ["java","-jar","muyu-modules-gen.jar"]
|
|
@ -0,0 +1 @@
|
|||
存放代码生成打包好的jar文件,用于docker启动应用。
|
|
@ -0,0 +1,15 @@
|
|||
# 基础镜像
|
||||
FROM openjdk:8-jre
|
||||
# author
|
||||
MAINTAINER muyu
|
||||
|
||||
# 挂载目录
|
||||
VOLUME /home/muyu
|
||||
# 创建目录
|
||||
RUN mkdir -p /home/muyu
|
||||
# 指定路径
|
||||
WORKDIR /home/muyu
|
||||
# 复制jar文件到路径
|
||||
COPY ./jar/muyu-modules-job.jar /home/muyu/muyu-modules-job.jar
|
||||
# 启动定时任务服务
|
||||
ENTRYPOINT ["java","-jar","muyu-modules-job.jar"]
|
|
@ -0,0 +1 @@
|
|||
存放定时任务打包好的jar文件,用于docker启动应用。
|
|
@ -0,0 +1,15 @@
|
|||
# 基础镜像
|
||||
FROM openjdk:8-jre
|
||||
# author
|
||||
MAINTAINER muyu
|
||||
|
||||
# 挂载目录
|
||||
VOLUME /home/muyu
|
||||
# 创建目录
|
||||
RUN mkdir -p /home/muyu
|
||||
# 指定路径
|
||||
WORKDIR /home/muyu
|
||||
# 复制jar文件到路径
|
||||
COPY ./jar/muyu-modules-system.jar /home/muyu/muyu-modules-system.jar
|
||||
# 启动系统服务
|
||||
ENTRYPOINT ["java","-jar","muyu-modules-system.jar"]
|
|
@ -0,0 +1 @@
|
|||
存放系统模块打包好的jar文件,用于docker启动应用。
|
|
@ -0,0 +1,15 @@
|
|||
# 基础镜像
|
||||
FROM openjdk:8-jre
|
||||
# author
|
||||
MAINTAINER muyu
|
||||
|
||||
# 挂载目录
|
||||
VOLUME /home/muyu
|
||||
# 创建目录
|
||||
RUN mkdir -p /home/muyu
|
||||
# 指定路径
|
||||
WORKDIR /home/muyu
|
||||
# 复制jar文件到路径
|
||||
COPY ./jar/muyu-visual-monitor.jar /home/muyu/muyu-visual-monitor.jar
|
||||
# 启动系统服务
|
||||
ENTRYPOINT ["java","-jar","muyu-visual-monitor.jar"]
|
|
@ -0,0 +1 @@
|
|||
存放监控中心打包好的jar文件,用于docker启动应用。
|
|
@ -0,0 +1,7 @@
|
|||
# 基础镜像
|
||||
FROM mysql:5.7
|
||||
# author
|
||||
MAINTAINER muyu
|
||||
|
||||
# 执行sql脚本
|
||||
ADD ./db/*.sql /docker-entrypoint-initdb.d/
|
|
@ -0,0 +1,32 @@
|
|||
spring.datasource.platform=mysql
|
||||
db.num=1
|
||||
db.url.0=jdbc:mysql://muyu-mysql:3306/ry-config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
|
||||
db.user=root
|
||||
db.password=password
|
||||
|
||||
nacos.naming.empty-service.auto-clean=true
|
||||
nacos.naming.empty-service.clean.initial-delay-ms=50000
|
||||
nacos.naming.empty-service.clean.period-time-ms=30000
|
||||
|
||||
management.endpoints.web.exposure.include=*
|
||||
|
||||
management.metrics.export.elastic.enabled=false
|
||||
management.metrics.export.influx.enabled=false
|
||||
|
||||
server.tomcat.accesslog.enabled=true
|
||||
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i
|
||||
|
||||
server.tomcat.basedir=/home/muyu/nacos/tomcat/logs
|
||||
|
||||
nacos.security.ignore.urls=/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-ui/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**
|
||||
|
||||
nacos.core.auth.system.type=nacos
|
||||
nacos.core.auth.enabled=false
|
||||
nacos.core.auth.default.token.expire.seconds=18000
|
||||
nacos.core.auth.default.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789
|
||||
nacos.core.auth.caching.enabled=true
|
||||
nacos.core.auth.enable.userAgentAuthWhite=false
|
||||
nacos.core.auth.server.identity.key=serverIdentity
|
||||
nacos.core.auth.server.identity.value=security
|
||||
|
||||
nacos.istio.mcp.server.enabled=false
|
|
@ -0,0 +1,7 @@
|
|||
# 基础镜像
|
||||
FROM nacos/nacos-server
|
||||
# author
|
||||
MAINTAINER muyu
|
||||
|
||||
# 复制conf文件到路径
|
||||
COPY ./conf/application.properties /home/nacos/conf/application.properties
|
|
@ -0,0 +1,41 @@
|
|||
worker_processes 1;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include mime.types;
|
||||
default_type application/octet-stream;
|
||||
sendfile on;
|
||||
keepalive_timeout 65;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
location / {
|
||||
root /home/muyu/projects/muyu-ui;
|
||||
try_files $uri $uri/ /index.html;
|
||||
index index.html index.htm;
|
||||
}
|
||||
|
||||
location /prod-api/{
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header REMOTE-HOST $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_pass http://muyu-gateway:8080/;
|
||||
}
|
||||
|
||||
# 避免actuator暴露
|
||||
if ($request_uri ~ "/actuator") {
|
||||
return 403;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root html;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
# 基础镜像
|
||||
FROM nginx
|
||||
# author
|
||||
MAINTAINER muyu
|
||||
|
||||
# 挂载目录
|
||||
VOLUME /home/muyu/projects/muyu-ui
|
||||
# 创建目录
|
||||
RUN mkdir -p /home/muyu/projects/muyu-ui
|
||||
# 指定路径
|
||||
WORKDIR /home/muyu/projects/muyu-ui
|
||||
# 复制conf文件到路径
|
||||
COPY ./conf/nginx.conf /etc/nginx/nginx.conf
|
||||
# 复制html文件到路径
|
||||
COPY ./html/dist /home/muyu/projects/muyu-ui
|
|
@ -0,0 +1,13 @@
|
|||
# 基础镜像
|
||||
FROM redis
|
||||
# author
|
||||
MAINTAINER muyu
|
||||
|
||||
# 挂载目录
|
||||
VOLUME /home/muyu/redis
|
||||
# 创建目录
|
||||
RUN mkdir -p /home/muyu/redis
|
||||
# 指定路径
|
||||
WORKDIR /home/muyu/redis
|
||||
# 复制conf文件到路径
|
||||
COPY ./conf/redis.conf /home/muyu/redis/redis.conf
|
|
@ -0,0 +1,198 @@
|
|||
<?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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>muyu-aliyun-openapi</artifactId>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
<name>sample</name>
|
||||
<description>Alibaba Cloud SDK Code Sample3 for Java
|
||||
</description>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>ecs20140526</artifactId>
|
||||
<version>3.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>tea-openapi</artifactId>
|
||||
<version>0.3.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>tea-util</artifactId>
|
||||
<version>0.2.21</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>darabonba-number</artifactId>
|
||||
<version>0.0.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>tea-console</artifactId>
|
||||
<version>0.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>darabonba-env</artifactId>
|
||||
<version>0.1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>tea</artifactId>
|
||||
<version>1.1.14</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-core</artifactId>
|
||||
</dependency>
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos Config -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Swagger UI -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.fox.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common DataSource -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-datasource</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common DataScope -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-datascope</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common Log -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common Swagger -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-swagger</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.6.1</version>
|
||||
<configuration>
|
||||
<source>7</source>
|
||||
<target>7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>1.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
<!-- <goals>-->
|
||||
<!-- <goal>sign</goal>-->
|
||||
<!-- </goals>-->
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.6.3</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<serverId>sonatype-nexus-staging</serverId>
|
||||
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
|
||||
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
<doclint>none</doclint>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>2.4.1</version>
|
||||
<configuration>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
<archive>
|
||||
<manifest>
|
||||
<addClasspath>true</addClasspath>
|
||||
<mainClass>com.aliyun.sample.Sample33</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<phase>package</phase>
|
||||
<!-- <goals>-->
|
||||
<!-- <goal>single</goal>-->
|
||||
<!-- </goals>-->
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,22 @@
|
|||
package com.muyu;
|
||||
|
||||
import com.muyu.common.security.annotation.*;
|
||||
import com.muyu.common.swagger.annotation.*;
|
||||
import org.springframework.boot.*;
|
||||
import org.springframework.boot.autoconfigure.*;
|
||||
|
||||
/**
|
||||
* @Author LiYonJie
|
||||
* @Date 2024/4/13
|
||||
* @Description TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
@EnableRyFeignClients
|
||||
@SpringBootApplication
|
||||
public class OpenApiApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(OpenApiApplication.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
// This file is auto-generated, don't edit it. Thanks.
|
||||
package com.muyu.create;
|
||||
|
||||
import com.aliyun.ecs20140526.models.*;
|
||||
import com.aliyun.tea.*;
|
||||
import com.aliyun.teaopenapi.models.*;
|
||||
import com.aliyun.teautil.*;
|
||||
|
||||
/**
|
||||
* 批量创建ECS实例
|
||||
* @Author LiYonJie
|
||||
* @Date 2024/4/12
|
||||
*/
|
||||
public class CreateEsc {
|
||||
|
||||
/**
|
||||
* Initialization 初始化公共请求参数
|
||||
*/
|
||||
public static com.aliyun.ecs20140526.Client initialization(String regionId) throws Exception {
|
||||
Config config = new Config();
|
||||
// 您的AccessKey ID
|
||||
config.accessKeyId = "LTAI5t6ge8HT4TBSmKy1tyAH";
|
||||
// 您的AccessKey Secret
|
||||
config.accessKeySecret = "HKP3tiYwitkaPDfulUPmx0TtATQG15";
|
||||
// 您的可用区ID
|
||||
config.regionId = regionId;
|
||||
return new com.aliyun.ecs20140526.Client(config);
|
||||
}
|
||||
|
||||
public static void main(String[] args_) throws Exception {
|
||||
java.util.List<String> args = java.util.Arrays.asList(args_);
|
||||
// 地域Id
|
||||
String regionId = "cn-zhangjiakou";
|
||||
// 镜像 ID,启动实例时选择的镜像资源。
|
||||
String imageId ="m-8vb2cpmwwggxp598kjue";
|
||||
// 实例规格
|
||||
String instanceType = "ecs.t6-c1m1.large";
|
||||
// 新创建实例所属于的安全组 ID。
|
||||
String securityGroupId = "sg-8vbamw309ei7fz4vucfb";
|
||||
// 虚拟交换机 ID。
|
||||
String vSwitchId = "vsw-8vb58xdkinpoka8e5tchy";
|
||||
// 公网出带宽最大值,单位为 Mbit/s。取值范围:0~100。 默认值:0。
|
||||
Integer internetMaxBandwidthOut = com.aliyun.darabonbanumber.Client.parseInt("5");
|
||||
// 网络计费类型。取值范围:
|
||||
// PayByBandwidth: 按固定带宽计费。
|
||||
// PayByTraffic: 按使用流量计费。
|
||||
// 默认值:PayByTraffic。
|
||||
String internetChargeType = "PayByTraffic";
|
||||
// 系统盘大小
|
||||
String size = "20";
|
||||
// 系统盘的云盘种类
|
||||
String category = "cloud_ssd";
|
||||
// ECS实例的计费方式
|
||||
// PrePaid:包年包月
|
||||
// PostPaid:按量付费
|
||||
String instanceChargeType = "PostPaid";
|
||||
com.aliyun.ecs20140526.Client client = CreateEsc.initialization(regionId);
|
||||
// 批量创建实例
|
||||
CreateEsc.runInstances(client, regionId, imageId, instanceType, securityGroupId, vSwitchId, internetMaxBandwidthOut, internetChargeType, size, category, instanceChargeType);
|
||||
com.aliyun.teaconsole.Client.log(client.toString());
|
||||
com.aliyun.teaconsole.Client.log(regionId);
|
||||
com.aliyun.teaconsole.Client.log(imageId);
|
||||
com.aliyun.teaconsole.Client.log(instanceType);
|
||||
com.aliyun.teaconsole.Client.log(securityGroupId);
|
||||
com.aliyun.teaconsole.Client.log(vSwitchId);
|
||||
com.aliyun.teaconsole.Client.log(""+internetMaxBandwidthOut);
|
||||
com.aliyun.teaconsole.Client.log(size);
|
||||
com.aliyun.teaconsole.Client.log(category);
|
||||
com.aliyun.teaconsole.Client.log(instanceChargeType);
|
||||
}
|
||||
|
||||
/**
|
||||
* RunInstances 通过备选实例规格创建ECS实例最佳实践
|
||||
* 该场景中,在调用RunInstances创建ECS实例时判断是否发生库存不足等错误,如果发生错误,将调用DescribeRecommendInstanceType查询备选实例,然后通过备选实例规格重新创建ECS实例。
|
||||
*/
|
||||
public static void runInstances(com.aliyun.ecs20140526.Client client, String regionId, String imageId, String instanceType, String securityGroupId, String vSwitchId, Integer internetMaxBandwidthOut, String internetChargeType, String size, String category, String instanceChargeType) throws Exception {
|
||||
RunInstancesRequest request1 = new RunInstancesRequest()
|
||||
.setRegionId(regionId)
|
||||
.setImageId(imageId)
|
||||
.setInstanceType(instanceType)
|
||||
.setSecurityGroupId(securityGroupId)
|
||||
.setVSwitchId(vSwitchId)
|
||||
.setInstanceName("ecsFirst")
|
||||
.setDescription("ecsFirst")
|
||||
.setInternetMaxBandwidthOut(internetMaxBandwidthOut)
|
||||
.setInternetChargeType(internetChargeType)
|
||||
.setInstanceChargeType(instanceChargeType)
|
||||
// 批量创建五台ECS实例,如果不设置该参数,默认创建一台ECS实例。
|
||||
// amount = 5,
|
||||
// 如果缺少库存可以接受的最低创建数量。
|
||||
// minAmount = 2,
|
||||
// 打开预检参数功能,不会实际创建ECS实例,只检查参数正确性、用户权限或者ECS库存等问题。
|
||||
// 实际情况下,设置了DryRun参数后,Amount必须为1,MinAmount必须为空,您可以根据实际需求修改代码。
|
||||
.setDryRun(false)
|
||||
.setSystemDisk(new RunInstancesRequest.RunInstancesRequestSystemDisk()
|
||||
.setSize(size)
|
||||
.setCategory(category));
|
||||
try {
|
||||
com.aliyun.teaconsole.Client.log("--------------------批量创建实例开始--------------------");
|
||||
RunInstancesResponse responces = client.runInstances(request1);
|
||||
com.aliyun.teaconsole.Client.log("--------------------创建实例成功,实例ID:" + Common.toJSONString(responces.body.instanceIdSets.instanceIdSet) + "--------------------");
|
||||
} catch (TeaException error) {
|
||||
error.printStackTrace();
|
||||
|
||||
} catch (Exception _error) {
|
||||
_error.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
//// This file is auto-generated, don't edit it. Thanks.
|
||||
//package com.muyu.remove;
|
||||
//
|
||||
//import com.aliyun.tea.*;
|
||||
//import com.aliyun.teaconsole.*;
|
||||
//import com.aliyun.darabonba.env.*;
|
||||
//import com.aliyun.teaopenapi.*;
|
||||
//import com.aliyun.teaopenapi.models.*;
|
||||
//import com.aliyun.ecs20140526.*;
|
||||
//import com.aliyun.ecs20140526.models.*;
|
||||
//import com.aliyun.teautil.*;
|
||||
//import com.aliyun.darabonbastring.*;
|
||||
//
|
||||
//public class Sample {
|
||||
//
|
||||
// public static com.aliyun.ecs20140526.Client createEcsClient(String regionId) throws Exception {
|
||||
// Config config = new Config()
|
||||
// .setAccessKeyId(com.aliyun.darabonba.env.EnvClient.getEnv("ACCESS_KEY_ID"))
|
||||
// .setAccessKeySecret(com.aliyun.darabonba.env.EnvClient.getEnv("ACCESS_KEY_SECRET"))
|
||||
// .setRegionId(regionId);
|
||||
// return new com.aliyun.ecs20140526.Client(config);
|
||||
// }
|
||||
//
|
||||
// public static DescribeInstancesResponse DescribeInstances(com.aliyun.ecs20140526.Client client, String regionId, String instanceIds, String instanceName) throws Exception {
|
||||
// DescribeInstancesRequest req = new DescribeInstancesRequest()
|
||||
// .setRegionId(regionId)
|
||||
// .setInstanceName(instanceName);
|
||||
// if (!com.aliyun.teautil.Common.empty(instanceIds)) {
|
||||
// req.instanceIds = com.aliyun.teautil.Common.toJSONString(com.aliyun.darabonbastring.Client.split(instanceIds, ",", 50));
|
||||
// }
|
||||
//
|
||||
// DescribeInstancesResponse resp = client.describeInstances(req);
|
||||
// com.aliyun.teaconsole.Client.log("--------------------3查询需要删除的实例--------------------");
|
||||
// return resp;
|
||||
// }
|
||||
//
|
||||
// public static void ModifyInstanceAttribute(com.aliyun.ecs20140526.Client client, String instatnceId) throws Exception {
|
||||
// ModifyInstanceAttributeRequest req = new ModifyInstanceAttributeRequest()
|
||||
// .setInstanceId(instatnceId)
|
||||
// .setDeletionProtection(false);
|
||||
// client.modifyInstanceAttribute(req);
|
||||
// com.aliyun.teaconsole.Client.log("--------------------" + instatnceId + "释放保护取消成功--------------------");
|
||||
// }
|
||||
//
|
||||
// public static void DeleteInstances(com.aliyun.ecs20140526.Client client, String regionId, String instanceIds, String force) throws Exception {
|
||||
// DeleteInstancesRequest req = new DeleteInstancesRequest()
|
||||
// .setRegionId(regionId)
|
||||
// .setInstanceId(com.aliyun.darabonbastring.Client.split(instanceIds, ",", 50))
|
||||
// .setForce(com.aliyun.teautil.Common.equalString(force, "true"));
|
||||
// DeleteInstancesResponse resp = client.deleteInstances(req);
|
||||
// com.aliyun.teaconsole.Client.log("--------------------实例释放成功--------------------");
|
||||
// com.aliyun.teaconsole.Client.log(com.aliyun.teautil.Common.toJSONString(com.aliyun.teautil.Common.toMap(resp)));
|
||||
// }
|
||||
//
|
||||
// public static void main(String[] args_) throws Exception {
|
||||
// java.util.List<String> args = java.util.Arrays.asList(args_);
|
||||
// // 区域ID
|
||||
// String regionId = args.get(0);
|
||||
// // 多个实例ID,用英文逗号分隔
|
||||
// String instanceIds = args.get(1);
|
||||
// // 实例名称,支持使用通配符*进行模糊搜索
|
||||
// String instanceName = args.get(2);
|
||||
// // 强制删除有删除保护的机器
|
||||
// String deleteProtected = args.get(3);
|
||||
// // 强制删除运行中的机器
|
||||
// String force = args.get(4);
|
||||
// com.aliyun.ecs20140526.Client client = Sample.createEcsClient(regionId);
|
||||
// if (com.aliyun.teautil.Common.equalString(deleteProtected, "true")) {
|
||||
// DescribeInstancesResponse describeInstancesResp = Sample.DescribeInstances(client, regionId, instanceIds, instanceName);
|
||||
// instanceIds = "";
|
||||
// for (DescribeInstancesResponseBody.DescribeInstancesResponseBodyInstancesInstance instance : describeInstancesResp.body.instances.instance) {
|
||||
// instanceIds = "" + instance.instanceId + "," + instanceIds + "";
|
||||
// if (instance.deletionProtection) {
|
||||
// Sample.ModifyInstanceAttribute(client, instance.instanceId);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// instanceIds = com.aliyun.darabonbastring.Client.subString(instanceIds, 0, -1);
|
||||
// }
|
||||
//
|
||||
// if (com.aliyun.teautil.Common.empty(instanceIds)) {
|
||||
// com.aliyun.teaconsole.Client.log("--------------------无有效实例可删除--------------------");
|
||||
// return ;
|
||||
// }
|
||||
//
|
||||
// Sample.DeleteInstances(client, regionId, instanceIds, force);
|
||||
// }
|
||||
//}
|
|
@ -0,0 +1,152 @@
|
|||
<?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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>muyu-analyze</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>20</maven.compiler.source>
|
||||
<maven.compiler.target>20</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-core</artifactId>
|
||||
</dependency>
|
||||
<!-- 这个依赖是监听用的-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.kafka</groupId>
|
||||
<artifactId>spring-kafka</artifactId>
|
||||
<version>2.8.1</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.kafka</groupId>-->
|
||||
<!-- <artifactId>kafka-clients</artifactId>-->
|
||||
<!-- <version>2.8.0</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
<!-- mqtt -->
|
||||
<dependency>
|
||||
<groupId>org.eclipse.paho</groupId>
|
||||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||
<version>1.2.5</version>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos Config -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Swagger UI -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.fox.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common DataSource -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-datasource</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common DataScope -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-datascope</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common Log -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common Swagger -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-swagger</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-file-remote</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-business-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-business-server</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-event</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
<!--RabbitMQ-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>10</source>
|
||||
<target>10</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,36 @@
|
|||
package com.muyu.analyze;
|
||||
|
||||
import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||
import com.muyu.common.security.annotation.EnableRyFeignClients;
|
||||
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
/**
|
||||
* 系统模块
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
@EnableRyFeignClients
|
||||
@SpringBootApplication
|
||||
@EnableScheduling
|
||||
public class MuYuAnalyzeApplication
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
SpringApplication.run(MuYuAnalyzeApplication.class, args);
|
||||
System.out.println("(♥◠‿◠)ノ゙ 系统模块启动成功 ლ(´ڡ`ლ)゙ \n" +
|
||||
" .-------. ____ __ \n" +
|
||||
" | _ _ \\ \\ \\ / / \n" +
|
||||
" | ( ' ) | \\ _. / ' \n" +
|
||||
" |(_ o _) / _( )_ .' \n" +
|
||||
" | (_,_).' __ ___(_ o _)' \n" +
|
||||
" | |\\ \\ | || |(_,_)' \n" +
|
||||
" | | \\ `' /| `-' / \n" +
|
||||
" | | \\ / \\ / \n" +
|
||||
" ''-' `'-' `-..-' ");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package com.muyu.analyze.config;
|
||||
|
||||
import org.apache.kafka.clients.consumer.ConsumerConfig;
|
||||
import org.apache.kafka.clients.producer.ProducerConfig;
|
||||
import org.apache.kafka.common.serialization.StringDeserializer;
|
||||
import org.apache.kafka.common.serialization.StringSerializer;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
@Configuration
|
||||
public class KafkaConfig {
|
||||
|
||||
// Kafka Bootstrap Servers
|
||||
public static final String BOOTSTRAP_SERVERS = "10.10.26.4:9092";
|
||||
|
||||
// 默认主题
|
||||
public static final String DEFAULT_TOPIC = "test";
|
||||
|
||||
public static final String DEFAULT_KEY = "10001";
|
||||
|
||||
|
||||
public static Properties properties1(){
|
||||
// 1;构建 Properties 对象 存放 kafka 生产者配置信息
|
||||
Properties properties1 = new Properties();
|
||||
// 设置 kafka 连接地址(从配置文件/环境变量获取)
|
||||
properties1.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, KafkaConfig.BOOTSTRAP_SERVERS);
|
||||
// 设置 键值 序列化
|
||||
properties1.setProperty(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer .class.getName());
|
||||
properties1.setProperty(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
|
||||
|
||||
return properties1;
|
||||
}
|
||||
|
||||
|
||||
public static Properties properties2(){
|
||||
Properties properties2 = new Properties();
|
||||
properties2.setProperty(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "10.10.26.4:9092");
|
||||
properties2.setProperty(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
|
||||
properties2.setProperty(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
|
||||
properties2.setProperty(ConsumerConfig.GROUP_ID_CONFIG, "group");
|
||||
|
||||
return properties2;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.muyu.analyze.config;
|
||||
|
||||
|
||||
import com.muyu.common.core.constant.*;
|
||||
import org.springframework.amqp.core.*;
|
||||
import org.springframework.context.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
* 声明队列绑定交换机
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@Configuration
|
||||
public class TutConfig {
|
||||
|
||||
@Bean
|
||||
public Queue fault() {
|
||||
return new Queue(MQQueueConstants.ALARM_QUEUE,true);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Queue alarm() {
|
||||
return new Queue(MQQueueConstants.FAULT_QUEUE, true);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
package com.muyu.analyze.consumer;
|
||||
|
||||
import com.muyu.analyze.mapper.VehicleMapper;
|
||||
import com.muyu.analyze.service.VehicleService;
|
||||
import com.muyu.analyze.utils.AnalyzeUtils;
|
||||
import com.muyu.common.core.utils.SpringUtils;
|
||||
import com.muyu.common.event.cache.VehicleEventCache;
|
||||
import com.muyu.business.domain.Fence;
|
||||
import com.muyu.system.common.domain.VehicleData;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.kafka.annotation.KafkaListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 类说明
|
||||
*
|
||||
* @author zhuwenqiang
|
||||
* @date 2023/3/1
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
//@RabbitListener(queues = "queue")
|
||||
public class Consumer {
|
||||
|
||||
|
||||
@Autowired
|
||||
private VehicleMapper vehicleMapper;
|
||||
|
||||
@Autowired
|
||||
private VehicleEventCache vehicleEventCache;
|
||||
|
||||
/**
|
||||
* kafka消费者--监听 kafka主题 test
|
||||
* @param msg
|
||||
*/
|
||||
// @KafkaListener(topics = "test", groupId = "group", properties = {"bootstrap.servers = 10.10.26.4:9092"})
|
||||
@KafkaListener(topics = "test2")
|
||||
public void getMessage(String msg) {
|
||||
VehicleData analyze = AnalyzeUtils.analyze(msg);
|
||||
log.info("。。。。。。。。。。。。非静止画面");
|
||||
|
||||
Set<String> eventList = vehicleEventCache.getEventList(analyze.getVin());
|
||||
|
||||
// List<Fence> fenceVin=vehicleMapper.selectFenceList();
|
||||
|
||||
for (String s : eventList) {
|
||||
VehicleService vehicleService = SpringUtils.getBean(s);
|
||||
vehicleService.eventResolution(analyze);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// @RabbitHandler
|
||||
// public void take(String msg, Channel channel, Message message) throws IOException {
|
||||
//// String messageId = message.getMessageProperties().getMessageId();
|
||||
//// long deliveryTag = message.getMessageProperties().getDeliveryTag();
|
||||
//
|
||||
// //解析
|
||||
// VehicleData analyze = AnalyzeUtils.analyze(msg);
|
||||
//
|
||||
// for (String s : list) {
|
||||
// VehicleService vehicleService = SpringUtils.getBean(s);
|
||||
// vehicleService.eventResolution(analyze);
|
||||
// }
|
||||
//
|
||||
// if (!redisTemplate.hasKey("mi2"+messageId)){
|
||||
// redisTemplate.opsForValue().set("mi2"+messageId,messageId);
|
||||
// }
|
||||
//
|
||||
// if (!redisTemplate.hasKey("cf2"+messageId)){
|
||||
// System.out.println(user);
|
||||
// System.out.println("通道2,,,,,,,,,,,,消费成功");
|
||||
// channel.basicAck(deliveryTag,false);
|
||||
// }else{
|
||||
// System.out.println("通道2,,,,,,,,,,,,,重复消费");
|
||||
// channel.basicAck(deliveryTag,false);
|
||||
// }
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
//package com.muyu.analyze.consumer;
|
||||
//
|
||||
///**
|
||||
// * @ProjectName: cloud-vehicles
|
||||
// * @PackageName: com.muyu.analyze.consumer
|
||||
// * @Description TODO
|
||||
// * @Author HuangDaJu
|
||||
// * @Date 2024/4/8 21:43
|
||||
// * @Version 1.0
|
||||
// */
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//import com.muyu.common.redis.service.RedisService;
|
||||
//import com.rabbitmq.client.Channel;
|
||||
//import lombok.extern.log4j.Log4j2;
|
||||
//import org.springframework.amqp.core.Message;
|
||||
//import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import java.io.IOException;
|
||||
//
|
||||
//
|
||||
//@Component
|
||||
//@RabbitListener(queues = "queue")
|
||||
//@Log4j2
|
||||
//public class RabbitMqConsumer {
|
||||
//
|
||||
//
|
||||
// @Autowired
|
||||
// private RedisService redisService;
|
||||
//
|
||||
// @RabbitHandler
|
||||
// public void take(String msg, Channel channel, Message message) throws IOException {
|
||||
//
|
||||
//
|
||||
// long deliveryTag = message.getMessageProperties().getDeliveryTag();
|
||||
// System.out.println("MQ消费:"+msg);
|
||||
// channel.basicAck(deliveryTag,false);
|
||||
//
|
||||
//
|
||||
// }
|
||||
//
|
||||
//}
|
||||
//
|
|
@ -0,0 +1,55 @@
|
|||
package com.muyu.analyze.controller;
|
||||
|
||||
|
||||
import com.muyu.analyze.service.impl.RealTimeDataEventImpl;
|
||||
import com.muyu.common.event.cache.VehicleEventCache;
|
||||
import com.muyu.common.event.constants.VehicleEventConstants;
|
||||
import com.muyu.system.common.domain.VehicleData;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @ProjectName: cloud-vehicles
|
||||
* @PackageName: com.muyu.analyze.controller
|
||||
* @Description TODO
|
||||
* @Author XiaoFan
|
||||
* @Date 2024/4/5 20:39
|
||||
* @Version 1.0
|
||||
*/
|
||||
@RestController
|
||||
public class RealTimeDataController {
|
||||
@Autowired
|
||||
private VehicleEventCache vehicleEventCache;
|
||||
@Autowired
|
||||
private RealTimeDataEventImpl realTimeDataEvent;
|
||||
// 定义一个接口,用于获取实时数据
|
||||
|
||||
// @GetMapping("/realTimeData")
|
||||
// public ResponseEntity<VehicleData> getRealTimeData() {
|
||||
// // 假设这里调用实时数据处理服务的某个方法来获取实时数据
|
||||
// VehicleData realTimeData = realTimeDataEvent.getRealTimeData();
|
||||
// System.out.println("数据为"+realTimeData);
|
||||
// // 实现这个方法需要根据你的具体业务逻辑
|
||||
// // 返回实时数据
|
||||
// return ResponseEntity.ok().body(realTimeData);
|
||||
// }
|
||||
|
||||
@PostMapping("/realTimeDataTwo/{vin}")
|
||||
public ResponseEntity<VehicleData> getRealTimeDataByVin(@PathVariable String vin) {
|
||||
|
||||
vehicleEventCache.addEvent(vin, VehicleEventConstants.SHI_SHI);
|
||||
|
||||
// 假设这里调用实时数据处理服务的某个方法来根据 VIN 获取实时数据
|
||||
VehicleData realTimeData = realTimeDataEvent.getRealTimeDataByVin(vin);
|
||||
System.out.println("VIN为" + vin + "的实时数据为:" + realTimeData);
|
||||
// 实现这个方法需要根据你的具体业务逻辑
|
||||
// 返回实时数据
|
||||
return ResponseEntity.ok().body(realTimeData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.muyu.analyze.mapper;
|
||||
|
||||
import com.muyu.business.domain.Fence;
|
||||
import com.muyu.system.common.domain.Car;
|
||||
import com.muyu.system.common.domain.VehicleData;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ProjectName: cloud-vehicles
|
||||
* @PackageName: com.muyu.analyze.mapper
|
||||
* @Description TODO
|
||||
* @Author HuangDaJu
|
||||
* @Date 2024/4/4 09:48
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface VehicleMapper{
|
||||
|
||||
Boolean addVehicleStoredEvent(ArrayList<VehicleData> list);
|
||||
|
||||
|
||||
List<Fence> selectFenceList();
|
||||
|
||||
|
||||
Car selectCarList(String vin);
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.muyu.analyze.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.system.common.domain.VehicleData;
|
||||
|
||||
|
||||
/**
|
||||
* @ProjectName: cloud-vehicles
|
||||
* @PackageName: com.muyu.analyze.service
|
||||
* @Description TODO
|
||||
* @Author HuangDaJu
|
||||
* @Date 2024/4/4 09:30
|
||||
* @Version 1.0
|
||||
*/
|
||||
public interface VehicleService {
|
||||
|
||||
void eventResolution(VehicleData analyze);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,250 @@
|
|||
package com.muyu.analyze.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
|
||||
import com.muyu.analyze.service.VehicleService;
|
||||
import com.muyu.analyze.utils.StateConstant;
|
||||
|
||||
|
||||
import com.muyu.business.domain.FaultLogs;
|
||||
import com.muyu.common.core.constant.*;
|
||||
import com.muyu.common.core.utils.uuid.*;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import com.muyu.system.common.domain.VehicleData;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
||||
import org.springframework.amqp.rabbit.core.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @ProjectName: cloud-vehicles
|
||||
* @PackageName: com.muyu.analyze.service.impl.historicalTrack
|
||||
* @Description 故障事件
|
||||
* @Author HuangDaJu
|
||||
* @Date 2024/4/4 09:36
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Service("breakdown")
|
||||
@Slf4j
|
||||
public class BreakdownImpl implements VehicleService{
|
||||
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
/**
|
||||
* 注入rabbitmq
|
||||
*/
|
||||
@Autowired
|
||||
private RabbitTemplate rabbittemplate;
|
||||
|
||||
/*
|
||||
* 故障事件处理器
|
||||
* @param vehicleData
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void eventResolution(VehicleData vehicleData) {
|
||||
|
||||
|
||||
|
||||
//判断故障
|
||||
if (StateConstant.VEHICLE_STATUS != vehicleData.getVehicleStatus()
|
||||
|| StateConstant.CHARGING_STATUS != vehicleData.getChgStatus()
|
||||
|| StateConstant.OPERATING_STATUS != vehicleData.getOperatingStatus()
|
||||
|| StateConstant.SOC_STATUS != vehicleData.getSocStatus()
|
||||
|| StateConstant.CHARGING_ENERGY_STORAGE_STATUS != vehicleData.getChargingEnergyStorageStatus()
|
||||
|| StateConstant.DRIVE_MOTOR_STATUS != vehicleData.getDriveMotorStatus()
|
||||
|| StateConstant.POSITION_STATUS != vehicleData.getPositionStatus()
|
||||
|| StateConstant.EAS_STATUS != vehicleData.getEasStatus()
|
||||
|| StateConstant.PTC_STATUS != vehicleData.getPtcStatus()
|
||||
|| StateConstant.ABS_STATUS != vehicleData.getAbsStatus()
|
||||
|| StateConstant.MCU_STATUS != vehicleData.getMcuStatus()
|
||||
|| StateConstant.HEATING_STATUS != vehicleData.getHeatingStatus()
|
||||
|| StateConstant.BATTERY_STATUS != vehicleData.getBatteryStatus()
|
||||
|| StateConstant.BATTERY_INSULATION_STATUS != vehicleData.getBatteryInsulationStatus()
|
||||
|| StateConstant.DCDC_STATUS != vehicleData.getDcdcStatus()
|
||||
|| StateConstant.CHG_STATUS != vehicleData.getChgStatus()) {
|
||||
|
||||
log.info("车辆VIN:"+vehicleData.getVin()+"发生故障,故障事件解析");
|
||||
|
||||
FaultLogs faultLogsAddReq = new FaultLogs();
|
||||
|
||||
faultLogsAddReq.setCarVin(vehicleData.getVin());
|
||||
|
||||
// 车辆状态
|
||||
// private int vehicleStatus ;
|
||||
|
||||
if (vehicleData.getVehicleStatus() == 0) {
|
||||
faultLogsAddReq.setFaultCode("GTB001");
|
||||
faultLogsAddReq.setFaultLevel(3);
|
||||
}
|
||||
|
||||
// 充电状态
|
||||
// private int chargingStatus;
|
||||
|
||||
if (vehicleData.getChargingStatus() == 0) {
|
||||
faultLogsAddReq.setFaultCode("GTB002");
|
||||
faultLogsAddReq.setFaultLevel(3);
|
||||
}
|
||||
|
||||
// 运行状态
|
||||
// private int operatingStatus;
|
||||
|
||||
if (vehicleData.getOperatingStatus() == 0) {
|
||||
faultLogsAddReq.setFaultCode("GTB003");
|
||||
faultLogsAddReq.setFaultLevel(3);
|
||||
}
|
||||
|
||||
// SOC
|
||||
// private int socStatus;
|
||||
|
||||
if (vehicleData.getSocStatus() == 0) {
|
||||
faultLogsAddReq.setFaultCode("GTO001");
|
||||
faultLogsAddReq.setFaultLevel(2);
|
||||
}
|
||||
//
|
||||
//
|
||||
//GTO003
|
||||
|
||||
|
||||
// 可充电储能装置工作状态
|
||||
// private int chargingEnergyStorageStatus ;
|
||||
if (vehicleData.getChargingEnergyStorageStatus() == 0) {
|
||||
faultLogsAddReq.setFaultCode("GTO002");
|
||||
faultLogsAddReq.setFaultLevel(2);
|
||||
}
|
||||
|
||||
// 驱动电机状态
|
||||
// private int driveMotorStatus ;
|
||||
if (vehicleData.getDriveMotorStatus() == 0) {
|
||||
faultLogsAddReq.setFaultCode("GT0003");
|
||||
faultLogsAddReq.setFaultLevel(2);
|
||||
}
|
||||
|
||||
// 定位是否有效
|
||||
// private int positionStatus ;
|
||||
if (vehicleData.getPositionStatus() == 0) {
|
||||
faultLogsAddReq.setFaultCode("GT0004");
|
||||
faultLogsAddReq.setFaultLevel(2);
|
||||
}
|
||||
|
||||
// * EAS(汽车防盗系统)状态
|
||||
// private int easStatus ;
|
||||
|
||||
if (vehicleData.getEasStatus() == 0) {
|
||||
faultLogsAddReq.setFaultCode("GTO005");
|
||||
faultLogsAddReq.setFaultLevel(2);
|
||||
}
|
||||
|
||||
// * PTC(电动加热器)状态
|
||||
// private int ptcStatus ;
|
||||
|
||||
if (vehicleData.getPtcStatus() == 0) {
|
||||
|
||||
faultLogsAddReq.setFaultCode("GTO006");
|
||||
faultLogsAddReq.setFaultLevel(2);
|
||||
}
|
||||
|
||||
// * EPS(电动助力系统)状态
|
||||
// private int epsStatus ;
|
||||
|
||||
if (vehicleData.getEpsStatus() == 0) {
|
||||
|
||||
faultLogsAddReq.setFaultCode("GTO007");
|
||||
faultLogsAddReq.setFaultLevel(2);
|
||||
}
|
||||
|
||||
// * ABS(防抱死)状态
|
||||
// private int absStatus ;
|
||||
|
||||
if (vehicleData.getAbsStatus() == 0) {
|
||||
faultLogsAddReq.setFaultCode("GTX001");
|
||||
faultLogsAddReq.setFaultLevel(1);
|
||||
}
|
||||
|
||||
|
||||
// * MCU(电机/逆变器)状态
|
||||
// private int mcuStatus ;
|
||||
|
||||
if (vehicleData.getMcuStatus() == 0) {
|
||||
|
||||
faultLogsAddReq.setFaultCode("GTX002");
|
||||
faultLogsAddReq.setFaultLevel(1);
|
||||
}
|
||||
|
||||
// * 动力电池加热状态
|
||||
// private int heatingStatus ;
|
||||
|
||||
if (vehicleData.getHeatingStatus() == 0) {
|
||||
|
||||
faultLogsAddReq.setFaultCode("GTX003");
|
||||
faultLogsAddReq.setFaultLevel(1);
|
||||
}
|
||||
|
||||
// * 动力电池当前状态
|
||||
// private int batteryStatus ;
|
||||
|
||||
if (vehicleData.getBatteryStatus() == 0) {
|
||||
|
||||
faultLogsAddReq.setFaultCode("GTX004");
|
||||
faultLogsAddReq.setFaultLevel(1);
|
||||
}
|
||||
|
||||
// 动力电池保温状态
|
||||
// private int batteryInsulationStatus ;
|
||||
|
||||
if (vehicleData.getBatteryInsulationStatus() == 0) {
|
||||
|
||||
faultLogsAddReq.setFaultCode("GTX005");
|
||||
faultLogsAddReq.setFaultLevel(1);
|
||||
}
|
||||
|
||||
// * DCDC(电力交换系统)状态
|
||||
// private int dcdcStatus ;
|
||||
|
||||
if (vehicleData.getDcdcStatus() == 0) {
|
||||
|
||||
faultLogsAddReq.setFaultCode("GTX006");
|
||||
faultLogsAddReq.setFaultLevel(1);
|
||||
}
|
||||
|
||||
// CHG(充电机)状态
|
||||
// private int chgStatus ;
|
||||
|
||||
if (vehicleData.getChgStatus() == 0) {
|
||||
faultLogsAddReq.setFaultCode("GTX007");
|
||||
faultLogsAddReq.setFaultLevel(1);
|
||||
}
|
||||
|
||||
//进入这里的都是有故障的,存入hashset 放入redis
|
||||
String key = "breakdown";
|
||||
HashSet<FaultLogs> hashSet = new HashSet<>();
|
||||
hashSet.add(faultLogsAddReq);
|
||||
redisService.setCacheSet(key, hashSet);
|
||||
// 设置过期时间
|
||||
redisService.expire(key, 20, TimeUnit.MINUTES);
|
||||
|
||||
rabbittemplate.convertAndSend(MQQueueConstants.FAULT_QUEUE, faultLogsAddReq, message -> {
|
||||
message.getMessageProperties().setMessageId(IdUtils.fastSimpleUUID());
|
||||
return message;
|
||||
});
|
||||
|
||||
log.info("车辆VIN:"+vehicleData.getVin()+"故障事件已记录");
|
||||
log.info("故障事件结束");
|
||||
|
||||
|
||||
}else{
|
||||
log.info("车辆VIN:"+vehicleData.getVin()+"没有故障,状态正常");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,175 @@
|
|||
package com.muyu.analyze.service.impl;
|
||||
|
||||
|
||||
import com.muyu.analyze.mapper.VehicleMapper;
|
||||
import com.muyu.analyze.service.VehicleService;
|
||||
import com.muyu.business.domain.*;
|
||||
import com.muyu.common.core.constant.*;
|
||||
import com.muyu.common.core.utils.*;
|
||||
import com.muyu.common.core.utils.uuid.*;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import com.muyu.system.common.domain.Car;
|
||||
import com.muyu.system.common.domain.VehicleData;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.core.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static java.lang.Double.parseDouble;
|
||||
|
||||
/**
|
||||
* @ProjectName: cloud-vehicles
|
||||
* @PackageName: com.muyu.analyze.service.impl
|
||||
* @Description 电子围栏报警
|
||||
* @Author HuangDaJu
|
||||
* @Date 2024/4/4 16:02
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Service("fenceAlarm")
|
||||
@Slf4j
|
||||
public class FenceAlarmImpl implements VehicleService {
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Autowired
|
||||
private VehicleMapper vehicleMapper;
|
||||
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void eventResolution(VehicleData analyze) {
|
||||
Fence fence = new Fence();
|
||||
//车的vin
|
||||
String vin = analyze.getVin();
|
||||
|
||||
//经度
|
||||
double pointLng = parseDouble(analyze.getLongitude());
|
||||
|
||||
//纬度
|
||||
double pointLat = parseDouble(analyze.getLatitude());
|
||||
|
||||
//这里修改为1对多的 电子围栏 目前是一对一
|
||||
|
||||
Car car =vehicleMapper.selectCarList(vin);
|
||||
|
||||
String carFenceId = car.getCarFenceId();
|
||||
|
||||
String[] split1 = carFenceId.split(",");
|
||||
|
||||
|
||||
Map<String, Object> fence1 = redisService.getCacheMap("fence");
|
||||
|
||||
|
||||
|
||||
for (Map.Entry<String, Object> entry : fence1.entrySet()) {
|
||||
for (String s : split1) {
|
||||
String key = entry.getKey();
|
||||
if (s.equals(key)){
|
||||
String value = (String) entry.getValue();
|
||||
|
||||
String[] split = value.split(";");
|
||||
|
||||
boolean withinFence = isWithinFence(pointLat, pointLng, Arrays.asList(split));
|
||||
|
||||
if (withinFence){
|
||||
log.info("车辆vin:"+vin+"------在电子围栏"+key+"---正常行驶---");
|
||||
}else {
|
||||
log.info("车辆vin:"+vin+"------驶出电子围栏"+key+"---报警---");
|
||||
|
||||
String key1 = "fenceType1";
|
||||
|
||||
HashSet<Fence> hashSet = new HashSet<>();
|
||||
fence.setCarVin(vin);
|
||||
fence.setFenceType("驶出");
|
||||
fence.setFenceId(Integer.valueOf(key));
|
||||
|
||||
hashSet.add(fence);
|
||||
redisService.setCacheSet(key1,hashSet);
|
||||
redisService.expire(key1, 20, TimeUnit.MINUTES); // 设置过期时间
|
||||
|
||||
FaultLogs faultLogs = new FaultLogs();
|
||||
faultLogs.setCarVin(vin);
|
||||
faultLogs.setFaultCode("GTX007");
|
||||
faultLogs.setStartAlarmTime(DateUtils.getNowDate());
|
||||
faultLogs.setAlarmFlag("Y");
|
||||
faultLogs.setDisposeStatus("1");
|
||||
rabbitTemplate.convertAndSend(MQQueueConstants.ALARM_QUEUE, faultLogs ,message -> {
|
||||
message.getMessageProperties().setMessageId(IdUtils.fastSimpleUUID());
|
||||
return message;
|
||||
});
|
||||
}
|
||||
|
||||
// if (withinFence){
|
||||
// log.info("车辆vin:"+vin+"------驶入禁行区----报警");
|
||||
//
|
||||
// String key1 = "fenceType1";
|
||||
// HashSet<Fence> hashSet = new HashSet<>();
|
||||
// fence.setCarVin(vin);
|
||||
// fence.setFenceType("驶入");
|
||||
// fence.setFenceId(Integer.valueOf(key));
|
||||
// hashSet.add(fence);
|
||||
// redisService.setCacheSet(key1,hashSet);
|
||||
// redisService.expire(key1, 20, TimeUnit.MINUTES); // 设置过期时间
|
||||
//
|
||||
// }else{
|
||||
// log.info("车辆vin:"+vin+"------在安全区");
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
//false是除了围栏要报警
|
||||
|
||||
}
|
||||
|
||||
|
||||
public boolean isWithinFence(double pointLat, double pointLng, List<String> split) {
|
||||
// 确保split列表至少包含四个经纬度对
|
||||
if (split.size() < 4) {
|
||||
throw new IllegalArgumentException("不符合条件");
|
||||
}
|
||||
|
||||
// 解析矩形的四个顶点
|
||||
double[] latitudes = new double[4];
|
||||
double[] longitudes = new double[4];
|
||||
|
||||
//39.958897,116.179075;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
String[] coordinates = split.get(i).split(",");
|
||||
latitudes[i] = Double.parseDouble(coordinates[0]);
|
||||
longitudes[i] = Double.parseDouble(coordinates[1]);
|
||||
}
|
||||
|
||||
// 检查点是否在矩形内
|
||||
return isPointInRectangle(pointLat, pointLng, latitudes, longitudes);
|
||||
}
|
||||
|
||||
private boolean isPointInRectangle(double pointLat, double pointLng, double[] latitudes, double[] longitudes) {
|
||||
// 根据矩形顶点顺序确定最小和最大纬度、经度
|
||||
double minLatitude = Arrays.stream(latitudes).min().orElseThrow();
|
||||
double maxLatitude = Arrays.stream(latitudes).max().orElseThrow();
|
||||
double minLongitude = Arrays.stream(longitudes).min().orElseThrow();
|
||||
double maxLongitude = Arrays.stream(longitudes).max().orElseThrow();
|
||||
|
||||
return pointLat >= minLatitude && pointLat <= maxLatitude &&
|
||||
pointLng >= minLongitude && pointLng <= maxLongitude;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
package com.muyu.analyze.service.impl;
|
||||
|
||||
|
||||
import com.muyu.analyze.service.VehicleService;
|
||||
import com.muyu.system.common.domain.VehicleData;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @ProjectName: cloud-vehicles
|
||||
* @PackageName: com.muyu.analyze.service.impl.realTimeDataEvent
|
||||
* @Description TODO
|
||||
* @Author HuangDaJu
|
||||
* @Date 2024/4/4 09:35
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Service("realTime")
|
||||
@Slf4j
|
||||
public class RealTimeDataEventImpl implements VehicleService {
|
||||
|
||||
|
||||
private VehicleData realTimeData; // 存储实时数据的变量
|
||||
|
||||
// 用于设置实时数据的方法
|
||||
public void setRealTimeData(VehicleData realTimeData) {
|
||||
this.realTimeData = realTimeData;
|
||||
}
|
||||
|
||||
// 用于获取实时数据的方法
|
||||
public VehicleData getRealTimeData() {
|
||||
return realTimeData;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void eventResolution(VehicleData analyze) {
|
||||
// 处理实时数据,并存储在realTimeData变量中
|
||||
this.realTimeData = analyze;
|
||||
log.info("我是实时数据");
|
||||
// System.out.println(analyze);
|
||||
// return analyze;
|
||||
}
|
||||
|
||||
|
||||
public VehicleData getRealTimeDataByVin(String vin) {
|
||||
if (realTimeData==null || realTimeData.getVin()==null){
|
||||
return null;
|
||||
}
|
||||
String dataVin = realTimeData.getVin();
|
||||
if (dataVin.equals(vin)){
|
||||
return realTimeData;
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
package com.muyu.analyze.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import com.muyu.analyze.mapper.VehicleMapper;
|
||||
import com.muyu.analyze.service.VehicleService;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import com.muyu.system.common.domain.VehicleData;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ProjectName: cloud-vehicles
|
||||
* @PackageName: com.muyu.analyze.service
|
||||
* @Description 事件存储
|
||||
* @Author HuangDaJu
|
||||
* @Date 2024/4/4 09:30
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Service("storedEvent")
|
||||
@Slf4j
|
||||
public class StoredEventImpl implements VehicleService {
|
||||
|
||||
@Autowired
|
||||
private VehicleMapper vehicleMapper;
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
private final ArrayList<VehicleData> list = new ArrayList<>();
|
||||
|
||||
|
||||
@Override
|
||||
public void eventResolution(VehicleData analyze) {
|
||||
|
||||
|
||||
Integer id = (Integer)redisService.getCacheObject("records:info:" + analyze.getVin());
|
||||
analyze.setRecordsId(id);
|
||||
|
||||
|
||||
list.add(analyze);
|
||||
if (list.size() >= 50) {
|
||||
log.info("集合满50,存储事件开始");
|
||||
Boolean i= vehicleMapper.addVehicleStoredEvent(list);
|
||||
|
||||
if (i) {
|
||||
list.clear();
|
||||
log.info("存储事件结束");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,320 @@
|
|||
package com.muyu.analyze.utils;
|
||||
|
||||
|
||||
|
||||
import com.muyu.system.common.domain.VehicleData;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Stack;
|
||||
|
||||
/**
|
||||
* @ProjectName: cloud-vehicles
|
||||
* @PackageName: com.muyu.analyze.config
|
||||
* @Description TODO
|
||||
* @Author HuangDaJu
|
||||
* @Date 2024/4/2 21:33
|
||||
* @Version 1.0
|
||||
*/
|
||||
|
||||
public class AnalyzeUtils {
|
||||
|
||||
public static VehicleData analyze(String aa) {
|
||||
|
||||
VehicleData vehicleData = new VehicleData();
|
||||
/**
|
||||
* 车辆VIN private String vin;
|
||||
*/
|
||||
String vin = aa.substring(0, 17);
|
||||
vehicleData.setVin(vin);
|
||||
|
||||
/**
|
||||
* 毫秒值 private String dateTime;
|
||||
*/
|
||||
String time = aa.substring(17, 30);
|
||||
vehicleData.setDateTime(time);
|
||||
|
||||
/**
|
||||
* 行驶路线 private String drivingRoute;
|
||||
*/
|
||||
|
||||
/**
|
||||
* 经度 private String longitude;
|
||||
*/
|
||||
|
||||
String longitude = aa.substring(30, 41);
|
||||
vehicleData.setLongitude(longitude);
|
||||
|
||||
/**
|
||||
* 纬度 private String latitude;
|
||||
*/
|
||||
|
||||
String latitude = aa.substring(41, 51);
|
||||
vehicleData.setLatitude(latitude);
|
||||
|
||||
/**
|
||||
* 速度 private String speed;
|
||||
*/
|
||||
|
||||
String speed = aa.substring(51, 57);
|
||||
vehicleData.setSpeed(speed);
|
||||
|
||||
/**
|
||||
* 里程 private BigDecimal mileage;
|
||||
*/
|
||||
|
||||
String mileage = aa.substring(57, 68);
|
||||
vehicleData.setMileage(new BigDecimal(mileage));
|
||||
|
||||
/**
|
||||
* 总电压 private String voltage;
|
||||
*/
|
||||
|
||||
String voltage = aa.substring(68, 74);
|
||||
vehicleData.setVoltage(voltage);
|
||||
|
||||
/**
|
||||
* 总电流 private String current;
|
||||
*/
|
||||
|
||||
String current = aa.substring(74, 79);
|
||||
vehicleData.setCurrent(current);
|
||||
|
||||
|
||||
/**
|
||||
* 绝缘电阻 private String resistance;
|
||||
*/
|
||||
String resistance = aa.substring(79, 88);
|
||||
vehicleData.setResistance(resistance);
|
||||
|
||||
/**
|
||||
* 档位 private String gear = "P";
|
||||
*/
|
||||
|
||||
String gear = aa.substring(88, 89);
|
||||
vehicleData.setGear(gear);
|
||||
|
||||
|
||||
/**
|
||||
* 加速踏板行程值 private String accelerationPedal;
|
||||
*/
|
||||
|
||||
String accelerationPedal = aa.substring(89, 91);
|
||||
vehicleData.setAccelerationPedal(accelerationPedal);
|
||||
|
||||
|
||||
/**
|
||||
* 制动踏板行程值 private String brakePedal;
|
||||
*/
|
||||
|
||||
String brakePedal =aa.substring(91,93);
|
||||
vehicleData.setBrakePedal(brakePedal);
|
||||
|
||||
/**
|
||||
* 燃料消耗率 private String fuelConsumptionRate;
|
||||
*/
|
||||
|
||||
String fuelConsumptionRate =aa.substring(93,98);
|
||||
vehicleData.setFuelConsumptionRate(fuelConsumptionRate);
|
||||
|
||||
/**
|
||||
* 电机控制器温度private String motorControllerTemperature;
|
||||
*/
|
||||
|
||||
String motorControllerTemperature =aa.substring(98,104);
|
||||
vehicleData.setMotorControllerTemperature(motorControllerTemperature);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 电机转速 private String motorSpeed;
|
||||
*/
|
||||
|
||||
String motorSpeed =aa.substring(104,109);
|
||||
vehicleData.setMotorSpeed(motorSpeed);
|
||||
|
||||
|
||||
/**
|
||||
* 电机转矩 private String motorTorque;
|
||||
*/
|
||||
String motorTorque = aa.substring(109, 113);
|
||||
vehicleData.setMotorTorque(motorTorque);
|
||||
|
||||
/**
|
||||
* 电机温度 private String motorTemperature;
|
||||
*/
|
||||
String motorTemperature = aa.substring(113, 119);
|
||||
vehicleData.setMotorTemperature(motorTemperature);
|
||||
|
||||
/**
|
||||
* 电机电压 private String motorVoltage;
|
||||
*/
|
||||
|
||||
String motorVoltage = aa.substring(119, 124);
|
||||
vehicleData.setMotorVoltage(motorVoltage);
|
||||
|
||||
/**
|
||||
* 电机电流private String motorCurrent;
|
||||
*/
|
||||
|
||||
|
||||
// 电机电流: 10446000
|
||||
String motorCurrent = aa.substring(124, 132);
|
||||
vehicleData.setMotorCurrent(motorCurrent);
|
||||
|
||||
// 动力电池剩余电量 SOC: 44103.
|
||||
/**
|
||||
* 动力电池剩余电量SOC private BigDecimal remainingBattery;
|
||||
*/
|
||||
|
||||
String remainingBattery = aa.substring(132, 138);
|
||||
vehicleData.setRemainingBattery(remainingBattery);
|
||||
|
||||
|
||||
// 当前状态允许的最大反馈功率: 400000
|
||||
/**
|
||||
* 当前状态允许的最大反馈功率private String maximumFeedbackPower;
|
||||
*/
|
||||
String maximumFeedbackPower = aa.substring(138, 144);
|
||||
vehicleData.setMaximumFeedbackPower(maximumFeedbackPower);
|
||||
|
||||
|
||||
// 当前状态允许最大放电功率: 130000
|
||||
/**
|
||||
* 当前状态允许最大放电功率 private String maximumDischargePower;
|
||||
*/
|
||||
|
||||
String maximumDischargePower = aa.substring(144, 150);
|
||||
vehicleData.setMaximumDischargePower(maximumDischargePower);
|
||||
|
||||
|
||||
// BMS 自检计数器: 20
|
||||
/**
|
||||
* BMS自检计数器private String selfCheckCounter;
|
||||
*/
|
||||
|
||||
String selfCheckCounter = aa.substring(150, 152);
|
||||
vehicleData.setSelfCheckCounter(selfCheckCounter);
|
||||
// 动力电池充放电电流: 00000
|
||||
/**
|
||||
* 动力电池充放电电流 private String totalBatteryCurrent;
|
||||
*/
|
||||
String totalBatteryCurrent = aa.substring(152, 157);
|
||||
vehicleData.setTotalBatteryCurrent(totalBatteryCurrent);
|
||||
|
||||
|
||||
// 动力电池负载端总电压 V3: 605000
|
||||
/**
|
||||
* 动力电池负载端总电压V3 private String totalBatteryVoltage;
|
||||
*/
|
||||
String totalBatteryVoltage = aa.substring(157, 163);
|
||||
vehicleData.setTotalBatteryVoltage(totalBatteryVoltage);
|
||||
|
||||
// 单次最大电压: 4000
|
||||
/**
|
||||
* 单次最大电压 private String singleBatteryMaxVoltage;
|
||||
*/
|
||||
|
||||
String singleBatteryMaxVoltage = aa.substring(163, 167);
|
||||
vehicleData.setSingleBatteryMaxVoltage(singleBatteryMaxVoltage);
|
||||
|
||||
// 单体电池最低电压: 3000
|
||||
/**
|
||||
* 单体电池最低电压 private String singleBatteryMinVoltage;
|
||||
*/
|
||||
|
||||
String singleBatteryMinVoltage = aa.substring(167, 171);
|
||||
vehicleData.setSingleBatteryMinVoltage(singleBatteryMinVoltage);
|
||||
|
||||
// 单体电池最高温度: 650000
|
||||
/**
|
||||
* 单体电池最高温度 private String singleBatteryMaxTemperature;
|
||||
*/
|
||||
String singleBatteryMaxTemperature = aa.substring(171, 177);
|
||||
vehicleData.setSingleBatteryMaxTemperature(singleBatteryMaxTemperature);
|
||||
|
||||
// 单体电池最低温度: 600000
|
||||
/**
|
||||
* 单体电池最低温度 private String singleBatteryMinTemperature;
|
||||
*/
|
||||
String singleBatteryMinTemperature = aa.substring(177, 183);
|
||||
vehicleData.setSingleBatteryMinTemperature(singleBatteryMinTemperature);
|
||||
|
||||
// 动力电池可用容量: 530000
|
||||
/**
|
||||
* 动力电池可用容量 private String availableBatteryCapacity;
|
||||
*/
|
||||
String availableBatteryCapacity = aa.substring(183, 189);
|
||||
vehicleData.setAvailableBatteryCapacity(availableBatteryCapacity);
|
||||
|
||||
|
||||
|
||||
// 车辆状态: 0
|
||||
String vehicleStatus = aa.substring(189, 190);
|
||||
vehicleData.setVehicleStatus(Integer.parseInt(vehicleStatus));
|
||||
|
||||
// 充电状态: 1
|
||||
String chargingStatus = aa.substring(190, 191);
|
||||
vehicleData.setChargingStatus(Integer.parseInt(chargingStatus));
|
||||
// 运行状态: 1
|
||||
String operatingStatus = aa.substring(191, 192);
|
||||
vehicleData.setOperatingStatus(Integer.parseInt(operatingStatus));
|
||||
|
||||
// SOC: 1
|
||||
String socStatus = aa.substring(192, 193);
|
||||
vehicleData.setSocStatus(Integer.parseInt(socStatus));
|
||||
|
||||
// 可充电储能装置工作状态: 0
|
||||
String chargingEnergyStorageStatus = aa.substring(193, 194);
|
||||
vehicleData.setChargingEnergyStorageStatus(Integer.parseInt(chargingEnergyStorageStatus));
|
||||
|
||||
// 驱动电机状态: 1
|
||||
String driveMotorStatus = aa.substring(194, 195);
|
||||
vehicleData.setDriveMotorStatus(Integer.parseInt(driveMotorStatus));
|
||||
|
||||
// 定位是否有效: 1
|
||||
String positionStatus = aa.substring(195, 196);
|
||||
vehicleData.setPositionStatus(Integer.parseInt(positionStatus));
|
||||
|
||||
// EAS: 1
|
||||
String easStatus = aa.substring(196, 197);
|
||||
vehicleData.setEasStatus(Integer.parseInt(easStatus));
|
||||
|
||||
// PTC: 1
|
||||
String ptcStatus = aa.substring(197, 198);
|
||||
vehicleData.setPtcStatus(Integer.parseInt(ptcStatus));
|
||||
|
||||
// EPS: 1
|
||||
String epsStatus = aa.substring(198, 199);
|
||||
vehicleData.setEpsStatus(Integer.parseInt(epsStatus));
|
||||
|
||||
// ABS: 1
|
||||
String absStatus = aa.substring(199, 200);
|
||||
vehicleData.setAbsStatus(Integer.parseInt(absStatus));
|
||||
|
||||
// MCU: 1
|
||||
String mcuStatus = aa.substring(200, 201);
|
||||
vehicleData.setMcuStatus(Integer.parseInt(mcuStatus));
|
||||
|
||||
// 动力电池加热状态: 1
|
||||
String heatingStatus = aa.substring(201, 202);
|
||||
vehicleData.setHeatingStatus(Integer.parseInt(heatingStatus));
|
||||
|
||||
// 动力电池当前状态: 1
|
||||
String batteryStatus = aa.substring(202, 203);
|
||||
vehicleData.setBatteryStatus(Integer.parseInt(batteryStatus));
|
||||
|
||||
// 动力电池保温状态: 1
|
||||
String batteryInsulationStatus = aa.substring(203, 204);
|
||||
vehicleData.setBatteryInsulationStatus(Integer.parseInt(batteryInsulationStatus));
|
||||
|
||||
// DCDC: 1
|
||||
String dcdcStatus = aa.substring(204, 205);
|
||||
vehicleData.setDcdcStatus(Integer.parseInt(dcdcStatus));
|
||||
|
||||
// CHG: 1
|
||||
String chgStatus = aa.substring(205, 206);
|
||||
vehicleData.setChgStatus(Integer.parseInt(chgStatus));
|
||||
|
||||
return vehicleData;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
package com.muyu.analyze.utils;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
* @Date: 2024/4/4
|
||||
* @Description:
|
||||
*/
|
||||
@Component
|
||||
public class StateConstant {
|
||||
|
||||
/**
|
||||
* 车辆状态
|
||||
*/
|
||||
public static final Integer VEHICLE_STATUS = 1;
|
||||
|
||||
/**
|
||||
* 充电状态
|
||||
*/
|
||||
public static final Integer CHARGING_STATUS = 1;
|
||||
|
||||
/**
|
||||
* 运行状态
|
||||
*/
|
||||
public static final Integer OPERATING_STATUS = 1;
|
||||
|
||||
/**
|
||||
* soc状态
|
||||
*/
|
||||
public static final Integer SOC_STATUS = 1;
|
||||
|
||||
/**
|
||||
* 可充电储能装置工作状态
|
||||
*/
|
||||
public static final Integer CHARGING_ENERGY_STORAGE_STATUS = 1;
|
||||
|
||||
/**
|
||||
* 驱动电机状态
|
||||
*/
|
||||
public static final Integer DRIVE_MOTOR_STATUS = 1;
|
||||
|
||||
/**
|
||||
* 定位是否有效
|
||||
*/
|
||||
public static final Integer POSITION_STATUS = 1;
|
||||
|
||||
/**
|
||||
* EAS(汽车防盗系统)状态
|
||||
*/
|
||||
public static final Integer EAS_STATUS = 1;
|
||||
|
||||
/**
|
||||
* PTC(电动加热器)状态
|
||||
*/
|
||||
public static final Integer PTC_STATUS = 1;
|
||||
|
||||
/**
|
||||
* ABS(防抱死)状态
|
||||
*/
|
||||
public static final Integer ABS_STATUS = 1;
|
||||
|
||||
/**
|
||||
* MCU(电机/逆变器)状态
|
||||
*/
|
||||
public static final Integer MCU_STATUS = 1;
|
||||
/**
|
||||
* 动力电池加热状态
|
||||
*/
|
||||
public static final Integer HEATING_STATUS = 1;
|
||||
/**
|
||||
* 动力电池当前状态
|
||||
*/
|
||||
public static final Integer BATTERY_STATUS = 1;
|
||||
/**
|
||||
* 动力电池保温状态
|
||||
*/
|
||||
public static final Integer BATTERY_INSULATION_STATUS = 1;
|
||||
/**
|
||||
* DCDC(电力交换系统) 状态
|
||||
*/
|
||||
public static final Integer DCDC_STATUS = 1;
|
||||
/**
|
||||
* CHG(充电机)状态
|
||||
*/
|
||||
public static final Integer CHG_STATUS = 1;
|
||||
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
//package com.muyu.analyze.utils;
|
||||
//
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.apache.kafka.clients.consumer.ConsumerConfig;
|
||||
//import org.apache.kafka.clients.consumer.ConsumerRecords;
|
||||
//import org.apache.kafka.clients.consumer.KafkaConsumer;
|
||||
//import org.apache.kafka.clients.producer.KafkaProducer;
|
||||
//import org.apache.kafka.clients.producer.ProducerConfig;
|
||||
//import org.apache.kafka.clients.producer.ProducerRecord;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import javax.annotation.PostConstruct;
|
||||
//import java.time.Duration;
|
||||
//import java.util.Collections;
|
||||
//import java.util.Properties;
|
||||
//
|
||||
///**
|
||||
// * @ProjectName: cloud-vehicles
|
||||
// * @PackageName: com.muyu.analyze.utils
|
||||
// * @Description TODO
|
||||
// * @Author HuangDaJu
|
||||
// * @Date 2024/4/8 12:41
|
||||
// * @Version 1.0
|
||||
// */
|
||||
//@Component
|
||||
//@Slf4j
|
||||
//public class Test {
|
||||
//
|
||||
// private static final String TOPIC_NAME = "online";
|
||||
// private static final String BOOTSTRAP_SERVERS = "10.10.26.4:9092";
|
||||
//
|
||||
// public static void main(String[] args) {
|
||||
// //生产者示例
|
||||
// produceMessage();
|
||||
//
|
||||
// //消费者示例
|
||||
// consumerMessages();
|
||||
//
|
||||
// }
|
||||
//
|
||||
// //生产者
|
||||
// @PostConstruct
|
||||
// private static void produceMessage() {
|
||||
// Properties props = new Properties();
|
||||
// props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, BOOTSTRAP_SERVERS);
|
||||
// props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer");
|
||||
// props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer");
|
||||
//
|
||||
// KafkaProducer<String, String> producer = new KafkaProducer<>(props);
|
||||
// //创建生产者
|
||||
// try {
|
||||
//
|
||||
// //发送消息
|
||||
// for (int i = 0; i < 10000; i++) {
|
||||
// String message = "佳佳来喽" + (i + 1);
|
||||
// producer.send(new ProducerRecord<>(TOPIC_NAME, message));
|
||||
//
|
||||
// System.out.println("发送消息:" + message);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// } finally {
|
||||
// producer.close();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //消费者
|
||||
// private static void consumerMessages() {
|
||||
// Properties props = new Properties();
|
||||
// props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, BOOTSTRAP_SERVERS);
|
||||
// props.put(ConsumerConfig.GROUP_ID_CONFIG, "my-consumer-group");
|
||||
// props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer");
|
||||
// props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer");
|
||||
//
|
||||
// //创建消费者
|
||||
// KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props);
|
||||
//
|
||||
// try {
|
||||
//
|
||||
// //订阅主题
|
||||
// consumer.subscribe(Collections.singletonList(TOPIC_NAME));
|
||||
//
|
||||
// //持续消费消息
|
||||
// while (true) {
|
||||
// ConsumerRecords<String, String> records = consumer.poll(Duration.ofMillis(100));
|
||||
// records.forEach(record -> {
|
||||
// System.out.println("消费者接受到的消息值:" + record.value());
|
||||
// });
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// } finally {
|
||||
// consumer.close();
|
||||
// }
|
||||
// }
|
||||
//}
|
|
@ -0,0 +1,36 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9008
|
||||
# Spring
|
||||
spring:
|
||||
kafka:
|
||||
bootstrap-servers: 10.10.26.4:9092
|
||||
consumer:
|
||||
group-id: group2
|
||||
auto-offset-reset: earliest
|
||||
|
||||
|
||||
application:
|
||||
# 应用名称
|
||||
name: muyu-analyze
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.207.39:8848
|
||||
# 命名空间
|
||||
namespace: lyj
|
||||
config:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.207.39:8848
|
||||
# 命名空间
|
||||
namespace: lyj
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?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">
|
||||
<!-- mybatis数据层 namespace命名空间-->
|
||||
<mapper namespace="com.muyu.analyze.mapper.VehicleMapper">
|
||||
|
||||
<insert id="addVehicleStoredEvent">
|
||||
INSERT INTO vehicle_data (vin, date_time, speed, longitude, latitude, single_battery_min_voltage, motor_voltage, motor_speed, self_check_counter, voltage, gear, remaining_battery, motor_current, brake_pedal, current, single_battery_max_voltage, fuel_consumption_rate, resistance, maximum_feedback_power, single_battery_max_temperature,records_id)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" index="index" separator=",">
|
||||
(#{item.vin}, #{item.dateTime}, #{item.speed}, #{item.longitude}, #{item.latitude}, #{item.singleBatteryMinVoltage}, #{item.motorVoltage}, #{item.motorSpeed}, #{item.selfCheckCounter}, #{item.voltage}, #{item.gear}, #{item.remainingBattery}, #{item.motorCurrent}, #{item.brakePedal}, #{item.current}, #{item.singleBatteryMaxVoltage}, #{item.fuelConsumptionRate}, #{item.resistance}, #{item.maximumFeedbackPower}, #{item.singleBatteryMaxTemperature},#{item.recordsId})
|
||||
</foreach>
|
||||
|
||||
</insert>
|
||||
<select id="selectFenceList" resultType="com.muyu.business.domain.Fence">
|
||||
select car_vin,fence_encoding,fence_id,fence_type,fence_radius from car left join fence on car.car_fence_id=fence.fence_id
|
||||
</select>
|
||||
<select id="selectCarList" resultType="com.muyu.system.common.domain.Car">
|
||||
select car_fence_id from car where car_vin=#{vin}
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,11 @@
|
|||
/**
|
||||
* @Author LiYonJie
|
||||
* @Date 2024/4/13
|
||||
* @Description TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class LoadTest {
|
||||
public void load(){
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
<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.muyu</groupId>
|
||||
<artifactId>muyu</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>muyu-auth</artifactId>
|
||||
|
||||
<description>
|
||||
muyu-auth认证授权中心
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos Config -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Web -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common Security-->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-system-remote</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,31 @@
|
|||
package com.muyu.auth;
|
||||
|
||||
import com.muyu.common.security.annotation.EnableRyFeignClients;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
|
||||
/**
|
||||
* 认证授权中心
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@EnableRyFeignClients
|
||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class })
|
||||
public class MuYuAuthApplication
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
SpringApplication.run(MuYuAuthApplication.class, args);
|
||||
System.out.println("(♥◠‿◠)ノ゙ 认证授权中心启动成功 ლ(´ڡ`ლ)゙ \n" +
|
||||
" .-------. ____ __ \n" +
|
||||
" | _ _ \\ \\ \\ / / \n" +
|
||||
" | ( ' ) | \\ _. / ' \n" +
|
||||
" |(_ o _) / _( )_ .' \n" +
|
||||
" | (_,_).' __ ___(_ o _)' \n" +
|
||||
" | |\\ \\ | || |(_,_)' \n" +
|
||||
" | | \\ `' /| `-' / \n" +
|
||||
" | | \\ / \\ / \n" +
|
||||
" ''-' `'-' `-..-' ");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
package com.muyu.auth.controller;
|
||||
|
||||
import com.muyu.auth.form.LoginBody;
|
||||
import com.muyu.auth.form.RegisterBody;
|
||||
import com.muyu.auth.service.SysLoginService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.JwtUtils;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.security.auth.AuthUtil;
|
||||
import com.muyu.common.security.service.TokenService;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.system.common.model.LoginUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import static com.muyu.common.core.domain.Result.success;
|
||||
|
||||
|
||||
/**
|
||||
* token 控制
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@RestController
|
||||
public class TokenController
|
||||
{
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
|
||||
@Autowired
|
||||
private SysLoginService sysLoginService;
|
||||
|
||||
@PostMapping("login")
|
||||
public Result<?> login(@RequestBody LoginBody form)
|
||||
{
|
||||
// 用户登录
|
||||
LoginUser userInfo = sysLoginService.login(form.getUsername(), form.getPassword());
|
||||
// 获取登录token
|
||||
return success(tokenService.createToken(userInfo));
|
||||
}
|
||||
|
||||
@DeleteMapping("logout")
|
||||
public Result<?> logout(HttpServletRequest request)
|
||||
{
|
||||
String token = SecurityUtils.getToken(request);
|
||||
if (StringUtils.isNotEmpty(token))
|
||||
{
|
||||
String username = JwtUtils.getUserName(token);
|
||||
// 删除用户缓存记录
|
||||
AuthUtil.logoutByToken(token);
|
||||
// 记录用户退出日志
|
||||
sysLoginService.logout(username);
|
||||
}
|
||||
return success();
|
||||
}
|
||||
|
||||
@PostMapping("refresh")
|
||||
public Result<?> refresh(HttpServletRequest request)
|
||||
{
|
||||
LoginUser loginUser = tokenService.getLoginUser(request);
|
||||
if (StringUtils.isNotNull(loginUser))
|
||||
{
|
||||
// 刷新令牌有效期
|
||||
tokenService.refreshToken(loginUser);
|
||||
return success();
|
||||
}
|
||||
return success();
|
||||
}
|
||||
|
||||
@PostMapping("register")
|
||||
public Result<?> register(@RequestBody RegisterBody registerBody)
|
||||
{
|
||||
// 用户注册
|
||||
sysLoginService.register(registerBody.getUsername(), registerBody.getPassword());
|
||||
return success();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.muyu.auth.form;
|
||||
|
||||
/**
|
||||
* 用户登录对象
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class LoginBody {
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 用户密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.muyu.auth.form;
|
||||
|
||||
/**
|
||||
* 用户注册对象
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class RegisterBody extends LoginBody
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,148 @@
|
|||
package com.muyu.auth.service;
|
||||
|
||||
import com.muyu.common.core.constant.CacheConstants;
|
||||
import com.muyu.common.core.constant.Constants;
|
||||
import com.muyu.common.core.constant.SecurityConstants;
|
||||
import com.muyu.common.core.constant.UserConstants;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.enums.UserStatus;
|
||||
import com.muyu.common.core.exception.ServiceException;
|
||||
import com.muyu.common.core.text.Convert;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.core.utils.ip.IpUtils;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.system.common.domain.SysUser;
|
||||
import com.muyu.system.common.model.LoginUser;
|
||||
import com.muyu.system.remote.RemoteUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
/**
|
||||
* 登录校验方法
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@Component
|
||||
public class SysLoginService
|
||||
{
|
||||
@Autowired
|
||||
private RemoteUserService remoteUserService;
|
||||
|
||||
@Autowired
|
||||
private SysPasswordService passwordService;
|
||||
|
||||
@Autowired
|
||||
private SysRecordLogService recordLogService;
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
public LoginUser login(String username, String password)
|
||||
{
|
||||
// 用户名或密码为空 错误
|
||||
if (StringUtils.isAnyBlank(username, password))
|
||||
{
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户/密码必须填写");
|
||||
throw new ServiceException("用户/密码必须填写");
|
||||
}
|
||||
// 密码如果不在指定范围内 错误
|
||||
if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
|
||||
|| password.length() > UserConstants.PASSWORD_MAX_LENGTH)
|
||||
{
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户密码不在指定范围");
|
||||
throw new ServiceException("用户密码不在指定范围");
|
||||
}
|
||||
// 用户名不在指定范围内 错误
|
||||
if (username.length() < UserConstants.USERNAME_MIN_LENGTH
|
||||
|| username.length() > UserConstants.USERNAME_MAX_LENGTH)
|
||||
{
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户名不在指定范围");
|
||||
throw new ServiceException("用户名不在指定范围");
|
||||
}
|
||||
// IP黑名单校验
|
||||
String blackStr = Convert.toStr(redisService.getCacheObject(CacheConstants.SYS_LOGIN_BLACKIPLIST));
|
||||
if (IpUtils.isMatchedIp(blackStr, IpUtils.getIpAddr()))
|
||||
{
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "很遗憾,访问IP已被列入系统黑名单");
|
||||
throw new ServiceException("很遗憾,访问IP已被列入系统黑名单");
|
||||
}
|
||||
// 查询用户信息
|
||||
Result<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
|
||||
|
||||
if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData()))
|
||||
{
|
||||
if(StringUtils.contains(username, "@")){
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "邮箱错误,请检查");
|
||||
throw new ServiceException("邮箱错误,请检查:" + username);
|
||||
}
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在");
|
||||
throw new ServiceException("登录用户:" + username + " 不存在");
|
||||
}
|
||||
|
||||
if (Result.FAIL == userResult.getCode())
|
||||
{
|
||||
throw new ServiceException(userResult.getMsg());
|
||||
}
|
||||
|
||||
LoginUser userInfo = userResult.getData();
|
||||
SysUser user = userResult.getData().getSysUser();
|
||||
if (UserStatus.DELETED.getCode().equals(user.getDelFlag()))
|
||||
{
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除");
|
||||
throw new ServiceException("对不起,您的账号:" + username + " 已被删除");
|
||||
}
|
||||
if (UserStatus.DISABLE.getCode().equals(user.getStatus()))
|
||||
{
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员");
|
||||
throw new ServiceException("对不起,您的账号:" + username + " 已停用");
|
||||
}
|
||||
passwordService.validate(user, password);
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功");
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
public void logout(String loginName)
|
||||
{
|
||||
recordLogService.recordLogininfor(loginName, Constants.LOGOUT, "退出成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
public void register(String username, String password)
|
||||
{
|
||||
// 用户名或密码为空 错误
|
||||
if (StringUtils.isAnyBlank(username, password))
|
||||
{
|
||||
throw new ServiceException("用户/密码必须填写");
|
||||
}
|
||||
if (username.length() < UserConstants.USERNAME_MIN_LENGTH
|
||||
|| username.length() > UserConstants.USERNAME_MAX_LENGTH)
|
||||
{
|
||||
throw new ServiceException("账户长度必须在2到20个字符之间");
|
||||
}
|
||||
if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
|
||||
|| password.length() > UserConstants.PASSWORD_MAX_LENGTH)
|
||||
{
|
||||
throw new ServiceException("密码长度必须在5到20个字符之间");
|
||||
}
|
||||
|
||||
// 注册用户信息
|
||||
SysUser sysUser = new SysUser();
|
||||
sysUser.setUserName(username);
|
||||
sysUser.setNickName(username);
|
||||
sysUser.setPassword(SecurityUtils.encryptPassword(password));
|
||||
Result<?> registerResult = remoteUserService.registerUserInfo(sysUser, SecurityConstants.INNER);
|
||||
|
||||
if (Result.FAIL == registerResult.getCode())
|
||||
{
|
||||
throw new ServiceException(registerResult.getMsg());
|
||||
}
|
||||
recordLogService.recordLogininfor(username, Constants.REGISTER, "注册成功");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
package com.muyu.auth.service;
|
||||
|
||||
import com.muyu.common.core.constant.CacheConstants;
|
||||
import com.muyu.common.core.constant.Constants;
|
||||
import com.muyu.common.core.exception.ServiceException;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.system.common.domain.SysUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
/**
|
||||
* 登录密码方法
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@Component
|
||||
public class SysPasswordService
|
||||
{
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
private int maxRetryCount = CacheConstants.PASSWORD_MAX_RETRY_COUNT;
|
||||
|
||||
private Long lockTime = CacheConstants.PASSWORD_LOCK_TIME;
|
||||
|
||||
@Autowired
|
||||
private SysRecordLogService recordLogService;
|
||||
|
||||
/**
|
||||
* 登录账户密码错误次数缓存键名
|
||||
*
|
||||
* @param username 用户名
|
||||
* @return 缓存键key
|
||||
*/
|
||||
private String getCacheKey(String username)
|
||||
{
|
||||
return CacheConstants.PWD_ERR_CNT_KEY + username;
|
||||
}
|
||||
|
||||
public void validate(SysUser user, String password)
|
||||
{
|
||||
String username = user.getUserName();
|
||||
|
||||
Integer retryCount = redisService.getCacheObject(getCacheKey(username));
|
||||
|
||||
if (retryCount == null)
|
||||
{
|
||||
retryCount = 0;
|
||||
}
|
||||
|
||||
if (retryCount >= Integer.valueOf(maxRetryCount).intValue())
|
||||
{
|
||||
String errMsg = String.format("密码输入错误%s次,帐户锁定%s分钟", maxRetryCount, lockTime);
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL,errMsg);
|
||||
throw new ServiceException(errMsg);
|
||||
}
|
||||
|
||||
if (!matches(user, password))
|
||||
{
|
||||
retryCount = retryCount + 1;
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, String.format("密码输入错误%s次", retryCount));
|
||||
redisService.setCacheObject(getCacheKey(username), retryCount, lockTime, TimeUnit.MINUTES);
|
||||
throw new ServiceException("用户不存在/密码错误");
|
||||
}
|
||||
else
|
||||
{
|
||||
clearLoginRecordCache(username);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean matches(SysUser user, String rawPassword)
|
||||
{
|
||||
return SecurityUtils.matchesPassword(rawPassword, user.getPassword());
|
||||
}
|
||||
|
||||
public void clearLoginRecordCache(String loginName)
|
||||
{
|
||||
if (redisService.hasKey(getCacheKey(loginName)))
|
||||
{
|
||||
redisService.deleteObject(getCacheKey(loginName));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package com.muyu.auth.service;
|
||||
|
||||
import com.muyu.common.core.constant.Constants;
|
||||
import com.muyu.common.core.constant.SecurityConstants;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.core.utils.ip.IpUtils;
|
||||
import com.muyu.system.common.domain.SysLogininfor;
|
||||
import com.muyu.system.remote.RemoteLogService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
/**
|
||||
* 记录日志方法
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@Component
|
||||
public class SysRecordLogService
|
||||
{
|
||||
@Autowired
|
||||
private RemoteLogService remoteLogService;
|
||||
|
||||
/**
|
||||
* 记录登录信息
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param status 状态
|
||||
* @param message 消息内容
|
||||
* @return
|
||||
*/
|
||||
public void recordLogininfor(String username, String status, String message)
|
||||
{
|
||||
SysLogininfor logininfor = new SysLogininfor();
|
||||
logininfor.setUserName(username);
|
||||
logininfor.setIpaddr(IpUtils.getIpAddr());
|
||||
logininfor.setMsg(message);
|
||||
// 日志状态
|
||||
if (StringUtils.equalsAny(status, Constants.LOGIN_SUCCESS, Constants.LOGOUT, Constants.REGISTER))
|
||||
{
|
||||
logininfor.setStatus(Constants.LOGIN_SUCCESS_STATUS);
|
||||
}
|
||||
else if (Constants.LOGIN_FAIL.equals(status))
|
||||
{
|
||||
logininfor.setStatus(Constants.LOGIN_FAIL_STATUS);
|
||||
}
|
||||
remoteLogService.saveLogininfor(logininfor, SecurityConstants.INNER);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
Spring Boot Version: ${spring-boot.version}
|
||||
Spring Application Name: ${spring.application.name}
|
||||
_ _ _
|
||||
(_) | | | |
|
||||
_ __ _ _ ___ _ _ _ ______ __ _ _ _ | |_ | |__
|
||||
| '__|| | | | / _ \ | | | || ||______| / _` || | | || __|| '_ \
|
||||
| | | |_| || (_) || |_| || | | (_| || |_| || |_ | | | |
|
||||
|_| \__,_| \___/ \__, ||_| \__,_| \__,_| \__||_| |_|
|
||||
__/ |
|
||||
|___/
|
|
@ -0,0 +1,29 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9001
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: muyu-auth
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.207.39:8848
|
||||
# 命名空间
|
||||
namespace: lyj
|
||||
config:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.207.39:8848
|
||||
# 命名空间
|
||||
namespace: lyj
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
@ -0,0 +1,74 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/muyu-auth" />
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 系统日志输出 -->
|
||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/info.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>INFO</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/error.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>ERROR</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 系统模块日志级别控制 -->
|
||||
<logger name="com.muyu" level="info" />
|
||||
<!-- Spring日志级别控制 -->
|
||||
<logger name="org.springframework" level="warn" />
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="console" />
|
||||
</root>
|
||||
|
||||
<!--系统操作日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="file_info" />
|
||||
<appender-ref ref="file_error" />
|
||||
</root>
|
||||
</configuration>
|
|
@ -0,0 +1,204 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>muyu-common-core</artifactId>
|
||||
|
||||
<description>
|
||||
muyu-common-core核心模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- SpringCloud Openfeign -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Loadbalancer -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Context Support -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context-support</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Web -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Transmittable ThreadLocal -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>transmittable-thread-local</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Pagehelper -->
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Hibernate Validator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Jackson -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Alibaba Fastjson -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.fastjson2</groupId>
|
||||
<artifactId>fastjson2</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Jwt -->
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- mybatis - plus 依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.3.1</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.github.jsqlparser</groupId>
|
||||
<artifactId>jsqlparser</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.mybatis</groupId>
|
||||
<artifactId>mybatis</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- Apache Lang3 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Commons Io -->
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</dependency>
|
||||
<!-- mybatis - plus 依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.3.1</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.github.jsqlparser</groupId>
|
||||
<artifactId>jsqlparser</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.mybatis</groupId>
|
||||
<artifactId>mybatis</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- excel工具 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
</dependency>
|
||||
<!-- Jaxb -->
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
</dependency>
|
||||
<!-- Java Servlet -->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- lombok依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Swagger -->
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- mybatis - plus 依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.3.1</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.github.jsqlparser</groupId>
|
||||
<artifactId>jsqlparser</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.mybatis</groupId>
|
||||
<artifactId>mybatis</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- mqtt -->
|
||||
<dependency>
|
||||
<groupId>org.eclipse.paho</groupId>
|
||||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||
<version>1.2.5</version>
|
||||
</dependency>
|
||||
<!--短信依赖 5条依赖-->
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpcore</artifactId>
|
||||
<version>4.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-util</artifactId>
|
||||
<version>9.3.7.v20160115</version>
|
||||
</dependency>
|
||||
<!-- spring boot 邮件发送 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-mail</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,183 @@
|
|||
package com.muyu.common.core.annotation;
|
||||
|
||||
import com.muyu.common.core.utils.poi.ExcelHandlerAdapter;
|
||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 自定义导出Excel数据注解
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface Excel
|
||||
{
|
||||
/**
|
||||
* 导出时在excel中排序
|
||||
*/
|
||||
public int sort() default Integer.MAX_VALUE;
|
||||
|
||||
/**
|
||||
* 导出到Excel中的名字.
|
||||
*/
|
||||
public String name() default "";
|
||||
|
||||
/**
|
||||
* 日期格式, 如: yyyy-MM-dd
|
||||
*/
|
||||
public String dateFormat() default "";
|
||||
|
||||
/**
|
||||
* 读取内容转表达式 (如: 0=男,1=女,2=未知)
|
||||
*/
|
||||
public String readConverterExp() default "";
|
||||
|
||||
/**
|
||||
* 分隔符,读取字符串组内容
|
||||
*/
|
||||
public String separator() default ",";
|
||||
|
||||
/**
|
||||
* BigDecimal 精度 默认:-1(默认不开启BigDecimal格式化)
|
||||
*/
|
||||
public int scale() default -1;
|
||||
|
||||
/**
|
||||
* BigDecimal 舍入规则 默认:BigDecimal.ROUND_HALF_EVEN
|
||||
*/
|
||||
public int roundingMode() default BigDecimal.ROUND_HALF_EVEN;
|
||||
|
||||
/**
|
||||
* 导出时在excel中每个列的高度
|
||||
*/
|
||||
public double height() default 14;
|
||||
|
||||
/**
|
||||
* 导出时在excel中每个列的宽度
|
||||
*/
|
||||
public double width() default 16;
|
||||
|
||||
/**
|
||||
* 文字后缀,如% 90 变成90%
|
||||
*/
|
||||
public String suffix() default "";
|
||||
|
||||
/**
|
||||
* 当值为空时,字段的默认值
|
||||
*/
|
||||
public String defaultValue() default "";
|
||||
|
||||
/**
|
||||
* 提示信息
|
||||
*/
|
||||
public String prompt() default "";
|
||||
|
||||
/**
|
||||
* 设置只能选择不能输入的列内容.
|
||||
*/
|
||||
public String[] combo() default {};
|
||||
|
||||
/**
|
||||
* 是否需要纵向合并单元格,应对需求:含有list集合单元格)
|
||||
*/
|
||||
public boolean needMerge() default false;
|
||||
|
||||
/**
|
||||
* 是否导出数据,应对需求:有时我们需要导出一份模板,这是标题需要但内容需要用户手工填写.
|
||||
*/
|
||||
public boolean isExport() default true;
|
||||
|
||||
/**
|
||||
* 另一个类中的属性名称,支持多级获取,以小数点隔开
|
||||
*/
|
||||
public String targetAttr() default "";
|
||||
|
||||
/**
|
||||
* 是否自动统计数据,在最后追加一行统计数据总和
|
||||
*/
|
||||
public boolean isStatistics() default false;
|
||||
|
||||
/**
|
||||
* 导出类型(0数字 1字符串)
|
||||
*/
|
||||
public ColumnType cellType() default ColumnType.STRING;
|
||||
|
||||
/**
|
||||
* 导出列头背景颜色
|
||||
*/
|
||||
public IndexedColors headerBackgroundColor() default IndexedColors.GREY_50_PERCENT;
|
||||
|
||||
/**
|
||||
* 导出列头字体颜色
|
||||
*/
|
||||
public IndexedColors headerColor() default IndexedColors.WHITE;
|
||||
|
||||
/**
|
||||
* 导出单元格背景颜色
|
||||
*/
|
||||
public IndexedColors backgroundColor() default IndexedColors.WHITE;
|
||||
|
||||
/**
|
||||
* 导出单元格字体颜色
|
||||
*/
|
||||
public IndexedColors color() default IndexedColors.BLACK;
|
||||
|
||||
/**
|
||||
* 导出字段对齐方式
|
||||
*/
|
||||
public HorizontalAlignment align() default HorizontalAlignment.CENTER;
|
||||
|
||||
/**
|
||||
* 自定义数据处理器
|
||||
*/
|
||||
public Class<?> handler() default ExcelHandlerAdapter.class;
|
||||
|
||||
/**
|
||||
* 自定义数据处理器参数
|
||||
*/
|
||||
public String[] args() default {};
|
||||
|
||||
/**
|
||||
* 字段类型(0:导出导入;1:仅导出;2:仅导入)
|
||||
*/
|
||||
Type type() default Type.ALL;
|
||||
|
||||
public enum Type
|
||||
{
|
||||
ALL(0), EXPORT(1), IMPORT(2);
|
||||
private final int value;
|
||||
|
||||
Type(int value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int value()
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
public enum ColumnType
|
||||
{
|
||||
NUMERIC(0), STRING(1), IMAGE(2);
|
||||
private final int value;
|
||||
|
||||
ColumnType(int value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int value()
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.muyu.common.core.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Excel注解集
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Excels
|
||||
{
|
||||
Excel[] value();
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package com.muyu.common.core.constant;
|
||||
|
||||
/**
|
||||
* 缓存常量信息
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class CacheConstants
|
||||
{
|
||||
/**
|
||||
* 缓存有效期,默认720(分钟)
|
||||
*/
|
||||
public final static long EXPIRATION = 720;
|
||||
|
||||
/**
|
||||
* 缓存刷新时间,默认120(分钟)
|
||||
*/
|
||||
public final static long REFRESH_TIME = 120;
|
||||
|
||||
/**
|
||||
* 密码最大错误次数
|
||||
*/
|
||||
public final static int PASSWORD_MAX_RETRY_COUNT = 5;
|
||||
|
||||
/**
|
||||
* 密码锁定时间,默认10(分钟)
|
||||
*/
|
||||
public final static long PASSWORD_LOCK_TIME = 10;
|
||||
|
||||
/**
|
||||
* 权限缓存前缀
|
||||
*/
|
||||
public final static String LOGIN_TOKEN_KEY = "login_tokens:";
|
||||
|
||||
/**
|
||||
* 验证码 redis key
|
||||
*/
|
||||
public static final String CAPTCHA_CODE_KEY = "captcha_codes:";
|
||||
|
||||
/**
|
||||
* 参数管理 cache key
|
||||
*/
|
||||
public static final String SYS_CONFIG_KEY = "sys_config:";
|
||||
|
||||
/**
|
||||
* 字典管理 cache key
|
||||
*/
|
||||
public static final String SYS_DICT_KEY = "sys_dict:";
|
||||
|
||||
/**
|
||||
* 登录账户密码错误次数 redis key
|
||||
*/
|
||||
public static final String PWD_ERR_CNT_KEY = "pwd_err_cnt:";
|
||||
|
||||
/**
|
||||
* 登录IP黑名单 cache key
|
||||
*/
|
||||
public static final String SYS_LOGIN_BLACKIPLIST = SYS_CONFIG_KEY + "sys.login.blackIPList";
|
||||
}
|
|
@ -0,0 +1,135 @@
|
|||
package com.muyu.common.core.constant;
|
||||
|
||||
/**
|
||||
* 通用常量信息
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class Constants
|
||||
{
|
||||
/**
|
||||
* UTF-8 字符集
|
||||
*/
|
||||
public static final String UTF8 = "UTF-8";
|
||||
|
||||
/**
|
||||
* GBK 字符集
|
||||
*/
|
||||
public static final String GBK = "GBK";
|
||||
|
||||
/**
|
||||
* www主域
|
||||
*/
|
||||
public static final String WWW = "www.";
|
||||
|
||||
/**
|
||||
* RMI 远程方法调用
|
||||
*/
|
||||
public static final String LOOKUP_RMI = "rmi:";
|
||||
|
||||
/**
|
||||
* LDAP 远程方法调用
|
||||
*/
|
||||
public static final String LOOKUP_LDAP = "ldap:";
|
||||
|
||||
/**
|
||||
* LDAPS 远程方法调用
|
||||
*/
|
||||
public static final String LOOKUP_LDAPS = "ldaps:";
|
||||
|
||||
/**
|
||||
* http请求
|
||||
*/
|
||||
public static final String HTTP = "http://";
|
||||
|
||||
/**
|
||||
* https请求
|
||||
*/
|
||||
public static final String HTTPS = "https://";
|
||||
|
||||
/**
|
||||
* 成功标记
|
||||
*/
|
||||
public static final Integer SUCCESS = 200;
|
||||
|
||||
/**
|
||||
* 失败标记
|
||||
*/
|
||||
public static final Integer FAIL = 500;
|
||||
|
||||
/**
|
||||
* 登录成功状态
|
||||
*/
|
||||
public static final String LOGIN_SUCCESS_STATUS = "0";
|
||||
|
||||
/**
|
||||
* 登录失败状态
|
||||
*/
|
||||
public static final String LOGIN_FAIL_STATUS = "1";
|
||||
|
||||
/**
|
||||
* 登录成功
|
||||
*/
|
||||
public static final String LOGIN_SUCCESS = "Success";
|
||||
|
||||
/**
|
||||
* 注销
|
||||
*/
|
||||
public static final String LOGOUT = "Logout";
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
public static final String REGISTER = "Register";
|
||||
|
||||
/**
|
||||
* 登录失败
|
||||
*/
|
||||
public static final String LOGIN_FAIL = "Error";
|
||||
|
||||
/**
|
||||
* 当前记录起始索引
|
||||
*/
|
||||
public static final String PAGE_NUM = "pageNum";
|
||||
|
||||
/**
|
||||
* 每页显示记录数
|
||||
*/
|
||||
public static final String PAGE_SIZE = "pageSize";
|
||||
|
||||
/**
|
||||
* 排序列
|
||||
*/
|
||||
public static final String ORDER_BY_COLUMN = "orderByColumn";
|
||||
|
||||
/**
|
||||
* 排序的方向 "desc" 或者 "asc".
|
||||
*/
|
||||
public static final String IS_ASC = "isAsc";
|
||||
|
||||
/**
|
||||
* 验证码有效期(分钟)
|
||||
*/
|
||||
public static final long CAPTCHA_EXPIRATION = 2;
|
||||
|
||||
/**
|
||||
* 资源映射路径 前缀
|
||||
*/
|
||||
public static final String RESOURCE_PREFIX = "/profile";
|
||||
|
||||
/**
|
||||
* 自动识别json对象白名单配置(仅允许解析的包名,范围越小越安全)
|
||||
*/
|
||||
public static final String[] JSON_WHITELIST_STR = { "org.springframework", "com.muyu" };
|
||||
|
||||
/**
|
||||
* 定时任务白名单配置(仅允许访问的包名,如其他需要可以自行添加)
|
||||
*/
|
||||
public static final String[] JOB_WHITELIST_STR = { "com.muyu" };
|
||||
|
||||
/**
|
||||
* 定时任务违规的字符
|
||||
*/
|
||||
public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
|
||||
"org.springframework", "org.apache", "com.muyu.common.core.utils.file" };
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
package com.muyu.common.core.constant;
|
||||
|
||||
/**
|
||||
* 代码生成通用常量
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class GenConstants
|
||||
{
|
||||
/** 单表(增删改查) */
|
||||
public static final String TPL_CRUD = "crud";
|
||||
|
||||
/** 树表(增删改查) */
|
||||
public static final String TPL_TREE = "tree";
|
||||
|
||||
/** 主子表(增删改查) */
|
||||
public static final String TPL_SUB = "sub";
|
||||
|
||||
/** 树编码字段 */
|
||||
public static final String TREE_CODE = "treeCode";
|
||||
|
||||
/** 树父编码字段 */
|
||||
public static final String TREE_PARENT_CODE = "treeParentCode";
|
||||
|
||||
/** 树名称字段 */
|
||||
public static final String TREE_NAME = "treeName";
|
||||
|
||||
/** 上级菜单ID字段 */
|
||||
public static final String PARENT_MENU_ID = "parentMenuId";
|
||||
|
||||
/** 上级菜单名称字段 */
|
||||
public static final String PARENT_MENU_NAME = "parentMenuName";
|
||||
|
||||
/** 数据库字符串类型 */
|
||||
public static final String[] COLUMNTYPE_STR = { "char", "varchar", "nvarchar", "varchar2" };
|
||||
|
||||
/** 数据库文本类型 */
|
||||
public static final String[] COLUMNTYPE_TEXT = { "tinytext", "text", "mediumtext", "longtext" };
|
||||
|
||||
/** 数据库时间类型 */
|
||||
public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" };
|
||||
|
||||
/** 数据库数字类型 */
|
||||
public static final String[] COLUMNTYPE_NUMBER = { "tinyint", "smallint", "mediumint", "int", "number", "integer",
|
||||
"bigint", "float", "double", "decimal" };
|
||||
|
||||
/** 页面不需要编辑字段 */
|
||||
public static final String[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "del_flag" };
|
||||
|
||||
/** 页面不需要显示的列表字段 */
|
||||
public static final String[] COLUMNNAME_NOT_LIST = { "id", "create_by", "create_time", "del_flag", "update_by",
|
||||
"update_time" };
|
||||
|
||||
/** 页面不需要查询字段 */
|
||||
public static final String[] COLUMNNAME_NOT_QUERY = { "id", "create_by", "create_time", "del_flag", "update_by",
|
||||
"update_time", "remark" };
|
||||
|
||||
/** Entity基类字段 */
|
||||
public static final String[] BASE_ENTITY = { "createBy", "createTime", "updateBy", "updateTime", "remark" };
|
||||
|
||||
/** Tree基类字段 */
|
||||
public static final String[] TREE_ENTITY = { "parentName", "parentId", "orderNum", "ancestors" };
|
||||
|
||||
/** 文本框 */
|
||||
public static final String HTML_INPUT = "input";
|
||||
|
||||
/** 文本域 */
|
||||
public static final String HTML_TEXTAREA = "textarea";
|
||||
|
||||
/** 下拉框 */
|
||||
public static final String HTML_SELECT = "select";
|
||||
|
||||
/** 单选框 */
|
||||
public static final String HTML_RADIO = "radio";
|
||||
|
||||
/** 复选框 */
|
||||
public static final String HTML_CHECKBOX = "checkbox";
|
||||
|
||||
/** 日期控件 */
|
||||
public static final String HTML_DATETIME = "datetime";
|
||||
|
||||
/** 图片上传控件 */
|
||||
public static final String HTML_IMAGE_UPLOAD = "imageUpload";
|
||||
|
||||
/** 文件上传控件 */
|
||||
public static final String HTML_FILE_UPLOAD = "fileUpload";
|
||||
|
||||
/** 富文本控件 */
|
||||
public static final String HTML_EDITOR = "editor";
|
||||
|
||||
/** 字符串类型 */
|
||||
public static final String TYPE_STRING = "String";
|
||||
|
||||
/** 整型 */
|
||||
public static final String TYPE_INTEGER = "Integer";
|
||||
|
||||
/** 长整型 */
|
||||
public static final String TYPE_LONG = "Long";
|
||||
|
||||
/** 浮点型 */
|
||||
public static final String TYPE_DOUBLE = "Double";
|
||||
|
||||
/** 高精度计算类型 */
|
||||
public static final String TYPE_BIGDECIMAL = "BigDecimal";
|
||||
|
||||
/** 时间类型 */
|
||||
public static final String TYPE_DATE = "Date";
|
||||
|
||||
/** 模糊查询 */
|
||||
public static final String QUERY_LIKE = "LIKE";
|
||||
|
||||
/** 相等查询 */
|
||||
public static final String QUERY_EQ = "EQ";
|
||||
|
||||
/** 需要 */
|
||||
public static final String REQUIRE = "1";
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
package com.muyu.common.core.constant;
|
||||
|
||||
/**
|
||||
* 返回状态码
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class HttpStatus
|
||||
{
|
||||
/**
|
||||
* 操作成功
|
||||
*/
|
||||
public static final int SUCCESS = 200;
|
||||
|
||||
/**
|
||||
* 对象创建成功
|
||||
*/
|
||||
public static final int CREATED = 201;
|
||||
|
||||
/**
|
||||
* 请求已经被接受
|
||||
*/
|
||||
public static final int ACCEPTED = 202;
|
||||
|
||||
/**
|
||||
* 操作已经执行成功,但是没有返回数据
|
||||
*/
|
||||
public static final int NO_CONTENT = 204;
|
||||
|
||||
/**
|
||||
* 资源已被移除
|
||||
*/
|
||||
public static final int MOVED_PERM = 301;
|
||||
|
||||
/**
|
||||
* 重定向
|
||||
*/
|
||||
public static final int SEE_OTHER = 303;
|
||||
|
||||
/**
|
||||
* 资源没有被修改
|
||||
*/
|
||||
public static final int NOT_MODIFIED = 304;
|
||||
|
||||
/**
|
||||
* 参数列表错误(缺少,格式不匹配)
|
||||
*/
|
||||
public static final int BAD_REQUEST = 400;
|
||||
|
||||
/**
|
||||
* 未授权
|
||||
*/
|
||||
public static final int UNAUTHORIZED = 401;
|
||||
|
||||
/**
|
||||
* 访问受限,授权过期
|
||||
*/
|
||||
public static final int FORBIDDEN = 403;
|
||||
|
||||
/**
|
||||
* 资源,服务未找到
|
||||
*/
|
||||
public static final int NOT_FOUND = 404;
|
||||
|
||||
/**
|
||||
* 不允许的http方法
|
||||
*/
|
||||
public static final int BAD_METHOD = 405;
|
||||
|
||||
/**
|
||||
* 资源冲突,或者资源被锁
|
||||
*/
|
||||
public static final int CONFLICT = 409;
|
||||
|
||||
/**
|
||||
* 不支持的数据,媒体类型
|
||||
*/
|
||||
public static final int UNSUPPORTED_TYPE = 415;
|
||||
|
||||
/**
|
||||
* 系统内部错误
|
||||
*/
|
||||
public static final int ERROR = 500;
|
||||
|
||||
/**
|
||||
* 接口未实现
|
||||
*/
|
||||
public static final int NOT_IMPLEMENTED = 501;
|
||||
|
||||
/**
|
||||
* 系统警告消息
|
||||
*/
|
||||
public static final int WARN = 601;
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.muyu.common.core.constant;
|
||||
|
||||
import lombok.extern.slf4j.*;
|
||||
import org.springframework.stereotype.*;
|
||||
|
||||
/**
|
||||
* MQ常量
|
||||
* @author LiYongJie
|
||||
* @date 2024/4/9
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class MQQueueConstants {
|
||||
/**
|
||||
* 报警队列
|
||||
*/
|
||||
public static final String ALARM_QUEUE = "alarm";
|
||||
|
||||
/**
|
||||
* 故障队列
|
||||
*/
|
||||
public static final String FAULT_QUEUE = "fault";
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.muyu.common.core.constant;
|
||||
|
||||
/**
|
||||
* 任务调度通用常量
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class ScheduleConstants
|
||||
{
|
||||
public static final String TASK_CLASS_NAME = "TASK_CLASS_NAME";
|
||||
|
||||
/** 执行目标key */
|
||||
public static final String TASK_PROPERTIES = "TASK_PROPERTIES";
|
||||
|
||||
/** 默认 */
|
||||
public static final String MISFIRE_DEFAULT = "0";
|
||||
|
||||
/** 立即触发执行 */
|
||||
public static final String MISFIRE_IGNORE_MISFIRES = "1";
|
||||
|
||||
/** 触发一次执行 */
|
||||
public static final String MISFIRE_FIRE_AND_PROCEED = "2";
|
||||
|
||||
/** 不触发立即执行 */
|
||||
public static final String MISFIRE_DO_NOTHING = "3";
|
||||
|
||||
public enum Status
|
||||
{
|
||||
/**
|
||||
* 正常
|
||||
*/
|
||||
NORMAL("0"),
|
||||
/**
|
||||
* 暂停
|
||||
*/
|
||||
PAUSE("1");
|
||||
|
||||
private String value;
|
||||
|
||||
private Status(String value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package com.muyu.common.core.constant;
|
||||
|
||||
/**
|
||||
* 权限相关通用常量
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class SecurityConstants
|
||||
{
|
||||
/**
|
||||
* 用户ID字段
|
||||
*/
|
||||
public static final String DETAILS_USER_ID = "user_id";
|
||||
|
||||
/**
|
||||
* 用户名字段
|
||||
*/
|
||||
public static final String DETAILS_USERNAME = "username";
|
||||
|
||||
/**
|
||||
* 授权信息字段
|
||||
*/
|
||||
public static final String AUTHORIZATION_HEADER = "authorization";
|
||||
|
||||
/**
|
||||
* 请求来源
|
||||
*/
|
||||
public static final String FROM_SOURCE = "from-source";
|
||||
|
||||
/**
|
||||
* 内部请求
|
||||
*/
|
||||
public static final String INNER = "inner";
|
||||
|
||||
/**
|
||||
* 用户标识
|
||||
*/
|
||||
public static final String USER_KEY = "user_key";
|
||||
|
||||
/**
|
||||
* 登录用户
|
||||
*/
|
||||
public static final String LOGIN_USER = "login_user";
|
||||
|
||||
/**
|
||||
* 角色权限
|
||||
*/
|
||||
public static final String ROLE_PERMISSION = "role_permission";
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.muyu.common.core.constant;
|
||||
|
||||
/**
|
||||
* 服务名称
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class ServiceNameConstants
|
||||
{
|
||||
/**
|
||||
* 认证服务的serviceid
|
||||
*/
|
||||
public static final String AUTH_SERVICE = "muyu-auth";
|
||||
|
||||
/**
|
||||
* 系统模块的serviceid
|
||||
*/
|
||||
public static final String SYSTEM_SERVICE = "muyu-system";
|
||||
|
||||
/**
|
||||
* 文件服务的serviceid
|
||||
*/
|
||||
public static final String FILE_SERVICE = "muyu-file";
|
||||
|
||||
/**
|
||||
* 业务服务的serviceid
|
||||
*/
|
||||
public static final String BUSINESS_SERVICE = "muyu-business";
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.muyu.common.core.constant;
|
||||
|
||||
/**
|
||||
* Token的Key常量
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class TokenConstants
|
||||
{
|
||||
/**
|
||||
* 令牌自定义标识
|
||||
*/
|
||||
public static final String AUTHENTICATION = "Authorization";
|
||||
|
||||
/**
|
||||
* 令牌前缀
|
||||
*/
|
||||
public static final String PREFIX = "Bearer ";
|
||||
|
||||
/**
|
||||
* 令牌秘钥
|
||||
*/
|
||||
public final static String SECRET = "abcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package com.muyu.common.core.constant;
|
||||
|
||||
/**
|
||||
* 用户常量信息
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class UserConstants
|
||||
{
|
||||
/**
|
||||
* 平台内系统用户的唯一标志
|
||||
*/
|
||||
public static final String SYS_USER = "SYS_USER";
|
||||
|
||||
/** 正常状态 */
|
||||
public static final String NORMAL = "0";
|
||||
|
||||
/** 异常状态 */
|
||||
public static final String EXCEPTION = "1";
|
||||
|
||||
/** 用户封禁状态 */
|
||||
public static final String USER_DISABLE = "1";
|
||||
|
||||
/** 角色封禁状态 */
|
||||
public static final String ROLE_DISABLE = "1";
|
||||
|
||||
/** 部门正常状态 */
|
||||
public static final String DEPT_NORMAL = "0";
|
||||
|
||||
/** 部门停用状态 */
|
||||
public static final String DEPT_DISABLE = "1";
|
||||
|
||||
/** 字典正常状态 */
|
||||
public static final String DICT_NORMAL = "0";
|
||||
|
||||
/** 是否为系统默认(是) */
|
||||
public static final String YES = "Y";
|
||||
|
||||
/** 是否菜单外链(是) */
|
||||
public static final String YES_FRAME = "0";
|
||||
|
||||
/** 是否菜单外链(否) */
|
||||
public static final String NO_FRAME = "1";
|
||||
|
||||
/** 菜单类型(目录) */
|
||||
public static final String TYPE_DIR = "M";
|
||||
|
||||
/** 菜单类型(菜单) */
|
||||
public static final String TYPE_MENU = "C";
|
||||
|
||||
/** 菜单类型(按钮) */
|
||||
public static final String TYPE_BUTTON = "F";
|
||||
|
||||
/** Layout组件标识 */
|
||||
public final static String LAYOUT = "Layout";
|
||||
|
||||
/** ParentView组件标识 */
|
||||
public final static String PARENT_VIEW = "ParentView";
|
||||
|
||||
/** InnerLink组件标识 */
|
||||
public final static String INNER_LINK = "InnerLink";
|
||||
|
||||
/** 校验是否唯一的返回标识 */
|
||||
public final static boolean UNIQUE = true;
|
||||
public final static boolean NOT_UNIQUE = false;
|
||||
|
||||
/**
|
||||
* 用户名长度限制
|
||||
*/
|
||||
public static final int USERNAME_MIN_LENGTH = 2;
|
||||
|
||||
public static final int USERNAME_MAX_LENGTH = 20;
|
||||
|
||||
/**
|
||||
* 密码长度限制
|
||||
*/
|
||||
public static final int PASSWORD_MIN_LENGTH = 5;
|
||||
|
||||
public static final int PASSWORD_MAX_LENGTH = 20;
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
package com.muyu.common.core.context;
|
||||
|
||||
import com.alibaba.ttl.TransmittableThreadLocal;
|
||||
import com.muyu.common.core.constant.SecurityConstants;
|
||||
import com.muyu.common.core.text.Convert;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* 获取当前线程变量中的 用户id、用户名称、Token等信息
|
||||
* 注意: 必须在网关通过请求头的方法传入,同时在HeaderInterceptor拦截器设置值。 否则这里无法获取
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class SecurityContextHolder
|
||||
{
|
||||
private static final TransmittableThreadLocal<Map<String, Object>> THREAD_LOCAL = new TransmittableThreadLocal<>();
|
||||
|
||||
public static void set(String key, Object value)
|
||||
{
|
||||
Map<String, Object> map = getLocalMap();
|
||||
map.put(key, value == null ? StringUtils.EMPTY : value);
|
||||
}
|
||||
|
||||
public static String get(String key)
|
||||
{
|
||||
Map<String, Object> map = getLocalMap();
|
||||
return Convert.toStr(map.getOrDefault(key, StringUtils.EMPTY));
|
||||
}
|
||||
|
||||
public static <T> T get(String key, Class<T> clazz)
|
||||
{
|
||||
Map<String, Object> map = getLocalMap();
|
||||
return StringUtils.cast(map.getOrDefault(key, null));
|
||||
}
|
||||
|
||||
public static Map<String, Object> getLocalMap()
|
||||
{
|
||||
Map<String, Object> map = THREAD_LOCAL.get();
|
||||
if (map == null)
|
||||
{
|
||||
map = new ConcurrentHashMap<String, Object>();
|
||||
THREAD_LOCAL.set(map);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public static void setLocalMap(Map<String, Object> threadLocalMap)
|
||||
{
|
||||
THREAD_LOCAL.set(threadLocalMap);
|
||||
}
|
||||
|
||||
public static Long getUserId()
|
||||
{
|
||||
return Convert.toLong(get(SecurityConstants.DETAILS_USER_ID), 0L);
|
||||
}
|
||||
|
||||
public static void setUserId(String account)
|
||||
{
|
||||
set(SecurityConstants.DETAILS_USER_ID, account);
|
||||
}
|
||||
|
||||
public static String getUserName()
|
||||
{
|
||||
return get(SecurityConstants.DETAILS_USERNAME);
|
||||
}
|
||||
|
||||
public static void setUserName(String username)
|
||||
{
|
||||
set(SecurityConstants.DETAILS_USERNAME, username);
|
||||
}
|
||||
|
||||
public static String getUserKey()
|
||||
{
|
||||
return get(SecurityConstants.USER_KEY);
|
||||
}
|
||||
|
||||
public static void setUserKey(String userKey)
|
||||
{
|
||||
set(SecurityConstants.USER_KEY, userKey);
|
||||
}
|
||||
|
||||
public static String getPermission()
|
||||
{
|
||||
return get(SecurityConstants.ROLE_PERMISSION);
|
||||
}
|
||||
|
||||
public static void setPermission(String permissions)
|
||||
{
|
||||
set(SecurityConstants.ROLE_PERMISSION, permissions);
|
||||
}
|
||||
|
||||
public static void remove()
|
||||
{
|
||||
THREAD_LOCAL.remove();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.muyu.common.core.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 列表返回结果集
|
||||
* @author XiaoFan
|
||||
* @description: 列表返回结果集
|
||||
*/
|
||||
@Data
|
||||
public class PageResult<T> implements Serializable {
|
||||
/**
|
||||
* 总条数
|
||||
*/
|
||||
private long total;
|
||||
/**
|
||||
* 结果集合
|
||||
*/
|
||||
private List<T> list;
|
||||
public PageResult() {
|
||||
}
|
||||
public PageResult(long total, List<T> list) {
|
||||
this.total = total;
|
||||
this.list = list;
|
||||
}
|
||||
public static <T> PageResult<T> toPageResult(long total, List<T> list){
|
||||
return new PageResult(total , list);
|
||||
}
|
||||
public static <T> Result<PageResult<T>> toResult(long total, List<T> list){
|
||||
return Result.success(PageResult.toPageResult(total,list));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
package com.muyu.common.core.domain;
|
||||
|
||||
import com.muyu.common.core.constant.Constants;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* 响应信息主体
|
||||
*
|
||||
* @author coderjacky
|
||||
*/
|
||||
public class Result<T> implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 成功 */
|
||||
public static final int SUCCESS = Constants.SUCCESS;
|
||||
|
||||
/** 失败 */
|
||||
public static final int FAIL = Constants.FAIL;
|
||||
|
||||
private int code;
|
||||
|
||||
private String msg;
|
||||
|
||||
private T data;
|
||||
|
||||
public static <T> Result<T> success()
|
||||
{
|
||||
return restResult(null, SUCCESS, null);
|
||||
}
|
||||
|
||||
public static <T> Result<T> success(T data)
|
||||
{
|
||||
return restResult(data, SUCCESS, null);
|
||||
}
|
||||
|
||||
public static <T> Result<T> success(T data, String msg)
|
||||
{
|
||||
return restResult(data, SUCCESS, msg);
|
||||
}
|
||||
|
||||
public static <T> Result<T> error()
|
||||
{
|
||||
return restResult(null, FAIL, null);
|
||||
}
|
||||
|
||||
public static <T> Result<T> error(String msg)
|
||||
{
|
||||
return restResult(null, FAIL, msg);
|
||||
}
|
||||
|
||||
public static <T> Result<T> error(T data)
|
||||
{
|
||||
return restResult(data, FAIL, null);
|
||||
}
|
||||
|
||||
public static <T> Result<T> error(T data, String msg)
|
||||
{
|
||||
return restResult(data, FAIL, msg);
|
||||
}
|
||||
|
||||
public static <T> Result<T> error(int code, String msg)
|
||||
{
|
||||
return restResult(null, code, msg);
|
||||
}
|
||||
|
||||
private static <T> Result<T> restResult(T data, int code, String msg)
|
||||
{
|
||||
Result<T> apiResult = new Result<>();
|
||||
apiResult.setCode(code);
|
||||
apiResult.setData(data);
|
||||
apiResult.setMsg(msg);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
public int getCode()
|
||||
{
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code)
|
||||
{
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg()
|
||||
{
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg)
|
||||
{
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public T getData()
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(T data)
|
||||
{
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public static <T> Boolean isError(Result<T> ret)
|
||||
{
|
||||
return !isSuccess(ret);
|
||||
}
|
||||
|
||||
public static <T> Boolean isSuccess(Result<T> ret)
|
||||
{
|
||||
return Result.SUCCESS == ret.getCode();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.muyu.common.core.enums;
|
||||
|
||||
/**
|
||||
* 用户状态
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public enum UserStatus
|
||||
{
|
||||
OK("0", "正常"), DISABLE("1", "停用"), DELETED("2", "删除");
|
||||
|
||||
private final String code;
|
||||
private final String info;
|
||||
|
||||
UserStatus(String code, String info)
|
||||
{
|
||||
this.code = code;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public String getCode()
|
||||
{
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getInfo()
|
||||
{
|
||||
return info;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.muyu.common.core.exception;
|
||||
|
||||
/**
|
||||
* 验证码错误异常类
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class CaptchaException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public CaptchaException(String msg)
|
||||
{
|
||||
super(msg);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.muyu.common.core.exception;
|
||||
|
||||
/**
|
||||
* 检查异常
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class CheckedException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public CheckedException(String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
|
||||
public CheckedException(Throwable cause)
|
||||
{
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public CheckedException(String message, Throwable cause)
|
||||
{
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public CheckedException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace)
|
||||
{
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.muyu.common.core.exception;
|
||||
|
||||
/**
|
||||
* 演示模式异常
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class DemoModeException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public DemoModeException()
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package com.muyu.common.core.exception;
|
||||
|
||||
/**
|
||||
* 全局异常
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class GlobalException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 错误提示
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* 错误明细,内部调试错误
|
||||
*
|
||||
* 和 {@link CommonResult#getDetailMessage()} 一致的设计
|
||||
*/
|
||||
private String detailMessage;
|
||||
|
||||
/**
|
||||
* 空构造方法,避免反序列化问题
|
||||
*/
|
||||
public GlobalException()
|
||||
{
|
||||
}
|
||||
|
||||
public GlobalException(String message)
|
||||
{
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getDetailMessage()
|
||||
{
|
||||
return detailMessage;
|
||||
}
|
||||
|
||||
public GlobalException setDetailMessage(String detailMessage)
|
||||
{
|
||||
this.detailMessage = detailMessage;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage()
|
||||
{
|
||||
return message;
|
||||
}
|
||||
|
||||
public GlobalException setMessage(String message)
|
||||
{
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.muyu.common.core.exception;
|
||||
|
||||
/**
|
||||
* 内部认证异常
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class InnerAuthException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public InnerAuthException(String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.muyu.common.core.exception;
|
||||
|
||||
/**
|
||||
* 权限异常
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class PreAuthorizeException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public PreAuthorizeException()
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package com.muyu.common.core.exception;
|
||||
|
||||
/**
|
||||
* 业务异常
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public final class ServiceException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 错误码
|
||||
*/
|
||||
private Integer code;
|
||||
|
||||
/**
|
||||
* 错误提示
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* 错误明细,内部调试错误
|
||||
*
|
||||
* 和 {@link CommonResult#getDetailMessage()} 一致的设计
|
||||
*/
|
||||
private String detailMessage;
|
||||
|
||||
/**
|
||||
* 空构造方法,避免反序列化问题
|
||||
*/
|
||||
public ServiceException()
|
||||
{
|
||||
}
|
||||
|
||||
public ServiceException(String message)
|
||||
{
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public ServiceException(String message, Integer code)
|
||||
{
|
||||
this.message = message;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getDetailMessage()
|
||||
{
|
||||
return detailMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage()
|
||||
{
|
||||
return message;
|
||||
}
|
||||
|
||||
public Integer getCode()
|
||||
{
|
||||
return code;
|
||||
}
|
||||
|
||||
public ServiceException setMessage(String message)
|
||||
{
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ServiceException setDetailMessage(String detailMessage)
|
||||
{
|
||||
this.detailMessage = detailMessage;
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.muyu.common.core.exception;
|
||||
|
||||
/**
|
||||
* 工具类异常
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class UtilException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 8247610319171014183L;
|
||||
|
||||
public UtilException(Throwable e)
|
||||
{
|
||||
super(e.getMessage(), e);
|
||||
}
|
||||
|
||||
public UtilException(String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
|
||||
public UtilException(String message, Throwable throwable)
|
||||
{
|
||||
super(message, throwable);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.muyu.common.core.exception.auth;
|
||||
|
||||
/**
|
||||
* 未能通过的登录认证异常
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class NotLoginException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public NotLoginException(String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.muyu.common.core.exception.auth;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* 未能通过的权限认证异常
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class NotPermissionException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public NotPermissionException(String permission)
|
||||
{
|
||||
super(permission);
|
||||
}
|
||||
|
||||
public NotPermissionException(String[] permissions)
|
||||
{
|
||||
super(StringUtils.join(permissions, ","));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.muyu.common.core.exception.auth;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* 未能通过的角色认证异常
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class NotRoleException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public NotRoleException(String role)
|
||||
{
|
||||
super(role);
|
||||
}
|
||||
|
||||
public NotRoleException(String[] roles)
|
||||
{
|
||||
super(StringUtils.join(roles, ","));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
package com.muyu.common.core.exception.base;
|
||||
|
||||
/**
|
||||
* 基础异常
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class BaseException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 所属模块
|
||||
*/
|
||||
private String module;
|
||||
|
||||
/**
|
||||
* 错误码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 错误码对应的参数
|
||||
*/
|
||||
private Object[] args;
|
||||
|
||||
/**
|
||||
* 错误消息
|
||||
*/
|
||||
private String defaultMessage;
|
||||
|
||||
public BaseException(String module, String code, Object[] args, String defaultMessage)
|
||||
{
|
||||
this.module = module;
|
||||
this.code = code;
|
||||
this.args = args;
|
||||
this.defaultMessage = defaultMessage;
|
||||
}
|
||||
|
||||
public BaseException(String module, String code, Object[] args)
|
||||
{
|
||||
this(module, code, args, null);
|
||||
}
|
||||
|
||||
public BaseException(String module, String defaultMessage)
|
||||
{
|
||||
this(module, null, null, defaultMessage);
|
||||
}
|
||||
|
||||
public BaseException(String code, Object[] args)
|
||||
{
|
||||
this(null, code, args, null);
|
||||
}
|
||||
|
||||
public BaseException(String defaultMessage)
|
||||
{
|
||||
this(null, null, null, defaultMessage);
|
||||
}
|
||||
|
||||
public String getModule()
|
||||
{
|
||||
return module;
|
||||
}
|
||||
|
||||
public String getCode()
|
||||
{
|
||||
return code;
|
||||
}
|
||||
|
||||
public Object[] getArgs()
|
||||
{
|
||||
return args;
|
||||
}
|
||||
|
||||
public String getDefaultMessage()
|
||||
{
|
||||
return defaultMessage;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.muyu.common.core.exception.file;
|
||||
|
||||
import com.muyu.common.core.exception.base.BaseException;
|
||||
|
||||
/**
|
||||
* 文件信息异常类
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class FileException extends BaseException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public FileException(String code, Object[] args, String msg)
|
||||
{
|
||||
super("file", code, args, msg);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.muyu.common.core.exception.file;
|
||||
|
||||
/**
|
||||
* 文件名称超长限制异常类
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class FileNameLengthLimitExceededException extends FileException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public FileNameLengthLimitExceededException(int defaultFileNameLength)
|
||||
{
|
||||
super("upload.filename.exceed.length", new Object[] { defaultFileNameLength }, "the filename is too long");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.muyu.common.core.exception.file;
|
||||
|
||||
/**
|
||||
* 文件名大小限制异常类
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class FileSizeLimitExceededException extends FileException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public FileSizeLimitExceededException(long defaultMaxSize)
|
||||
{
|
||||
super("upload.exceed.maxSize", new Object[] { defaultMaxSize }, "the filesize is too large");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.muyu.common.core.exception.file;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
/**
|
||||
* 文件上传异常类
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class FileUploadException extends Exception
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Throwable cause;
|
||||
|
||||
public FileUploadException()
|
||||
{
|
||||
this(null, null);
|
||||
}
|
||||
|
||||
public FileUploadException(final String msg)
|
||||
{
|
||||
this(msg, null);
|
||||
}
|
||||
|
||||
public FileUploadException(String msg, Throwable cause)
|
||||
{
|
||||
super(msg);
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printStackTrace(PrintStream stream)
|
||||
{
|
||||
super.printStackTrace(stream);
|
||||
if (cause != null)
|
||||
{
|
||||
stream.println("Caused by:");
|
||||
cause.printStackTrace(stream);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printStackTrace(PrintWriter writer)
|
||||
{
|
||||
super.printStackTrace(writer);
|
||||
if (cause != null)
|
||||
{
|
||||
writer.println("Caused by:");
|
||||
cause.printStackTrace(writer);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Throwable getCause()
|
||||
{
|
||||
return cause;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package com.muyu.common.core.exception.file;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 文件上传 误异常类
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class InvalidExtensionException extends FileUploadException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String[] allowedExtension;
|
||||
private String extension;
|
||||
private String filename;
|
||||
|
||||
public InvalidExtensionException(String[] allowedExtension, String extension, String filename)
|
||||
{
|
||||
super("filename : [" + filename + "], extension : [" + extension + "], allowed extension : [" + Arrays.toString(allowedExtension) + "]");
|
||||
this.allowedExtension = allowedExtension;
|
||||
this.extension = extension;
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
public String[] getAllowedExtension()
|
||||
{
|
||||
return allowedExtension;
|
||||
}
|
||||
|
||||
public String getExtension()
|
||||
{
|
||||
return extension;
|
||||
}
|
||||
|
||||
public String getFilename()
|
||||
{
|
||||
return filename;
|
||||
}
|
||||
|
||||
public static class InvalidImageExtensionException extends InvalidExtensionException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public InvalidImageExtensionException(String[] allowedExtension, String extension, String filename)
|
||||
{
|
||||
super(allowedExtension, extension, filename);
|
||||
}
|
||||
}
|
||||
|
||||
public static class InvalidFlashExtensionException extends InvalidExtensionException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public InvalidFlashExtensionException(String[] allowedExtension, String extension, String filename)
|
||||
{
|
||||
super(allowedExtension, extension, filename);
|
||||
}
|
||||
}
|
||||
|
||||
public static class InvalidMediaExtensionException extends InvalidExtensionException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public InvalidMediaExtensionException(String[] allowedExtension, String extension, String filename)
|
||||
{
|
||||
super(allowedExtension, extension, filename);
|
||||
}
|
||||
}
|
||||
|
||||
public static class InvalidVideoExtensionException extends InvalidExtensionException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public InvalidVideoExtensionException(String[] allowedExtension, String extension, String filename)
|
||||
{
|
||||
super(allowedExtension, extension, filename);
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue