Переглянути джерело

chore: 清理中间构建脚本,完善.gitignore安全规则

- 移除已跟踪的16个中间文件(build_v*.py/repack*.py/extract_deps.py/start_v*.sh/start-backend.bat)
- .gitignore新增排除规则:构建脚本、迁移脚本、部署目录、临时bat文件
- 保留敏感配置排除规则(application-dev.yml/application-prod.yml/.env)
- 保留IDE/OS/编译产物排除规则(.idea/node_modules/target/dist)
C 2 місяців тому
батько
коміт
b0831f7de3

+ 12 - 0
.gitignore

@@ -21,6 +21,18 @@ desktop.ini
 # Logs
 *.log
 
+# 中间构建/打包/部署脚本(非源码,不入库)
+backend/build_v*.py
+backend/repack*.py
+backend/extract_deps.py
+backend/run_migration*.py
+backend/verify_*.py
+backend/start_v*.sh
+backend/lib/
+backend/build_tmp_classes/
+start-backend.bat
+deploy/
+
 # 含明文凭据的本地配置,禁止提交
 backend/src/main/resources/application-dev.yml
 backend/src/main/resources/application-prod.yml

+ 0 - 131
backend/build_v10.py

@@ -1,131 +0,0 @@
-import zipfile, os, subprocess, glob, sys, shutil
-
-BASE = os.path.dirname(os.path.abspath(__file__))
-SRC = os.path.join(BASE, "src", "main", "java")
-RES = os.path.join(BASE, "src", "main", "resources")
-OUT = os.path.join(BASE, "build_tmp_classes")
-LIB = os.path.join(BASE, "lib")
-JAVAC = r"D:\Program Files\Java\jdk-17\bin\javac.exe"
-LOMBOK = r"C:\Users\BXD-XTYW\.m2\repository\org\projectlombok\lombok\1.18.32\lombok-1.18.32.jar"
-SRC_JAR = os.path.join(BASE, "target", "resource-platform-v9.jar")
-DST_JAR = os.path.join(BASE, "target", "resource-platform-v10.jar")
-
-# 1) 准备依赖 classpath: 从 fat jar 抽取 BOOT-INF/lib 到 lib/(若缺失), 并放入 lombok
-os.makedirs(LIB, exist_ok=True)
-if not glob.glob(os.path.join(LIB, "*.jar")):
-    with zipfile.ZipFile(SRC_JAR) as z:
-        for name in z.namelist():
-            if name.startswith("BOOT-INF/lib/") and name.endswith(".jar"):
-                out = os.path.join(LIB, os.path.basename(name))
-                with open(out, "wb") as f:
-                    f.write(z.read(name))
-if not os.path.exists(os.path.join(LIB, "lombok-1.18.32.jar")):
-    shutil.copy(LOMBOK, os.path.join(LIB, "lombok-1.18.32.jar"))
-
-dep_jars = sorted(glob.glob(os.path.join(LIB, "*.jar")))
-cp = ";".join(dep_jars)
-print("classpath entries:", len(dep_jars))
-
-# 2) 编译全部源码
-sources = []
-for root, _, files in os.walk(SRC):
-    for f in files:
-        if f.endswith(".java"):
-            sources.append(os.path.join(root, f))
-print("source files:", len(sources))
-
-os.makedirs(OUT, exist_ok=True)
-cmd = [JAVAC, "-parameters", "-encoding", "UTF-8", "-cp", cp, "-d", OUT] + sources
-r = subprocess.run(cmd, capture_output=True)
-print("javac returncode:", r.returncode)
-if r.returncode != 0:
-    err = (r.stderr or b"").decode("utf-8", "replace")
-    print("=== STDERR (first 60 lines) ===")
-    print("\n".join(err.splitlines()[:60]))
-    sys.exit(1)
-print("compiled classes:", len(glob.glob(os.path.join(OUT, "**", "*.class"), recursive=True)))
-
-# 3) 重打包: 以 v9 为基底, 替换最新编译的 class, 并注入 src/main/resources 中的资源(xml等)
-with zipfile.ZipFile(SRC_JAR) as zin:
-    infos = zin.infolist()
-
-    def local_for(entry_name):
-        if entry_name.startswith("BOOT-INF/classes/") and entry_name.endswith(".class"):
-            rel = entry_name[len("BOOT-INF/classes/"):]
-            local = os.path.join(OUT, rel)
-            if os.path.isfile(local):
-                return local
-            return None
-        if entry_name.startswith("BOOT-INF/classes/"):
-            rel = entry_name[len("BOOT-INF/classes/"):]
-            local = os.path.join(RES, rel)
-            if os.path.isfile(local):
-                return local
-        return None
-
-    manifest_name = "META-INF/MANIFEST.MF"
-    all_names = set(zin.namelist())
-    extra_resources = []
-    for root, _, files in os.walk(RES):
-        for f in files:
-            full = os.path.join(root, f)
-            rel = os.path.relpath(full, RES).replace("\\", "/")
-            entry = "BOOT-INF/classes/" + rel
-            if entry not in all_names:
-                extra_resources.append((entry, full))
-
-    # 源码中新增的类, 在基底 jar 里原本不存在, 需补打到新 jar
-    extra_classes = []
-    for root, _, files in os.walk(OUT):
-        for f in files:
-            if f.endswith(".class"):
-                full = os.path.join(root, f)
-                rel = os.path.relpath(full, OUT).replace("\\", "/")
-                entry = "BOOT-INF/classes/" + rel
-                if entry not in all_names:
-                    extra_classes.append((entry, full))
-
-    with zipfile.ZipFile(DST_JAR, "w", compression=zipfile.ZIP_DEFLATED) as zout:
-        mi = next(i for i in infos if i.filename == manifest_name)
-        zout.writestr(mi, zin.read(manifest_name))
-        for i in infos:
-            if i.filename == manifest_name:
-                continue
-            local = local_for(i.filename)
-            if local:
-                with open(local, "rb") as lf:
-                    data = lf.read()
-                zi = zipfile.ZipInfo(i.filename)
-                zi.external_attr = i.external_attr
-                zi.date_time = i.date_time
-                zout.writestr(zi, data)
-            else:
-                zout.writestr(i, zin.read(i.filename))
-        for entry, full in extra_resources:
-            with open(full, "rb") as lf:
-                data = lf.read()
-            zout.writestr(zipfile.ZipInfo(entry), data)
-        for entry, full in extra_classes:
-            with open(full, "rb") as lf:
-                data = lf.read()
-            zout.writestr(zipfile.ZipInfo(entry), data)
-
-print("built:", DST_JAR, "exists:", os.path.exists(DST_JAR))
-zm = zipfile.ZipFile(DST_JAR)
-print("manifest first:", zm.namelist()[0] == manifest_name)
-
-# 校验关键新类已打入
-for cls in ["ProjectAllocationDTO.class", "ProjectResource.class", "ResourceDTO.class",
-            "ResourceVO.class", "ProcurementCostVO.class", "ProcurementCostExportVO.class",
-            "ResourceServiceImpl.class", "ResourceMapper.xml"]:
-    if cls.endswith(".xml"):
-        entry = "BOOT-INF/classes/mapper/" + cls
-    elif cls == "ResourceMapper.xml":
-        entry = "BOOT-INF/classes/mapper/" + cls
-    elif cls in ("ProjectAllocationDTO.class", "ProcurementCostVO.class", "ProcurementCostExportVO.class", "ResourceDTO.class"):
-        entry = "BOOT-INF/classes/com/example/resourceplatform/dto/" + cls
-    elif cls == "ProjectResource.class":
-        entry = "BOOT-INF/classes/com/example/resourceplatform/entity/" + cls
-    else:
-        entry = "BOOT-INF/classes/com/example/resourceplatform/service/impl/" + cls
-    print("contains", entry, ":", entry in zm.namelist())

