mirror of
https://gitee.com/y_project/RuoYi-Cloud.git
synced 2026-01-27 20:21:56 +08:00
Compare commits
122 Commits
c148fc156a
...
springboot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df0f7d16a4 | ||
|
|
a5ced3b531 | ||
|
|
2d9ce89b2e | ||
|
|
ec8e955955 | ||
|
|
0398aa0333 | ||
|
|
14063cd6ed | ||
|
|
a8b6799d8d | ||
|
|
a492ebf41e | ||
|
|
8d6790b358 | ||
|
|
c763a0f356 | ||
|
|
227f62dbe2 | ||
|
|
e5d494d018 | ||
|
|
0f9e698fb5 | ||
|
|
3d4c6f4fa1 | ||
|
|
40a52af8ee | ||
|
|
9e67041290 | ||
|
|
c17ed8bb04 | ||
|
|
64e5288625 | ||
|
|
afe8236b42 | ||
|
|
21ee628202 | ||
|
|
b54e00529a | ||
|
|
3f4484107a | ||
|
|
341c9a8851 | ||
|
|
81bfef9a3c | ||
|
|
7238dbb807 | ||
|
|
ff9068b9d4 | ||
|
|
ea8351cce0 | ||
|
|
8ef3b5490e | ||
|
|
1284f6763f | ||
|
|
eeb6303200 | ||
|
|
513335d9db | ||
|
|
1a373f41e6 | ||
|
|
e73aa3b497 | ||
|
|
d5d6b9789c | ||
|
|
6b0bd81f56 | ||
|
|
0be3a0720d | ||
|
|
83e5f2e24d | ||
|
|
942df70c21 | ||
|
|
32cb5e8851 | ||
|
|
ffce2af11e | ||
|
|
aeb698985b | ||
|
|
ec15604725 | ||
|
|
67642ed19a | ||
|
|
604345f72b | ||
|
|
eb01cde0b1 | ||
|
|
217119575d | ||
|
|
86d5eae71f | ||
|
|
aa72ac20d1 | ||
|
|
b1e0418c77 | ||
|
|
8e32654d46 | ||
|
|
c8c0127185 | ||
|
|
46e75b4d7e | ||
|
|
a735ed90f7 | ||
|
|
e64bb2d7be | ||
|
|
496d6113c4 | ||
|
|
f871171d32 | ||
|
|
a36e19d88e | ||
|
|
235728fdb9 | ||
|
|
381077253d | ||
|
|
5f3a93d12e | ||
|
|
e22323971e | ||
|
|
f593d36745 | ||
|
|
9978594069 | ||
|
|
9026c8e49e | ||
|
|
c359924d4e | ||
|
|
f8d726f966 | ||
|
|
cbdbc91784 | ||
|
|
3a61e8df5a | ||
|
|
9d242f0182 | ||
|
|
2afad16eba | ||
|
|
637a628cfc | ||
|
|
785f3c3515 | ||
|
|
85dc2aef8f | ||
|
|
3a91cb47a4 | ||
|
|
7d611b754f | ||
|
|
6be79bd7d4 | ||
|
|
13942b41b2 | ||
|
|
583f653890 | ||
|
|
9ebb230d66 | ||
|
|
65cc92286f | ||
|
|
fe1badd9a6 | ||
|
|
48830b1181 | ||
|
|
4257ca91b2 | ||
|
|
15b2502ffa | ||
|
|
eb035d179b | ||
|
|
b959a91d26 | ||
|
|
28377670bb | ||
|
|
1215d5d474 | ||
|
|
7b4fbf4e13 | ||
|
|
eaeb8d759e | ||
|
|
bba6433113 | ||
|
|
61a49b5951 | ||
|
|
8d631d1325 | ||
|
|
d302cdb324 | ||
|
|
33af14461f | ||
|
|
cff2e611c5 | ||
|
|
72bc8bfc53 | ||
|
|
4a6603d8b3 | ||
|
|
2b425e62e4 | ||
|
|
a837f49291 | ||
|
|
3a2e434a53 | ||
|
|
08484eea75 | ||
|
|
a5f3be78ec | ||
|
|
0fc5c7199e | ||
|
|
1af0861a3b | ||
|
|
bea8f763bb | ||
|
|
78d958ec8c | ||
|
|
101f7e3cf7 | ||
|
|
b92fb20439 | ||
|
|
264d6e320e | ||
|
|
1f0eb72a58 | ||
|
|
eb2e089d57 | ||
|
|
efdc96abb6 | ||
|
|
64dc968949 | ||
|
|
dcc303a8d4 | ||
|
|
cc0c6deb38 | ||
|
|
c2157d7f2a | ||
|
|
f6c8be3285 | ||
|
|
4f8c2215b3 | ||
|
|
6f94f4d1e0 | ||
|
|
f2aad7a76c | ||
|
|
c50a2b4200 |
@@ -1,11 +1,11 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<img alt="logo" src="https://oscimg.oschina.net/oscnet/up-b99b286755aef70355a7084753f89cdb7c9.png">
|
<img alt="logo" src="https://oscimg.oschina.net/oscnet/up-b99b286755aef70355a7084753f89cdb7c9.png">
|
||||||
</p>
|
</p>
|
||||||
<h1 align="center" style="margin: 30px 0 30px; font-weight: bold;">RuoYi v3.6.5</h1>
|
<h1 align="center" style="margin: 30px 0 30px; font-weight: bold;">RuoYi v3.6.7</h1>
|
||||||
<h4 align="center">基于 Vue/Element UI 和 Spring Boot/Spring Cloud & Alibaba 前后端分离的分布式微服务架构</h4>
|
<h4 align="center">基于 Vue/Element UI 和 Spring Boot/Spring Cloud & Alibaba 前后端分离的分布式微服务架构</h4>
|
||||||
<p align="center">
|
<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/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.5-brightgreen.svg"></a>
|
<a href="https://gitee.com/y_project/RuoYi-Cloud"><img src="https://img.shields.io/badge/RuoYi-v3.6.7-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>
|
<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>
|
</p>
|
||||||
|
|
||||||
@@ -126,4 +126,4 @@ com.ruoyi
|
|||||||
|
|
||||||
## 若依微服务交流群
|
## 若依微服务交流群
|
||||||
|
|
||||||
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) [](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=lx1uEdEDuxeM7rUvF3qmlFdqKqdJ5Z-R&authKey=rgyPW9yhhh4IIURKVFa6NgP3qiqH04WAzrJ0trsgkr3pjzm6sKIOGyA58oOjoj%2FJ&noverify=0&group_code=158753145) 点击按钮入群。
|
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) [](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=lx1uEdEDuxeM7rUvF3qmlFdqKqdJ5Z-R&authKey=rgyPW9yhhh4IIURKVFa6NgP3qiqH04WAzrJ0trsgkr3pjzm6sKIOGyA58oOjoj%2FJ&noverify=0&group_code=158753145) [](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=Kuaw0Xdlw2Nlgn6s8h9elzuquHGxGObD&authKey=cSrQcWQ%2BzQZAFFrwxaR%2BbzcumX4WRduZnd1O6JO1dlclQMiu%2BKwxAy8t2JfNp67V&noverify=0&group_code=112869560) 点击按钮入群。
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
# Kubernates 部署Ruoyi-Cloud项目
|
|
||||||
|
|
||||||
本部署所用到的k8s配置均为简易版,仅作为初步入门学习使用,有不合理的地方还请见谅。
|
|
||||||
|
|
||||||
### 后期考虑功能:
|
|
||||||
* HPA自动扩缩容
|
|
||||||
* MySQL主从、Redis集群、服务集群
|
|
||||||
* ELK日志收集
|
|
||||||
|
|
||||||
## 容器分布
|
|
||||||
~~~
|
|
||||||
namespace
|
|
||||||
├── redis
|
|
||||||
│ └── redis // StatefulSet
|
|
||||||
├── kube-ruoyi
|
|
||||||
│ └── ruoyi-mysql // Deployment
|
|
||||||
│ └── ruoyi-nacos
|
|
||||||
│ └── ruoyi-nginx
|
|
||||||
│ └── ruoyi-sentinel
|
|
||||||
│ └── ruoyi-gateway
|
|
||||||
│ └── ruoyi-auth
|
|
||||||
│ └── ruoyi-system
|
|
||||||
│ └── ruoyi-gen
|
|
||||||
│ └── ruoyi-job
|
|
||||||
│ └── ruoyi-file
|
|
||||||
│ └── ruoyi-monitor
|
|
||||||
│ └── elasticsearch
|
|
||||||
│ └── skywalking
|
|
||||||
│ └── skywalking-ui
|
|
||||||
├── minio
|
|
||||||
│ └── minio
|
|
||||||
├── monitor-sa
|
|
||||||
│ └── node-exporter
|
|
||||||
│ └── prometheus-server
|
|
||||||
│ └── monitoring-grafana
|
|
||||||
~~~
|
|
||||||
|
|
||||||
## 部署顺序及要点
|
|
||||||
1. Redis
|
|
||||||
2. MySQL,手动Dockerfile打包镜像,初始化准备好的数据脚本。使用了Secret加密密码等配置。
|
|
||||||
3. Nacos, 配置好MODE=standalone,使用configMap设置数据库。
|
|
||||||
4. Sentinel
|
|
||||||
5. Gateway,本服务需要用Dockerfile打包镜像,否则会报错。其他RuoYi服务可以直接使用spring-boot的image命令一键打包生成镜像[每个服务都有使用额外的SpringBoot配置文件(bootstrap-k8s.yml)加入到服务中,同时在原配置文件中把active换成${SPRING_PROFILES_ACTIVE:dev}后再打包,以读取deployment的env变量。启动服务前记得提前在nacos中克隆,新增服务配置以把dev改成k8s(deployment中启动的环境是SPRING_PROFILES_ACTIVE=k8s),修改好Redis地址(redis.redis)、MySQL地址(ruoyi-mysql)、Sentinel地址(ruoyi-sentinel)]
|
|
||||||
6. Nginx,部署之前先打包好前端静态文件,使用本地磁盘方式挂载到容器 (注:我使用的是Window的DockerDesktop启动的K8s,挂载磁盘路径必须带/run/desktop/mnt/host),修改好nginx配置ruoyi-gateway就可以启动(启动后输入localhost:30080就可以访问前端项目)。
|
|
||||||
7. Auth
|
|
||||||
8. System,配置好后就可以登录了
|
|
||||||
9. Gen
|
|
||||||
10. Job
|
|
||||||
11. File,改成minio服务之后需要修改静态文件中读取文件的端口地址
|
|
||||||
12. Monitor,需要修改前端静态文件中的Monitor端口地址
|
|
||||||
13. Minio,挂载本地文件。修改ruoyi-file服务中@Primary注释改到MinioServer上以使用Minio服务(记得修改nacos配置)
|
|
||||||
14. Elasticsearch,部署文件一并放入到了skywalking文件夹中
|
|
||||||
15. skywalking,需要在Java服务中使用agent进行跟踪(自制agent镜像然后使用initContainers方式挂载到同一个容器,模板放到了agent-in-server文件)
|
|
||||||
16. skywalking-ui
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
name: minio
|
|
||||||
name: minio
|
|
||||||
namespace: minio
|
|
||||||
spec:
|
|
||||||
replicas: 1
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: minio
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: minio
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: minio
|
|
||||||
image: minio/minio
|
|
||||||
imagePullPolicy: Always
|
|
||||||
ports:
|
|
||||||
- containerPort: 9000
|
|
||||||
name: tcp
|
|
||||||
- containerPort: 9090
|
|
||||||
protocol: TCP
|
|
||||||
name: console
|
|
||||||
command:
|
|
||||||
- /bin/sh
|
|
||||||
- -c
|
|
||||||
- minio server /data --console-address ":9090"
|
|
||||||
env:
|
|
||||||
- name: MINIO_ACCESS_KEY
|
|
||||||
value: minioadmin
|
|
||||||
- name: MINIO_SECRET_KEY
|
|
||||||
value: minioadmin
|
|
||||||
readinessProbe:
|
|
||||||
failureThreshold: 3
|
|
||||||
httpGet:
|
|
||||||
path: /minio/health/ready
|
|
||||||
port: 9000
|
|
||||||
scheme: HTTP
|
|
||||||
initialDelaySeconds: 10
|
|
||||||
periodSeconds: 10
|
|
||||||
successThreshold: 1
|
|
||||||
timeoutSeconds: 5
|
|
||||||
volumeMounts:
|
|
||||||
- mountPath: /data
|
|
||||||
name: minio-data
|
|
||||||
volumes:
|
|
||||||
- name: minio-data
|
|
||||||
hostPath:
|
|
||||||
path: /run/desktop/mnt/host/c/k8sVolume/minio/data
|
|
||||||
type: Directory
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: Namespace
|
|
||||||
metadata:
|
|
||||||
name: minio
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: minio
|
|
||||||
namespace: minio
|
|
||||||
labels:
|
|
||||||
app: minio
|
|
||||||
spec:
|
|
||||||
type: NodePort
|
|
||||||
publishNotReadyAddresses: true
|
|
||||||
ports:
|
|
||||||
- port: 9000
|
|
||||||
name: tcp
|
|
||||||
targetPort: 9000
|
|
||||||
- port: 9090
|
|
||||||
name: console
|
|
||||||
targetPort: 9090
|
|
||||||
nodePort: 30090
|
|
||||||
selector:
|
|
||||||
app: minio
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: Namespace
|
|
||||||
metadata:
|
|
||||||
name: monitor-sa
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
apiVersion: apps/v1
|
|
||||||
kind: DaemonSet
|
|
||||||
metadata:
|
|
||||||
name: node-exporter
|
|
||||||
namespace: monitor-sa
|
|
||||||
labels:
|
|
||||||
name: node-exporter
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
name: node-exporter
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
name: node-exporter
|
|
||||||
spec:
|
|
||||||
hostPID: true
|
|
||||||
hostIPC: true
|
|
||||||
hostNetwork: true # 共享宿主机网络和进程
|
|
||||||
containers:
|
|
||||||
- name: node-exporter
|
|
||||||
image: prom/node-exporter:v0.16.0
|
|
||||||
imagePullPolicy: IfNotPresent
|
|
||||||
ports:
|
|
||||||
- containerPort: 9100 # 容器暴露端口为9100
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
cpu: 0.15
|
|
||||||
securityContext:
|
|
||||||
privileged: true # 开启特权模式
|
|
||||||
args:
|
|
||||||
- --path.procfs
|
|
||||||
- /host/proc
|
|
||||||
- --path.sysfs
|
|
||||||
- /host/sys
|
|
||||||
- --collector.filesystem.ignored-mount-points
|
|
||||||
- '"^/(sys|proc|dev|host|etc)($|/)"'
|
|
||||||
volumeMounts: # 挂载宿主机目录以收集宿主机信息
|
|
||||||
- name: dev
|
|
||||||
mountPath: /host/dev
|
|
||||||
- name: proc
|
|
||||||
mountPath: /host/proc
|
|
||||||
- name: sys
|
|
||||||
mountPath: /host/sys
|
|
||||||
- name: rootfs
|
|
||||||
mountPath: /rootfs
|
|
||||||
tolerations: # 定义容忍度,使其可调度到默认有污点的master
|
|
||||||
- key: "node-role.kubernetes.io/master"
|
|
||||||
operator: "Exists"
|
|
||||||
effect: "NoSchedule"
|
|
||||||
volumes: # 定义存储卷
|
|
||||||
- name: proc
|
|
||||||
hostPath:
|
|
||||||
path: /proc
|
|
||||||
- name: dev
|
|
||||||
hostPath:
|
|
||||||
path: /dev
|
|
||||||
- name: sys
|
|
||||||
hostPath:
|
|
||||||
path: /sys
|
|
||||||
- name: rootfs
|
|
||||||
hostPath:
|
|
||||||
path: /
|
|
||||||
@@ -1,169 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: ConfigMap #
|
|
||||||
metadata:
|
|
||||||
name: prometheus-config
|
|
||||||
namespace: kube-system
|
|
||||||
labels:
|
|
||||||
kubernetes.io/cluster-service: "true"
|
|
||||||
addonmanager.kubernetes.io/mode: EnsureExists
|
|
||||||
data:
|
|
||||||
prometheus.yml: |
|
|
||||||
rule_files:
|
|
||||||
- /etc/config/rules/*.rules
|
|
||||||
|
|
||||||
scrape_configs:
|
|
||||||
- job_name: prometheus
|
|
||||||
static_configs:
|
|
||||||
- targets:
|
|
||||||
- localhost:9090
|
|
||||||
|
|
||||||
- job_name: kubernetes-nodes
|
|
||||||
scrape_interval: 30s
|
|
||||||
static_configs:
|
|
||||||
- targets:
|
|
||||||
- 192.168.73.135:9100
|
|
||||||
- 192.168.73.138:9100
|
|
||||||
- 192.168.73.139:9100
|
|
||||||
- 192.168.73.140:9100
|
|
||||||
|
|
||||||
- job_name: kubernetes-apiservers
|
|
||||||
kubernetes_sd_configs:
|
|
||||||
- role: endpoints
|
|
||||||
relabel_configs:
|
|
||||||
- action: keep
|
|
||||||
regex: default;kubernetes;https
|
|
||||||
source_labels:
|
|
||||||
- __meta_kubernetes_namespace
|
|
||||||
- __meta_kubernetes_service_name
|
|
||||||
- __meta_kubernetes_endpoint_port_name
|
|
||||||
scheme: https
|
|
||||||
tls_config:
|
|
||||||
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
|
|
||||||
insecure_skip_verify: true
|
|
||||||
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
|
|
||||||
|
|
||||||
- job_name: kubernetes-nodes-kubelet
|
|
||||||
kubernetes_sd_configs:
|
|
||||||
- role: node
|
|
||||||
relabel_configs:
|
|
||||||
- action: labelmap
|
|
||||||
regex: __meta_kubernetes_node_label_(.+)
|
|
||||||
scheme: https
|
|
||||||
tls_config:
|
|
||||||
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
|
|
||||||
insecure_skip_verify: true
|
|
||||||
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
|
|
||||||
|
|
||||||
- job_name: kubernetes-nodes-cadvisor
|
|
||||||
kubernetes_sd_configs:
|
|
||||||
- role: node
|
|
||||||
relabel_configs:
|
|
||||||
- action: labelmap
|
|
||||||
regex: __meta_kubernetes_node_label_(.+)
|
|
||||||
- target_label: __metrics_path__
|
|
||||||
replacement: /metrics/cadvisor
|
|
||||||
scheme: https
|
|
||||||
tls_config:
|
|
||||||
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
|
|
||||||
insecure_skip_verify: true
|
|
||||||
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
|
|
||||||
|
|
||||||
- job_name: kubernetes-service-endpoints
|
|
||||||
kubernetes_sd_configs:
|
|
||||||
- role: endpoints
|
|
||||||
relabel_configs:
|
|
||||||
- action: keep
|
|
||||||
regex: true
|
|
||||||
source_labels:
|
|
||||||
- __meta_kubernetes_service_annotation_prometheus_io_scrape
|
|
||||||
- action: replace
|
|
||||||
regex: (https?)
|
|
||||||
source_labels:
|
|
||||||
- __meta_kubernetes_service_annotation_prometheus_io_scheme
|
|
||||||
target_label: __scheme__
|
|
||||||
- action: replace
|
|
||||||
regex: (.+)
|
|
||||||
source_labels:
|
|
||||||
- __meta_kubernetes_service_annotation_prometheus_io_path
|
|
||||||
target_label: __metrics_path__
|
|
||||||
- action: replace
|
|
||||||
regex: ([^:]+)(?::\d+)?;(\d+)
|
|
||||||
replacement: $1:$2
|
|
||||||
source_labels:
|
|
||||||
- __address__
|
|
||||||
- __meta_kubernetes_service_annotation_prometheus_io_port
|
|
||||||
target_label: __address__
|
|
||||||
- action: labelmap
|
|
||||||
regex: __meta_kubernetes_service_label_(.+)
|
|
||||||
- action: replace
|
|
||||||
source_labels:
|
|
||||||
- __meta_kubernetes_namespace
|
|
||||||
target_label: kubernetes_namespace
|
|
||||||
- action: replace
|
|
||||||
source_labels:
|
|
||||||
- __meta_kubernetes_service_name
|
|
||||||
target_label: kubernetes_name
|
|
||||||
|
|
||||||
- job_name: kubernetes-services
|
|
||||||
kubernetes_sd_configs:
|
|
||||||
- role: service
|
|
||||||
metrics_path: /probe
|
|
||||||
params:
|
|
||||||
module:
|
|
||||||
- http_2xx
|
|
||||||
relabel_configs:
|
|
||||||
- action: keep
|
|
||||||
regex: true
|
|
||||||
source_labels:
|
|
||||||
- __meta_kubernetes_service_annotation_prometheus_io_probe
|
|
||||||
- source_labels:
|
|
||||||
- __address__
|
|
||||||
target_label: __param_target
|
|
||||||
- replacement: blackbox
|
|
||||||
target_label: __address__
|
|
||||||
- source_labels:
|
|
||||||
- __param_target
|
|
||||||
target_label: instance
|
|
||||||
- action: labelmap
|
|
||||||
regex: __meta_kubernetes_service_label_(.+)
|
|
||||||
- source_labels:
|
|
||||||
- __meta_kubernetes_namespace
|
|
||||||
target_label: kubernetes_namespace
|
|
||||||
- source_labels:
|
|
||||||
- __meta_kubernetes_service_name
|
|
||||||
target_label: kubernetes_name
|
|
||||||
|
|
||||||
- job_name: kubernetes-pods
|
|
||||||
kubernetes_sd_configs:
|
|
||||||
- role: pod
|
|
||||||
relabel_configs:
|
|
||||||
- action: keep
|
|
||||||
regex: true
|
|
||||||
source_labels:
|
|
||||||
- __meta_kubernetes_pod_annotation_prometheus_io_scrape
|
|
||||||
- action: replace
|
|
||||||
regex: (.+)
|
|
||||||
source_labels:
|
|
||||||
- __meta_kubernetes_pod_annotation_prometheus_io_path
|
|
||||||
target_label: __metrics_path__
|
|
||||||
- action: replace
|
|
||||||
regex: ([^:]+)(?::\d+)?;(\d+)
|
|
||||||
replacement: $1:$2
|
|
||||||
source_labels:
|
|
||||||
- __address__
|
|
||||||
- __meta_kubernetes_pod_annotation_prometheus_io_port
|
|
||||||
target_label: __address__
|
|
||||||
- action: labelmap
|
|
||||||
regex: __meta_kubernetes_pod_label_(.+)
|
|
||||||
- action: replace
|
|
||||||
source_labels:
|
|
||||||
- __meta_kubernetes_namespace
|
|
||||||
target_label: kubernetes_namespace
|
|
||||||
- action: replace
|
|
||||||
source_labels:
|
|
||||||
- __meta_kubernetes_pod_name
|
|
||||||
target_label: kubernetes_pod_name
|
|
||||||
alerting:
|
|
||||||
alertmanagers:
|
|
||||||
- static_configs:
|
|
||||||
- targets: ["alertmanager:80"]
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
存放sql目录下的所有脚本,用于docker自动执行。
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# 基础镜像
|
|
||||||
FROM mysql:5.7
|
|
||||||
|
|
||||||
# 执行sql脚本
|
|
||||||
ADD ./db/*.sql /docker-entrypoint-initdb.d/
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: ruoyi-mysql #指定deployment的名字
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
labels:
|
|
||||||
app: ruoyi-mysql-local
|
|
||||||
spec: #规约
|
|
||||||
replicas: 1 #pod的副本数量,就是希望创建多少个pod的副本.可p选字段。它的默认值是1。
|
|
||||||
selector: #selector 字段定义 Deployment 如何查找要管理的 Pods。必须匹配 .spec.template.metadata.labels,否则请求会被 API 拒绝。
|
|
||||||
matchLabels:
|
|
||||||
app: ruoyi-mysql-local
|
|
||||||
template: #Deployment Pod 模板;它和 Pod 的语法规则完全相同。 只是这里它是嵌套的,因此不需要 apiVersion 或 kind。
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: ruoyi-mysql-local
|
|
||||||
spec: #pod模板规约
|
|
||||||
containers: #容器
|
|
||||||
- name: ruoyi-mysql #容器的名称
|
|
||||||
image: ruoyi/mysql:5.7 #容器使用的镜像
|
|
||||||
ports:
|
|
||||||
- containerPort: 3306
|
|
||||||
volumeMounts:
|
|
||||||
- name: mysql-local-data #pv的name
|
|
||||||
mountPath: /var/lib/mysql #MySQL容器的数据都是存在这个目录的,要对这个目录做数据持久化
|
|
||||||
env:
|
|
||||||
- name: MYSQL_ROOT_PASSWORD
|
|
||||||
valueFrom: # Read environment variables from kubernetes secrets
|
|
||||||
secretKeyRef:
|
|
||||||
name: ruoyi-mysql-secret
|
|
||||||
key: mysql-root-pass
|
|
||||||
- name: MYSQL_USER
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: ruoyi-mysql-secret
|
|
||||||
key: mysql-user
|
|
||||||
- name: MYSQL_PASSWORD
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: ruoyi-mysql-secret
|
|
||||||
key: mysql-password
|
|
||||||
volumes:
|
|
||||||
- name: mysql-local-data #pv的name
|
|
||||||
hostPath:
|
|
||||||
path: /run/desktop/mnt/host/c/k8sVolume/mysql/data
|
|
||||||
type: Directory
|
|
||||||
restartPolicy: Always #Deployment 中的 Pod 模板必须指定适当的标签和适当的重新启动策略。只有 .spec.template.spec.restartPolicy 等于 Always 才是被允许的,这也是在没有指定时的默认设置
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: PersistentVolume
|
|
||||||
metadata:
|
|
||||||
name: mysql-pv
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
spec:
|
|
||||||
capacity:
|
|
||||||
storage: 3Gi
|
|
||||||
accessModes:
|
|
||||||
- ReadWriteMany
|
|
||||||
persistentVolumeReclaimPolicy: Retain # 手动删除
|
|
||||||
storageClassName: hostpath #表明这个pv所属的storageClass
|
|
||||||
hostPath:
|
|
||||||
path: /mnt/data #节点上卷的完整路径。(必须是存在的路径,不然容器无法创建,deployment会报错)可以是目录或块设备(磁盘、分区…)。
|
|
||||||
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: PersistentVolumeClaim
|
|
||||||
metadata:
|
|
||||||
name: mysql-pvc-local
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
spec:
|
|
||||||
accessModes: #访问模式 申领在请求具有特定访问模式的存储时,使用与卷相同的访问模式约定。
|
|
||||||
- ReadWriteMany
|
|
||||||
volumeMode: Filesystem #卷模式
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
storage: 1Gi
|
|
||||||
storageClassName: hostpath # 此处须显式设置空字符串或指定值,否则会被设置为默认的 StorageClass
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: Secret
|
|
||||||
metadata:
|
|
||||||
name: ruoyi-mysql-secret
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
type: Opaque #base-64加密
|
|
||||||
data:
|
|
||||||
mysql-root-pass: cGFzc3dvcmQ=
|
|
||||||
mysql-user: YWRtaW4=
|
|
||||||
mysql-password: MTIzNDU2
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: ruoyi-mysql
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
spec:
|
|
||||||
ports:
|
|
||||||
- port: 3306
|
|
||||||
nodePort: 30060
|
|
||||||
selector:
|
|
||||||
app: ruoyi-mysql-local # 该 Service 会将所有具有标签 app: mysql-labels-app暴露到一个抽象的 Service 端口上(targetPort:容器接收流量的端口;port:可任意取值的抽象的 Service 端口,其他 Pod 通过该端口访问 Service
|
|
||||||
type: NodePort
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: ConfigMap
|
|
||||||
metadata:
|
|
||||||
name: ruoyi-nacos-config
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
data:
|
|
||||||
application.properties: |
|
|
||||||
spring.datasource.platform=mysql
|
|
||||||
db.num=1
|
|
||||||
db.url.0=jdbc:mysql://ruoyi-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/ruoyi/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.plugin.nacos.token.expire.seconds=18000
|
|
||||||
nacos.core.auth.plugin.nacos.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
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: ruoyi-nacos
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
spec:
|
|
||||||
replicas: 1
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: ruoyi-nacos
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: ruoyi-nacos
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: ruoyi-nacos
|
|
||||||
image: nacos/nacos-server
|
|
||||||
imagePullPolicy: Always
|
|
||||||
ports:
|
|
||||||
- containerPort: 8848
|
|
||||||
name: client
|
|
||||||
- containerPort: 9848
|
|
||||||
name: client-rpc
|
|
||||||
- containerPort: 9849
|
|
||||||
name: raft-rpc
|
|
||||||
env:
|
|
||||||
- name: MODE
|
|
||||||
value: standalone
|
|
||||||
volumeMounts:
|
|
||||||
- mountPath: /home/nacos/conf/application.properties
|
|
||||||
name: nacos-conf
|
|
||||||
subPath: application.properties
|
|
||||||
volumes:
|
|
||||||
- name: nacos-conf
|
|
||||||
configMap:
|
|
||||||
name: ruoyi-nacos-config
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: ruoyi-nacos
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
labels:
|
|
||||||
app: ruoyi-nacos
|
|
||||||
spec:
|
|
||||||
type: NodePort
|
|
||||||
publishNotReadyAddresses: true
|
|
||||||
ports:
|
|
||||||
- port: 8848
|
|
||||||
name: server
|
|
||||||
targetPort: 8848
|
|
||||||
nodePort: 30848
|
|
||||||
- port: 9848
|
|
||||||
name: client-rpc
|
|
||||||
targetPort: 9848
|
|
||||||
- port: 9849
|
|
||||||
name: raft-rpc
|
|
||||||
targetPort: 9849
|
|
||||||
selector:
|
|
||||||
app: ruoyi-nacos
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: ConfigMap
|
|
||||||
metadata:
|
|
||||||
name: ruoyi-nginx-config
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
data:
|
|
||||||
nginx.conf: |
|
|
||||||
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/ruoyi/projects/ruoyi-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://ruoyi-gateway:8080/;
|
|
||||||
}
|
|
||||||
error_page 500 502 503 504 /50x.html;
|
|
||||||
location = /50x.html {
|
|
||||||
root html;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: ruoyi-nginx
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
spec:
|
|
||||||
replicas: 1
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: ruoyi-nginx
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: ruoyi-nginx
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: ruoyi-nginx
|
|
||||||
image: nginx
|
|
||||||
imagePullPolicy: Always
|
|
||||||
ports:
|
|
||||||
- containerPort: 80
|
|
||||||
volumeMounts:
|
|
||||||
- mountPath: /etc/nginx/nginx.conf
|
|
||||||
name: nginx-conf
|
|
||||||
subPath: nginx.conf
|
|
||||||
- mountPath: /home/ruoyi/projects/ruoyi-ui
|
|
||||||
name: local-path #/usr/share/nginx/html 挂载到volumes中server+path
|
|
||||||
volumes:
|
|
||||||
- name: nginx-conf
|
|
||||||
configMap:
|
|
||||||
name: ruoyi-nginx-config
|
|
||||||
- name: local-path
|
|
||||||
hostPath:
|
|
||||||
path: /run/desktop/mnt/host/c/k8sVolume/dist
|
|
||||||
type: Directory
|
|
||||||
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: ruoyi-nginx
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
labels:
|
|
||||||
name: ruoyi-nginx
|
|
||||||
spec:
|
|
||||||
type: NodePort
|
|
||||||
ports:
|
|
||||||
- port: 80
|
|
||||||
targetPort: 80
|
|
||||||
nodePort: 30080
|
|
||||||
selector:
|
|
||||||
app: ruoyi-nginx
|
|
||||||
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: ConfigMap
|
|
||||||
metadata:
|
|
||||||
name: redis-config
|
|
||||||
namespace: redis
|
|
||||||
data:
|
|
||||||
redis.conf: |-
|
|
||||||
maxmemory 1000mb
|
|
||||||
maxmemory-policy allkeys-lru
|
|
||||||
protected-mode no
|
|
||||||
tcp-backlog 511
|
|
||||||
daemonize no
|
|
||||||
supervised no
|
|
||||||
dir /data
|
|
||||||
pidfile /data/redis_6379.pid
|
|
||||||
port 6379
|
|
||||||
loglevel notice
|
|
||||||
logfile ""
|
|
||||||
databases 16
|
|
||||||
stop-writes-on-bgsave-error yes
|
|
||||||
rdbcompression yes
|
|
||||||
rdbchecksum yes
|
|
||||||
dbfilename dump.rdb
|
|
||||||
replica-serve-stale-data yes
|
|
||||||
replica-read-only no
|
|
||||||
repl-diskless-sync no
|
|
||||||
repl-diskless-sync-delay 5
|
|
||||||
repl-disable-tcp-nodelay no
|
|
||||||
replica-priority 100
|
|
||||||
lazyfree-lazy-eviction no
|
|
||||||
lazyfree-lazy-expire no
|
|
||||||
lazyfree-lazy-server-del no
|
|
||||||
replica-lazy-flush no
|
|
||||||
appendonly no
|
|
||||||
appendfilename "appendonly.aof"
|
|
||||||
appendfsync everysec
|
|
||||||
no-appendfsync-on-rewrite no
|
|
||||||
auto-aof-rewrite-percentage 100
|
|
||||||
auto-aof-rewrite-min-size 64mb
|
|
||||||
aof-load-truncated yes
|
|
||||||
aof-use-rdb-preamble yes
|
|
||||||
lua-time-limit 5000
|
|
||||||
slowlog-log-slower-than 10000
|
|
||||||
slowlog-max-len 128
|
|
||||||
latency-monitor-threshold 0
|
|
||||||
notify-keyspace-events ""
|
|
||||||
set-max-intset-entries 512
|
|
||||||
hll-sparse-max-bytes 3000
|
|
||||||
stream-node-max-bytes 4096
|
|
||||||
stream-node-max-entries 100
|
|
||||||
activerehashing yes
|
|
||||||
client-output-buffer-limit normal 0 0 0
|
|
||||||
client-output-buffer-limit replica 256mb 64mb 60
|
|
||||||
client-output-buffer-limit pubsub 32mb 8mb 60
|
|
||||||
hz 10
|
|
||||||
dynamic-hz yes
|
|
||||||
aof-rewrite-incremental-fsync yes
|
|
||||||
rdb-save-incremental-fsync yes
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: Namespace
|
|
||||||
metadata:
|
|
||||||
name: redis
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
apiVersion: apps/v1
|
|
||||||
kind: StatefulSet
|
|
||||||
metadata:
|
|
||||||
name: redis
|
|
||||||
labels:
|
|
||||||
app: redis
|
|
||||||
namespace: redis
|
|
||||||
spec:
|
|
||||||
serviceName: redis
|
|
||||||
replicas: 1
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: redis
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: redis
|
|
||||||
spec:
|
|
||||||
initContainers:
|
|
||||||
- name: config
|
|
||||||
image: redis:7.0.6
|
|
||||||
command: [ "sh", "-c" ]
|
|
||||||
args:
|
|
||||||
- |
|
|
||||||
cp /tmp/redis/redis.conf /etc/redis/redis.conf
|
|
||||||
|
|
||||||
echo "finding master..."
|
|
||||||
MASTER_FDQN=`hostname -f | sed -e 's/redis-[0-9]\./redis-0./'`
|
|
||||||
if [ "$(redis-cli -h sentinel -p 5000 ping)" != "PONG" ]; then
|
|
||||||
echo "master not found, defaulting to redis-0"
|
|
||||||
if [ "$(hostname)" = "redis-0" ]; then
|
|
||||||
echo "this is redis-0, not updating config..."
|
|
||||||
else
|
|
||||||
echo "updating redis.conf..."
|
|
||||||
echo "\nslaveof $MASTER_FDQN 6379" >> /etc/redis/redis.conf
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "sentinel found, finding master"
|
|
||||||
MASTER="$(redis-cli -h sentinel -p 5000 sentinel get-master-addr-by-name mymaster | grep -E '(^redis-\d{1,})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})')"
|
|
||||||
echo "master found : $MASTER, updating redis.conf"
|
|
||||||
echo "slaveof $MASTER 6379" >> /etc/redis/redis.conf
|
|
||||||
fi
|
|
||||||
volumeMounts:
|
|
||||||
- name: redis-config
|
|
||||||
mountPath: /etc/redis/
|
|
||||||
- name: config
|
|
||||||
mountPath: /tmp/redis/
|
|
||||||
containers:
|
|
||||||
- name: redis
|
|
||||||
image: redis:7.0.6
|
|
||||||
command: [ "redis-server" ]
|
|
||||||
args: [ "/etc/redis/redis.conf" ]
|
|
||||||
ports:
|
|
||||||
- containerPort: 6379
|
|
||||||
name: redis
|
|
||||||
volumeMounts:
|
|
||||||
- name: data
|
|
||||||
mountPath: /data
|
|
||||||
- name: redis-config
|
|
||||||
mountPath: /etc/redis/
|
|
||||||
resources:
|
|
||||||
limits:
|
|
||||||
memory: 1100Mi
|
|
||||||
requests:
|
|
||||||
memory: 1100Mi
|
|
||||||
volumes:
|
|
||||||
- name: redis-config
|
|
||||||
emptyDir: { }
|
|
||||||
- name: config
|
|
||||||
configMap:
|
|
||||||
name: redis-config
|
|
||||||
volumeClaimTemplates:
|
|
||||||
- metadata:
|
|
||||||
name: data
|
|
||||||
spec:
|
|
||||||
storageClassName: hostpath
|
|
||||||
accessModes:
|
|
||||||
- ReadWriteOnce
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
storage: 500Mi
|
|
||||||
|
|
||||||
---
|
|
||||||
apiVersion: v1 # API version
|
|
||||||
kind: Service # Type of the kubernetes resource
|
|
||||||
metadata:
|
|
||||||
name: redis # Name of the kubernetes resource
|
|
||||||
labels: # Labels that will be applied to this resource
|
|
||||||
app: redis
|
|
||||||
namespace: redis
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
app: redis # The service exposes Pods with label `app=redis`
|
|
||||||
ports:
|
|
||||||
- name: redis-port
|
|
||||||
port: 6379
|
|
||||||
nodePort: 30079
|
|
||||||
type: NodePort
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: Namespace
|
|
||||||
metadata:
|
|
||||||
name: kube-ruoyi
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: ruoyi-sentinel
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
spec:
|
|
||||||
replicas: 1
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: ruoyi-sentinel
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: ruoyi-sentinel
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: ruoyi-sentinel
|
|
||||||
image: bladex/sentinel-dashboard
|
|
||||||
imagePullPolicy: Always
|
|
||||||
ports:
|
|
||||||
- containerPort: 8858
|
|
||||||
env: # Environment variables supplied to the Pod
|
|
||||||
- name: JAVA_TOOL_OPTIONS
|
|
||||||
value: "-Dserver.port=8858 -Dcsp.sentinel.dashboard.server=localhost:8858 -Dproject.name=sentinel-dashboard"
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: ruoyi-sentinel
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
labels:
|
|
||||||
name: ruoyi-sentinel
|
|
||||||
spec:
|
|
||||||
type: NodePort
|
|
||||||
ports:
|
|
||||||
- port: 8858
|
|
||||||
targetPort: 8858
|
|
||||||
nodePort: 30858
|
|
||||||
selector:
|
|
||||||
app: ruoyi-sentinel
|
|
||||||
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
apiVersion: apps/v1 # API version
|
|
||||||
kind: Deployment # Type of kubernetes resource
|
|
||||||
metadata:
|
|
||||||
name: ruoyi-auth # Name of the kubernetes resource
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
labels: # Labels that will be applied to this resource
|
|
||||||
app: ruoyi-auth
|
|
||||||
spec:
|
|
||||||
replicas: 1 # No. of replicas/pods to run in this deployment
|
|
||||||
selector:
|
|
||||||
matchLabels: # The deployment applies to any pods matching the specified labels
|
|
||||||
app: ruoyi-auth
|
|
||||||
template: # Template for creating the pods in this deployment
|
|
||||||
metadata:
|
|
||||||
labels: # Labels that will be applied to each Pod in this deployment
|
|
||||||
app: ruoyi-auth
|
|
||||||
spec: # Spec for the containers that will be run in the Pods
|
|
||||||
containers:
|
|
||||||
- name: ruoyi-auth-server
|
|
||||||
image: ruoyi-auth:3.6.2
|
|
||||||
ports:
|
|
||||||
- name: http
|
|
||||||
containerPort: 9200 # The port that the container exposes
|
|
||||||
env: # Environment variables supplied to the Pod
|
|
||||||
- name: SPRING_PROFILES_ACTIVE
|
|
||||||
value: k8s
|
|
||||||
- name: SERVER_NAME
|
|
||||||
value: ruoyi-auth
|
|
||||||
- name: NACOS_SERVER
|
|
||||||
value: ruoyi-nacos # nacos svc name
|
|
||||||
- name: NACOS_PORT
|
|
||||||
value: "8848"
|
|
||||||
- name: NACOS_SHARED_CONFIGS
|
|
||||||
value: application-dev.yml
|
|
||||||
---
|
|
||||||
apiVersion: v1 # API version
|
|
||||||
kind: Service # Type of the kubernetes resource
|
|
||||||
metadata:
|
|
||||||
name: ruoyi-auth # Name of the kubernetes resource
|
|
||||||
labels: # Labels that will be applied to this resource
|
|
||||||
app: ruoyi-auth
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
spec:
|
|
||||||
type: NodePort # The service will be exposed by opening a Port on each node and proxying it.
|
|
||||||
selector:
|
|
||||||
app: ruoyi-auth # The service exposes Pods with label `app=ruoyi-auth`
|
|
||||||
ports: # Forward incoming connections on port 9200 to the target port 9200
|
|
||||||
- name: http
|
|
||||||
port: 9200
|
|
||||||
targetPort: 9200
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
apiVersion: apps/v1 # API version
|
|
||||||
kind: Deployment # Type of kubernetes resource
|
|
||||||
metadata:
|
|
||||||
name: ruoyi-gateway # Name of the kubernetes resource
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
labels: # Labels that will be applied to this resource
|
|
||||||
app: ruoyi-gateway
|
|
||||||
spec:
|
|
||||||
replicas: 1 # No. of replicas/pods to run in this deployment
|
|
||||||
selector:
|
|
||||||
matchLabels: # The deployment applies to any pods matching the specified labels
|
|
||||||
app: ruoyi-gateway
|
|
||||||
template: # Template for creating the pods in this deployment
|
|
||||||
metadata:
|
|
||||||
labels: # Labels that will be applied to each Pod in this deployment
|
|
||||||
app: ruoyi-gateway
|
|
||||||
spec: # Spec for the containers that will be run in the Pods
|
|
||||||
containers:
|
|
||||||
- name: ruoyi-gateway-server
|
|
||||||
image: ruoyi-gateway:3.6.2
|
|
||||||
ports:
|
|
||||||
- name: http
|
|
||||||
containerPort: 8080 # The port that the container exposes
|
|
||||||
env: # Environment variables supplied to the Pod
|
|
||||||
- name: SPRING_PROFILES_ACTIVE
|
|
||||||
value: k8s
|
|
||||||
- name: SERVER_NAME
|
|
||||||
value: ruoyi-gateway
|
|
||||||
- name: NACOS_SERVER
|
|
||||||
value: ruoyi-nacos # nacos svc name
|
|
||||||
- name: NACOS_PORT
|
|
||||||
value: "8848"
|
|
||||||
- name: NACOS_SHARED_CONFIGS
|
|
||||||
value: application-dev.yml
|
|
||||||
---
|
|
||||||
apiVersion: v1 # API version
|
|
||||||
kind: Service # Type of the kubernetes resource
|
|
||||||
metadata:
|
|
||||||
name: ruoyi-gateway # Name of the kubernetes resource
|
|
||||||
labels: # Labels that will be applied to this resource
|
|
||||||
app: ruoyi-gateway
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
spec:
|
|
||||||
type: NodePort # The service will be exposed by opening a Port on each node and proxying it.
|
|
||||||
selector:
|
|
||||||
app: ruoyi-gateway # The service exposes Pods with label `app=ruoyi-gateway`
|
|
||||||
ports: # Forward incoming connections on port 8080 to the target port 8080
|
|
||||||
- name: http
|
|
||||||
port: 8080
|
|
||||||
targetPort: 8080
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
apiVersion: apps/v1 # API version
|
|
||||||
kind: Deployment # Type of kubernetes resource
|
|
||||||
metadata:
|
|
||||||
name: ruoyi-file # Name of the kubernetes resource
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
labels: # Labels that will be applied to this resource
|
|
||||||
app: ruoyi-file
|
|
||||||
spec:
|
|
||||||
replicas: 1 # No. of replicas/pods to run in this deployment
|
|
||||||
selector:
|
|
||||||
matchLabels: # The deployment applies to any pods matching the specified labels
|
|
||||||
app: ruoyi-file
|
|
||||||
template: # Template for creating the pods in this deployment
|
|
||||||
metadata:
|
|
||||||
labels: # Labels that will be applied to each Pod in this deployment
|
|
||||||
app: ruoyi-file
|
|
||||||
spec: # Spec for the containers that will be run in the Pods
|
|
||||||
containers:
|
|
||||||
- name: ruoyi-file-server
|
|
||||||
image: ruoyi-modules-file:3.6.2
|
|
||||||
ports:
|
|
||||||
- name: http
|
|
||||||
containerPort: 9300 # The port that the container exposes
|
|
||||||
env: # Environment variables supplied to the Pod
|
|
||||||
- name: SPRING_PROFILES_ACTIVE
|
|
||||||
value: k8s
|
|
||||||
- name: SERVER_NAME
|
|
||||||
value: ruoyi-file
|
|
||||||
- name: NACOS_SERVER
|
|
||||||
value: ruoyi-nacos # nacos svc name
|
|
||||||
- name: NACOS_PORT
|
|
||||||
value: "8848"
|
|
||||||
- name: NACOS_SHARED_CONFIGS
|
|
||||||
value: application-dev.yml
|
|
||||||
---
|
|
||||||
apiVersion: v1 # API version
|
|
||||||
kind: Service # Type of the kubernetes resource
|
|
||||||
metadata:
|
|
||||||
name: ruoyi-file # Name of the kubernetes resource
|
|
||||||
labels: # Labels that will be applied to this resource
|
|
||||||
app: ruoyi-file
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
spec:
|
|
||||||
type: NodePort # The service will be exposed by opening a Port on each node and proxying it.
|
|
||||||
selector:
|
|
||||||
app: ruoyi-file # The service exposes Pods with label `app=ruoyi-file`
|
|
||||||
ports: # Forward incoming connections on port 9300 to the target port 9300
|
|
||||||
- name: http
|
|
||||||
port: 9300
|
|
||||||
targetPort: 9300
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
apiVersion: apps/v1 # API version
|
|
||||||
kind: Deployment # Type of kubernetes resource
|
|
||||||
metadata:
|
|
||||||
name: ruoyi-gen # Name of the kubernetes resource
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
labels: # Labels that will be applied to this resource
|
|
||||||
app: ruoyi-gen
|
|
||||||
spec:
|
|
||||||
replicas: 1 # No. of replicas/pods to run in this deployment
|
|
||||||
selector:
|
|
||||||
matchLabels: # The deployment applies to any pods matching the specified labels
|
|
||||||
app: ruoyi-gen
|
|
||||||
template: # Template for creating the pods in this deployment
|
|
||||||
metadata:
|
|
||||||
labels: # Labels that will be applied to each Pod in this deployment
|
|
||||||
app: ruoyi-gen
|
|
||||||
spec: # Spec for the containers that will be run in the Pods
|
|
||||||
containers:
|
|
||||||
- name: ruoyi-gen-server
|
|
||||||
image: ruoyi-modules-gen:3.6.2
|
|
||||||
ports:
|
|
||||||
- name: http
|
|
||||||
containerPort: 9202 # The port that the container exposes
|
|
||||||
env: # Environment variables supplied to the Pod
|
|
||||||
- name: SPRING_PROFILES_ACTIVE
|
|
||||||
value: k8s
|
|
||||||
- name: SERVER_NAME
|
|
||||||
value: ruoyi-gen
|
|
||||||
- name: NACOS_SERVER
|
|
||||||
value: ruoyi-nacos # nacos svc name
|
|
||||||
- name: NACOS_PORT
|
|
||||||
value: "8848"
|
|
||||||
- name: NACOS_SHARED_CONFIGS
|
|
||||||
value: application-dev.yml
|
|
||||||
---
|
|
||||||
apiVersion: v1 # API version
|
|
||||||
kind: Service # Type of the kubernetes resource
|
|
||||||
metadata:
|
|
||||||
name: ruoyi-gen # Name of the kubernetes resource
|
|
||||||
labels: # Labels that will be applied to this resource
|
|
||||||
app: ruoyi-gen
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
spec:
|
|
||||||
type: NodePort # The service will be exposed by opening a Port on each node and proxying it.
|
|
||||||
selector:
|
|
||||||
app: ruoyi-gen # The service exposes Pods with label `app=ruoyi-gen`
|
|
||||||
ports: # Forward incoming connections on port 9202 to the target port 9202
|
|
||||||
- name: http
|
|
||||||
port: 9202
|
|
||||||
targetPort: 9202
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
apiVersion: apps/v1 # API version
|
|
||||||
kind: Deployment # Type of kubernetes resource
|
|
||||||
metadata:
|
|
||||||
name: ruoyi-job # Name of the kubernetes resource
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
labels: # Labels that will be applied to this resource
|
|
||||||
app: ruoyi-job
|
|
||||||
spec:
|
|
||||||
replicas: 1 # No. of replicas/pods to run in this deployment
|
|
||||||
selector:
|
|
||||||
matchLabels: # The deployment applies to any pods matching the specified labels
|
|
||||||
app: ruoyi-job
|
|
||||||
template: # Template for creating the pods in this deployment
|
|
||||||
metadata:
|
|
||||||
labels: # Labels that will be applied to each Pod in this deployment
|
|
||||||
app: ruoyi-job
|
|
||||||
spec: # Spec for the containers that will be run in the Pods
|
|
||||||
containers:
|
|
||||||
- name: ruoyi-job-server
|
|
||||||
image: ruoyi-modules-job:3.6.2
|
|
||||||
ports:
|
|
||||||
- name: http
|
|
||||||
containerPort: 9203 # The port that the container exposes
|
|
||||||
env: # Environment variables supplied to the Pod
|
|
||||||
- name: SPRING_PROFILES_ACTIVE
|
|
||||||
value: k8s
|
|
||||||
- name: SERVER_NAME
|
|
||||||
value: ruoyi-job
|
|
||||||
- name: NACOS_SERVER
|
|
||||||
value: ruoyi-nacos # nacos svc name
|
|
||||||
- name: NACOS_PORT
|
|
||||||
value: "8848"
|
|
||||||
- name: NACOS_SHARED_CONFIGS
|
|
||||||
value: application-dev.yml
|
|
||||||
---
|
|
||||||
apiVersion: v1 # API version
|
|
||||||
kind: Service # Type of the kubernetes resource
|
|
||||||
metadata:
|
|
||||||
name: ruoyi-job # Name of the kubernetes resource
|
|
||||||
labels: # Labels that will be applied to this resource
|
|
||||||
app: ruoyi-job
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
spec:
|
|
||||||
type: NodePort # The service will be exposed by opening a Port on each node and proxying it.
|
|
||||||
selector:
|
|
||||||
app: ruoyi-job # The service exposes Pods with label `app=ruoyi-job`
|
|
||||||
ports: # Forward incoming connections on port 9203 to the target port 9203
|
|
||||||
- name: http
|
|
||||||
port: 9203
|
|
||||||
targetPort: 9203
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
apiVersion: apps/v1 # API version
|
|
||||||
kind: Deployment # Type of kubernetes resource
|
|
||||||
metadata:
|
|
||||||
name: ruoyi-system # Name of the kubernetes resource
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
labels: # Labels that will be applied to this resource
|
|
||||||
app: ruoyi-system
|
|
||||||
spec:
|
|
||||||
replicas: 1 # No. of replicas/pods to run in this deployment
|
|
||||||
selector:
|
|
||||||
matchLabels: # The deployment applies to any pods matching the specified labels
|
|
||||||
app: ruoyi-system
|
|
||||||
template: # Template for creating the pods in this deployment
|
|
||||||
metadata:
|
|
||||||
labels: # Labels that will be applied to each Pod in this deployment
|
|
||||||
app: ruoyi-system
|
|
||||||
spec: # Spec for the containers that will be run in the Pods
|
|
||||||
containers:
|
|
||||||
- name: ruoyi-system-server
|
|
||||||
image: ruoyi-modules-system:3.6.2
|
|
||||||
ports:
|
|
||||||
- name: http
|
|
||||||
containerPort: 9201 # The port that the container exposes
|
|
||||||
env: # Environment variables supplied to the Pod
|
|
||||||
- name: SPRING_PROFILES_ACTIVE
|
|
||||||
value: k8s
|
|
||||||
- name: SERVER_NAME
|
|
||||||
value: ruoyi-system
|
|
||||||
- name: NACOS_SERVER
|
|
||||||
value: ruoyi-nacos # nacos svc name
|
|
||||||
- name: NACOS_PORT
|
|
||||||
value: "8848"
|
|
||||||
- name: NACOS_SHARED_CONFIGS
|
|
||||||
value: application-dev.yml
|
|
||||||
---
|
|
||||||
apiVersion: v1 # API version
|
|
||||||
kind: Service # Type of the kubernetes resource
|
|
||||||
metadata:
|
|
||||||
name: ruoyi-system # Name of the kubernetes resource
|
|
||||||
labels: # Labels that will be applied to this resource
|
|
||||||
app: ruoyi-system
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
spec:
|
|
||||||
type: NodePort # The service will be exposed by opening a Port on each node and proxying it.
|
|
||||||
selector:
|
|
||||||
app: ruoyi-system # The service exposes Pods with label `app=ruoyi-system`
|
|
||||||
ports: # Forward incoming connections on port 9201 to the target port 9201
|
|
||||||
- name: http
|
|
||||||
port: 9201
|
|
||||||
targetPort: 9201
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
apiVersion: apps/v1 # API version
|
|
||||||
kind: Deployment # Type of kubernetes resource
|
|
||||||
metadata:
|
|
||||||
name: ruoyi-monitor # Name of the kubernetes resource
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
labels: # Labels that will be applied to this resource
|
|
||||||
app: ruoyi-monitor
|
|
||||||
spec:
|
|
||||||
replicas: 1 # No. of replicas/pods to run in this deployment
|
|
||||||
selector:
|
|
||||||
matchLabels: # The deployment applies to any pods matching the specified labels
|
|
||||||
app: ruoyi-monitor
|
|
||||||
template: # Template for creating the pods in this deployment
|
|
||||||
metadata:
|
|
||||||
labels: # Labels that will be applied to each Pod in this deployment
|
|
||||||
app: ruoyi-monitor
|
|
||||||
spec: # Spec for the containers that will be run in the Pods
|
|
||||||
containers:
|
|
||||||
- name: ruoyi-monitor-server
|
|
||||||
image: ruoyi-visual-monitor:3.6.2
|
|
||||||
ports:
|
|
||||||
- name: http
|
|
||||||
containerPort: 9100 # The port that the container exposes
|
|
||||||
env: # Environment variables supplied to the Pod
|
|
||||||
- name: SPRING_PROFILES_ACTIVE
|
|
||||||
value: k8s
|
|
||||||
- name: SERVER_NAME
|
|
||||||
value: ruoyi-monitor
|
|
||||||
- name: NACOS_SERVER
|
|
||||||
value: ruoyi-nacos # nacos svc name
|
|
||||||
- name: NACOS_PORT
|
|
||||||
value: "8848"
|
|
||||||
- name: NACOS_SHARED_CONFIGS
|
|
||||||
value: application-dev.yml
|
|
||||||
---
|
|
||||||
apiVersion: v1 # API version
|
|
||||||
kind: Service # Type of the kubernetes resource
|
|
||||||
metadata:
|
|
||||||
name: ruoyi-monitor # Name of the kubernetes resource
|
|
||||||
labels: # Labels that will be applied to this resource
|
|
||||||
app: ruoyi-monitor
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
spec:
|
|
||||||
type: NodePort # The service will be exposed by opening a Port on each node and proxying it.
|
|
||||||
selector:
|
|
||||||
app: ruoyi-monitor # The service exposes Pods with label `app=ruoyi-monitor`
|
|
||||||
ports: # Forward incoming connections on port 9100 to the target port 9100
|
|
||||||
- name: http
|
|
||||||
port: 9100
|
|
||||||
targetPort: 9100
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
# Tomcat
|
|
||||||
server:
|
|
||||||
port: 8080
|
|
||||||
|
|
||||||
# Spring
|
|
||||||
spring:
|
|
||||||
application:
|
|
||||||
# 应用名称
|
|
||||||
name: ${SERVER_NAME}
|
|
||||||
cloud:
|
|
||||||
nacos:
|
|
||||||
discovery:
|
|
||||||
# 服务注册地址
|
|
||||||
server-addr: ${NACOS_SERVER}:${NACOS_PORT}
|
|
||||||
config:
|
|
||||||
# 配置中心地址
|
|
||||||
server-addr: ${NACOS_SERVER}:${NACOS_PORT}
|
|
||||||
# 配置文件格式
|
|
||||||
file-extension: yml
|
|
||||||
# 共享配置
|
|
||||||
shared-configs:
|
|
||||||
- ${NACOS_SHARED_CONFIGS}
|
|
||||||
sentinel:
|
|
||||||
# 取消控制台懒加载
|
|
||||||
eager: true
|
|
||||||
transport:
|
|
||||||
# 控制台地址
|
|
||||||
dashboard: 127.0.0.1:8718
|
|
||||||
# nacos配置持久化
|
|
||||||
datasource:
|
|
||||||
ds1:
|
|
||||||
nacos:
|
|
||||||
server-addr: ${NACOS_SERVER}:${NACOS_PORT}
|
|
||||||
dataId: sentinel-ruoyi-gateway
|
|
||||||
groupId: DEFAULT_GROUP
|
|
||||||
data-type: json
|
|
||||||
rule-type: gw-flow
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
# 基础镜像
|
|
||||||
FROM openjdk:8-jre
|
|
||||||
# author
|
|
||||||
MAINTAINER ruoyi
|
|
||||||
|
|
||||||
# 挂载目录
|
|
||||||
VOLUME /home/ruoyi
|
|
||||||
# 创建目录
|
|
||||||
RUN mkdir -p /home/ruoyi
|
|
||||||
# 指定路径
|
|
||||||
WORKDIR /home/ruoyi
|
|
||||||
# 复制jar文件到路径
|
|
||||||
COPY ./jar/ruoyi-gateway.jar /home/ruoyi/ruoyi-gateway.jar
|
|
||||||
# 启动网关服务
|
|
||||||
ENTRYPOINT ["java","-jar","ruoyi-gateway.jar"]
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
存放网关模块打包好的jar文件,用于docker启动应用。
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
apiVersion: apps/v1 # API version
|
|
||||||
kind: Deployment # Type of kubernetes resource
|
|
||||||
metadata:
|
|
||||||
name: ruoyi-system # Name of the kubernetes resource
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
labels: # Labels that will be applied to this resource
|
|
||||||
app: ruoyi-system
|
|
||||||
spec:
|
|
||||||
replicas: 1 # No. of replicas/pods to run in this deployment
|
|
||||||
selector:
|
|
||||||
matchLabels: # The deployment applies to any pods matching the specified labels
|
|
||||||
app: ruoyi-system
|
|
||||||
template: # Template for creating the pods in this deployment
|
|
||||||
metadata:
|
|
||||||
labels: # Labels that will be applied to each Pod in this deployment
|
|
||||||
app: ruoyi-system
|
|
||||||
spec: # Spec for the containers that will be run in the Pods
|
|
||||||
containers:
|
|
||||||
- name: ruoyi-system-server
|
|
||||||
image: ruoyi-modules-system:3.6.2
|
|
||||||
ports:
|
|
||||||
- name: http
|
|
||||||
containerPort: 9201 # The port that the container exposes
|
|
||||||
env: # Environment variables supplied to the Pod
|
|
||||||
- name: SPRING_PROFILES_ACTIVE
|
|
||||||
value: k8s
|
|
||||||
- name: SERVER_NAME
|
|
||||||
value: ruoyi-system
|
|
||||||
- name: NACOS_SERVER
|
|
||||||
value: ruoyi-nacos # nacos svc name
|
|
||||||
- name: NACOS_PORT
|
|
||||||
value: "8848"
|
|
||||||
- name: NACOS_SHARED_CONFIGS
|
|
||||||
value: application-dev.yml
|
|
||||||
- name: JAVA_OPTS
|
|
||||||
value: -javaagent:/javaagent/skywalking-agent/skywalking-agent.jar -Dskywalking.agent.service_name=k8s::$(SERVER_NAME) -Dskywalking.collector.backend_service=skywalking:11800
|
|
||||||
volumeMounts:
|
|
||||||
- mountPath: /javaagent
|
|
||||||
name: agent-jar
|
|
||||||
volumes:
|
|
||||||
- emptyDir: { }
|
|
||||||
name: agent-jar
|
|
||||||
initContainers:
|
|
||||||
# 官网用脚本命令行+args的方式执行多条command语句
|
|
||||||
- command: ['sh']
|
|
||||||
args:
|
|
||||||
- "-c"
|
|
||||||
- |
|
|
||||||
cp -r /opt/skywalking-agent /javaagent
|
|
||||||
chown -R 65534:65534 /javaagent
|
|
||||||
/bin/chmod -R 777 /javaagent
|
|
||||||
image: skywalking-agent:8.14.0
|
|
||||||
imagePullPolicy: IfNotPresent
|
|
||||||
name: skywalking-agent
|
|
||||||
volumeMounts:
|
|
||||||
- mountPath: /javaagent
|
|
||||||
name: agent-jar
|
|
||||||
---
|
|
||||||
apiVersion: v1 # API version
|
|
||||||
kind: Service # Type of the kubernetes resource
|
|
||||||
metadata:
|
|
||||||
name: ruoyi-system # Name of the kubernetes resource
|
|
||||||
labels: # Labels that will be applied to this resource
|
|
||||||
app: ruoyi-system
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
spec:
|
|
||||||
type: NodePort # The service will be exposed by opening a Port on each node and proxying it.
|
|
||||||
selector:
|
|
||||||
app: ruoyi-system # The service exposes Pods with label `app=ruoyi-system`
|
|
||||||
ports: # Forward incoming connections on port 9201 to the target port 9201
|
|
||||||
- name: http
|
|
||||||
port: 9201
|
|
||||||
targetPort: 9201
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
## cat Dcokerfile
|
|
||||||
|
|
||||||
FROM docker.io/library/busybox:latest AS base
|
|
||||||
|
|
||||||
# 使用 ADD 下载 java-agent,你也可以使用其他下载命令,或者下载到本地,再 使用 COPY或者ADD 指令添加到 镜像里
|
|
||||||
ADD https://dlcdn.apache.org/skywalking/java-agent/9.0.0/apache-skywalking-java-agent-9.0.0.tgz /tmp/
|
|
||||||
RUN mkdir -p /opt \
|
|
||||||
&& tar -xzf /tmp/apache-skywalking-java-agent-9.0.0.tgz -C /opt/ \
|
|
||||||
&& rm -rf /tmp/*
|
|
||||||
#ADD skywalking-agent.tar.gz /opt/
|
|
||||||
RUN mkdir -p /javaagent
|
|
||||||
|
|
||||||
## java-agent 使用 方法
|
|
||||||
## https://skywalking.apache.org/docs/skywalking-java/next/en/setup/service-agent/java-agent/readme/
|
|
||||||
## java -javaagent:/opt/skywalking-agent/skywalking-agent.jar -jar yourApp.jar
|
|
||||||
## -javaagent:/opt/skywalking-agent/skywalking-agent.jar=agent.service_name=yourAppName,collector.backend_service=127.0.0.1:11800
|
|
||||||
## -javaagent:/opt/skywalking-agent/skywalking-agent.jar -Dskywalking.agent.service_name=yourAppName -Dskywalking.collector.backend_service=127.0.0.1:11800
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
name: elasticsearch
|
|
||||||
name: elasticsearch
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
spec:
|
|
||||||
replicas: 1
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: elasticsearch
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: elasticsearch
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: elasticsearch
|
|
||||||
image: elasticsearch:7.14.2
|
|
||||||
ports:
|
|
||||||
- containerPort: 9200
|
|
||||||
name: cluster-node
|
|
||||||
env:
|
|
||||||
- name: discovery.type
|
|
||||||
value: single-node
|
|
||||||
- name: TZ
|
|
||||||
value: Asia/Shanghai
|
|
||||||
- name: ES_JAVA_OPTS
|
|
||||||
value: -Xms512m -Xmx512m
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: elasticsearch
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
spec:
|
|
||||||
ports:
|
|
||||||
- port: 9220 # 和auth-server的端口冲突了,对外暴露换一个端口访问
|
|
||||||
targetPort: 9200
|
|
||||||
name: cluster-node
|
|
||||||
selector:
|
|
||||||
app: elasticsearch # 该 Service 会将所有具有标签 app: mysql-labels-app暴露到一个抽象的 Service 端口上(targetPort:容器接收流量的端口;port:可任意取值的抽象的 Service 端口,其他 Pod 通过该端口访问 Service
|
|
||||||
type: NodePort
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
name: skywalking
|
|
||||||
name: skywalking
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
spec:
|
|
||||||
replicas: 1
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: skywalking
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: skywalking
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: skywalking
|
|
||||||
image: apache/skywalking-oap-server
|
|
||||||
imagePullPolicy: Always
|
|
||||||
ports:
|
|
||||||
- containerPort: 11800
|
|
||||||
name: collector
|
|
||||||
- containerPort: 12800
|
|
||||||
name: oap
|
|
||||||
env:
|
|
||||||
- name: SW_STORAGE
|
|
||||||
value: elasticsearch
|
|
||||||
- name: TZ
|
|
||||||
value: Asia/Shanghai
|
|
||||||
- name: SW_STORAGE_ES_CLUSTER_NODES
|
|
||||||
value: elasticsearch:9220
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: skywalking
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
spec:
|
|
||||||
ports:
|
|
||||||
- port: 11800
|
|
||||||
targetPort: 11800
|
|
||||||
name: collector
|
|
||||||
- port: 12800
|
|
||||||
targetPort: 12800
|
|
||||||
name: oap
|
|
||||||
selector:
|
|
||||||
app: skywalking # 该 Service 会将所有具有标签 app: mysql-labels-app暴露到一个抽象的 Service 端口上(targetPort:容器接收流量的端口;port:可任意取值的抽象的 Service 端口,其他 Pod 通过该端口访问 Service
|
|
||||||
type: NodePort
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
name: skywalking-ui
|
|
||||||
name: skywalking-ui
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
spec:
|
|
||||||
replicas: 1
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: skywalking-ui
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: skywalking-ui
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: skywalking-ui
|
|
||||||
image: apache/skywalking-ui
|
|
||||||
imagePullPolicy: Always
|
|
||||||
ports:
|
|
||||||
- containerPort: 8080
|
|
||||||
name: console
|
|
||||||
env:
|
|
||||||
- name: SW_OAP_ADDRESS
|
|
||||||
value: http://skywalking:12800
|
|
||||||
- name: TZ
|
|
||||||
value: Asia/Shanghai
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: skywalking-ui
|
|
||||||
namespace: kube-ruoyi
|
|
||||||
spec:
|
|
||||||
ports:
|
|
||||||
- port: 8080
|
|
||||||
nodePort: 30088
|
|
||||||
selector:
|
|
||||||
app: skywalking-ui # 该 Service 会将所有具有标签 app: mysql-labels-app暴露到一个抽象的 Service 端口上(targetPort:容器接收流量的端口;port:可任意取值的抽象的 Service 端口,其他 Pod 通过该端口访问 Service
|
|
||||||
type: NodePort
|
|
||||||
@@ -9,8 +9,8 @@ usage() {
|
|||||||
|
|
||||||
# copy sql
|
# copy sql
|
||||||
echo "begin copy sql "
|
echo "begin copy sql "
|
||||||
cp ../sql/ry_20240629.sql ./mysql/db
|
cp ../sql/ry_20250523.sql ./mysql/db
|
||||||
cp ../sql/ry_config_20250224.sql ./mysql/db
|
cp ../sql/ry_config_20250902.sql ./mysql/db
|
||||||
|
|
||||||
# copy html
|
# copy html
|
||||||
echo "begin copy html "
|
echo "begin copy html "
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ http {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# 避免actuator暴露
|
# 避免actuator暴露
|
||||||
if ($request_uri ~ "/actuator") {
|
if ($uri ~ "/actuator") {
|
||||||
return 403;
|
return 403;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
95
pom.xml
95
pom.xml
@@ -6,54 +6,40 @@
|
|||||||
|
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.6.5</version>
|
<version>3.6.7</version>
|
||||||
|
|
||||||
<name>ruoyi</name>
|
<name>ruoyi</name>
|
||||||
<url>http://www.ruoyi.vip</url>
|
<url>http://www.ruoyi.vip</url>
|
||||||
<description>若依微服务系统</description>
|
<description>若依微服务系统</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<ruoyi.version>3.6.5</ruoyi.version>
|
<ruoyi.version>3.6.7</ruoyi.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>1.8</java.version>
|
<java.version>17</java.version>
|
||||||
<spring-boot.version>2.7.18</spring-boot.version>
|
<spring-boot.version>3.3.5</spring-boot.version>
|
||||||
<spring-cloud.version>2021.0.9</spring-cloud.version>
|
<spring-cloud.version>2023.0.3</spring-cloud.version>
|
||||||
<spring-cloud-alibaba.version>2021.0.6.1</spring-cloud-alibaba.version>
|
<spring-cloud-alibaba.version>2023.0.1.2</spring-cloud-alibaba.version>
|
||||||
<spring-boot-admin.version>2.7.16</spring-boot-admin.version>
|
<spring-boot-admin.version>3.3.5</spring-boot-admin.version>
|
||||||
<tobato.version>1.27.2</tobato.version>
|
<mybatis-spring.version>3.0.3</mybatis-spring.version>
|
||||||
<kaptcha.version>2.3.3</kaptcha.version>
|
<kaptcha.version>2.3.3</kaptcha.version>
|
||||||
<pagehelper.boot.version>2.0.0</pagehelper.boot.version>
|
<pagehelper.boot.version>2.1.0</pagehelper.boot.version>
|
||||||
<druid.version>1.2.23</druid.version>
|
<druid.version>1.2.27</druid.version>
|
||||||
<dynamic-ds.version>4.3.1</dynamic-ds.version>
|
<dynamic-ds.version>4.3.1</dynamic-ds.version>
|
||||||
<commons.io.version>2.13.0</commons.io.version>
|
<commons.io.version>2.21.0</commons.io.version>
|
||||||
<velocity.version>2.3</velocity.version>
|
<velocity.version>2.3</velocity.version>
|
||||||
<fastjson.version>2.0.53</fastjson.version>
|
<fastjson.version>2.0.60</fastjson.version>
|
||||||
<jjwt.version>0.9.1</jjwt.version>
|
<jjwt.version>0.9.1</jjwt.version>
|
||||||
<minio.version>8.2.2</minio.version>
|
<minio.version>8.2.2</minio.version>
|
||||||
<poi.version>4.1.2</poi.version>
|
<poi.version>4.1.2</poi.version>
|
||||||
<springdoc.version>1.6.9</springdoc.version>
|
<springdoc.version>2.6.0</springdoc.version>
|
||||||
<transmittable-thread-local.version>2.14.4</transmittable-thread-local.version>
|
<transmittable-thread-local.version>2.14.4</transmittable-thread-local.version>
|
||||||
|
|
||||||
<!-- override dependency version -->
|
|
||||||
<tomcat.version>9.0.98</tomcat.version>
|
|
||||||
<logback.version>1.2.13</logback.version>
|
|
||||||
<spring-framework.version>5.3.39</spring-framework.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<!-- 依赖声明 -->
|
<!-- 依赖声明 -->
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<!-- 覆盖SpringFramework的依赖配置-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-framework-bom</artifactId>
|
|
||||||
<version>${spring-framework.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- SpringCloud 微服务 -->
|
<!-- SpringCloud 微服务 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
@@ -81,49 +67,10 @@
|
|||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 覆盖logback的依赖配置-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>ch.qos.logback</groupId>
|
|
||||||
<artifactId>logback-core</artifactId>
|
|
||||||
<version>${logback.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>ch.qos.logback</groupId>
|
|
||||||
<artifactId>logback-classic</artifactId>
|
|
||||||
<version>${logback.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 覆盖tomcat的依赖配置-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.tomcat.embed</groupId>
|
|
||||||
<artifactId>tomcat-embed-core</artifactId>
|
|
||||||
<version>${tomcat.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.tomcat.embed</groupId>
|
|
||||||
<artifactId>tomcat-embed-el</artifactId>
|
|
||||||
<version>${tomcat.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.tomcat.embed</groupId>
|
|
||||||
<artifactId>tomcat-embed-websocket</artifactId>
|
|
||||||
<version>${tomcat.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- FastDFS 分布式文件系统 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.tobato</groupId>
|
|
||||||
<artifactId>fastdfs-client</artifactId>
|
|
||||||
<version>${tobato.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Springdoc webmvc 依赖配置 -->
|
<!-- Springdoc webmvc 依赖配置 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springdoc</groupId>
|
<groupId>org.springdoc</groupId>
|
||||||
<artifactId>springdoc-openapi-ui</artifactId>
|
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||||
<version>${springdoc.version}</version>
|
<version>${springdoc.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@@ -139,6 +86,18 @@
|
|||||||
<groupId>com.github.pagehelper</groupId>
|
<groupId>com.github.pagehelper</groupId>
|
||||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||||
<version>${pagehelper.boot.version}</version>
|
<version>${pagehelper.boot.version}</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>mybatis-spring</artifactId>
|
||||||
|
<groupId>org.mybatis</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis</groupId>
|
||||||
|
<artifactId>mybatis-spring</artifactId>
|
||||||
|
<version>${mybatis-spring.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- io常用工具类 -->
|
<!-- io常用工具类 -->
|
||||||
@@ -279,7 +238,9 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.11.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<parameters>true</parameters>
|
||||||
<source>${java.version}</source>
|
<source>${java.version}</source>
|
||||||
<target>${java.version}</target>
|
<target>${java.version}</target>
|
||||||
<encoding>${project.build.sourceEncoding}</encoding>
|
<encoding>${project.build.sourceEncoding}</encoding>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.6.5</version>
|
<version>3.6.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-api</artifactId>
|
<artifactId>ruoyi-api</artifactId>
|
||||||
<version>3.6.5</version>
|
<version>3.6.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package com.ruoyi.system.api;
|
|||||||
|
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import com.ruoyi.common.core.constant.ServiceNameConstants;
|
import com.ruoyi.common.core.constant.ServiceNameConstants;
|
||||||
@@ -26,4 +28,13 @@ public interface RemoteFileService
|
|||||||
*/
|
*/
|
||||||
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||||
public R<SysFile> upload(@RequestPart(value = "file") MultipartFile file);
|
public R<SysFile> upload(@RequestPart(value = "file") MultipartFile file);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除文件
|
||||||
|
*
|
||||||
|
* @param fileUrl 文件地址
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@DeleteMapping(value = "/delete", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
|
||||||
|
public R<Boolean> delete(@RequestParam("fileUrl") String fileUrl);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ package com.ruoyi.system.api.domain;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.validation.constraints.Email;
|
import jakarta.validation.constraints.Email;
|
||||||
import javax.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import javax.validation.constraints.Size;
|
import jakarta.validation.constraints.Size;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.ruoyi.system.api.domain;
|
package com.ruoyi.system.api.domain;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.Size;
|
import jakarta.validation.constraints.Size;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
import com.ruoyi.common.core.annotation.Excel;
|
import com.ruoyi.common.core.annotation.Excel;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.ruoyi.system.api.domain;
|
package com.ruoyi.system.api.domain;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.Pattern;
|
import jakarta.validation.constraints.Pattern;
|
||||||
import javax.validation.constraints.Size;
|
import jakarta.validation.constraints.Size;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
import com.ruoyi.common.core.annotation.Excel;
|
import com.ruoyi.common.core.annotation.Excel;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package com.ruoyi.system.api.domain;
|
package com.ruoyi.system.api.domain;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import javax.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import javax.validation.constraints.Size;
|
import jakarta.validation.constraints.Size;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
import com.ruoyi.common.core.annotation.Excel;
|
import com.ruoyi.common.core.annotation.Excel;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package com.ruoyi.system.api.domain;
|
|||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.validation.constraints.*;
|
import jakarta.validation.constraints.*;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
import com.ruoyi.common.core.annotation.Excel;
|
import com.ruoyi.common.core.annotation.Excel;
|
||||||
@@ -56,8 +56,8 @@ public class SysUser extends BaseEntity
|
|||||||
/** 密码 */
|
/** 密码 */
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
/** 帐号状态(0正常 1停用) */
|
/** 账号状态(0正常 1停用) */
|
||||||
@Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
|
@Excel(name = "账号状态", readConverterExp = "0=正常,1=停用")
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
/** 删除标志(0代表存在 2代表删除) */
|
/** 删除标志(0代表存在 2代表删除) */
|
||||||
@@ -71,6 +71,9 @@ public class SysUser extends BaseEntity
|
|||||||
@Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
|
@Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
|
||||||
private Date loginDate;
|
private Date loginDate;
|
||||||
|
|
||||||
|
/** 密码最后更新时间 */
|
||||||
|
private Date pwdUpdateDate;
|
||||||
|
|
||||||
/** 部门对象 */
|
/** 部门对象 */
|
||||||
@Excels({
|
@Excels({
|
||||||
@Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
|
@Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
|
||||||
@@ -111,11 +114,6 @@ public class SysUser extends BaseEntity
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAdmin()
|
public boolean isAdmin()
|
||||||
{
|
|
||||||
return isAdmin(this.userId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isAdmin(Long userId)
|
|
||||||
{
|
{
|
||||||
return UserConstants.isAdmin(userId);
|
return UserConstants.isAdmin(userId);
|
||||||
}
|
}
|
||||||
@@ -248,6 +246,16 @@ public class SysUser extends BaseEntity
|
|||||||
this.loginDate = loginDate;
|
this.loginDate = loginDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Date getPwdUpdateDate()
|
||||||
|
{
|
||||||
|
return pwdUpdateDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPwdUpdateDate(Date pwdUpdateDate)
|
||||||
|
{
|
||||||
|
this.pwdUpdateDate = pwdUpdateDate;
|
||||||
|
}
|
||||||
|
|
||||||
public SysDept getDept()
|
public SysDept getDept()
|
||||||
{
|
{
|
||||||
return dept;
|
return dept;
|
||||||
@@ -297,6 +305,7 @@ public class SysUser extends BaseEntity
|
|||||||
{
|
{
|
||||||
this.roleId = roleId;
|
this.roleId = roleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
@@ -313,6 +322,7 @@ public class SysUser extends BaseEntity
|
|||||||
.append("delFlag", getDelFlag())
|
.append("delFlag", getDelFlag())
|
||||||
.append("loginIp", getLoginIp())
|
.append("loginIp", getLoginIp())
|
||||||
.append("loginDate", getLoginDate())
|
.append("loginDate", getLoginDate())
|
||||||
|
.append("pwdUpdateDate", getPwdUpdateDate())
|
||||||
.append("createBy", getCreateBy())
|
.append("createBy", getCreateBy())
|
||||||
.append("createTime", getCreateTime())
|
.append("createTime", getCreateTime())
|
||||||
.append("updateBy", getUpdateBy())
|
.append("updateBy", getUpdateBy())
|
||||||
|
|||||||
@@ -30,6 +30,12 @@ public class RemoteFileFallbackFactory implements FallbackFactory<RemoteFileServ
|
|||||||
{
|
{
|
||||||
return R.fail("上传文件失败:" + throwable.getMessage());
|
return R.fail("上传文件失败:" + throwable.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R<Boolean> delete(String fileUrl)
|
||||||
|
{
|
||||||
|
return R.fail("删除文件失败:" + throwable.getMessage());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.6.5</version>
|
<version>3.6.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.ruoyi.auth.controller;
|
package com.ruoyi.auth.controller;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
|||||||
@@ -143,6 +143,7 @@ public class SysLoginService
|
|||||||
SysUser sysUser = new SysUser();
|
SysUser sysUser = new SysUser();
|
||||||
sysUser.setUserName(username);
|
sysUser.setUserName(username);
|
||||||
sysUser.setNickName(username);
|
sysUser.setNickName(username);
|
||||||
|
sysUser.setPwdUpdateDate(DateUtils.getNowDate());
|
||||||
sysUser.setPassword(SecurityUtils.encryptPassword(password));
|
sysUser.setPassword(SecurityUtils.encryptPassword(password));
|
||||||
R<?> registerResult = remoteUserService.registerUserInfo(sysUser, SecurityConstants.INNER);
|
R<?> registerResult = remoteUserService.registerUserInfo(sysUser, SecurityConstants.INNER);
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
# Tomcat
|
|
||||||
server:
|
|
||||||
port: 9200
|
|
||||||
|
|
||||||
# Spring
|
|
||||||
spring:
|
|
||||||
application:
|
|
||||||
# 应用名称
|
|
||||||
name: ${SERVER_NAME}
|
|
||||||
cloud:
|
|
||||||
nacos:
|
|
||||||
discovery:
|
|
||||||
# 服务注册地址
|
|
||||||
server-addr: ${NACOS_SERVER}:${NACOS_PORT}
|
|
||||||
config:
|
|
||||||
# 配置中心地址
|
|
||||||
server-addr: ${NACOS_SERVER}:${NACOS_PORT}
|
|
||||||
# 配置文件格式
|
|
||||||
file-extension: yml
|
|
||||||
# 共享配置
|
|
||||||
shared-configs:
|
|
||||||
- ${NACOS_SHARED_CONFIGS}
|
|
||||||
@@ -9,7 +9,7 @@ spring:
|
|||||||
name: ruoyi-auth
|
name: ruoyi-auth
|
||||||
profiles:
|
profiles:
|
||||||
# 环境配置
|
# 环境配置
|
||||||
active: ${SPRING_PROFILES_ACTIVE:dev}
|
active: dev
|
||||||
cloud:
|
cloud:
|
||||||
nacos:
|
nacos:
|
||||||
discovery:
|
discovery:
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.6.5</version>
|
<version>3.6.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.6.5</version>
|
<version>3.6.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@@ -53,12 +53,24 @@
|
|||||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Mybatis Spring -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis</groupId>
|
||||||
|
<artifactId>mybatis-spring</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Hibernate Validator -->
|
<!-- Hibernate Validator -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-validation</artifactId>
|
<artifactId>spring-boot-starter-validation</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Spring Aop -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-aop</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Jackson -->
|
<!-- Jackson -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
@@ -81,6 +93,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.xml.bind</groupId>
|
<groupId>javax.xml.bind</groupId>
|
||||||
<artifactId>jaxb-api</artifactId>
|
<artifactId>jaxb-api</artifactId>
|
||||||
|
<version>2.3.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Apache Lang3 -->
|
<!-- Apache Lang3 -->
|
||||||
@@ -103,8 +116,8 @@
|
|||||||
|
|
||||||
<!-- Java Servlet -->
|
<!-- Java Servlet -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.servlet</groupId>
|
<groupId>jakarta.servlet</groupId>
|
||||||
<artifactId>javax.servlet-api</artifactId>
|
<artifactId>jakarta.servlet-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
@@ -51,7 +51,8 @@ public @interface Excel
|
|||||||
/**
|
/**
|
||||||
* BigDecimal 舍入规则 默认:BigDecimal.ROUND_HALF_EVEN
|
* BigDecimal 舍入规则 默认:BigDecimal.ROUND_HALF_EVEN
|
||||||
*/
|
*/
|
||||||
public int roundingMode() default BigDecimal.ROUND_HALF_EVEN;
|
@SuppressWarnings("deprecation")
|
||||||
|
public int roundingMode() default BigDecimal.ROUND_HALF_EVEN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出时在excel中每个列的高度
|
* 导出时在excel中每个列的高度
|
||||||
|
|||||||
@@ -87,6 +87,16 @@ public class Constants
|
|||||||
*/
|
*/
|
||||||
public static final String LOGIN_FAIL = "Error";
|
public static final String LOGIN_FAIL = "Error";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所有权限标识
|
||||||
|
*/
|
||||||
|
public static final String ALL_PERMISSION = "*:*:*";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理员角色权限标识
|
||||||
|
*/
|
||||||
|
public static final String SUPER_ADMIN = "admin";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前记录起始索引
|
* 当前记录起始索引
|
||||||
*/
|
*/
|
||||||
@@ -120,7 +130,7 @@ public class Constants
|
|||||||
/**
|
/**
|
||||||
* 自动识别json对象白名单配置(仅允许解析的包名,范围越小越安全)
|
* 自动识别json对象白名单配置(仅允许解析的包名,范围越小越安全)
|
||||||
*/
|
*/
|
||||||
public static final String[] JSON_WHITELIST_STR = { "org.springframework", "com.ruoyi" };
|
public static final String[] JSON_WHITELIST_STR = { "com.ruoyi" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 定时任务白名单配置(仅允许访问的包名,如其他需要可以自行添加)
|
* 定时任务白名单配置(仅允许访问的包名,如其他需要可以自行添加)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.ruoyi.common.core.exception.file;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件上传 误异常类
|
* 文件上传无效扩展名异常类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -136,6 +136,14 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
|||||||
return new Date(time);
|
return new Date(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算相差天数
|
||||||
|
*/
|
||||||
|
public static int differentDaysByMillisecond(Date date1, Date date2)
|
||||||
|
{
|
||||||
|
return Math.abs((int) ((date2.getTime() - date1.getTime()) / (1000 * 3600 * 24)));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算时间差
|
* 计算时间差
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ import java.util.Collections;
|
|||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.servlet.ServletRequest;
|
import jakarta.servlet.ServletRequest;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import javax.servlet.http.HttpSession;
|
import jakarta.servlet.http.HttpSession;
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
import org.springframework.core.io.buffer.DataBuffer;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package com.ruoyi.common.core.utils.bean;
|
package com.ruoyi.common.core.utils.bean;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import javax.validation.ConstraintViolation;
|
import jakarta.validation.ConstraintViolation;
|
||||||
import javax.validation.ConstraintViolationException;
|
import jakarta.validation.ConstraintViolationException;
|
||||||
import javax.validation.Validator;
|
import jakarta.validation.Validator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* bean对象属性验证
|
* bean对象属性验证
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import java.io.OutputStream;
|
|||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
|
||||||
@@ -114,20 +114,20 @@ public class FileUtils
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查文件是否可下载
|
* 校验文件路径合法性(安全性与扩展名)
|
||||||
*
|
*
|
||||||
* @param resource 需要下载的文件
|
* @param fileUrl 待校验的文件地址
|
||||||
* @return true 正常 false 非法
|
* @return true 正常 false 非法
|
||||||
*/
|
*/
|
||||||
public static boolean checkAllowDownload(String resource)
|
public static boolean validateFilePath(String fileUrl)
|
||||||
{
|
{
|
||||||
// 禁止目录上跳级别
|
// 禁止目录上跳级别
|
||||||
if (StringUtils.contains(resource, ".."))
|
if (StringUtils.contains(fileUrl, ".."))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 判断是否在允许下载的文件规则内
|
// 判断是否在允许下载的文件规则内
|
||||||
return ArrayUtils.contains(MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION, FileTypeUtils.getFileType(resource));
|
return ArrayUtils.contains(MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION, FileTypeUtils.getFileType(fileUrl));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package com.ruoyi.common.core.utils.ip;
|
|||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import com.ruoyi.common.core.utils.ServletUtils;
|
import com.ruoyi.common.core.utils.ServletUtils;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.apache.commons.lang3.RegExUtils;
|
import org.apache.commons.lang3.RegExUtils;
|
||||||
import org.apache.commons.lang3.reflect.FieldUtils;
|
import org.apache.commons.lang3.reflect.FieldUtils;
|
||||||
@@ -73,6 +73,8 @@ public class ExcelUtil<T>
|
|||||||
{
|
{
|
||||||
private static final Logger log = LoggerFactory.getLogger(ExcelUtil.class);
|
private static final Logger log = LoggerFactory.getLogger(ExcelUtil.class);
|
||||||
|
|
||||||
|
public static final String SEPARATOR = ",";
|
||||||
|
|
||||||
public static final String FORMULA_REGEX_STR = "=|-|\\+|@";
|
public static final String FORMULA_REGEX_STR = "=|-|\\+|@";
|
||||||
|
|
||||||
public static final String[] FORMULA_STR = { "=", "-", "+", "@" };
|
public static final String[] FORMULA_STR = { "=", "-", "+", "@" };
|
||||||
@@ -145,23 +147,18 @@ public class ExcelUtil<T>
|
|||||||
/**
|
/**
|
||||||
* 对象的子列表方法
|
* 对象的子列表方法
|
||||||
*/
|
*/
|
||||||
private Method subMethod;
|
private Map<String, Method> subMethods;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对象的子列表属性
|
* 对象的子列表属性
|
||||||
*/
|
*/
|
||||||
private List<Field> subFields;
|
private Map<String, List<Field>> subFieldsMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 统计列表
|
* 统计列表
|
||||||
*/
|
*/
|
||||||
private Map<Integer, Double> statistics = new HashMap<Integer, Double>();
|
private Map<Integer, Double> statistics = new HashMap<Integer, Double>();
|
||||||
|
|
||||||
/**
|
|
||||||
* 数字格式
|
|
||||||
*/
|
|
||||||
private static final DecimalFormat DOUBLE_FORMAT = new DecimalFormat("######0.00");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 实体对象
|
* 实体对象
|
||||||
*/
|
*/
|
||||||
@@ -228,7 +225,10 @@ public class ExcelUtil<T>
|
|||||||
int titleLastCol = this.fields.size() - 1;
|
int titleLastCol = this.fields.size() - 1;
|
||||||
if (isSubList())
|
if (isSubList())
|
||||||
{
|
{
|
||||||
titleLastCol = titleLastCol + subFields.size() - 1;
|
for (List<Field> currentSubFields : subFieldsMap.values())
|
||||||
|
{
|
||||||
|
titleLastCol = titleLastCol + currentSubFields.size() - 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Row titleRow = sheet.createRow(rownum == 0 ? rownum++ : 0);
|
Row titleRow = sheet.createRow(rownum == 0 ? rownum++ : 0);
|
||||||
titleRow.setHeightInPoints(30);
|
titleRow.setHeightInPoints(30);
|
||||||
@@ -248,16 +248,17 @@ public class ExcelUtil<T>
|
|||||||
{
|
{
|
||||||
Row subRow = sheet.createRow(rownum);
|
Row subRow = sheet.createRow(rownum);
|
||||||
int column = 0;
|
int column = 0;
|
||||||
int subFieldSize = subFields != null ? subFields.size() : 0;
|
|
||||||
for (Object[] objects : fields)
|
for (Object[] objects : fields)
|
||||||
{
|
{
|
||||||
Field field = (Field) objects[0];
|
Field field = (Field) objects[0];
|
||||||
Excel attr = (Excel) objects[1];
|
Excel attr = (Excel) objects[1];
|
||||||
|
CellStyle cellStyle = styles.get(StringUtils.format("header_{}_{}", attr.headerColor(), attr.headerBackgroundColor()));
|
||||||
if (Collection.class.isAssignableFrom(field.getType()))
|
if (Collection.class.isAssignableFrom(field.getType()))
|
||||||
{
|
{
|
||||||
Cell cell = subRow.createCell(column);
|
Cell cell = subRow.createCell(column);
|
||||||
cell.setCellValue(attr.name());
|
cell.setCellValue(attr.name());
|
||||||
cell.setCellStyle(styles.get(StringUtils.format("header_{}_{}", attr.headerColor(), attr.headerBackgroundColor())));
|
cell.setCellStyle(cellStyle);
|
||||||
|
int subFieldSize = subFieldsMap != null ? subFieldsMap.get(field.getName()).size() : 0;
|
||||||
if (subFieldSize > 1)
|
if (subFieldSize > 1)
|
||||||
{
|
{
|
||||||
CellRangeAddress cellAddress = new CellRangeAddress(rownum, rownum, column, column + subFieldSize - 1);
|
CellRangeAddress cellAddress = new CellRangeAddress(rownum, rownum, column, column + subFieldSize - 1);
|
||||||
@@ -269,7 +270,7 @@ public class ExcelUtil<T>
|
|||||||
{
|
{
|
||||||
Cell cell = subRow.createCell(column++);
|
Cell cell = subRow.createCell(column++);
|
||||||
cell.setCellValue(attr.name());
|
cell.setCellValue(attr.name());
|
||||||
cell.setCellStyle(styles.get(StringUtils.format("header_{}_{}", attr.headerColor(), attr.headerBackgroundColor())));
|
cell.setCellStyle(cellStyle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rownum++;
|
rownum++;
|
||||||
@@ -341,7 +342,11 @@ public class ExcelUtil<T>
|
|||||||
Map<String, Integer> cellMap = new HashMap<String, Integer>();
|
Map<String, Integer> cellMap = new HashMap<String, Integer>();
|
||||||
// 获取表头
|
// 获取表头
|
||||||
Row heard = sheet.getRow(titleNum);
|
Row heard = sheet.getRow(titleNum);
|
||||||
for (int i = 0; i < heard.getPhysicalNumberOfCells(); i++)
|
if (heard == null)
|
||||||
|
{
|
||||||
|
throw new UtilException("文件标题行为空,请检查Excel文件格式");
|
||||||
|
}
|
||||||
|
for (int i = 0; i < heard.getLastCellNum(); i++)
|
||||||
{
|
{
|
||||||
Cell cell = heard.getCell(i);
|
Cell cell = heard.getCell(i);
|
||||||
if (StringUtils.isNotNull(cell))
|
if (StringUtils.isNotNull(cell))
|
||||||
@@ -349,10 +354,6 @@ public class ExcelUtil<T>
|
|||||||
String value = this.getCellValue(heard, i).toString();
|
String value = this.getCellValue(heard, i).toString();
|
||||||
cellMap.put(value, i);
|
cellMap.put(value, i);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
cellMap.put(null, i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// 有数据时才处理 得到类的所有field.
|
// 有数据时才处理 得到类的所有field.
|
||||||
List<Object[]> fields = this.getFields();
|
List<Object[]> fields = this.getFields();
|
||||||
@@ -381,7 +382,7 @@ public class ExcelUtil<T>
|
|||||||
Object val = this.getCellValue(row, entry.getKey());
|
Object val = this.getCellValue(row, entry.getKey());
|
||||||
|
|
||||||
// 如果不存在实例则新建.
|
// 如果不存在实例则新建.
|
||||||
entity = (entity == null ? clazz.newInstance() : entity);
|
entity = (entity == null ? clazz.getDeclaredConstructor().newInstance() : entity);
|
||||||
// 从map中得到对应列的field.
|
// 从map中得到对应列的field.
|
||||||
Field field = (Field) entry.getValue()[0];
|
Field field = (Field) entry.getValue()[0];
|
||||||
Excel attr = (Excel) entry.getValue()[1];
|
Excel attr = (Excel) entry.getValue()[1];
|
||||||
@@ -390,7 +391,7 @@ public class ExcelUtil<T>
|
|||||||
if (String.class == fieldType)
|
if (String.class == fieldType)
|
||||||
{
|
{
|
||||||
String s = Convert.toStr(val);
|
String s = Convert.toStr(val);
|
||||||
if (StringUtils.endsWith(s, ".0"))
|
if (s.matches("^\\d+\\.0$"))
|
||||||
{
|
{
|
||||||
val = StringUtils.substringBefore(s, ".0");
|
val = StringUtils.substringBefore(s, ".0");
|
||||||
}
|
}
|
||||||
@@ -565,7 +566,8 @@ public class ExcelUtil<T>
|
|||||||
Excel excel = (Excel) os[1];
|
Excel excel = (Excel) os[1];
|
||||||
if (Collection.class.isAssignableFrom(field.getType()))
|
if (Collection.class.isAssignableFrom(field.getType()))
|
||||||
{
|
{
|
||||||
for (Field subField : subFields)
|
List<Field> currentSubFields = subFieldsMap.get(field.getName());
|
||||||
|
for (Field subField : currentSubFields)
|
||||||
{
|
{
|
||||||
Excel subExcel = subField.getAnnotation(Excel.class);
|
Excel subExcel = subField.getAnnotation(Excel.class);
|
||||||
this.createHeadCell(subExcel, row, column++);
|
this.createHeadCell(subExcel, row, column++);
|
||||||
@@ -578,7 +580,7 @@ public class ExcelUtil<T>
|
|||||||
}
|
}
|
||||||
if (Type.EXPORT.equals(type))
|
if (Type.EXPORT.equals(type))
|
||||||
{
|
{
|
||||||
fillExcelData(index, row);
|
fillExcelData(index);
|
||||||
addStatisticsRow();
|
addStatisticsRow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -588,10 +590,9 @@ public class ExcelUtil<T>
|
|||||||
* 填充excel数据
|
* 填充excel数据
|
||||||
*
|
*
|
||||||
* @param index 序号
|
* @param index 序号
|
||||||
* @param row 单元格行
|
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void fillExcelData(int index, Row row)
|
public void fillExcelData(int index)
|
||||||
{
|
{
|
||||||
int startNo = index * sheetSize;
|
int startNo = index * sheetSize;
|
||||||
int endNo = Math.min(startNo + sheetSize, list.size());
|
int endNo = Math.min(startNo + sheetSize, list.size());
|
||||||
@@ -599,7 +600,7 @@ public class ExcelUtil<T>
|
|||||||
|
|
||||||
for (int i = startNo; i < endNo; i++)
|
for (int i = startNo; i < endNo; i++)
|
||||||
{
|
{
|
||||||
row = sheet.createRow(currentRowNum);
|
Row row = sheet.createRow(currentRowNum);
|
||||||
T vo = (T) list.get(i);
|
T vo = (T) list.get(i);
|
||||||
int column = 0;
|
int column = 0;
|
||||||
int maxSubListSize = getCurrentMaxSubListSize(vo);
|
int maxSubListSize = getCurrentMaxSubListSize(vo);
|
||||||
@@ -612,6 +613,7 @@ public class ExcelUtil<T>
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Collection<?> subList = (Collection<?>) getTargetValue(vo, field, excel);
|
Collection<?> subList = (Collection<?>) getTargetValue(vo, field, excel);
|
||||||
|
List<Field> currentSubFields = subFieldsMap.get(field.getName());
|
||||||
if (subList != null && !subList.isEmpty())
|
if (subList != null && !subList.isEmpty())
|
||||||
{
|
{
|
||||||
int subIndex = 0;
|
int subIndex = 0;
|
||||||
@@ -624,15 +626,15 @@ public class ExcelUtil<T>
|
|||||||
}
|
}
|
||||||
|
|
||||||
int subColumn = column;
|
int subColumn = column;
|
||||||
for (Field subField : subFields)
|
for (Field subField : currentSubFields)
|
||||||
{
|
{
|
||||||
Excel subExcel = subField.getAnnotation(Excel.class);
|
Excel subExcel = subField.getAnnotation(Excel.class);
|
||||||
addCell(subExcel, subRow, (T) subVo, subField, subColumn++);
|
addCell(subExcel, subRow, (T) subVo, subField, subColumn++);
|
||||||
}
|
}
|
||||||
subIndex++;
|
subIndex++;
|
||||||
}
|
}
|
||||||
column += subFields.size();
|
|
||||||
}
|
}
|
||||||
|
column += currentSubFields.size();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -724,6 +726,7 @@ public class ExcelUtil<T>
|
|||||||
style = wb.createCellStyle();
|
style = wb.createCellStyle();
|
||||||
style.setAlignment(HorizontalAlignment.CENTER);
|
style.setAlignment(HorizontalAlignment.CENTER);
|
||||||
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||||
|
style.setDataFormat(dataFormat.getFormat("######0.00"));
|
||||||
Font totalFont = wb.createFont();
|
Font totalFont = wb.createFont();
|
||||||
totalFont.setFontName("Arial");
|
totalFont.setFontName("Arial");
|
||||||
totalFont.setFontHeightInPoints((short) 10);
|
totalFont.setFontHeightInPoints((short) 10);
|
||||||
@@ -972,7 +975,8 @@ public class ExcelUtil<T>
|
|||||||
/**
|
/**
|
||||||
* 添加单元格
|
* 添加单元格
|
||||||
*/
|
*/
|
||||||
public Cell addCell(Excel attr, Row row, T vo, Field field, int column)
|
@SuppressWarnings("deprecation")
|
||||||
|
public Cell addCell(Excel attr, Row row, T vo, Field field, int column)
|
||||||
{
|
{
|
||||||
Cell cell = null;
|
Cell cell = null;
|
||||||
try
|
try
|
||||||
@@ -984,7 +988,7 @@ public class ExcelUtil<T>
|
|||||||
{
|
{
|
||||||
// 创建cell
|
// 创建cell
|
||||||
cell = row.createCell(column);
|
cell = row.createCell(column);
|
||||||
if (isSubListValue(vo) && getListCellValue(vo).size() > 1 && attr.needMerge())
|
if (isSubListValue(vo) && getListCellValue(vo) > 1 && attr.needMerge())
|
||||||
{
|
{
|
||||||
if (subMergedLastRowNum >= subMergedFirstRowNum)
|
if (subMergedLastRowNum >= subMergedFirstRowNum)
|
||||||
{
|
{
|
||||||
@@ -1000,7 +1004,7 @@ public class ExcelUtil<T>
|
|||||||
String separator = attr.separator();
|
String separator = attr.separator();
|
||||||
if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value))
|
if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value))
|
||||||
{
|
{
|
||||||
cell.getCellStyle().setDataFormat(this.wb.getCreationHelper().createDataFormat().getFormat(dateFormat));
|
cell.setCellStyle(createCellStyle(cell.getCellStyle(), dateFormat));
|
||||||
cell.setCellValue(parseDateToStr(dateFormat, value));
|
cell.setCellValue(parseDateToStr(dateFormat, value));
|
||||||
}
|
}
|
||||||
else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value))
|
else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value))
|
||||||
@@ -1030,6 +1034,21 @@ public class ExcelUtil<T>
|
|||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用自定义格式,同时避免样式污染
|
||||||
|
*
|
||||||
|
* @param cellStyle 从此样式复制
|
||||||
|
* @param format 格式匹配的字符串
|
||||||
|
* @return 格式化后CellStyle对象
|
||||||
|
*/
|
||||||
|
private CellStyle createCellStyle(CellStyle cellStyle, String format)
|
||||||
|
{
|
||||||
|
CellStyle style = wb.createCellStyle();
|
||||||
|
style.cloneStyleFrom(cellStyle);
|
||||||
|
style.setDataFormat(wb.getCreationHelper().createDataFormat().getFormat(format));
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置 POI XSSFSheet 单元格提示或选择框
|
* 设置 POI XSSFSheet 单元格提示或选择框
|
||||||
*
|
*
|
||||||
@@ -1081,18 +1100,36 @@ public class ExcelUtil<T>
|
|||||||
public void setXSSFValidationWithHidden(Sheet sheet, String[] textlist, String promptContent, int firstRow, int endRow, int firstCol, int endCol)
|
public void setXSSFValidationWithHidden(Sheet sheet, String[] textlist, String promptContent, int firstRow, int endRow, int firstCol, int endCol)
|
||||||
{
|
{
|
||||||
String hideSheetName = "combo_" + firstCol + "_" + endCol;
|
String hideSheetName = "combo_" + firstCol + "_" + endCol;
|
||||||
Sheet hideSheet = wb.createSheet(hideSheetName); // 用于存储 下拉菜单数据
|
Sheet hideSheet = null;
|
||||||
for (int i = 0; i < textlist.length; i++)
|
String hideSheetDataName = hideSheetName + "_data";
|
||||||
|
Name name = wb.getName(hideSheetDataName);
|
||||||
|
if (name != null)
|
||||||
{
|
{
|
||||||
hideSheet.createRow(i).createCell(0).setCellValue(textlist[i]);
|
// 名称已存在,尝试从名称的引用中找到sheet名称
|
||||||
|
String refersToFormula = name.getRefersToFormula();
|
||||||
|
if (StringUtils.isNotEmpty(refersToFormula) && refersToFormula.contains("!"))
|
||||||
|
{
|
||||||
|
String sheetNameFromFormula = refersToFormula.substring(0, refersToFormula.indexOf("!"));
|
||||||
|
hideSheet = wb.getSheet(sheetNameFromFormula);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 创建名称,可被其他单元格引用
|
|
||||||
Name name = wb.createName();
|
if (hideSheet == null)
|
||||||
name.setNameName(hideSheetName + "_data");
|
{
|
||||||
name.setRefersToFormula(hideSheetName + "!$A$1:$A$" + textlist.length);
|
hideSheet = wb.createSheet(hideSheetName); // 用于存储 下拉菜单数据
|
||||||
|
for (int i = 0; i < textlist.length; i++)
|
||||||
|
{
|
||||||
|
hideSheet.createRow(i).createCell(0).setCellValue(textlist[i]);
|
||||||
|
}
|
||||||
|
// 创建名称,可被其他单元格引用
|
||||||
|
name = wb.createName();
|
||||||
|
name.setNameName(hideSheetDataName);
|
||||||
|
name.setRefersToFormula(hideSheetName + "!$A$1:$A$" + textlist.length);
|
||||||
|
}
|
||||||
|
|
||||||
DataValidationHelper helper = sheet.getDataValidationHelper();
|
DataValidationHelper helper = sheet.getDataValidationHelper();
|
||||||
// 加载下拉列表内容
|
// 加载下拉列表内容
|
||||||
DataValidationConstraint constraint = helper.createFormulaListConstraint(hideSheetName + "_data");
|
DataValidationConstraint constraint = helper.createFormulaListConstraint(hideSheetDataName);
|
||||||
// 设置数据有效性加载在哪个单元格上,四个参数分别是:起始行、终止行、起始列、终止列
|
// 设置数据有效性加载在哪个单元格上,四个参数分别是:起始行、终止行、起始列、终止列
|
||||||
CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol);
|
CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol);
|
||||||
// 数据有效性对象
|
// 数据有效性对象
|
||||||
@@ -1130,7 +1167,7 @@ public class ExcelUtil<T>
|
|||||||
public static String convertByExp(String propertyValue, String converterExp, String separator)
|
public static String convertByExp(String propertyValue, String converterExp, String separator)
|
||||||
{
|
{
|
||||||
StringBuilder propertyString = new StringBuilder();
|
StringBuilder propertyString = new StringBuilder();
|
||||||
String[] convertSource = converterExp.split(",");
|
String[] convertSource = converterExp.split(SEPARATOR);
|
||||||
for (String item : convertSource)
|
for (String item : convertSource)
|
||||||
{
|
{
|
||||||
String[] itemArray = item.split("=");
|
String[] itemArray = item.split("=");
|
||||||
@@ -1167,7 +1204,7 @@ public class ExcelUtil<T>
|
|||||||
public static String reverseByExp(String propertyValue, String converterExp, String separator)
|
public static String reverseByExp(String propertyValue, String converterExp, String separator)
|
||||||
{
|
{
|
||||||
StringBuilder propertyString = new StringBuilder();
|
StringBuilder propertyString = new StringBuilder();
|
||||||
String[] convertSource = converterExp.split(",");
|
String[] convertSource = converterExp.split(SEPARATOR);
|
||||||
for (String item : convertSource)
|
for (String item : convertSource)
|
||||||
{
|
{
|
||||||
String[] itemArray = item.split("=");
|
String[] itemArray = item.split("=");
|
||||||
@@ -1204,7 +1241,7 @@ public class ExcelUtil<T>
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Object instance = excel.handler().newInstance();
|
Object instance = excel.handler().getDeclaredConstructor().newInstance();
|
||||||
Method formatMethod = excel.handler().getMethod("format", new Class[] { Object.class, String[].class, Cell.class, Workbook.class });
|
Method formatMethod = excel.handler().getMethod("format", new Class[] { Object.class, String[].class, Cell.class, Workbook.class });
|
||||||
value = formatMethod.invoke(instance, value, excel.args(), cell, this.wb);
|
value = formatMethod.invoke(instance, value, excel.args(), cell, this.wb);
|
||||||
}
|
}
|
||||||
@@ -1255,7 +1292,7 @@ public class ExcelUtil<T>
|
|||||||
{
|
{
|
||||||
cell = row.createCell(key);
|
cell = row.createCell(key);
|
||||||
cell.setCellStyle(styles.get("total"));
|
cell.setCellStyle(styles.get("total"));
|
||||||
cell.setCellValue(DOUBLE_FORMAT.format(statistics.get(key)));
|
cell.setCellValue(statistics.get(key));
|
||||||
}
|
}
|
||||||
statistics.clear();
|
statistics.clear();
|
||||||
}
|
}
|
||||||
@@ -1330,6 +1367,8 @@ public class ExcelUtil<T>
|
|||||||
{
|
{
|
||||||
List<Object[]> fields = new ArrayList<Object[]>();
|
List<Object[]> fields = new ArrayList<Object[]>();
|
||||||
List<Field> tempFields = new ArrayList<>();
|
List<Field> tempFields = new ArrayList<>();
|
||||||
|
subFieldsMap = new HashMap<>();
|
||||||
|
subMethods = new HashMap<>();
|
||||||
tempFields.addAll(Arrays.asList(clazz.getSuperclass().getDeclaredFields()));
|
tempFields.addAll(Arrays.asList(clazz.getSuperclass().getDeclaredFields()));
|
||||||
tempFields.addAll(Arrays.asList(clazz.getDeclaredFields()));
|
tempFields.addAll(Arrays.asList(clazz.getDeclaredFields()));
|
||||||
if (StringUtils.isNotEmpty(includeFields))
|
if (StringUtils.isNotEmpty(includeFields))
|
||||||
@@ -1377,10 +1416,11 @@ public class ExcelUtil<T>
|
|||||||
}
|
}
|
||||||
if (Collection.class.isAssignableFrom(field.getType()))
|
if (Collection.class.isAssignableFrom(field.getType()))
|
||||||
{
|
{
|
||||||
subMethod = getSubMethod(field.getName(), clazz);
|
String fieldName = field.getName();
|
||||||
|
subMethods.put(fieldName, getSubMethod(fieldName, clazz));
|
||||||
ParameterizedType pt = (ParameterizedType) field.getGenericType();
|
ParameterizedType pt = (ParameterizedType) field.getGenericType();
|
||||||
Class<?> subClass = (Class<?>) pt.getActualTypeArguments()[0];
|
Class<?> subClass = (Class<?>) pt.getActualTypeArguments()[0];
|
||||||
this.subFields = FieldUtils.getFieldsListWithAnnotation(subClass, Excel.class);
|
subFieldsMap.put(fieldName, FieldUtils.getFieldsListWithAnnotation(subClass, Excel.class));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1449,7 +1489,8 @@ public class ExcelUtil<T>
|
|||||||
{
|
{
|
||||||
this.sheet = wb.createSheet();
|
this.sheet = wb.createSheet();
|
||||||
this.createTitle();
|
this.createTitle();
|
||||||
wb.setSheetName(index, sheetName + index);
|
int actualIndex = wb.getSheetIndex(this.sheet);
|
||||||
|
wb.setSheetName(actualIndex, sheetName + index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1574,7 +1615,7 @@ public class ExcelUtil<T>
|
|||||||
*/
|
*/
|
||||||
public boolean isSubList()
|
public boolean isSubList()
|
||||||
{
|
{
|
||||||
return StringUtils.isNotNull(subFields) && subFields.size() > 0;
|
return !StringUtils.isEmpty(subFieldsMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1582,24 +1623,32 @@ public class ExcelUtil<T>
|
|||||||
*/
|
*/
|
||||||
public boolean isSubListValue(T vo)
|
public boolean isSubListValue(T vo)
|
||||||
{
|
{
|
||||||
return StringUtils.isNotNull(subFields) && subFields.size() > 0 && StringUtils.isNotNull(getListCellValue(vo)) && getListCellValue(vo).size() > 0;
|
return !StringUtils.isEmpty(subFieldsMap) && getListCellValue(vo) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取集合的值
|
* 获取集合的值
|
||||||
*/
|
*/
|
||||||
public Collection<?> getListCellValue(Object obj)
|
public int getListCellValue(Object obj)
|
||||||
{
|
{
|
||||||
Object value;
|
Collection<?> value;
|
||||||
|
int max = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
value = subMethod.invoke(obj, new Object[] {});
|
for (String s : subMethods.keySet())
|
||||||
|
{
|
||||||
|
value = (Collection<?>) subMethods.get(s).invoke(obj);
|
||||||
|
if (value.size() > max)
|
||||||
|
{
|
||||||
|
max = value.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
return new ArrayList<Object>();
|
return 0;
|
||||||
}
|
}
|
||||||
return (Collection<?>) value;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -310,7 +310,8 @@ public class ReflectUtils
|
|||||||
/**
|
/**
|
||||||
* 改变private/protected的方法为public,尽量不调用实际改动的语句,避免JDK的SecurityManager抱怨。
|
* 改变private/protected的方法为public,尽量不调用实际改动的语句,避免JDK的SecurityManager抱怨。
|
||||||
*/
|
*/
|
||||||
public static void makeAccessible(Method method)
|
@SuppressWarnings("deprecation")
|
||||||
|
public static void makeAccessible(Method method)
|
||||||
{
|
{
|
||||||
if ((!Modifier.isPublic(method.getModifiers()) || !Modifier.isPublic(method.getDeclaringClass().getModifiers()))
|
if ((!Modifier.isPublic(method.getModifiers()) || !Modifier.isPublic(method.getDeclaringClass().getModifiers()))
|
||||||
&& !method.isAccessible())
|
&& !method.isAccessible())
|
||||||
@@ -322,7 +323,8 @@ public class ReflectUtils
|
|||||||
/**
|
/**
|
||||||
* 改变private/protected的成员变量为public,尽量不调用实际改动的语句,避免JDK的SecurityManager抱怨。
|
* 改变private/protected的成员变量为public,尽量不调用实际改动的语句,避免JDK的SecurityManager抱怨。
|
||||||
*/
|
*/
|
||||||
public static void makeAccessible(Field field)
|
@SuppressWarnings("deprecation")
|
||||||
|
public static void makeAccessible(Field field)
|
||||||
{
|
{
|
||||||
if ((!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers())
|
if ((!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers())
|
||||||
|| Modifier.isFinal(field.getModifiers())) && !field.isAccessible())
|
|| Modifier.isFinal(field.getModifiers())) && !field.isAccessible())
|
||||||
|
|||||||
@@ -343,25 +343,25 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
|
|||||||
final StringBuilder builder = new StringBuilder(isSimple ? 32 : 36);
|
final StringBuilder builder = new StringBuilder(isSimple ? 32 : 36);
|
||||||
// time_low
|
// time_low
|
||||||
builder.append(digits(mostSigBits >> 32, 8));
|
builder.append(digits(mostSigBits >> 32, 8));
|
||||||
if (false == isSimple)
|
if (!isSimple)
|
||||||
{
|
{
|
||||||
builder.append('-');
|
builder.append('-');
|
||||||
}
|
}
|
||||||
// time_mid
|
// time_mid
|
||||||
builder.append(digits(mostSigBits >> 16, 4));
|
builder.append(digits(mostSigBits >> 16, 4));
|
||||||
if (false == isSimple)
|
if (!isSimple)
|
||||||
{
|
{
|
||||||
builder.append('-');
|
builder.append('-');
|
||||||
}
|
}
|
||||||
// time_high_and_version
|
// time_high_and_version
|
||||||
builder.append(digits(mostSigBits, 4));
|
builder.append(digits(mostSigBits, 4));
|
||||||
if (false == isSimple)
|
if (!isSimple)
|
||||||
{
|
{
|
||||||
builder.append('-');
|
builder.append('-');
|
||||||
}
|
}
|
||||||
// variant_and_sequence
|
// variant_and_sequence
|
||||||
builder.append(digits(leastSigBits >> 48, 4));
|
builder.append(digits(leastSigBits >> 48, 4));
|
||||||
if (false == isSimple)
|
if (!isSimple)
|
||||||
{
|
{
|
||||||
builder.append('-');
|
builder.append('-');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.ruoyi.common.core.xss;
|
package com.ruoyi.common.core.xss;
|
||||||
|
|
||||||
import javax.validation.Constraint;
|
import jakarta.validation.Constraint;
|
||||||
import javax.validation.Payload;
|
import jakarta.validation.Payload;
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package com.ruoyi.common.core.xss;
|
|||||||
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import javax.validation.ConstraintValidator;
|
import jakarta.validation.ConstraintValidator;
|
||||||
import javax.validation.ConstraintValidatorContext;
|
import jakarta.validation.ConstraintValidatorContext;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.6.5</version>
|
<version>3.6.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ public class DataScopeAspect
|
|||||||
List<String> conditions = new ArrayList<String>();
|
List<String> conditions = new ArrayList<String>();
|
||||||
List<String> scopeCustomIds = new ArrayList<String>();
|
List<String> scopeCustomIds = new ArrayList<String>();
|
||||||
user.getRoles().forEach(role -> {
|
user.getRoles().forEach(role -> {
|
||||||
if (DATA_SCOPE_CUSTOM.equals(role.getDataScope()) && StringUtils.equals(role.getStatus(), UserConstants.ROLE_NORMAL) && StringUtils.containsAny(role.getPermissions(), Convert.toStrArray(permission)))
|
if (DATA_SCOPE_CUSTOM.equals(role.getDataScope()) && StringUtils.equals(role.getStatus(), UserConstants.ROLE_NORMAL) && (StringUtils.isEmpty(permission) || StringUtils.containsAny(role.getPermissions(), Convert.toStrArray(permission))))
|
||||||
{
|
{
|
||||||
scopeCustomIds.add(Convert.toStr(role.getRoleId()));
|
scopeCustomIds.add(Convert.toStr(role.getRoleId()));
|
||||||
}
|
}
|
||||||
@@ -107,7 +107,7 @@ public class DataScopeAspect
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!StringUtils.containsAny(role.getPermissions(), Convert.toStrArray(permission)))
|
if (StringUtils.isNotEmpty(permission) && !StringUtils.containsAny(role.getPermissions(), Convert.toStrArray(permission)))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.6.5</version>
|
<version>3.6.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@@ -20,14 +20,14 @@
|
|||||||
<!-- Druid -->
|
<!-- Druid -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>druid-spring-boot-starter</artifactId>
|
<artifactId>druid-spring-boot-3-starter</artifactId>
|
||||||
<version>${druid.version}</version>
|
<version>${druid.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Dynamic DataSource -->
|
<!-- Dynamic DataSource -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baomidou</groupId>
|
<groupId>com.baomidou</groupId>
|
||||||
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
|
<artifactId>dynamic-datasource-spring-boot3-starter</artifactId>
|
||||||
<version>${dynamic-ds.version}</version>
|
<version>${dynamic-ds.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.6.5</version>
|
<version>3.6.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package com.ruoyi.common.log.aspect;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.aspectj.lang.JoinPoint;
|
import org.aspectj.lang.JoinPoint;
|
||||||
import org.aspectj.lang.annotation.AfterReturning;
|
import org.aspectj.lang.annotation.AfterReturning;
|
||||||
@@ -48,6 +48,9 @@ public class LogAspect
|
|||||||
/** 计算操作消耗时间 */
|
/** 计算操作消耗时间 */
|
||||||
private static final ThreadLocal<Long> TIME_THREADLOCAL = new NamedThreadLocal<Long>("Cost Time");
|
private static final ThreadLocal<Long> TIME_THREADLOCAL = new NamedThreadLocal<Long>("Cost Time");
|
||||||
|
|
||||||
|
/** 参数最大长度限制 */
|
||||||
|
private static final int PARAM_MAX_LENGTH = 2000;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AsyncLogService asyncLogService;
|
private AsyncLogService asyncLogService;
|
||||||
|
|
||||||
@@ -166,16 +169,16 @@ public class LogAspect
|
|||||||
*/
|
*/
|
||||||
private void setRequestValue(JoinPoint joinPoint, SysOperLog operLog, String[] excludeParamNames) throws Exception
|
private void setRequestValue(JoinPoint joinPoint, SysOperLog operLog, String[] excludeParamNames) throws Exception
|
||||||
{
|
{
|
||||||
Map<?, ?> paramsMap = ServletUtils.getParamMap(ServletUtils.getRequest());
|
|
||||||
String requestMethod = operLog.getRequestMethod();
|
String requestMethod = operLog.getRequestMethod();
|
||||||
|
Map<?, ?> paramsMap = ServletUtils.getParamMap(ServletUtils.getRequest());
|
||||||
if (StringUtils.isEmpty(paramsMap) && StringUtils.equalsAny(requestMethod, HttpMethod.PUT.name(), HttpMethod.POST.name(), HttpMethod.DELETE.name()))
|
if (StringUtils.isEmpty(paramsMap) && StringUtils.equalsAny(requestMethod, HttpMethod.PUT.name(), HttpMethod.POST.name(), HttpMethod.DELETE.name()))
|
||||||
{
|
{
|
||||||
String params = argsArrayToString(joinPoint.getArgs(), excludeParamNames);
|
String params = argsArrayToString(joinPoint.getArgs(), excludeParamNames);
|
||||||
operLog.setOperParam(StringUtils.substring(params, 0, 2000));
|
operLog.setOperParam(params);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
operLog.setOperParam(StringUtils.substring(JSON.toJSONString(paramsMap, excludePropertyPreFilter(excludeParamNames)), 0, 2000));
|
operLog.setOperParam(StringUtils.substring(JSON.toJSONString(paramsMap, excludePropertyPreFilter(excludeParamNames)), 0, PARAM_MAX_LENGTH));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,7 +187,7 @@ public class LogAspect
|
|||||||
*/
|
*/
|
||||||
private String argsArrayToString(Object[] paramsArray, String[] excludeParamNames)
|
private String argsArrayToString(Object[] paramsArray, String[] excludeParamNames)
|
||||||
{
|
{
|
||||||
String params = "";
|
StringBuilder params = new StringBuilder();
|
||||||
if (paramsArray != null && paramsArray.length > 0)
|
if (paramsArray != null && paramsArray.length > 0)
|
||||||
{
|
{
|
||||||
for (Object o : paramsArray)
|
for (Object o : paramsArray)
|
||||||
@@ -194,15 +197,20 @@ public class LogAspect
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
String jsonObj = JSON.toJSONString(o, excludePropertyPreFilter(excludeParamNames));
|
String jsonObj = JSON.toJSONString(o, excludePropertyPreFilter(excludeParamNames));
|
||||||
params += jsonObj.toString() + " ";
|
params.append(jsonObj).append(" ");
|
||||||
|
if (params.length() >= PARAM_MAX_LENGTH)
|
||||||
|
{
|
||||||
|
return StringUtils.substring(params.toString(), 0, PARAM_MAX_LENGTH);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
log.error("请求参数拼装异常 msg:{}, 参数:{}", e.getMessage(), paramsArray, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return params.trim();
|
return params.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.6.5</version>
|
<version>3.6.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
|
|||||||
@Configuration
|
@Configuration
|
||||||
@EnableCaching
|
@EnableCaching
|
||||||
@AutoConfigureBefore(RedisAutoConfiguration.class)
|
@AutoConfigureBefore(RedisAutoConfiguration.class)
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public class RedisConfig extends CachingConfigurerSupport
|
public class RedisConfig extends CachingConfigurerSupport
|
||||||
{
|
{
|
||||||
@Bean
|
@Bean
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.6.5</version>
|
<version>3.6.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.6.5</version>
|
<version>3.6.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -56,16 +56,8 @@ public class PreAuthorizeAspect
|
|||||||
// 注解鉴权
|
// 注解鉴权
|
||||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||||
checkMethodAnnotation(signature.getMethod());
|
checkMethodAnnotation(signature.getMethod());
|
||||||
try
|
// 执行原有逻辑
|
||||||
{
|
return joinPoint.proceed();
|
||||||
// 执行原有逻辑
|
|
||||||
Object obj = joinPoint.proceed();
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
catch (Throwable e)
|
|
||||||
{
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.ruoyi.common.security.feign;
|
package com.ruoyi.common.security.feign;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||||
import com.ruoyi.common.core.utils.ServletUtils;
|
import com.ruoyi.common.core.utils.ServletUtils;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.ruoyi.common.security.handler;
|
package com.ruoyi.common.security.handler;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.validation.BindException;
|
import org.springframework.validation.BindException;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.ruoyi.common.security.interceptor;
|
package com.ruoyi.common.security.interceptor;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.web.method.HandlerMethod;
|
import org.springframework.web.method.HandlerMethod;
|
||||||
import org.springframework.web.servlet.AsyncHandlerInterceptor;
|
import org.springframework.web.servlet.AsyncHandlerInterceptor;
|
||||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.ruoyi.common.security.service;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
package com.ruoyi.common.security.utils;
|
package com.ruoyi.common.security.utils;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||||
import com.ruoyi.common.core.constant.TokenConstants;
|
import com.ruoyi.common.core.constant.TokenConstants;
|
||||||
|
import com.ruoyi.common.core.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.context.SecurityContextHolder;
|
import com.ruoyi.common.core.context.SecurityContextHolder;
|
||||||
import com.ruoyi.common.core.utils.ServletUtils;
|
import com.ruoyi.common.core.utils.ServletUtils;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.system.api.model.LoginUser;
|
import com.ruoyi.system.api.model.LoginUser;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 权限获取工具类
|
* 权限获取工具类
|
||||||
@@ -79,6 +80,16 @@ public class SecurityUtils
|
|||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为管理员
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public static boolean isAdmin()
|
||||||
|
{
|
||||||
|
return isAdmin(getUserId());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否为管理员
|
* 是否为管理员
|
||||||
*
|
*
|
||||||
@@ -87,7 +98,7 @@ public class SecurityUtils
|
|||||||
*/
|
*/
|
||||||
public static boolean isAdmin(Long userId)
|
public static boolean isAdmin(Long userId)
|
||||||
{
|
{
|
||||||
return userId != null && 1L == userId;
|
return UserConstants.isAdmin(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.6.5</version>
|
<version>3.6.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.6.5</version>
|
<version>3.6.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
<!-- SpringDoc webmvc -->
|
<!-- SpringDoc webmvc -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springdoc</groupId>
|
<groupId>org.springdoc</groupId>
|
||||||
<artifactId>springdoc-openapi-ui</artifactId>
|
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package com.ruoyi.common.swagger.config;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.springdoc.core.configuration.SpringDocConfiguration;
|
||||||
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
@@ -19,6 +21,7 @@ import io.swagger.v3.oas.models.servers.Server;
|
|||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
|
@AutoConfiguration(before = SpringDocConfiguration.class)
|
||||||
@EnableConfigurationProperties(SpringDocProperties.class)
|
@EnableConfigurationProperties(SpringDocProperties.class)
|
||||||
@ConditionalOnProperty(name = "springdoc.api-docs.enabled", havingValue = "true", matchIfMissing = true)
|
@ConditionalOnProperty(name = "springdoc.api-docs.enabled", havingValue = "true", matchIfMissing = true)
|
||||||
public class SpringDocAutoConfiguration
|
public class SpringDocAutoConfiguration
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.6.5</version>
|
<version>3.6.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@
|
|||||||
<!-- Springdoc -->
|
<!-- Springdoc -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springdoc</groupId>
|
<groupId>org.springdoc</groupId>
|
||||||
<artifactId>springdoc-openapi-webflux-ui</artifactId>
|
<artifactId>springdoc-openapi-starter-webflux-ui</artifactId>
|
||||||
<version>${springdoc.version}</version>
|
<version>${springdoc.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package com.ruoyi.gateway.config;
|
|||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import org.springdoc.core.AbstractSwaggerUiConfigProperties;
|
import org.springdoc.core.properties.AbstractSwaggerUiConfigProperties;
|
||||||
import org.springdoc.core.SwaggerUiConfigProperties;
|
import org.springdoc.core.properties.SwaggerUiConfigProperties;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
|||||||
@@ -1,87 +0,0 @@
|
|||||||
package com.ruoyi.gateway.filter;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import org.springframework.cloud.gateway.filter.GatewayFilter;
|
|
||||||
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
|
||||||
import org.springframework.cloud.gateway.filter.OrderedGatewayFilter;
|
|
||||||
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
|
|
||||||
import org.springframework.cloud.gateway.support.ServerWebExchangeUtils;
|
|
||||||
import org.springframework.http.HttpMethod;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.web.server.ServerWebExchange;
|
|
||||||
import reactor.core.publisher.Mono;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取body请求数据(解决流不能重复读取问题)
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class CacheRequestFilter extends AbstractGatewayFilterFactory<CacheRequestFilter.Config>
|
|
||||||
{
|
|
||||||
public CacheRequestFilter()
|
|
||||||
{
|
|
||||||
super(Config.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String name()
|
|
||||||
{
|
|
||||||
return "CacheRequestFilter";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public GatewayFilter apply(Config config)
|
|
||||||
{
|
|
||||||
CacheRequestGatewayFilter cacheRequestGatewayFilter = new CacheRequestGatewayFilter();
|
|
||||||
Integer order = config.getOrder();
|
|
||||||
if (order == null)
|
|
||||||
{
|
|
||||||
return cacheRequestGatewayFilter;
|
|
||||||
}
|
|
||||||
return new OrderedGatewayFilter(cacheRequestGatewayFilter, order);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class CacheRequestGatewayFilter implements GatewayFilter
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain)
|
|
||||||
{
|
|
||||||
// GET DELETE 不过滤
|
|
||||||
HttpMethod method = exchange.getRequest().getMethod();
|
|
||||||
if (method == null || method == HttpMethod.GET || method == HttpMethod.DELETE)
|
|
||||||
{
|
|
||||||
return chain.filter(exchange);
|
|
||||||
}
|
|
||||||
return ServerWebExchangeUtils.cacheRequestBodyAndRequest(exchange, (serverHttpRequest) -> {
|
|
||||||
if (serverHttpRequest == exchange.getRequest())
|
|
||||||
{
|
|
||||||
return chain.filter(exchange);
|
|
||||||
}
|
|
||||||
return chain.filter(exchange.mutate().request(serverHttpRequest).build());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> shortcutFieldOrder()
|
|
||||||
{
|
|
||||||
return Collections.singletonList("order");
|
|
||||||
}
|
|
||||||
|
|
||||||
static class Config
|
|
||||||
{
|
|
||||||
private Integer order;
|
|
||||||
|
|
||||||
public Integer getOrder()
|
|
||||||
{
|
|
||||||
return order;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOrder(Integer order)
|
|
||||||
{
|
|
||||||
this.order = order;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -64,6 +64,7 @@ public class ValidateCodeFilter extends AbstractGatewayFilterFactory<Object>
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
private String resolveBodyFromRequest(ServerHttpRequest serverHttpRequest)
|
private String resolveBodyFromRequest(ServerHttpRequest serverHttpRequest)
|
||||||
{
|
{
|
||||||
// 获取请求体
|
// 获取请求体
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.ruoyi.gateway.service.impl;
|
|||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import javax.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
# Tomcat
|
|
||||||
server:
|
|
||||||
port: 8080
|
|
||||||
|
|
||||||
# Spring
|
|
||||||
spring:
|
|
||||||
application:
|
|
||||||
# 应用名称
|
|
||||||
name: ${SERVER_NAME}
|
|
||||||
cloud:
|
|
||||||
nacos:
|
|
||||||
discovery:
|
|
||||||
# 服务注册地址
|
|
||||||
server-addr: ${NACOS_SERVER}:${NACOS_PORT}
|
|
||||||
config:
|
|
||||||
# 配置中心地址
|
|
||||||
server-addr: ${NACOS_SERVER}:${NACOS_PORT}
|
|
||||||
# 配置文件格式
|
|
||||||
file-extension: yml
|
|
||||||
# 共享配置
|
|
||||||
shared-configs:
|
|
||||||
- ${NACOS_SHARED_CONFIGS}
|
|
||||||
sentinel:
|
|
||||||
# 取消控制台懒加载
|
|
||||||
eager: true
|
|
||||||
transport:
|
|
||||||
# 控制台地址
|
|
||||||
dashboard: 127.0.0.1:8718
|
|
||||||
# nacos配置持久化
|
|
||||||
datasource:
|
|
||||||
ds1:
|
|
||||||
nacos:
|
|
||||||
server-addr: ${NACOS_SERVER}:${NACOS_PORT}
|
|
||||||
dataId: sentinel-ruoyi-gateway
|
|
||||||
groupId: DEFAULT_GROUP
|
|
||||||
data-type: json
|
|
||||||
rule-type: gw-flow
|
|
||||||
@@ -9,7 +9,7 @@ spring:
|
|||||||
name: ruoyi-gateway
|
name: ruoyi-gateway
|
||||||
profiles:
|
profiles:
|
||||||
# 环境配置
|
# 环境配置
|
||||||
active: ${SPRING_PROFILES_ACTIVE:dev}
|
active: dev
|
||||||
cloud:
|
cloud:
|
||||||
nacos:
|
nacos:
|
||||||
discovery:
|
discovery:
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.6.5</version>
|
<version>3.6.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-modules</artifactId>
|
<artifactId>ruoyi-modules</artifactId>
|
||||||
<version>3.6.5</version>
|
<version>3.6.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@@ -47,12 +47,6 @@
|
|||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- FastDFS -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.tobato</groupId>
|
|
||||||
<artifactId>fastdfs-client</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Minio -->
|
<!-- Minio -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.minio</groupId>
|
<groupId>io.minio</groupId>
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package com.ruoyi.file.config;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import jakarta.servlet.DispatcherType;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import com.ruoyi.file.filter.RefererFilter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter配置
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class FilterConfig
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 资源映射路径 前缀
|
||||||
|
*/
|
||||||
|
@Value("${file.prefix}")
|
||||||
|
public String localFilePrefix;
|
||||||
|
|
||||||
|
@Value("${referer.allowed-domains}")
|
||||||
|
private String allowedDomains;
|
||||||
|
|
||||||
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnProperty(value = "referer.enabled", havingValue = "true")
|
||||||
|
public FilterRegistrationBean refererFilterRegistration()
|
||||||
|
{
|
||||||
|
FilterRegistrationBean registration = new FilterRegistrationBean();
|
||||||
|
registration.setDispatcherTypes(DispatcherType.REQUEST);
|
||||||
|
registration.setFilter(new RefererFilter());
|
||||||
|
registration.addUrlPatterns(localFilePrefix + "/*");
|
||||||
|
registration.setName("refererFilter");
|
||||||
|
registration.setOrder(FilterRegistrationBean.HIGHEST_PRECEDENCE);
|
||||||
|
Map<String, String> initParameters = new HashMap<String, String>();
|
||||||
|
initParameters.put("allowedDomains", allowedDomains);
|
||||||
|
registration.setInitParameters(initParameters);
|
||||||
|
return registration;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,10 +3,12 @@ package com.ruoyi.file.controller;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
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.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.utils.file.FileUtils;
|
import com.ruoyi.common.core.utils.file.FileUtils;
|
||||||
import com.ruoyi.file.service.ISysFileService;
|
import com.ruoyi.file.service.ISysFileService;
|
||||||
import com.ruoyi.system.api.domain.SysFile;
|
import com.ruoyi.system.api.domain.SysFile;
|
||||||
@@ -45,4 +47,26 @@ public class SysFileController
|
|||||||
return R.fail(e.getMessage());
|
return R.fail(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件删除请求
|
||||||
|
*/
|
||||||
|
@DeleteMapping("delete")
|
||||||
|
public R<Boolean> delete(String fileUrl)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!FileUtils.validateFilePath(fileUrl))
|
||||||
|
{
|
||||||
|
throw new Exception(StringUtils.format("资源文件({})非法,不允许删除。 ", fileUrl));
|
||||||
|
}
|
||||||
|
sysFileService.deleteFile(fileUrl);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.error("删除文件失败", e);
|
||||||
|
return R.fail(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user