Compare commits
3
Commits
cfe0b0c4f0
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab3d9b748a | ||
|
|
8b18fbc49f | ||
|
|
a227611512 |
@@ -25,7 +25,10 @@ jobs:
|
|||||||
options: --network infra-infra-net
|
options: --network infra-infra-net
|
||||||
steps:
|
steps:
|
||||||
- name: 安装 git / curl(alpine)
|
- name: 安装 git / curl(alpine)
|
||||||
run: apk add --no-cache git curl
|
run: |
|
||||||
|
# 统一走 aliyun 源:dl-cdn 时段性被拦会卡满 60s×2(2026-10-20 事故)
|
||||||
|
sed -i 's#dl-cdn.alpinelinux.org#mirrors.aliyun.com#g' /etc/apk/repositories
|
||||||
|
apk add --no-cache git curl
|
||||||
|
|
||||||
# 内网 Gitea 无法访问 GitHub 拉 actions/checkout,手动 clone 本仓库
|
# 内网 Gitea 无法访问 GitHub 拉 actions/checkout,手动 clone 本仓库
|
||||||
- name: 拉取源码(内网无 GitHub,手动 clone 本仓库)
|
- name: 拉取源码(内网无 GitHub,手动 clone 本仓库)
|
||||||
@@ -55,18 +58,24 @@ jobs:
|
|||||||
- name: 构建 jar(maven 容器,复用宿主 m2 缓存)
|
- name: 构建 jar(maven 容器,复用宿主 m2 缓存)
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
docker rm -f mavenbuild 2>/dev/null || true
|
# 构建容器名必须全局唯一:runner 挂的是宿主 docker.sock,容器名在整个 daemon 上共享
|
||||||
docker run -d --name mavenbuild \
|
# 命名空间。固定名会在多仓/多条 workflow 并发时互相 docker rm -f 掉对方正在构建的
|
||||||
|
# 容器,表现为无编译报错的 exit 137(SIGKILL,2026-10-21 实测复现)。
|
||||||
|
# GITHUB_RUN_ID 实例级唯一,再拼时间戳兜底。
|
||||||
|
BUILD_CONTAINER="mavenbuild-${GITHUB_RUN_ID:-0}-$(date +%s)"
|
||||||
|
echo "BUILD_CONTAINER=${BUILD_CONTAINER}"
|
||||||
|
docker rm -f "$BUILD_CONTAINER" 2>/dev/null || true
|
||||||
|
docker run -d --name "$BUILD_CONTAINER" \
|
||||||
--network infra-infra-net \
|
--network infra-infra-net \
|
||||||
-v /opt/docker/projman-m2:/root/.m2 \
|
-v /opt/docker/projman-m2:/root/.m2 \
|
||||||
-w /build maven:3.6.3-jdk-8 sleep 3600
|
-w /build maven:3.6.3-jdk-8 sleep 3600
|
||||||
docker cp "${PWD}/." mavenbuild:/build/
|
docker cp "${PWD}/." "$BUILD_CONTAINER":/build/
|
||||||
docker exec mavenbuild sh -c "printf '%s' '<settings><profiles><profile><id>nexus-repo</id><repositories><repository><id>nexus-internal</id><url>http://nexus:8081/repository/maven-public/</url><releases><enabled>true</enabled></releases><snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots></repository></repositories></profile></profiles><activeProfiles><activeProfile>nexus-repo</activeProfile></activeProfiles></settings>' > /root/.m2/settings.xml"
|
docker exec "$BUILD_CONTAINER" sh -c "printf '%s' '<settings><profiles><profile><id>nexus-repo</id><repositories><repository><id>nexus-internal</id><url>http://nexus:8081/repository/maven-public/</url><releases><enabled>true</enabled></releases><snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots></repository></repositories></profile></profiles><activeProfiles><activeProfile>nexus-repo</activeProfile></activeProfiles></settings>' > /root/.m2/settings.xml"
|
||||||
docker exec mavenbuild sh -c 'cd /build && mvn -B -DskipTests clean package'
|
docker exec "$BUILD_CONTAINER" sh -c 'cd /build && mvn -B -DskipTests clean package'
|
||||||
docker exec mavenbuild sh -c 'cd /build/target && cp *.jar app.jar'
|
docker exec "$BUILD_CONTAINER" sh -c 'cd /build/target && cp *.jar app.jar'
|
||||||
mkdir -p "${PWD}/target"
|
mkdir -p "${PWD}/target"
|
||||||
docker cp mavenbuild:/build/target/app.jar "${PWD}/target/app.jar"
|
docker cp "$BUILD_CONTAINER":/build/target/app.jar "${PWD}/target/app.jar"
|
||||||
docker rm -f mavenbuild
|
docker rm -f "$BUILD_CONTAINER"
|
||||||
|
|
||||||
- name: 构建并推送镜像
|
- name: 构建并推送镜像
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -53,11 +53,9 @@ public class FileService implements IFileService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private UpFileRepository upFileRepository;
|
private UpFileRepository upFileRepository;
|
||||||
|
|
||||||
@Value("${file.upload-path}")
|
@Value("${FILE_PATH}")
|
||||||
private String uploadPath;
|
private String uploadPath;
|
||||||
|
|
||||||
private static final String DEFAULT_APP_TYPE = "notice";
|
|
||||||
|
|
||||||
// ============================ 上传 ============================
|
// ============================ 上传 ============================
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -77,13 +75,10 @@ public class FileService implements IFileService {
|
|||||||
ext = originalName.substring(dotIdx + 1).toLowerCase();
|
ext = originalName.substring(dotIdx + 1).toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 构造存储子路径:{appType}/{yyyyMMdd}/{uuid}.{ext}
|
|
||||||
String dateDir = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
|
||||||
String savedName = UUID.randomUUID().toString().replace("-", "") + (ext.isEmpty() ? "" : "." + ext);
|
String savedName = UUID.randomUUID().toString().replace("-", "") + (ext.isEmpty() ? "" : "." + ext);
|
||||||
String relativePath = (appType == null ? DEFAULT_APP_TYPE : appType) + "/" + dateDir + "/" + savedName;
|
|
||||||
|
|
||||||
// 物理写入
|
// 物理写入
|
||||||
Path fullPath = Paths.get(uploadPath, relativePath);
|
Path fullPath = Paths.get(uploadPath, savedName);
|
||||||
try {
|
try {
|
||||||
Files.createDirectories(fullPath.getParent());
|
Files.createDirectories(fullPath.getParent());
|
||||||
file.transferTo(fullPath.toFile());
|
file.transferTo(fullPath.toFile());
|
||||||
@@ -94,10 +89,10 @@ public class FileService implements IFileService {
|
|||||||
|
|
||||||
// 入库
|
// 入库
|
||||||
UpFile entity = new UpFile();
|
UpFile entity = new UpFile();
|
||||||
entity.setTopicType(appType == null ? DEFAULT_APP_TYPE : appType);
|
entity.setTopicType(appType);
|
||||||
entity.setTopicId(topicId);
|
entity.setTopicId(topicId);
|
||||||
entity.setFileTrueName(originalName);
|
entity.setFileTrueName(originalName);
|
||||||
entity.setFileName(relativePath);
|
entity.setFileName(savedName);
|
||||||
entity.setFileSize((int) file.getSize());
|
entity.setFileSize((int) file.getSize());
|
||||||
entity.setFileType(ext);
|
entity.setFileType(ext);
|
||||||
upFileRepository.save(entity);
|
upFileRepository.save(entity);
|
||||||
@@ -125,8 +120,7 @@ public class FileService implements IFileService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<UpFileVo> listByTopic(String appType, Integer topicId) {
|
public List<UpFileVo> listByTopic(String appType, Integer topicId) {
|
||||||
String type = appType == null ? DEFAULT_APP_TYPE : appType;
|
return upFileRepository.findByTopicTypeAndTopicId(appType, topicId).stream()
|
||||||
return upFileRepository.findByTopicTypeAndTopicId(type, topicId).stream()
|
|
||||||
.map(this::toVo)
|
.map(this::toVo)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
@@ -279,8 +273,7 @@ public class FileService implements IFileService {
|
|||||||
@Override
|
@Override
|
||||||
public void downloadZipByTopic(String topicType, Integer topicId, String zipName,
|
public void downloadZipByTopic(String topicType, Integer topicId, String zipName,
|
||||||
HttpServletResponse response) {
|
HttpServletResponse response) {
|
||||||
String type = topicType == null ? DEFAULT_APP_TYPE : topicType;
|
List<UpFile> files = upFileRepository.findByTopicTypeAndTopicId(topicType, topicId);
|
||||||
List<UpFile> files = upFileRepository.findByTopicTypeAndTopicId(type, topicId);
|
|
||||||
downloadZip(files, zipName, response);
|
downloadZip(files, zipName, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,9 +286,8 @@ public class FileService implements IFileService {
|
|||||||
if (files == null || files.length == 0) {
|
if (files == null || files.length == 0) {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
String type = appType != null ? appType : DEFAULT_APP_TYPE;
|
|
||||||
for (MultipartFile file : files) {
|
for (MultipartFile file : files) {
|
||||||
results.add(upload(file, type, null));
|
results.add(upload(file, appType, null));
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ spring:
|
|||||||
auto-startup: false
|
auto-startup: false
|
||||||
|
|
||||||
# 文件上传存储路径(Docker 部署时与 volume 挂载一致)
|
# 文件上传存储路径(Docker 部署时与 volume 挂载一致)
|
||||||
file:
|
#file:
|
||||||
upload-path: D:/data/upload
|
# upload-path: D:/data/upload
|
||||||
|
|
||||||
# 短信模块配置
|
# 短信模块配置
|
||||||
sms:
|
sms:
|
||||||
@@ -76,3 +76,5 @@ yh:
|
|||||||
# 审批人资格组ID(用户中心组):>0 时 Submit 逐个校验被选人属于该组;
|
# 审批人资格组ID(用户中心组):>0 时 Submit 逐个校验被选人属于该组;
|
||||||
# 0 = 仅校验用户存在(审批资格数据源待产品确认,改造方案 5.1-#5)
|
# 0 = 仅校验用户存在(审批资格数据源待产品确认,改造方案 5.1-#5)
|
||||||
approver-group-id: 0
|
approver-group-id: 0
|
||||||
|
|
||||||
|
FILE_PATH: D:/data/upload
|
||||||
|
|||||||
Reference in New Issue
Block a user