+ 0 - 126
backend/build_v11.py

@@ -1,126 +0,0 @@
-import zipfile, os, subprocess, glob, sys, shutil
-
-BASE = os.path.dirname(os.path.abspath(__file__))
-SRC = os.path.join(BASE, "src", "main", "java")
-RES = os.path.join(BASE, "src", "main", "resources")
-OUT = os.path.join(BASE, "build_tmp_classes")
-LIB = os.path.join(BASE, "lib")
-JAVAC = r"D:\Program Files\Java\jdk-17\bin\javac.exe"
-LOMBOK = r"C:\Users\BXD-XTYW\.m2\repository\org\projectlombok\lombok\1.18.32\lombok-1.18.32.jar"
-SRC_JAR = os.path.join(BASE, "target", "resource-platform-v10.jar")
-DST_JAR = os.path.join(BASE, "target", "resource-platform-v11.jar")
-
-# 1) 准备依赖 classpath: 从 fat jar 抽取 BOOT-INF/lib 到 lib/(若缺失), 并放入 lombok
-os.makedirs(LIB, exist_ok=True)
-if not glob.glob(os.path.join(LIB, "*.jar")):
-    with zipfile.ZipFile(SRC_JAR) as z:
-        for name in z.namelist():
-            if name.startswith("BOOT-INF/lib/") and name.endswith(".jar"):
-                out = os.path.join(LIB, os.path.basename(name))
-                with open(out, "wb") as f:
-                    f.write(z.read(name))
-if not os.path.exists(os.path.join(LIB, "lombok-1.18.32.jar")):
-    shutil.copy(LOMBOK, os.path.join(LIB, "lombok-1.18.32.jar"))
-
-dep_jars = sorted(glob.glob(os.path.join(LIB, "*.jar")))
-cp = ";".join(dep_jars)
-print("classpath entries:", len(dep_jars))
-
-# 2) 编译全部源码
-sources = []
-for root, _, files in os.walk(SRC):
-    for f in files:
-        if f.endswith(".java"):
-            sources.append(os.path.join(root, f))
-print("source files:", len(sources))
-
-os.makedirs(OUT, exist_ok=True)
-cmd = [JAVAC, "-parameters", "-encoding", "UTF-8", "-cp", cp, "-d", OUT] + sources
-r = subprocess.run(cmd, capture_output=True)
-print("javac returncode:", r.returncode)
-if r.returncode != 0:
-    err = (r.stderr or b"").decode("utf-8", "replace")
-    print("=== STDERR (first 60 lines) ===")
-    print("\n".join(err.splitlines()[:60]))
-    sys.exit(1)
-print("compiled classes:", len(glob.glob(os.path.join(OUT, "**", "*.class"), recursive=True)))
-
-# 3) 重打包: 以 v10 为基底, 替换最新编译的 class, 并注入 src/main/resources 中的资源(xml等)
-with zipfile.ZipFile(SRC_JAR) as zin:
-    infos = zin.infolist()
-
-    def local_for(entry_name):
-        if entry_name.startswith("BOOT-INF/classes/") and entry_name.endswith(".class"):
-            rel = entry_name[len("BOOT-INF/classes/"):]
-            local = os.path.join(OUT, rel)
-            if os.path.isfile(local):
-                return local
-            return None
-        if entry_name.startswith("BOOT-INF/classes/"):
-            rel = entry_name[len("BOOT-INF/classes/"):]
-            local = os.path.join(RES, rel)
-            if os.path.isfile(local):
-                return local
-        return None
-
-    manifest_name = "META-INF/MANIFEST.MF"
-    all_names = set(zin.namelist())
-    extra_resources = []
-    for root, _, files in os.walk(RES):
-        for f in files:
-            full = os.path.join(root, f)
-            rel = os.path.relpath(full, RES).replace("\\", "/")
-            entry = "BOOT-INF/classes/" + rel
-            if entry not in all_names:
-                extra_resources.append((entry, full))
-
-    # 源码中新增的类, 在基底 jar 里原本不存在, 需补打到新 jar
-    extra_classes = []
-    for root, _, files in os.walk(OUT):
-        for f in files:
-            if f.endswith(".class"):
-                full = os.path.join(root, f)
-                rel = os.path.relpath(full, OUT).replace("\\", "/")
-                entry = "BOOT-INF/classes/" + rel
-                if entry not in all_names:
-                    extra_classes.append((entry, full))
-
-    with zipfile.ZipFile(DST_JAR, "w", compression=zipfile.ZIP_DEFLATED) as zout:
-        mi = next(i for i in infos if i.filename == manifest_name)
-        zout.writestr(mi, zin.read(manifest_name))
-        for i in infos:
-            if i.filename == manifest_name:
-                continue
-            local = local_for(i.filename)
-            if local:
-                with open(local, "rb") as lf:
-                    data = lf.read()
-                zi = zipfile.ZipInfo(i.filename)
-                zi.external_attr = i.external_attr
-                zi.date_time = i.date_time
-                zout.writestr(zi, data)
-            else:
-                zout.writestr(i, zin.read(i.filename))
-        for entry, full in extra_resources:
-            with open(full, "rb") as lf:
-                data = lf.read()
-            zout.writestr(zipfile.ZipInfo(entry), data)
-        for entry, full in extra_classes:
-            with open(full, "rb") as lf:
-                data = lf.read()
-            zout.writestr(zipfile.ZipInfo(entry), data)
-
-print("built:", DST_JAR, "exists:", os.path.exists(DST_JAR))
-zm = zipfile.ZipFile(DST_JAR)
-print("manifest first:", zm.namelist()[0] == manifest_name)
-
-# 校验关键改动类已打入
-for cls in ["ResourceRenewalService.class", "ResourceRenewalServiceImpl.class",
-            "ResourceController.class"]:
-    if cls == "ResourceController.class":
-        entry = "BOOT-INF/classes/com/example/resourceplatform/controller/" + cls
-    elif cls == "ResourceRenewalServiceImpl.class":
-        entry = "BOOT-INF/classes/com/example/resourceplatform/service/impl/" + cls
-    else:
-        entry = "BOOT-INF/classes/com/example/resourceplatform/service/" + cls
-    print("contains", entry, ":", entry in zm.namelist())

