Bladeren bron

feat(resource): 购买时长选项改为 1个月/2个月/3个月/6个月/1年/2年/3年

- PurchaseDuration 枚举由 按量/月/季度/半年/年(1-5) 改为
  1个月/2个月/3个月/6个月/1年/2年/3年(1-7),移除 lombok 依赖改为显式 getter
- 同步更新 Resource/ResourceDTO/ResourceVO 字段注释
- 前端 ResourceForm 下拉选项同步更新
- RDS 存量数据迁移: 月->1个月, 季度->3个月, 半年->6个月, 年->1年, 按量->NULL
  (实测仅 1 行非 NULL, 已正确映射; 48 行本就为空)
- 后端离线重编译重打包并重启(8080),repack.py 保留为无 Maven 环境下的重部署工具
C 2 maanden geleden
bovenliggende
commit
7894f8aaa0

+ 35 - 0
backend/repack.py

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

+ 16 - 8
backend/src/main/java/com/example/resourceplatform/common/PurchaseDuration.java

@@ -1,18 +1,18 @@
 package com.example.resourceplatform.common;
 
-import lombok.Getter;
-
 /**
  * 购买时长枚举
+ * 编码: 1-1个月 2-2个月 3-3个月 4-6个月 5-1年 6-2年 7-3年
  */
-@Getter
 public enum PurchaseDuration {
 
-    PAY_AS_YOU_GO(1, "按量"),
-    MONTH(2, "月"),
-    QUARTER(3, "季度"),
-    HALF_YEAR(4, "半年"),
-    YEAR(5, "年");
+    MONTH_1(1, "1个月"),
+    MONTH_2(2, "2个月"),
+    MONTH_3(3, "3个月"),
+    MONTH_6(4, "6个月"),
+    YEAR_1(5, "1年"),
+    YEAR_2(6, "2年"),
+    YEAR_3(7, "3年");
 
     private final int code;
     private final String text;
@@ -22,6 +22,14 @@ public enum PurchaseDuration {
         this.text = text;
     }
 
+    public int getCode() {
+        return code;
+    }
+
+    public String getText() {
+        return text;
+    }
+
     public static String getTextByCode(Integer code) {
         if (code == null) return "";
         for (PurchaseDuration d : values()) {

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

@@ -36,7 +36,7 @@ public class ResourceDTO {
 
     private String remark;
 
-    /** 购买时长: 1-按量 2-月 3-季度 4-半年 5-年 */
+    /** 购买时长: 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-按量 2-月 3-季度 4-半年 5-年 */
+    /** 购买时长编码: 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-按量 2-月 3-季度 4-半年 5-年 */
+    /** 购买时长: 1-1个月 2-2个月 3-3个月 4-6个月 5-1年 6-2年 7-3年 */
     private Integer purchaseDuration;
 
     private LocalDateTime createTime;

+ 7 - 5
frontend/src/views/resource/ResourceForm.vue

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