瀏覽代碼

feat(resource): 购买时长新增「按量」选项(编码8)

- PurchaseDuration 枚举新增 ANLIANG(8, "按量"),编码现为 8-按量 1-1个月...7-3年
- 采用追加方式(编码8),不动原有 1-7,存量数据无需迁移
- 同步更新 Resource/ResourceDTO/ResourceVO 字段注释
- 前端 ResourceForm 下拉首位增加「按量」(value=8)
- 后端离线重编译重打包为 resource-platform-v3.jar 并重启(8080)
- 反射验证 getTextByCode(8) 正确返回 按量;列表/详情接口 200 正常
C 2 月之前
父節點
當前提交
2b188b1d16

+ 39 - 0
backend/repack_v3.py

@@ -0,0 +1,39 @@
+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)

+ 2 - 1
backend/src/main/java/com/example/resourceplatform/common/PurchaseDuration.java

@@ -2,10 +2,11 @@ package com.example.resourceplatform.common;
 
 /**
  * 购买时长枚举
- * 编码: 1-1个月 2-2个月 3-3个月 4-6个月 5-1年 6-2年 7-3年
+ * 编码: 8-按量 1-1个月 2-2个月 3-3个月 4-6个月 5-1年 6-2年 7-3年
  */
 public enum PurchaseDuration {
 
+    ANLIANG(8, "按量"),
     MONTH_1(1, "1个月"),
     MONTH_2(2, "2个月"),
     MONTH_3(3, "3个月"),

+ 1 - 1
backend/src/main/java/com/example/resourceplatform/dto/ResourceDTO.java

@@ -36,7 +36,7 @@ public class ResourceDTO {
 
     private String remark;
 
-    /** 购买时长: 1-1个月 2-2个月 3-3个月 4-6个月 5-1年 6-2年 7-3年 */
+    /** 购买时长: 8-按量 1-1个月 2-2个月 3-3个月 4-6个月 5-1年 6-2年 7-3年 */
     private Integer purchaseDuration;
 
     /** 关联的项目id列表,支持一个资源同时关联多个项目 */

+ 1 - 1
backend/src/main/java/com/example/resourceplatform/dto/ResourceVO.java

@@ -44,7 +44,7 @@ public class ResourceVO {
 
     private String remark;
 
-    /** 购买时长编码: 1-1个月 2-2个月 3-3个月 4-6个月 5-1年 6-2年 7-3年 */
+    /** 购买时长编码: 8-按量 1-1个月 2-2个月 3-3个月 4-6个月 5-1年 6-2年 7-3年 */
     private Integer purchaseDuration;
 
     /** 购买时长中文文本,用于前端展示 */

+ 1 - 1
backend/src/main/java/com/example/resourceplatform/entity/Resource.java

@@ -41,7 +41,7 @@ public class Resource {
 
     private String remark;
 
-    /** 购买时长: 1-1个月 2-2个月 3-3个月 4-6个月 5-1年 6-2年 7-3年 */
+    /** 购买时长: 8-按量 1-1个月 2-2个月 3-3个月 4-6个月 5-1年 6-2年 7-3年 */
     private Integer purchaseDuration;
 
     private LocalDateTime createTime;

+ 1 - 0
frontend/src/views/resource/ResourceForm.vue

@@ -65,6 +65,7 @@
         <el-col :span="12">
           <el-form-item label="购买时长">
             <el-select v-model="form.purchaseDuration" style="width: 100%" clearable placeholder="请选择">
+              <el-option label="按量" :value="8" />
               <el-option label="1个月" :value="1" />
               <el-option label="2个月" :value="2" />
               <el-option label="3个月" :value="3" />