+ 0 - 69
backend/build_v6.py

@@ -1,69 +0,0 @@
-import zipfile, os, subprocess, glob, sys
-
-BASE = os.path.dirname(os.path.abspath(__file__))
-SRC = os.path.join(BASE, "src", "main", "java")
-OUT = os.path.join(BASE, "build_tmp_classes")
-LIB = os.path.join(BASE, "lib")
-JAVAC = r"D:\Program Files\Java\jdk-17\bin\javac.exe"
-SRC_JAR = os.path.join(BASE, "target", "resource-platform-v5.jar")
-DST_JAR = os.path.join(BASE, "target", "resource-platform-v6.jar")
-
-# 1) 收集依赖 classpath
-dep_jars = sorted(glob.glob(os.path.join(LIB, "*.jar")))
-cp = ";".join(dep_jars)
-print("classpath entries:", len(dep_jars))
-
-# 2) 编译全部源码
-sources = []
-for root, _, files in os.walk(SRC):
-    for f in files:
-        if f.endswith(".java"):
-            sources.append(os.path.join(root, f))
-print("source files:", len(sources))
-
-os.makedirs(OUT, exist_ok=True)
-cmd = [JAVAC, "-parameters", "-encoding", "UTF-8", "-cp", cp, "-d", OUT] + sources
-r = subprocess.run(cmd, capture_output=True)
-print("javac returncode:", r.returncode)
-if r.returncode != 0:
-    err = (r.stderr or b"").decode("utf-8", "replace")
-    print("=== STDERR (first 40 lines) ===")
-    print("\n".join(err.splitlines()[:40]))
-    sys.exit(1)
-print("compiled classes:", len(glob.glob(os.path.join(OUT, "**", "*.class"), recursive=True)))
-
-# 3) 重打包: 以 v5 为基底, 替换 BOOT-INF/classes 下新编译的 class
-with zipfile.ZipFile(SRC_JAR) as zin:
-    infos = zin.infolist()
-    names = set(zin.namelist())
-
-    def class_local(entry_name):
-        # 仅替换真正的 .class 文件; 目录条目(以/结尾)直接沿用原 jar
-        if entry_name.startswith("BOOT-INF/classes/") and entry_name.endswith(".class"):
-            rel = entry_name[len("BOOT-INF/classes/"):]
-            local = os.path.join(OUT, rel)
-            if os.path.isfile(local):
-                return local
-        return None
-
-    # MANIFEST 必须第一个写入
-    manifest_name = "META-INF/MANIFEST.MF"
-    with zipfile.ZipFile(DST_JAR, "w", compression=zipfile.ZIP_DEFLATED) as zout:
-        mi = next(i for i in infos if i.filename == manifest_name)
-        zout.writestr(mi, zin.read(manifest_name))
-        for i in infos:
-            if i.filename == manifest_name:
-                continue
-            local = class_local(i.filename)
-            if local:
-                with open(local, "rb") as lf:
-                    data = lf.read()
-                zi = zipfile.ZipInfo(i.filename)
-                zi.external_attr = i.external_attr
-                zi.date_time = i.date_time
-                zout.writestr(zi, data)
-            else:
-                zout.writestr(i, zin.read(i.filename))
-
-print("built:", DST_JAR, "exists:", os.path.exists(DST_JAR))
-print("manifest first:", zipfile.ZipFile(DST_JAR).namelist()[0] == manifest_name)

