refactor: streaming download, Git LFS templates, deploy workflow

- Replace base64 JSON response with StreamingResponseBody (zero-buffer)
- Error responses return JSON via GlobalExceptionHandler (400/404)
- Add git-lfs track for *.docx to keep repo lean
- Add deploy/deploy.sh: one-click build + restart
- Add deploy/clean-lfs.sh: periodic LFS cache cleanup
- Add deploy/gmp-service.service: systemd service unit
- Remove unused ApiResponse and DocxExportData DTOs
- Fix build.sh/run.sh jar name (gmp-mock-service -> gmp-service)
- Add TemplateNotFoundException for missing templates
This commit is contained in:
agentuser
2026-05-08 11:12:47 +08:00
parent ad4b0e93f0
commit 7442f77bd0
14 changed files with 296 additions and 105 deletions
+74
View File
@@ -0,0 +1,74 @@
#!/bin/bash
# Git LFS 缓存清理脚本
#
# 用法:
# ./deploy/clean-lfs.sh # 交互式预览
# ./deploy/clean-lfs.sh --prune # 执行清理
# ./deploy/clean-lfs.sh --force # 强制清理所有缓存
#
# Git LFS 会把所有历史版本的二进制文件缓存在 .git/lfs/objects/ 下。
# 这些缓存不会自动删除,时间久了会占用大量磁盘空间。
# 此脚本用于安全地清理不再需要的 LFS 缓存对象。
set -e
LFS_DIR="$(git rev-parse --git-dir 2>/dev/null || echo ".git")/lfs/objects"
cd "$(git rev-parse --show-toplevel 2>/dev/null || echo ".")"
echo "===== Git LFS 缓存分析 ====="
echo "仓库: $(pwd)"
# 统计当前缓存大小
if [ -d "$LFS_DIR" ]; then
CACHE_SIZE=$(du -sh "$LFS_DIR" 2>/dev/null | cut -f1)
CACHE_FILES=$(find "$LFS_DIR" -type f 2>/dev/null | wc -l)
echo "LFS 缓存目录: .git/lfs/objects/"
echo "缓存文件数: ${CACHE_FILES:-0}"
echo "缓存总大小: ${CACHE_SIZE:-0}"
else
echo "LFS 缓存目录不存在,尚无缓存文件。"
CACHE_SIZE="0B"
fi
echo ""
# 检查 git lfs 是否可用
if ! git lfs version &>/dev/null; then
echo "错误: git lfs 未安装。"
exit 1
fi
# 分析可清理的空间
echo "===== 可清理空间分析 ====="
git lfs prune --dry-run 2>&1 | head -20
echo ""
case "${1:-}" in
--prune)
echo "===== 执行清理 ====="
git lfs prune
echo ""
# 统计清理后
if [ -d "$LFS_DIR" ]; then
NEW_SIZE=$(du -sh "$LFS_DIR" 2>/dev/null | cut -f1)
echo "清理完成: ${CACHE_SIZE} -> ${NEW_SIZE}"
fi
;;
--force)
echo "===== 强制清理所有 LFS 缓存 ====="
echo "注意: 这将删除所有不在当前 checkout 中的 LFS 对象。"
echo "如果你需要切换回旧版本,LFS 对象会被重新下载。"
echo ""
git lfs prune --force 2>&1 | tail -5
;;
*)
echo "这是预览模式,未执行任何操作。"
echo ""
echo "执行清理: bash $0 --prune"
echo "强制清理: bash $0 --force"
echo ""
echo "提示: 定期执行 'git lfs prune' 可以删除旧版本 LFS 缓存。"
echo " Git LFS 的默认保留策略是最近 3 天的对象 + 当前 HEAD 可达的对象。"
;;
esac