feat: 完成财务中台核心功能与前后端基础设施搭建
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
# 财务系统每日备份(CentOS)
|
||||
# 依赖 /etc/finance/backup.cnf(chmod 600),内容示例:
|
||||
# [client]
|
||||
# host=127.0.0.1
|
||||
# port=3307
|
||||
# user=fin_migrate
|
||||
# password=替换成密码
|
||||
set -euo pipefail
|
||||
umask 077
|
||||
|
||||
BACKUP_DIR="${BACKUP_DIR:-/data/backup}"
|
||||
KEEP_DAYS="${KEEP_DAYS:-30}"
|
||||
DB_NAME="${DB_NAME:-fin_platform}"
|
||||
MYSQL_DEFAULTS="${MYSQL_DEFAULTS:-/etc/finance/backup.cnf}"
|
||||
STAMP="$(date +%F_%H%M%S)"
|
||||
|
||||
mkdir -p "${BACKUP_DIR}"
|
||||
|
||||
echo "[1/2] 备份 MySQL ${DB_NAME}"
|
||||
mysqldump --defaults-extra-file="${MYSQL_DEFAULTS}" \
|
||||
--single-transaction --routines --triggers --events \
|
||||
"${DB_NAME}" | gzip > "${BACKUP_DIR}/fin_platform_${STAMP}.sql.gz"
|
||||
|
||||
echo "[2/2] 备份配置与加密密钥"
|
||||
tar czf "${BACKUP_DIR}/finance_conf_${STAMP}.tgz" \
|
||||
/etc/finance/finance.env \
|
||||
/data/finance/runtime/secret-enc.key \
|
||||
/opt/finance/finance-server-1.0.0.jar
|
||||
|
||||
find "${BACKUP_DIR}" -type f -mtime +"${KEEP_DAYS}" -delete
|
||||
echo "备份完成: ${BACKUP_DIR}"
|
||||
@@ -0,0 +1,39 @@
|
||||
# 财务系统生产环境变量模板(CentOS + 现有 MySQL 3307 / Redis 6280)
|
||||
# 复制到 /etc/finance/finance.env,chmod 600
|
||||
# 密码中如含 # 等特殊字符,必须用单引号包起来
|
||||
|
||||
SPRING_PROFILES_ACTIVE=prod
|
||||
SERVER_ADDRESS=127.0.0.1
|
||||
SERVER_PORT=8080
|
||||
SERVER_MANAGEMENT_PORT=8081
|
||||
|
||||
# 与 MySQL 同机时用 127.0.0.1;跨机改成 www.zhulongtech.com
|
||||
FIN_DB_HOST=127.0.0.1
|
||||
FIN_DB_PORT=3307
|
||||
FIN_DB_NAME=fin_platform
|
||||
# 推荐新建 fin_app / fin_migrate;若临时用 root,则把两项都改成 root 并填 application-prod.yaml 的密码
|
||||
FIN_DB_USER=fin_app
|
||||
FIN_DB_PASSWORD='<新生成的 fin_app 密码>'
|
||||
FIN_FLYWAY_USER=fin_migrate
|
||||
FIN_FLYWAY_PASSWORD='<新生成的 fin_migrate 密码>'
|
||||
FIN_DB_POOL_MAX=20
|
||||
|
||||
# 复用现有 Redis,使用独立 db2,避免与数据中台 db0/db1 冲突
|
||||
FIN_REDIS_HOST=127.0.0.1
|
||||
FIN_REDIS_PORT=6280
|
||||
FIN_REDIS_PASSWORD='<从 application-prod.yaml 复制 Redis 密码>'
|
||||
FIN_REDIS_DB=2
|
||||
|
||||
# 财务系统独立密钥:openssl rand -base64 32
|
||||
FIN_SECRET_ENC_KEY='<32 字节 Base64 密钥>'
|
||||
FIN_RUNTIME_DIR=/data/finance/runtime
|
||||
FIN_ALLOWED_ORIGINS=https://www.zhulongtech.com:8443
|
||||
FIN_TRUST_PROXY=1
|
||||
FIN_DEMO_TICKET_ENABLED=0
|
||||
FIN_WORKER_ID=0
|
||||
|
||||
# 首次启动保持 1;拿到 admin 初始凭据并完成改密/TOTP 后改为 0
|
||||
FIN_BOOTSTRAP_ADMIN_ENABLED=1
|
||||
FIN_TOTP_OUTPUT_ENABLED=1
|
||||
|
||||
LOGGING_FILE_NAME=/var/log/finance/finance.log
|
||||
@@ -0,0 +1,27 @@
|
||||
[Unit]
|
||||
Description=Finance API (Central Billing Platform)
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
# 如果 MySQL / Redis 由 systemd 管理,按实际服务名取消注释:
|
||||
# After=mysqld.service redis.service
|
||||
# Wants=mysqld.service redis.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=finance
|
||||
Group=finance
|
||||
WorkingDirectory=/opt/finance
|
||||
EnvironmentFile=/etc/finance/finance.env
|
||||
ExecStart=/usr/bin/java -server -Xms2g -Xmx2g -XX:+UseG1GC \
|
||||
-XX:MaxGCPauseMillis=200 \
|
||||
-Duser.timezone=Asia/Shanghai -Dfile.encoding=UTF-8 \
|
||||
-jar /opt/finance/finance-server-1.0.0.jar
|
||||
SuccessExitStatus=143
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
LimitNOFILE=65535
|
||||
NoNewPrivileges=true
|
||||
PrivateTmp=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,70 @@
|
||||
# 财务系统 Nginx 配置(CentOS,同一台机器,复用 www.zhulongtech.com 证书,独立 8443 端口)
|
||||
# 放到 /etc/nginx/conf.d/finance.conf
|
||||
# 说明:
|
||||
# 1. 现有 443 的 www/data 中台配置保持不变;
|
||||
# 2. 财务系统只监听 8443,证书复用现有 www.zhulongtech.com 证书;
|
||||
# 3. 证书路径请从现有 443 server 块复制,可用 nginx -T | grep ssl_certificate 查找。
|
||||
|
||||
limit_req_zone $binary_remote_addr zone=finance_login:10m rate=5r/m;
|
||||
|
||||
server {
|
||||
listen 8443 ssl http2;
|
||||
server_name www.zhulongtech.com;
|
||||
|
||||
# 改成现有 443 配置中 www.zhulongtech.com 的证书路径
|
||||
ssl_certificate /etc/nginx/ssl/www.zhulongtech.com.crt;
|
||||
ssl_certificate_key /etc/nginx/ssl/www.zhulongtech.com.key;
|
||||
# CentOS 7 自带 OpenSSL 1.0.2 不支持 TLS1.3;若系统是 CentOS Stream 8/9 可改为 TLSv1.2 TLSv1.3
|
||||
ssl_protocols TLSv1.2;
|
||||
ssl_prefer_server_ciphers off;
|
||||
|
||||
server_tokens off;
|
||||
client_max_body_size 1m;
|
||||
|
||||
add_header X-Content-Type-Options nosniff always;
|
||||
add_header X-Frame-Options DENY always;
|
||||
add_header Referrer-Policy no-referrer always;
|
||||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||
|
||||
root /var/www/finance;
|
||||
index index.html;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
location = /index.html {
|
||||
add_header Cache-Control "no-store";
|
||||
}
|
||||
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|svg|ico|woff2?)$ {
|
||||
expires 30d;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
# 登录接口单独限流
|
||||
location = /api/admin/login {
|
||||
limit_req zone=finance_login burst=5 nodelay;
|
||||
proxy_pass http://127.0.0.1:8080;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_read_timeout 30s;
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://127.0.0.1:8080;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_read_timeout 30s;
|
||||
}
|
||||
|
||||
location /actuator/ {
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user