+ 0 - 106
backend/build_v7.py

@@ -1,106 +0,0 @@
-import zipfile, os, subprocess, glob, sys, shutil
-
-BASE = os.path.dirname(os.path.abspath(__file__))
-SRC = os.path.join(BASE, "src", "main", "java")
-RES = os.path.join(BASE, "src", "main", "resources")
-OUT = os.path.join(BASE, "build_tmp_classes")
-LIB = os.path.join(BASE, "lib")
-JAVAC = r"D:\Program Files\Java\jdk-17\bin\javac.exe"
-LOMBOK = r"C:\Users\BXD-XTYW\.m2\repository\org\projectlombok\lombok\1.18.32\lombok-1.18.32.jar"
-SRC_JAR = os.path.join(BASE, "target", "resource-platform-v6.jar")
-DST_JAR = os.path.join(BASE, "target", "resource-platform-v7.jar")
-
-# 1) 准备依赖 classpath: 从 fat jar 抽取 BOOT-INF/lib 到 lib/(若缺失), 并放入 lombok
-os.makedirs(LIB, exist_ok=True)
-if not glob.glob(os.path.join(LIB, "*.jar")):
-    with zipfile.ZipFile(SRC_JAR) as z:
-        for name in z.namelist():
-            if name.startswith("BOOT-INF/lib/") and name.endswith(".jar"):
-                out = os.path.join(LIB, os.path.basename(name))
-                with open(out, "wb") as f:
-                    f.write(z.read(name))
-if not os.path.exists(os.path.join(LIB, "lombok-1.18.32.jar")):
-    shutil.copy(LOMBOK, os.path.join(LIB, "lombok-1.18.32.jar"))
-
-dep_jars = sorted(glob.glob(os.path.join(LIB, "*.jar")))
-cp = ";".join(dep_jars)
-print("classpath entries:", len(dep_jars))
-
-# 2) 编译全部源码
-sources = []
-for root, _, files in os.walk(SRC):
-    for f in files:
-        if f.endswith(".java"):
-            sources.append(os.path.join(root, f))
-print("source files:", len(sources))
-
-os.makedirs(OUT, exist_ok=True)
-cmd = [JAVAC, "-parameters", "-encoding", "UTF-8", "-cp", cp, "-d", OUT] + sources
-r = subprocess.run(cmd, capture_output=True)
-print("javac returncode:", r.returncode)
-if r.returncode != 0:
-    err = (r.stderr or b"").decode("utf-8", "replace")
-    print("=== STDERR (first 40 lines) ===")
-    print("\n".join(err.splitlines()[:40]))
-    sys.exit(1)
-print("compiled classes:", len(glob.glob(os.path.join(OUT, "**", "*.class"), recursive=True)))
-
-# 3) 重打包: 以 v6 为基底, 替换最新编译的 class, 并注入 src/main/resources 中的资源(xml等)
-with zipfile.ZipFile(SRC_JAR) as zin:
-    infos = zin.infolist()
-
-    def local_for(entry_name):
-        # 已编译 class: 来自 OUT
-        if entry_name.startswith("BOOT-INF/classes/") and entry_name.endswith(".class"):
-            rel = entry_name[len("BOOT-INF/classes/"):]
-            local = os.path.join(OUT, rel)
-            if os.path.isfile(local):
-                return local
-            return None
-        # 资源文件: 用 src/main/resources 中的最新版本
-        if entry_name.startswith("BOOT-INF/classes/"):
-            rel = entry_name[len("BOOT-INF/classes/"):]
-            local = os.path.join(RES, rel)
-            if os.path.isfile(local):
-                return local
-        return None
-
-    manifest_name = "META-INF/MANIFEST.MF"
-    all_names = set(zin.namelist())
-    # 收集 src/main/resources 中新增的、jar 里没有的资源条目
-    extra_resources = []
-    for root, _, files in os.walk(RES):
-        for f in files:
-            full = os.path.join(root, f)
-            rel = os.path.relpath(full, RES).replace("\\", "/")
-            entry = "BOOT-INF/classes/" + rel
-            if entry not in all_names:
-                extra_resources.append((entry, full))
-
-    with zipfile.ZipFile(DST_JAR, "w", compression=zipfile.ZIP_DEFLATED) as zout:
-        mi = next(i for i in infos if i.filename == manifest_name)
-        zout.writestr(mi, zin.read(manifest_name))
-        for i in infos:
-            if i.filename == manifest_name:
-                continue
-            local = local_for(i.filename)
-            if local:
-                with open(local, "rb") as lf:
-                    data = lf.read()
-                zi = zipfile.ZipInfo(i.filename)
-                zi.external_attr = i.external_attr
-                zi.date_time = i.date_time
-                zout.writestr(zi, data)
-            else:
-                zout.writestr(i, zin.read(i.filename))
-        for entry, full in extra_resources:
-            with open(full, "rb") as lf:
-                data = lf.read()
-            zi = zipfile.ZipInfo(entry)
-            zout.writestr(zi, data)
-
-print("built:", DST_JAR, "exists:", os.path.exists(DST_JAR))
-zm = zipfile.ZipFile(DST_JAR)
-print("manifest first:", zm.namelist()[0] == manifest_name)
-xml_name = "BOOT-INF/classes/mapper/ResourceMapper.xml"
-print("mapper xml present:", xml_name in zm.namelist())

+ 0 - 126
backend/build_v8.py

@@ -1,126 +0,0 @@
-import zipfile, os, subprocess, glob, sys, shutil
-
-BASE = os.path.dirname(os.path.abspath(__file__))
-SRC = os.path.join(BASE, "src", "main", "java")
-RES = os.path.join(BASE, "src", "main", "resources")
-OUT = os.path.join(BASE, "build_tmp_classes")
-LIB = os.path.join(BASE, "lib")
-JAVAC = r"D:\Program Files\Java\jdk-17\bin\javac.exe"
-LOMBOK = r"C:\Users\BXD-XTYW\.m2\repository\org\projectlombok\lombok\1.18.32\lombok-1.18.32.jar"
-SRC_JAR = os.path.join(BASE, "target", "resource-platform-v7.jar")
-DST_JAR = os.path.join(BASE, "target", "resource-platform-v8.jar")
-
-# 1) 准备依赖 classpath: 从 fat jar 抽取 BOOT-INF/lib 到 lib/(若缺失), 并放入 lombok
-os.makedirs(LIB, exist_ok=True)
-if not glob.glob(os.path.join(LIB, "*.jar")):
-    with zipfile.ZipFile(SRC_JAR) as z:
-        for name in z.namelist():
-            if name.startswith("BOOT-INF/lib/") and name.endswith(".jar"):
-                out = os.path.join(LIB, os.path.basename(name))
-                with open(out, "wb") as f:
-                    f.write(z.read(name))
-if not os.path.exists(os.path.join(LIB, "lombok-1.18.32.jar")):
-    shutil.copy(LOMBOK, os.path.join(LIB, "lombok-1.18.32.jar"))
-
-dep_jars = sorted(glob.glob(os.path.join(LIB, "*.jar")))
-cp = ";".join(dep_jars)
-print("classpath entries:", len(dep_jars))
-
-# 2) 编译全部源码
-sources = []
-for root, _, files in os.walk(SRC):
-    for f in files:
-        if f.endswith(".java"):
-            sources.append(os.path.join(root, f))
-print("source files:", len(sources))
-
-os.makedirs(OUT, exist_ok=True)
-cmd = [JAVAC, "-parameters", "-encoding", "UTF-8", "-cp", cp, "-d", OUT] + sources
-r = subprocess.run(cmd, capture_output=True)
-print("javac returncode:", r.returncode)
-if r.returncode != 0:
-    err = (r.stderr or b"").decode("utf-8", "replace")
-    print("=== STDERR (first 50 lines) ===")
-    print("\n".join(err.splitlines()[:50]))
-    sys.exit(1)
-print("compiled classes:", len(glob.glob(os.path.join(OUT, "**", "*.class"), recursive=True)))
-
-# 3) 重打包: 以 v7 为基底, 替换最新编译的 class, 并注入 src/main/resources 中的资源(xml等)
-with zipfile.ZipFile(SRC_JAR) as zin:
-    infos = zin.infolist()
-
-    def local_for(entry_name):
-        if entry_name.startswith("BOOT-INF/classes/") and entry_name.endswith(".class"):
-            rel = entry_name[len("BOOT-INF/classes/"):]
-            local = os.path.join(OUT, rel)
-            if os.path.isfile(local):
-                return local
-            return None
-        if entry_name.startswith("BOOT-INF/classes/"):
-            rel = entry_name[len("BOOT-INF/classes/"):]
-            local = os.path.join(RES, rel)
-            if os.path.isfile(local):
-                return local
-        return None
-
-    manifest_name = "META-INF/MANIFEST.MF"
-    all_names = set(zin.namelist())
-    extra_resources = []
-    for root, _, files in os.walk(RES):
-        for f in files:
-            full = os.path.join(root, f)
-            rel = os.path.relpath(full, RES).replace("\\", "/")
-            entry = "BOOT-INF/classes/" + rel
-            if entry not in all_names:
-                extra_resources.append((entry, full))
-
-    # 源码中新增的类, 在基底 jar 里原本不存在, 需补打到新 jar
-    extra_classes = []
-    for root, _, files in os.walk(OUT):
-        for f in files:
-            if f.endswith(".class"):
-                full = os.path.join(root, f)
-                rel = os.path.relpath(full, OUT).replace("\\", "/")
-                entry = "BOOT-INF/classes/" + rel
-                if entry not in all_names:
-                    extra_classes.append((entry, full))
-
-    with zipfile.ZipFile(DST_JAR, "w", compression=zipfile.ZIP_DEFLATED) as zout:
-        mi = next(i for i in infos if i.filename == manifest_name)
-        zout.writestr(mi, zin.read(manifest_name))
-        for i in infos:
-            if i.filename == manifest_name:
-                continue
-            local = local_for(i.filename)
-            if local:
-                with open(local, "rb") as lf:
-                    data = lf.read()
-                zi = zipfile.ZipInfo(i.filename)
-                zi.external_attr = i.external_attr
-                zi.date_time = i.date_time
-                zout.writestr(zi, data)
-            else:
-                zout.writestr(i, zin.read(i.filename))
-        for entry, full in extra_resources:
-            with open(full, "rb") as lf:
-                data = lf.read()
-            zout.writestr(zipfile.ZipInfo(entry), data)
-        for entry, full in extra_classes:
-            with open(full, "rb") as lf:
-                data = lf.read()
-            zout.writestr(zipfile.ZipInfo(entry), data)
-
-print("built:", DST_JAR, "exists:", os.path.exists(DST_JAR))
-zm = zipfile.ZipFile(DST_JAR)
-print("manifest first:", zm.namelist()[0] == manifest_name)
-
-# 校验关键新类已打入
-for cls in ["ResourceRenewal.class", "ResourceRenewalMapper.class",
-            "ProcurementCostVO.class", "ResourceRenewalServiceImpl.class"]:
-    name = "BOOT-INF/classes/com/example/resourceplatform/" + (
-        "entity/" if "Renewal.class" in cls and "Mapper" not in cls and "Service" not in cls
-        else "mapper/" if "Mapper" in cls
-        else "dto/" if "VO" in cls
-        else "service/impl/")
-    entry = name + cls
-    print("contains", entry, ":", entry in zm.namelist())

+ 0 - 125
backend/build_v9.py

@@ -1,125 +0,0 @@
-import zipfile, os, subprocess, glob, sys, shutil
-
-BASE = os.path.dirname(os.path.abspath(__file__))
-SRC = os.path.join(BASE, "src", "main", "java")
-RES = os.path.join(BASE, "src", "main", "resources")
-OUT = os.path.join(BASE, "build_tmp_classes")
-LIB = os.path.join(BASE, "lib")
-JAVAC = r"D:\Program Files\Java\jdk-17\bin\javac.exe"
-LOMBOK = r"C:\Users\BXD-XTYW\.m2\repository\org\projectlombok\lombok\1.18.32\lombok-1.18.32.jar"
-SRC_JAR = os.path.join(BASE, "target", "resource-platform-v8.jar")
-DST_JAR = os.path.join(BASE, "target", "resource-platform-v9.jar")
-
-# 1) 准备依赖 classpath: 从 fat jar 抽取 BOOT-INF/lib 到 lib/(若缺失), 并放入 lombok
-os.makedirs(LIB, exist_ok=True)
-if not glob.glob(os.path.join(LIB, "*.jar")):
-    with zipfile.ZipFile(SRC_JAR) as z:
-        for name in z.namelist():
-            if name.startswith("BOOT-INF/lib/") and name.endswith(".jar"):
-                out = os.path.join(LIB, os.path.basename(name))
-                with open(out, "wb") as f:
-                    f.write(z.read(name))
-if not os.path.exists(os.path.join(LIB, "lombok-1.18.32.jar")):
-    shutil.copy(LOMBOK, os.path.join(LIB, "lombok-1.18.32.jar"))
-
-dep_jars = sorted(glob.glob(os.path.join(LIB, "*.jar")))
-cp = ";".join(dep_jars)
-print("classpath entries:", len(dep_jars))
-
-# 2) 编译全部源码
-sources = []
-for root, _, files in os.walk(SRC):
-    for f in files:
-        if f.endswith(".java"):
-            sources.append(os.path.join(root, f))
-print("source files:", len(sources))
-
-os.makedirs(OUT, exist_ok=True)
-cmd = [JAVAC, "-parameters", "-encoding", "UTF-8", "-cp", cp, "-d", OUT] + sources
-r = subprocess.run(cmd, capture_output=True)
-print("javac returncode:", r.returncode)
-if r.returncode != 0:
-    err = (r.stderr or b"").decode("utf-8", "replace")
-    print("=== STDERR (first 60 lines) ===")
-    print("\n".join(err.splitlines()[:60]))
-    sys.exit(1)
-print("compiled classes:", len(glob.glob(os.path.join(OUT, "**", "*.class"), recursive=True)))
-
-# 3) 重打包: 以 v8 为基底, 替换最新编译的 class, 并注入 src/main/resources 中的资源(xml等)
-with zipfile.ZipFile(SRC_JAR) as zin:
-    infos = zin.infolist()
-
-    def local_for(entry_name):
-        if entry_name.startswith("BOOT-INF/classes/") and entry_name.endswith(".class"):
-            rel = entry_name[len("BOOT-INF/classes/"):]
-            local = os.path.join(OUT, rel)
-            if os.path.isfile(local):
-                return local
-            return None
-        if entry_name.startswith("BOOT-INF/classes/"):
-            rel = entry_name[len("BOOT-INF/classes/"):]
-            local = os.path.join(RES, rel)
-            if os.path.isfile(local):
-                return local
-        return None
-
-    manifest_name = "META-INF/MANIFEST.MF"
-    all_names = set(zin.namelist())
-    extra_resources = []
-    for root, _, files in os.walk(RES):
-        for f in files:
-            full = os.path.join(root, f)
-            rel = os.path.relpath(full, RES).replace("\\", "/")
-            entry = "BOOT-INF/classes/" + rel
-            if entry not in all_names:
-                extra_resources.append((entry, full))
-
-    # 源码中新增的类, 在基底 jar 里原本不存在, 需补打到新 jar
-    extra_classes = []
-    for root, _, files in os.walk(OUT):
-        for f in files:
-            if f.endswith(".class"):
-                full = os.path.join(root, f)
-                rel = os.path.relpath(full, OUT).replace("\\", "/")
-                entry = "BOOT-INF/classes/" + rel
-                if entry not in all_names:
-                    extra_classes.append((entry, full))
-
-    with zipfile.ZipFile(DST_JAR, "w", compression=zipfile.ZIP_DEFLATED) as zout:
-        mi = next(i for i in infos if i.filename == manifest_name)
-        zout.writestr(mi, zin.read(manifest_name))
-        for i in infos:
-            if i.filename == manifest_name:
-                continue
-            local = local_for(i.filename)
-            if local:
-                with open(local, "rb") as lf:
-                    data = lf.read()
-                zi = zipfile.ZipInfo(i.filename)
-                zi.external_attr = i.external_attr
-                zi.date_time = i.date_time
-                zout.writestr(zi, data)
-            else:
-                zout.writestr(i, zin.read(i.filename))
-        for entry, full in extra_resources:
-            with open(full, "rb") as lf:
-                data = lf.read()
-            zout.writestr(zipfile.ZipInfo(entry), data)
-        for entry, full in extra_classes:
-            with open(full, "rb") as lf:
-                data = lf.read()
-            zout.writestr(zipfile.ZipInfo(entry), data)
-
-print("built:", DST_JAR, "exists:", os.path.exists(DST_JAR))
-zm = zipfile.ZipFile(DST_JAR)
-print("manifest first:", zm.namelist()[0] == manifest_name)
-
-# 校验关键新类已打入
-for cls in ["ProcurementCostExportVO.class", "ProcurementCostQuery.class",
-            "ResourceController.class", "ResourceServiceImpl.class"]:
-    entry = "BOOT-INF/classes/com/example/resourceplatform/" + (
-        "dto/" if cls.endswith("VO.class") or "Query" in cls
-        else "controller/" if "Controller" in cls
-        else "service/impl/")
-    entry = entry + cls
-    print("contains", entry, ":", entry in zm.namelist())

+ 0 - 14
backend/extract_deps.py

@@ -1,14 +0,0 @@
-import zipfile, os
-
-jar = "target/resource-platform-v5.jar"
-out_dir = "lib"
-os.makedirs(out_dir, exist_ok=True)
-z = zipfile.ZipFile(jar)
-n = 0
-for name in z.namelist():
-    if name.startswith("BOOT-INF/lib/") and name.endswith(".jar"):
-        out = os.path.join(out_dir, os.path.basename(name))
-        with open(out, "wb") as f:
-            f.write(z.read(name))
-        n += 1
-print("extracted", n, "dependency jars into", out_dir)

+ 0 - 35
backend/repack.py

@@ -1,35 +0,0 @@
-import zipfile, os, sys
-
-SRC = "target/resource-platform-new.jar"
-DST = "target/resource-platform-v2.jar"
-NEW_CLASS_SRC = "build_tmp_classes/com/example/resourceplatform/common/PurchaseDuration.class"
-TARGET_ENTRY = "BOOT-INF/classes/com/example/resourceplatform/common/PurchaseDuration.class"
-
-with open(NEW_CLASS_SRC, "rb") as f:
-    new_bytes = f.read()
-
-with zipfile.ZipFile(SRC, "r") as zin:
-    infos = zin.infolist()
-    # manifest must be first
-    manifest = zin.getinfo("META-INF/MANIFEST.MF")
-    with zipfile.ZipFile(DST, "w", compression=zipfile.ZIP_DEFLATED) as zout:
-        # 1) manifest first
-        zout.writestr(manifest, zin.read(manifest.filename))
-        for info in infos:
-            name = info.filename
-            if name == "META-INF/MANIFEST.MF":
-                continue
-            if name == TARGET_ENTRY:
-                zi = zipfile.ZipInfo(name)
-                zi.compress_type = info.compress_type
-                zi.external_attr = info.external_attr
-                zi.date_time = info.date_time
-                zout.writestr(zi, new_bytes)
-                print("replaced:", name)
-            else:
-                data = zin.read(info.filename)
-                zi = zipfile.ZipInfo(name, date_time=info.date_time)
-                zi.compress_type = info.compress_type
-                zi.external_attr = info.external_attr
-                zout.writestr(zi, data)
-    print("wrote", DST, os.path.getsize(DST), "bytes")

+ 0 - 39
backend/repack_v3.py

@@ -1,39 +0,0 @@
-import zipfile, os
-
-SRC = "target/resource-platform-v2.jar"
-DST = "target/resource-platform-v3.jar"
-NEW_CLASS_SRC = "build_tmp_classes/com/example/resourceplatform/common/PurchaseDuration.class"
-TARGET_ENTRY = "BOOT-INF/classes/com/example/resourceplatform/common/PurchaseDuration.class"
-
-with open(NEW_CLASS_SRC, "rb") as f:
-    new_bytes = f.read()
-
-with zipfile.ZipFile(SRC, "r") as zin:
-    infos = zin.infolist()
-    manifest = zin.getinfo("META-INF/MANIFEST.MF")
-    with zipfile.ZipFile(DST, "w", compression=zipfile.ZIP_DEFLATED) as zout:
-        zout.writestr(manifest, zin.read(manifest.filename))
-        for info in infos:
-            name = info.filename
-            if name == "META-INF/MANIFEST.MF":
-                continue
-            if name == TARGET_ENTRY:
-                zi = zipfile.ZipInfo(name)
-                zi.compress_type = info.compress_type
-                zi.external_attr = info.external_attr
-                zi.date_time = info.date_time
-                zout.writestr(zi, new_bytes)
-                print("replaced:", name)
-            else:
-                data = zin.read(info.filename)
-                zi = zipfile.ZipInfo(name, date_time=info.date_time)
-                zi.compress_type = info.compress_type
-                zi.external_attr = info.external_attr
-                zout.writestr(zi, data)
-    print("wrote", DST, os.path.getsize(DST), "bytes")
-
-# sanity: manifest first + class present
-with zipfile.ZipFile(DST) as z:
-    names = z.namelist()
-    print("manifest first?", names[0] == "META-INF/MANIFEST.MF")
-    print("class present?", TARGET_ENTRY in names)

+ 0 - 39
backend/repack_v5.py

@@ -1,39 +0,0 @@
-import zipfile, os
-
-SRC = "target/resource-platform-v4.jar"
-OUT = "target/resource-platform-v5.jar"
-CLASSES = "build_tmp_classes"
-
-zin = zipfile.ZipFile(SRC)
-names = zin.namelist()
-
-def is_lib(n):
-    return n.startswith("BOOT-INF/lib/")
-
-new_map = {}
-for root, _, files in os.walk(CLASSES):
-    for f in files:
-        full = os.path.join(root, f)
-        arc = "BOOT-INF/classes/" + os.path.relpath(full, CLASSES).replace(os.sep, "/")
-        new_map[arc] = full
-
-zout = zipfile.ZipFile(OUT, "w", zipfile.ZIP_DEFLATED)
-zout.writestr("META-INF/MANIFEST.MF", zin.read("META-INF/MANIFEST.MF"), zipfile.ZIP_STORED)
-for n in names:
-    if n == "META-INF/MANIFEST.MF":
-        continue
-    if is_lib(n):
-        zout.writestr(n, zin.read(n), zipfile.ZIP_STORED)
-    elif n.startswith("BOOT-INF/classes/") and not n.endswith("/"):
-        if n in new_map:
-            with open(new_map[n], "rb") as fh:
-                zout.writestr(n, fh.read(), zipfile.ZIP_DEFLATED)
-        else:
-            zout.writestr(n, zin.read(n), zipfile.ZIP_DEFLATED)
-    else:
-        zout.writestr(n, zin.read(n), zipfile.ZIP_DEFLATED)
-zout.close()
-
-zv = zipfile.ZipFile(OUT)
-print("manifest first?", zv.namelist()[0] == "META-INF/MANIFEST.MF")
-print("BusinessException replaced?", "BOOT-INF/classes/com/example/resourceplatform/common/BusinessException.class" in zv.namelist())

+ 0 - 9
backend/start_v10.sh

@@ -1,9 +0,0 @@
-#!/bin/bash
-cd /d/demo/resource-platform/backend
-"D:/Program Files/Java/jdk-17/bin/java.exe" \
-  -Dspring.profiles.active=dev \
-  -Dserver.port=8080 \
-  -DDB_URL='jdbc:mysql://rm-uf64611sxm4qe438g8o.mysql.rds.aliyuncs.com:33450/resource_platform?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&useSSL=false' \
-  -DDB_USERNAME=root \
-  -DDB_PASSWORD=Cmt123456 \
-  -jar target/resource-platform-v10.jar

+ 0 - 9
backend/start_v11.sh

@@ -1,9 +0,0 @@
-#!/bin/bash
-cd /d/demo/resource-platform/backend
-"D:/Program Files/Java/jdk-17/bin/java.exe" \
-  -Dspring.profiles.active=dev \
-  -Dserver.port=8080 \
-  -DDB_URL='jdbc:mysql://rm-uf64611sxm4qe438g8o.mysql.rds.aliyuncs.com:33450/resource_platform?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&useSSL=false' \
-  -DDB_USERNAME=root \
-  -DDB_PASSWORD=Cmt123456 \
-  -jar target/resource-platform-v11.jar

+ 0 - 9
backend/start_v7.sh

@@ -1,9 +0,0 @@
-#!/bin/bash
-cd /d/demo/resource-platform/backend
-"D:/Program Files/Java/jdk-17/bin/java.exe" \
-  -Dspring.profiles.active=dev \
-  -Dserver.port=8080 \
-  -DDB_URL='jdbc:mysql://rm-uf64611sxm4qe438g8o.mysql.rds.aliyuncs.com:33450/resource_platform?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&useSSL=false' \
-  -DDB_USERNAME=root \
-  -DDB_PASSWORD=Cmt123456 \
-  -jar target/resource-platform-v7.jar

+ 0 - 9
backend/start_v8.sh

@@ -1,9 +0,0 @@
-#!/bin/bash
-cd /d/demo/resource-platform/backend
-"D:/Program Files/Java/jdk-17/bin/java.exe" \
-  -Dspring.profiles.active=dev \
-  -Dserver.port=8080 \
-  -DDB_URL='jdbc:mysql://rm-uf64611sxm4qe438g8o.mysql.rds.aliyuncs.com:33450/resource_platform?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&useSSL=false' \
-  -DDB_USERNAME=root \
-  -DDB_PASSWORD=Cmt123456 \
-  -jar target/resource-platform-v8.jar

+ 0 - 9
backend/start_v9.sh

@@ -1,9 +0,0 @@
-#!/bin/bash
-cd /d/demo/resource-platform/backend
-"D:/Program Files/Java/jdk-17/bin/java.exe" \
-  -Dspring.profiles.active=dev \
-  -Dserver.port=8080 \
-  -DDB_URL='jdbc:mysql://rm-uf64611sxm4qe438g8o.mysql.rds.aliyuncs.com:33450/resource_platform?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&useSSL=false' \
-  -DDB_USERNAME=root \
-  -DDB_PASSWORD=Cmt123456 \
-  -jar target/resource-platform-v9.jar

+ 0 - 4
start-backend.bat

@@ -1,4 +0,0 @@
-@echo off
-set JAVA_HOME=D:\Program Files\Java\jdk-17
-cd /d d:\demo\resource-platform\backend
-mvn spring-boot:run