浏览代码

merge: 合并远程 cfclub(通知模板/健康报告编辑/商品套餐设计等)与本地 SKU 价格单位统一 + 规格选择修复

asus 1 月之前
父节点
当前提交
aa76c31ef7
共有 100 个文件被更改,包括 629 次插入545 次删除
  1. 37 6
      cfc-backend/src/main/java/com/etotem/cfc/config/DatabaseInitializer.java
  2. 13 12
      cfc-backend/src/main/java/com/etotem/cfc/controller/ActivityController.java
  3. 6 5
      cfc-backend/src/main/java/com/etotem/cfc/controller/ActivityFeedbackController.java
  4. 4 3
      cfc-backend/src/main/java/com/etotem/cfc/controller/ActivityMaterialController.java
  5. 2 1
      cfc-backend/src/main/java/com/etotem/cfc/controller/ActivityOrderController.java
  6. 9 8
      cfc-backend/src/main/java/com/etotem/cfc/controller/AiQuestionnaireController.java
  7. 9 8
      cfc-backend/src/main/java/com/etotem/cfc/controller/BadgeController.java
  8. 3 4
      cfc-backend/src/main/java/com/etotem/cfc/controller/CircleChallengeController.java
  9. 5 4
      cfc-backend/src/main/java/com/etotem/cfc/controller/ContactController.java
  10. 5 4
      cfc-backend/src/main/java/com/etotem/cfc/controller/ContactMatchController.java
  11. 6 6
      cfc-backend/src/main/java/com/etotem/cfc/controller/CouponController.java
  12. 6 10
      cfc-backend/src/main/java/com/etotem/cfc/controller/DailyCheckinController.java
  13. 4 6
      cfc-backend/src/main/java/com/etotem/cfc/controller/DailyFeedbackController.java
  14. 2 1
      cfc-backend/src/main/java/com/etotem/cfc/controller/DailyTaskController.java
  15. 23 27
      cfc-backend/src/main/java/com/etotem/cfc/controller/DanAssessmentController.java
  16. 2 1
      cfc-backend/src/main/java/com/etotem/cfc/controller/DanReportController.java
  17. 3 4
      cfc-backend/src/main/java/com/etotem/cfc/controller/DistributionInviteController.java
  18. 2 3
      cfc-backend/src/main/java/com/etotem/cfc/controller/EmiReportController.java
  19. 12 22
      cfc-backend/src/main/java/com/etotem/cfc/controller/EnergyController.java
  20. 3 4
      cfc-backend/src/main/java/com/etotem/cfc/controller/FamilyChallengeController.java
  21. 5 8
      cfc-backend/src/main/java/com/etotem/cfc/controller/FamilyPlatformBalanceController.java
  22. 5 4
      cfc-backend/src/main/java/com/etotem/cfc/controller/GameRecordController.java
  23. 3 4
      cfc-backend/src/main/java/com/etotem/cfc/controller/HealthAlertController.java
  24. 5 8
      cfc-backend/src/main/java/com/etotem/cfc/controller/HealthCheckinController.java
  25. 3 4
      cfc-backend/src/main/java/com/etotem/cfc/controller/HealthCircleController.java
  26. 3 4
      cfc-backend/src/main/java/com/etotem/cfc/controller/HealthDimensionController.java
  27. 2 1
      cfc-backend/src/main/java/com/etotem/cfc/controller/HealthExerciseController.java
  28. 5 8
      cfc-backend/src/main/java/com/etotem/cfc/controller/HealthGrowthRecordController.java
  29. 3 4
      cfc-backend/src/main/java/com/etotem/cfc/controller/HealthInteractionController.java
  30. 2 1
      cfc-backend/src/main/java/com/etotem/cfc/controller/HealthKnowledgeBaseController.java
  31. 2 1
      cfc-backend/src/main/java/com/etotem/cfc/controller/HealthMealController.java
  32. 2 1
      cfc-backend/src/main/java/com/etotem/cfc/controller/HealthMeditationController.java
  33. 2 1
      cfc-backend/src/main/java/com/etotem/cfc/controller/HealthPlanController.java
  34. 56 73
      cfc-backend/src/main/java/com/etotem/cfc/controller/HealthReportController.java
  35. 3 4
      cfc-backend/src/main/java/com/etotem/cfc/controller/HealthScoreController.java
  36. 2 1
      cfc-backend/src/main/java/com/etotem/cfc/controller/HealthSleepController.java
  37. 2 2
      cfc-backend/src/main/java/com/etotem/cfc/controller/HealthTimelineController.java
  38. 2 1
      cfc-backend/src/main/java/com/etotem/cfc/controller/HealthWaterController.java
  39. 3 3
      cfc-backend/src/main/java/com/etotem/cfc/controller/MealRecommendController.java
  40. 3 2
      cfc-backend/src/main/java/com/etotem/cfc/controller/MembershipController.java
  41. 5 8
      cfc-backend/src/main/java/com/etotem/cfc/controller/MicroActionController.java
  42. 2 2
      cfc-backend/src/main/java/com/etotem/cfc/controller/PackageLogisticsController.java
  43. 6 5
      cfc-backend/src/main/java/com/etotem/cfc/controller/PackagePaymentController.java
  44. 4 3
      cfc-backend/src/main/java/com/etotem/cfc/controller/PointsExchangeController.java
  45. 2 2
      cfc-backend/src/main/java/com/etotem/cfc/controller/ProblemPackageController.java
  46. 3 4
      cfc-backend/src/main/java/com/etotem/cfc/controller/ProblemSurveyController.java
  47. 2 2
      cfc-backend/src/main/java/com/etotem/cfc/controller/PromotionController.java
  48. 3 2
      cfc-backend/src/main/java/com/etotem/cfc/controller/PromotionMaterialController.java
  49. 2 1
      cfc-backend/src/main/java/com/etotem/cfc/controller/RecommendController.java
  50. 2 1
      cfc-backend/src/main/java/com/etotem/cfc/controller/ReportStatsController.java
  51. 5 8
      cfc-backend/src/main/java/com/etotem/cfc/controller/ReportSurveyController.java
  52. 3 6
      cfc-backend/src/main/java/com/etotem/cfc/controller/ReviewController.java
  53. 3 2
      cfc-backend/src/main/java/com/etotem/cfc/controller/ServiceRoleApplicationController.java
  54. 4 3
      cfc-backend/src/main/java/com/etotem/cfc/controller/ShareController.java
  55. 7 9
      cfc-backend/src/main/java/com/etotem/cfc/controller/SurveyController.java
  56. 6 5
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminActivityController.java
  57. 2 1
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminActivityRegistrationController.java
  58. 4 3
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminAfterSalesController.java
  59. 16 15
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminArticleController.java
  60. 4 9
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminButlerController.java
  61. 3 2
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminCategoryController.java
  62. 3 2
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminCfValueController.java
  63. 4 9
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminCommissionController.java
  64. 5 4
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminController.java
  65. 5 4
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminCouponController.java
  66. 3 2
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminDiscountController.java
  67. 8 7
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminDistributionController.java
  68. 3 2
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminEnergyBehaviorConfigController.java
  69. 2 1
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminEnergyConfigController.java
  70. 3 2
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminEnergyRuleController.java
  71. 4 3
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminFoodController.java
  72. 4 9
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminGrowthArchiveProductController.java
  73. 16 18
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminInventoryController.java
  74. 3 2
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminNoticeController.java
  75. 90 0
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminNotificationTemplateController.java
  76. 4 3
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminPeriodicServiceController.java
  77. 2 1
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminPlanRuleController.java
  78. 2 1
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminProblemDomainController.java
  79. 6 15
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminProductController.java
  80. 5 4
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminProductPpointController.java
  81. 4 3
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminPromotionTierController.java
  82. 2 1
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminRecipeController.java
  83. 2 1
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminSeasonalController.java
  84. 2 1
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminSupplierController.java
  85. 2 1
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminSurveyController.java
  86. 5 4
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminUnlockGateController.java
  87. 2 3
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminVendorController.java
  88. 11 10
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminVirtualTeamController.java
  89. 5 4
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/CommissionDistController.java
  90. 2 1
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/EcomSupplierController.java
  91. 3 2
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/FamilyAttributeController.java
  92. 3 2
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/FileRecordController.java
  93. 3 2
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/IndicatorAdminController.java
  94. 10 9
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/PpointConfigAdminController.java
  95. 5 4
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/ServiceContentController.java
  96. 4 9
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/SupplierProductController.java
  97. 21 20
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/SupplyHierarchyController.java
  98. 4 4
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/SupplySettlementController.java
  99. 8 7
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/SupplySystemController.java
  100. 2 1
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/VirtualGoodsConfigAdminController.java

+ 37 - 6
cfc-backend/src/main/java/com/etotem/cfc/config/DatabaseInitializer.java

@@ -1076,8 +1076,6 @@ log.info("已添加template_id列到tasks表");
             insertProductSeed("肠道菌群检测套装", "家用检测 + 报告解读", "physical", 59900, "body", "budget");
             insertProductSeed("儿童多模态认知测评", "在线测评 + 个性化建议", "digital", 9900, "wisdom", "none");
             insertProductSeed("成长规划师1对1咨询", "60分钟专业规划", "service", 50000, "wealth", "budget");
-            insertProductSeed("21天科学减重套餐", "基于肠道菌群的个性化减重方案,21天找到适合自己体质的减重方式,不再反弹", "physical", 49900, "body", "all");
-            insertProductSeed("28天血糖平稳管理套餐", "餐后血糖生活方式管理,基于菌群的个性化饮食方案,帮助糖前期人群平稳血糖", "physical", 49900, "body", "all");
             log.info("Product 种子数据已加载");
         } catch (Exception e) {
             log.warn("Product 种子数据初始化失败: {}", e.getMessage());
@@ -9125,7 +9123,40 @@ private void runMigration100() {
 			log.warn("初始化sys_menu种子数据失败: " + e.getMessage());
 		}
 
-		// 迁移245: product_skus 存量价格 ×100(元→分),sys_config 幂等标记
+// 迁移245: 创建 notification_templates 表(通知模板管理 W3)
+		try {
+			jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS notification_templates (" +
+					"id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
+					"type VARCHAR(30) NOT NULL COMMENT '通知类型: report_ready/reward_granted/system', " +
+					"title VARCHAR(200) NOT NULL COMMENT '默认标题(支持占位符)', " +
+					"content VARCHAR(1000) NOT NULL COMMENT '默认内容模板(支持占位符)', " +
+					"channels VARCHAR(100) DEFAULT 'in_app' COMMENT '推送通道: in_app,sms,wechat,phone 逗号分隔', " +
+					"status TINYINT DEFAULT 1 COMMENT '1启用 0停用', " +
+					"created_at DATETIME DEFAULT CURRENT_TIMESTAMP, " +
+					"updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, " +
+					"UNIQUE KEY uk_type (type)" +
+					") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='通知模板(改版v1 W3)'");
+			log.info("已创建notification_templates表");
+		} catch (Exception e) {
+			log.warn("创建notification_templates表可能已存在: {}", e.getMessage());
+		}
+		// 迁移245b: notification_templates 种子数据(表为空才插入,幂等)
+		try {
+			Integer tplCount = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM notification_templates", Integer.class);
+			if (tplCount == null || tplCount == 0) {
+				jdbcTemplate.execute("INSERT INTO notification_templates (type, title, content, channels) VALUES " +
+						"('report_ready', '健康报告已完成分析', '您的健康报告已完成解析,可前往查看结果与成长方案。', 'in_app,sms'), " +
+						"('reward_granted', '问题域完成奖励已到账', '恭喜完成「{domainName}」全部任务,奖励 {reward} CF 已发放至家庭账户。', 'in_app,sms,wechat'), " +
+						"('system', '系统通知', '您有一条新的系统通知,请前往查看。', 'in_app')");
+				log.info("notification_templates 种子数据已插入");
+			} else {
+				log.info("notification_templates 已有 {} 条数据,跳过种子插入", tplCount);
+			}
+		} catch (Exception e) {
+			log.warn("初始化notification_templates种子数据失败: " + e.getMessage());
+		}
+
+		// 迁移246: product_skus 存量价格 ×100(元→分),sys_config 幂等标记
 		try {
 			Integer migrated = jdbcTemplate.queryForObject(
 					"SELECT COUNT(*) FROM sys_config WHERE config_key = 'sku_price_to_cents_done'",
@@ -9133,12 +9164,12 @@ private void runMigration100() {
 			if (migrated == null || migrated == 0) {
 				jdbcTemplate.update("UPDATE product_skus SET price = IFNULL(price, 0) * 100, original_price = IFNULL(original_price, 0) * 100");
 				jdbcTemplate.update("INSERT INTO sys_config (config_key, config_value, description) VALUES ('sku_price_to_cents_done', '1', 'SKU价格已迁移为分单位')");
-				log.info("迁移245: product_skus 价格已×100(元→分)");
+				log.info("迁移246: product_skus 价格已×100(元→分)");
 			} else {
-				log.info("迁移245: product_skus 价格已迁移过,跳过");
+				log.info("迁移246: product_skus 价格已迁移过,跳过");
 			}
 		} catch (Exception e) {
-			log.warn("迁移245失败: {}", e.getMessage());
+			log.warn("迁移246失败: {}", e.getMessage());
 		}
 
 	}

+ 13 - 12
cfc-backend/src/main/java/com/etotem/cfc/controller/ActivityController.java

@@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/activity")
@@ -29,7 +30,7 @@ public class ActivityController {
     @PostMapping("/detail")
     public Result<ActivityDTO> detail(@RequestBody Map<String, Object> params,
                                        @RequestAttribute(value = "userId", required = false) Long userId) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) return Result.error("id不能为空");
         return activityService.detail(id, userId);
     }
@@ -65,7 +66,7 @@ public class ActivityController {
         if (!"admin".equals(role) && !"activity_admin".equals(role)) {
             return Result.error("只有管理员或活动管理员可以发布活动");
         }
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) return Result.error("id不能为空");
         try {
             return activityService.publish(id);
@@ -79,7 +80,7 @@ public class ActivityController {
                                @RequestAttribute(value = "userId", required = false) Long userId,
                                @RequestAttribute("role") String role) {
         if (!"admin".equals(role) && !"activity_admin".equals(role)) {
-            Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+            Long id = ParamUtils.getLong(params.get("id"));
             if (id == null) return Result.error("id不能为空");
             Activity existing = activityService.getById(id);
             if (existing == null) return Result.error("活动不存在");
@@ -87,7 +88,7 @@ public class ActivityController {
                 return Result.error("只有创建人或管理员可以结束活动");
             }
         }
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) return Result.error("id不能为空");
         return activityService.end(id);
     }
@@ -96,7 +97,7 @@ public class ActivityController {
     public Result<String> submitReview(@RequestBody Map<String, Object> params,
                                         @RequestAttribute(value = "userId", required = false) Long userId,
                                         @RequestAttribute("role") String role) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) return Result.error("id不能为空");
         Activity existing = activityService.getById(id);
         if (existing == null) return Result.error("活动不存在");
@@ -111,7 +112,7 @@ public class ActivityController {
     @PostMapping("/register")
     public Result<Map<String, Object>> register(@RequestBody Map<String, Object> params, @RequestAttribute(value = "userId", required = false) Long userId,
                                                 @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long activityId = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long activityId = ParamUtils.getLong(params.get("id"));
         if (activityId == null) return Result.error("活动ID不能为空");
         // batch registration with registrants list
         Object registrantsObj = params.get("registrants");
@@ -120,7 +121,7 @@ public class ActivityController {
             return registrationService.batchRegister(activityId, userId, registrants);
         }
         // single registration (backward compatibility)
-        Long memberId = params.get("memberId") != null ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         if (memberId == null) return Result.error("孩子ID不能为空");
         return registrationService.register(activityId, userId, memberId);
     }
@@ -128,8 +129,8 @@ public class ActivityController {
     @PostMapping("/cancel-registration")
     public Result<Void> cancelRegistration(@RequestBody Map<String, Object> params, @RequestAttribute(value = "userId", required = false) Long userId,
                                            @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long activityId = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
-        Long memberId = params.get("memberId") != null ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long activityId = ParamUtils.getLong(params.get("id"));
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         if (activityId == null) return Result.error("活动ID不能为空");
         if (memberId == null) return Result.error("孩子ID不能为空");
         return registrationService.cancel(activityId, userId, memberId);
@@ -138,7 +139,7 @@ public class ActivityController {
     @PostMapping("/my-registrations")
     public Result<Map<String, Object>> myRegistrations(@RequestBody Map<String, Object> params, @RequestAttribute(value = "userId", required = false) Long userId,
                                                        @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = params.get("memberId") != null ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         Integer page = params.get("page") != null ? Integer.valueOf(params.get("page").toString()) : 1;
         Integer size = params.get("size") != null ? Integer.valueOf(params.get("size").toString()) : 10;
         return registrationService.getMyRegistrations(userId, memberId, page, size);
@@ -147,8 +148,8 @@ public class ActivityController {
     @PostMapping("/checkin")
     public Result<Map<String, Object>> checkin(@RequestBody Map<String, Object> params, @RequestAttribute(value = "userId", required = false) Long userId,
                                                @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
-        Long memberId = params.get("memberId") != null ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long id = ParamUtils.getLong(params.get("id"));
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         if (id == null) return Result.error("id不能为空");
         Map<String, Object> checkinResult = activityService.checkin(id, userId, memberId);
         if (checkinResult.containsKey("error")) return Result.error(checkinResult.get("error").toString());

+ 6 - 5
cfc-backend/src/main/java/com/etotem/cfc/controller/ActivityFeedbackController.java

@@ -5,6 +5,7 @@ import com.etotem.cfc.service.ActivityFeedbackService;
 import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/activity/feedback")
@@ -16,8 +17,8 @@ public class ActivityFeedbackController {
     public Result<?> submit(@RequestBody Map<String, Object> params,
                             @RequestAttribute("userId") Long userId,
                             @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long activityId = params.get("activityId") != null ? Long.valueOf(params.get("activityId").toString()) : null;
-        Long memberId = params.get("memberId") != null ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long activityId = ParamUtils.getLong(params.get("activityId"));
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         String ratings = (String) params.get("ratings");
         String comment = (String) params.get("comment");
         if (activityId == null) return Result.error("活动ID不能为空");
@@ -26,7 +27,7 @@ public class ActivityFeedbackController {
 
     @PostMapping("/list")
     public Result<?> list(@RequestBody Map<String, Object> params) {
-        Long activityId = params.get("activityId") != null ? Long.valueOf(params.get("activityId").toString()) : null;
+        Long activityId = ParamUtils.getLong(params.get("activityId"));
         if (activityId == null) return Result.error("活动ID不能为空");
         return activityFeedbackService.getFeedbackList(activityId);
     }
@@ -35,8 +36,8 @@ public class ActivityFeedbackController {
     public Result<?> my(@RequestBody Map<String, Object> params,
                         @RequestAttribute("userId") Long userId,
                         @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long activityId = params.get("activityId") != null ? Long.valueOf(params.get("activityId").toString()) : null;
-        Long memberId = params.get("memberId") != null ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long activityId = ParamUtils.getLong(params.get("activityId"));
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         if (activityId == null) return Result.error("活动ID不能为空");
         return activityFeedbackService.getMyFeedback(activityId, memberId != null ? memberId : null);
     }

+ 4 - 3
cfc-backend/src/main/java/com/etotem/cfc/controller/ActivityMaterialController.java

@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/activity/material")
@@ -24,7 +25,7 @@ public class ActivityMaterialController {
     public Result<ActivityMaterial> upload(@RequestBody Map<String, Object> params,
                                            @RequestAttribute("userId") Long userId,
                                            @RequestAttribute("role") String role) {
-        Long activityId = params.get("activityId") != null ? Long.valueOf(params.get("activityId").toString()) : null;
+        Long activityId = ParamUtils.getLong(params.get("activityId"));
         if (activityId == null) return Result.error("活动ID不能为空");
         String title = (String) params.get("title");
         String fileUrl = (String) params.get("fileUrl");
@@ -34,7 +35,7 @@ public class ActivityMaterialController {
 
     @PostMapping("/list")
     public Result<List<ActivityMaterial>> list(@RequestBody Map<String, Object> params) {
-        Long activityId = params.get("activityId") != null ? Long.valueOf(params.get("activityId").toString()) : null;
+        Long activityId = ParamUtils.getLong(params.get("activityId"));
         if (activityId == null) return Result.error("活动ID不能为空");
         return materialService.list(activityId);
     }
@@ -43,7 +44,7 @@ public class ActivityMaterialController {
     public Result<String> delete(@RequestBody Map<String, Object> params,
                                  @RequestAttribute("userId") Long userId,
                                  @RequestAttribute("role") String role) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) return Result.error("资料ID不能为空");
         return materialService.delete(id, userId, role);
     }

+ 2 - 1
cfc-backend/src/main/java/com/etotem/cfc/controller/ActivityOrderController.java

@@ -17,6 +17,7 @@ import java.io.BufferedReader;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/activity/order")
@@ -31,7 +32,7 @@ public class ActivityOrderController {
     @PostMapping("/create")
     public Result<Map<String, Object>> create(@RequestBody Map<String, Object> params,
                                               @RequestAttribute("userId") Long userId) {
-        Long activityId = params.get("activityId") != null ? Long.valueOf(params.get("activityId").toString()) : null;
+        Long activityId = ParamUtils.getLong(params.get("activityId"));
         if (activityId == null) return Result.error("活动ID不能为空");
         Object registrantsObj = params.get("registrants");
         if (!(registrantsObj instanceof List)) return Result.error("报名人不能为空");

+ 9 - 8
cfc-backend/src/main/java/com/etotem/cfc/controller/AiQuestionnaireController.java

@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 /**
  * AI 动态问卷引擎 — 会话/画像/场景管理
@@ -69,8 +70,8 @@ public class AiQuestionnaireController {
     public Result<Map<String, Object>> start(
             @RequestBody Map<String, Object> params,
             @RequestAttribute("userId") Long userId) {
-        Long sceneId = params.get("sceneId") == null ? null : Long.valueOf(params.get("sceneId").toString());
-        Long memberId = params.get("memberId") == null ? null : Long.valueOf(params.get("memberId").toString());
+        Long sceneId = ParamUtils.getLong(params.get("sceneId"));
+        Long memberId = ParamUtils.getLong(params.get("memberId"));
         if (sceneId == null || memberId == null) return Result.error("缺少 sceneId/memberId");
         try {
             return Result.success(aiQuestionnaireService.start(userId, sceneId, memberId));
@@ -84,7 +85,7 @@ public class AiQuestionnaireController {
     public Result<Map<String, Object>> answer(
             @RequestBody Map<String, Object> params,
             @RequestAttribute("userId") Long userId) {
-        Long sessionId = params.get("sessionId") == null ? null : Long.valueOf(params.get("sessionId").toString());
+        Long sessionId = ParamUtils.getLong(params.get("sessionId"));
         Object answer = params.get("answer");
         if (sessionId == null || answer == null) return Result.error("缺少 sessionId/answer");
         try {
@@ -99,7 +100,7 @@ public class AiQuestionnaireController {
     public Result<Map<String, Object>> finish(
             @RequestBody Map<String, Object> params,
             @RequestAttribute("userId") Long userId) {
-        Long sessionId = params.get("sessionId") == null ? null : Long.valueOf(params.get("sessionId").toString());
+        Long sessionId = ParamUtils.getLong(params.get("sessionId"));
         if (sessionId == null) return Result.error("缺少 sessionId");
         try {
             AiQProfile profile = aiQuestionnaireService.finish(userId, sessionId);
@@ -114,7 +115,7 @@ public class AiQuestionnaireController {
     public Result<Map<String, Object>> profileDetail(
             @RequestBody Map<String, Object> params,
             @RequestAttribute("userId") Long userId) {
-        Long sessionId = params.get("sessionId") == null ? null : Long.valueOf(params.get("sessionId").toString());
+        Long sessionId = ParamUtils.getLong(params.get("sessionId"));
         if (sessionId == null) return Result.error("缺少 sessionId");
         try {
             return Result.success(aiQuestionnaireService.getProfileDetail(userId, sessionId));
@@ -128,8 +129,8 @@ public class AiQuestionnaireController {
     public Result<List<AiQSession>> history(
             @RequestBody Map<String, Object> params,
             @RequestAttribute("userId") Long userId) {
-        Long memberId = params.get("memberId") == null ? null : Long.valueOf(params.get("memberId").toString());
-        Long sceneId = params.get("sceneId") == null ? null : Long.valueOf(params.get("sceneId").toString());
+        Long memberId = ParamUtils.getLong(params.get("memberId"));
+        Long sceneId = ParamUtils.getLong(params.get("sceneId"));
         return Result.success(aiQuestionnaireService.getHistory(userId, memberId, sceneId));
     }
 
@@ -138,7 +139,7 @@ public class AiQuestionnaireController {
     public Result<Void> abort(
             @RequestBody Map<String, Object> params,
             @RequestAttribute("userId") Long userId) {
-        Long sessionId = params.get("sessionId") == null ? null : Long.valueOf(params.get("sessionId").toString());
+        Long sessionId = ParamUtils.getLong(params.get("sessionId"));
         if (sessionId == null) return Result.error("缺少 sessionId");
         aiQuestionnaireService.abort(userId, sessionId);
         return Result.success(null);

+ 9 - 8
cfc-backend/src/main/java/com/etotem/cfc/controller/BadgeController.java

@@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "勋章管理", description = "勋章系统相关接口")
 @RestController
@@ -37,7 +38,7 @@ public class BadgeController {
     @Operation(summary = "获取勋章详情")
     @PostMapping("/detail")
     public Result<Badge> getBadgeDetail(@RequestBody Map<String, Object> body) {
-        Long id = Long.valueOf(body.get("id").toString());
+        Long id = ParamUtils.getLong(body.get("id"));
         Badge badge = badgeService.getBadgeById(id);
         if (badge == null) {
             return Result.error("勋章不存在");
@@ -62,7 +63,7 @@ public class BadgeController {
     @Operation(summary = "删除勋章")
     @PostMapping("/delete")
     public Result<String> deleteBadge(@RequestBody Map<String, Object> body) {
-        Long id = Long.valueOf(body.get("id").toString());
+        Long id = ParamUtils.getLong(body.get("id"));
         badgeService.deleteBadge(id);
         return Result.success("删除成功");
     }
@@ -73,8 +74,8 @@ public class BadgeController {
     @PostMapping("/grant")
     public Result<String> grantBadge(@RequestBody Map<String, Object> body,
                                      @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = body.get("memberId") != null ? Long.valueOf(body.get("memberId").toString()) : currentMemberId;
-        Long badgeId = Long.valueOf(body.get("badgeId").toString());
+        Long memberId = ParamUtils.getLong(body.get("memberId"), currentMemberId);
+        Long badgeId = ParamUtils.getLong(body.get("badgeId"));
         badgeService.grantBadge(memberId, badgeId);
         return Result.success("授予成功");
     }
@@ -85,7 +86,7 @@ public class BadgeController {
     @PostMapping("/child/list")
     public Result<List<Map<String, Object>>> getChildBadges(@RequestBody Map<String, Object> body,
                                                             @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = body.get("memberId") != null ? Long.valueOf(body.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(body.get("memberId"), currentMemberId);
         List<ChildBadge> childBadges = badgeService.getActiveChildBadges(memberId);
         List<Map<String, Object>> result = new java.util.ArrayList<>();
         for (ChildBadge cb : childBadges) {
@@ -104,8 +105,8 @@ public class BadgeController {
     @PostMapping("/favorite")
     public Result<String> toggleFavorite(@RequestBody Map<String, Object> body,
                                          @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = body.get("memberId") != null ? Long.valueOf(body.get("memberId").toString()) : currentMemberId;
-        Long badgeId = Long.valueOf(body.get("badgeId").toString());
+        Long memberId = ParamUtils.getLong(body.get("memberId"), currentMemberId);
+        Long badgeId = ParamUtils.getLong(body.get("badgeId"));
         badgeService.toggleFavorite(memberId, badgeId);
         return Result.success("操作成功");
     }
@@ -116,7 +117,7 @@ public class BadgeController {
     @PostMapping("/statistics/child")
     public Result<Map<String, Object>> getChildStats(@RequestBody Map<String, Object> body,
                                                      @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = body.get("memberId") != null ? Long.valueOf(body.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(body.get("memberId"), currentMemberId);
         return Result.success(badgeService.getChildBadgeStats(memberId));
     }
 

+ 3 - 4
cfc-backend/src/main/java/com/etotem/cfc/controller/CircleChallengeController.java

@@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/health/circle/challenge")
@@ -18,15 +19,13 @@ public class CircleChallengeController {
 
     @PostMapping("/list")
     public Result<List<CircleChallenge>> getList(@RequestBody Map<String, Object> params) {
-        Long circleId = params.get("circleId") != null
-                ? Long.valueOf(params.get("circleId").toString()) : null;
+        Long circleId = ParamUtils.getLong(params.get("circleId"));
         return Result.success(circleChallengeService.getActiveChallenges(circleId));
     }
 
     @PostMapping("/history")
     public Result<List<CircleChallenge>> getHistory(@RequestBody Map<String, Object> params) {
-        Long circleId = params.get("circleId") != null
-                ? Long.valueOf(params.get("circleId").toString()) : null;
+        Long circleId = ParamUtils.getLong(params.get("circleId"));
         return Result.success(circleChallengeService.getChallengeHistory(circleId));
     }
 }

+ 5 - 4
cfc-backend/src/main/java/com/etotem/cfc/controller/ContactController.java

@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/contact")
@@ -37,14 +38,14 @@ public class ContactController {
     @PostMapping("/delete")
     public Result<String> delete(@RequestBody Map<String, Object> params,
                                  @RequestAttribute("userId") Long userId) {
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         return contactService.delete(id, userId);
     }
 
     @PostMapping("/detail")
     public Result<ContactDTO> detail(@RequestBody Map<String, Object> params,
                                      @RequestAttribute("userId") Long userId) {
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         return contactService.detail(id, userId);
     }
 
@@ -60,14 +61,14 @@ public class ContactController {
     @PostMapping("/interaction")
     public Result<ContactDTO> interaction(@RequestBody Map<String, Object> params,
                                           @RequestAttribute("userId") Long userId) {
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         return contactService.recordInteraction(id, userId);
     }
 
     @PostMapping("/invite-to-family")
     public Result<Map<String, Object>> inviteToFamily(@RequestBody Map<String, Object> params,
                                                      @RequestAttribute("userId") Long userId) {
-        Long contactId = Long.valueOf(params.get("contactId").toString());
+        Long contactId = ParamUtils.getLong(params.get("contactId"));
         String relationshipType = (String) params.get("relationshipType");
         String generationLevel = (String) params.get("generationLevel");
         return contactService.inviteToFamily(contactId, relationshipType, generationLevel, userId);

+ 5 - 4
cfc-backend/src/main/java/com/etotem/cfc/controller/ContactMatchController.java

@@ -7,6 +7,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/contact/match")
@@ -17,8 +18,8 @@ public class ContactMatchController {
     @PostMapping("/send")
     public Result<ContactMatchRequest> send(@RequestBody Map<String, Object> params,
                                             @RequestAttribute("userId") Long userId) {
-        Long targetUserId = Long.valueOf(params.get("targetUserId").toString());
-        Long contactId = params.get("contactId") != null ? Long.valueOf(params.get("contactId").toString()) : null;
+        Long targetUserId = ParamUtils.getLong(params.get("targetUserId"));
+        Long contactId = ParamUtils.getLong(params.get("contactId"));
         String message = params.get("message") != null ? params.get("message").toString() : null;
         return Result.success(service.sendRequest(userId, targetUserId, contactId, message));
     }
@@ -26,14 +27,14 @@ public class ContactMatchController {
     @PostMapping("/accept")
     public Result<Void> accept(@RequestBody Map<String, Object> params,
                                 @RequestAttribute("userId") Long userId) {
-        Long requestId = Long.valueOf(params.get("requestId").toString());
+        Long requestId = ParamUtils.getLong(params.get("requestId"));
         service.acceptRequest(userId, requestId); return Result.success(null);
     }
 
     @PostMapping("/reject")
     public Result<Void> reject(@RequestBody Map<String, Object> params,
                                 @RequestAttribute("userId") Long userId) {
-        Long requestId = Long.valueOf(params.get("requestId").toString());
+        Long requestId = ParamUtils.getLong(params.get("requestId"));
         service.rejectRequest(userId, requestId); return Result.success(null);
     }
 

+ 6 - 6
cfc-backend/src/main/java/com/etotem/cfc/controller/CouponController.java

@@ -11,6 +11,7 @@ import javax.annotation.Resource;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/coupon")
@@ -30,7 +31,7 @@ public class CouponController {
     @PostMapping("/claim")
     public Result<String> claim(@RequestAttribute("userId") Long userId,
                                 @RequestBody Map<String, Object> params) {
-        Long couponId = Long.valueOf(params.get("couponId").toString());
+        Long couponId = ParamUtils.getLong(params.get("couponId"));
         String result = couponService.claim(userId, couponId);
         if ("领取成功".equals(result)) {
             return Result.success(result);
@@ -41,7 +42,7 @@ public class CouponController {
     @PostMapping("/apply")
     public Result<Map<String, Object>> apply(@RequestAttribute("userId") Long userId,
                                              @RequestBody Map<String, Object> params) {
-        Long userCouponId = Long.valueOf(params.get("userCouponId").toString());
+        Long userCouponId = ParamUtils.getLong(params.get("userCouponId"));
         String orderType = (String) params.get("orderType");
         Integer orderAmount = Integer.valueOf(params.get("orderAmount").toString());
         Integer discount = couponService.apply(userId, userCouponId, orderType, orderAmount);
@@ -54,7 +55,7 @@ public class CouponController {
     @PostMapping("/exchange")
     public Result<Map<String, Object>> exchange(@RequestAttribute("userId") Long userId,
                                                 @RequestBody Map<String, Object> params) {
-        Long couponId = Long.valueOf(params.get("couponId").toString());
+        Long couponId = ParamUtils.getLong(params.get("couponId"));
         Object memberId = params.get("memberId");
         Long childId = memberId != null ? Long.valueOf(memberId.toString()) : null;
         PointsExchangeRecord record = pointsExchangeService.exchangeCoupon(userId, childId, couponId);
@@ -68,7 +69,7 @@ public class CouponController {
 
     @PostMapping("/product")
     public Result<List<Coupon>> productCoupons(@RequestBody Map<String, Object> params) {
-        Long productId = Long.valueOf(params.get("productId").toString());
+        Long productId = ParamUtils.getLong(params.get("productId"));
         return Result.success(couponService.listByProduct(productId));
     }
 
@@ -80,8 +81,7 @@ public class CouponController {
             @RequestAttribute("userId") Long userId,
             @RequestBody Map<String, Object> params) {
         if (userId == null) return Result.error("未登录");
-        Long productId = params.get("productId") != null
-                ? Long.valueOf(params.get("productId").toString()) : null;
+        Long productId = ParamUtils.getLong(params.get("productId"));
         List<Coupon> coupons = couponService.listUnownedExchangeable(userId, productId);
         List<Map<String, Object>> result = new ArrayList<>();
         for (Coupon c : coupons) {

+ 6 - 10
cfc-backend/src/main/java/com/etotem/cfc/controller/DailyCheckinController.java

@@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "每日健康打卡", description = "每日健康打卡记录(饮食/运动/睡眠/饮水/心情)")
 @RestController
@@ -23,8 +24,7 @@ public class DailyCheckinController {
     @PostMapping("/list")
     public Result<List<DailyHealthCheckin>> list(@RequestBody Map<String, Object> params,
                                                  @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         if (memberId == null) {
             return Result.error("memberId不能为空");
         }
@@ -34,8 +34,7 @@ public class DailyCheckinController {
     @Operation(summary = "获取打卡详情")
     @PostMapping("/detail")
     public Result<DailyHealthCheckin> detail(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null
-                ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) {
             return Result.error("id不能为空");
         }
@@ -56,8 +55,7 @@ public class DailyCheckinController {
     @Operation(summary = "更新打卡记录")
     @PostMapping("/update")
     public Result<DailyHealthCheckin> update(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null
-                ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) {
             return Result.error("id不能为空");
         }
@@ -73,10 +71,8 @@ public class DailyCheckinController {
     @Operation(summary = "删除打卡记录")
     @PostMapping("/delete")
     public Result<String> delete(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null
-                ? Long.valueOf(params.get("id").toString()) : null;
-        Long userId = params.get("userId") != null
-                ? Long.valueOf(params.get("userId").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
+        Long userId = ParamUtils.getLong(params.get("userId"));
         if (id == null) {
             return Result.error("id不能为空");
         }

+ 4 - 6
cfc-backend/src/main/java/com/etotem/cfc/controller/DailyFeedbackController.java

@@ -11,6 +11,7 @@ import javax.annotation.Resource;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 /**
  * 每日反馈接口 — 即时多巴胺反馈(L2: AI/预设深度反馈)
@@ -29,8 +30,7 @@ public class DailyFeedbackController {
             @RequestBody Map<String, Object> params,
             @RequestAttribute("userId") Long userId,
             @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         DailyFeedback feedback = dailyFeedbackService.getTodayFeedback(memberId);
 
         // Auto-generate if none exists
@@ -47,8 +47,7 @@ public class DailyFeedbackController {
     @Operation(summary = "标记反馈为已读")
     @PostMapping("/read")
     public Result<String> markAsRead(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null
-                ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) {
             return Result.error("id不能为空");
         }
@@ -60,8 +59,7 @@ public class DailyFeedbackController {
     @PostMapping("/recent")
     public Result<List<DailyFeedback>> recent(@RequestBody Map<String, Object> params,
                                               @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         int limit = params.get("limit") != null
                 ? Integer.parseInt(params.get("limit").toString()) : 7;
         return Result.success(dailyFeedbackService.getRecentFeedbacks(memberId, limit));

+ 2 - 1
cfc-backend/src/main/java/com/etotem/cfc/controller/DailyTaskController.java

@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 /**
  * 今日任务聚合接口(只读)
@@ -31,7 +32,7 @@ public class DailyTaskController {
             @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId,
             @RequestAttribute(value = "familyId", required = false) Long familyId) {
         Long memberId = (params != null && params.get("memberId") != null)
-                ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+                ? ParamUtils.getLong(params.get("memberId")) : currentMemberId;
         if (memberId == null) {
             return Result.error("memberId不能为空");
         }

+ 23 - 27
cfc-backend/src/main/java/com/etotem/cfc/controller/DanAssessmentController.java

@@ -15,6 +15,7 @@ import javax.annotation.Resource;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "DAN测评", description = "DAN专注力测评相关接口")
 @RestController
@@ -93,12 +94,10 @@ public class DanAssessmentController {
         if (familyId == null) {
             return Result.noFamily("请先创建或加入家庭");
         }
-        Long materialId = body.get("materialId") != null
-                ? Long.valueOf(body.get("materialId").toString()) : null;
+        Long materialId = ParamUtils.getLong(body.get("materialId"));
         Integer remindMonths = body.get("remindMonths") != null
                 ? Integer.valueOf(body.get("remindMonths").toString()) : 6;
-        Long createdBy = body.get("createdBy") != null
-                ? Long.valueOf(body.get("createdBy").toString()) : null;
+        Long createdBy = ParamUtils.getLong(body.get("createdBy"));
         boolean ok = assessmentService.enableFamilyAssessment(familyId, materialId, remindMonths, createdBy);
         return ok ? Result.success("启用成功") : Result.error("启用失败");
     }
@@ -123,16 +122,15 @@ public class DanAssessmentController {
         if (familyId == null) {
             return Result.noFamily("请先创建或加入家庭");
         }
-        Long memberId = body.get("memberId") != null ? Long.valueOf(body.get("memberId").toString()) : currentMemberId;
-        Long materialId = body.get("materialId") != null
-                ? Long.valueOf(body.get("materialId").toString()) : null;
+        Long memberId = ParamUtils.getLong(body.get("memberId"), currentMemberId);
+        Long materialId = ParamUtils.getLong(body.get("materialId"));
         return Result.success(assessmentService.createRecord(familyId, memberId, materialId));
     }
 
     @Operation(summary = "完成测评记录")
     @PostMapping("/record/complete")
     public Result<String> completeRecord(@RequestBody Map<String, Object> body) {
-        Long recordId = Long.valueOf(body.get("recordId").toString());
+        Long recordId = ParamUtils.getLong(body.get("recordId"));
         boolean ok = assessmentService.completeRecord(recordId);
         return ok ? Result.success("完成成功") : Result.error("记录不存在");
     }
@@ -188,9 +186,9 @@ public class DanAssessmentController {
     public Result<AssessmentAppointment> createAppointment(@RequestBody Map<String, Object> body,
                                                            @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId,
                                                            @RequestAttribute("userId") Long userId) {
-        Long memberId = body.get("memberId") != null ? Long.valueOf(body.get("memberId").toString()) : currentMemberId;
-        Long guideId = Long.valueOf(body.get("guideId").toString());
-        Long packageId = body.get("packageId") != null ? Long.valueOf(body.get("packageId").toString()) : null;
+        Long memberId = ParamUtils.getLong(body.get("memberId"), currentMemberId);
+        Long guideId = ParamUtils.getLong(body.get("guideId"));
+        Long packageId = ParamUtils.getLong(body.get("packageId"));
         String appointmentDate = (String) body.get("appointmentDate");
         String appointmentTime = (String) body.get("appointmentTime");
         String notes = (String) body.get("notes");
@@ -202,8 +200,8 @@ public class DanAssessmentController {
     @Operation(summary = "确认预约")
     @PostMapping("/appointment/confirm")
     public Result<String> confirmAppointment(@RequestBody Map<String, Object> body) {
-        Long id = Long.valueOf(body.get("id").toString());
-        Long teacherId = Long.valueOf(body.get("teacherId").toString());
+        Long id = ParamUtils.getLong(body.get("id"));
+        Long teacherId = ParamUtils.getLong(body.get("teacherId"));
         boolean ok = appointmentService.confirmAppointment(id, teacherId);
         return ok ? Result.success("确认成功") : Result.error("确认失败");
     }
@@ -211,8 +209,8 @@ public class DanAssessmentController {
     @Operation(summary = "完成预约")
     @PostMapping("/appointment/complete")
     public Result<String> completeAppointment(@RequestBody Map<String, Object> body) {
-        Long id = Long.valueOf(body.get("id").toString());
-        Long teacherId = Long.valueOf(body.get("teacherId").toString());
+        Long id = ParamUtils.getLong(body.get("id"));
+        Long teacherId = ParamUtils.getLong(body.get("teacherId"));
         boolean ok = appointmentService.completeAppointment(id, teacherId);
         return ok ? Result.success("完成成功") : Result.error("完成失败");
     }
@@ -220,7 +218,7 @@ public class DanAssessmentController {
     @Operation(summary = "取消预约")
     @PostMapping("/appointment/cancel")
     public Result<String> cancelAppointment(@RequestBody Map<String, Object> body) {
-        Long id = Long.valueOf(body.get("id").toString());
+        Long id = ParamUtils.getLong(body.get("id"));
         boolean ok = appointmentService.cancelAppointment(id);
         return ok ? Result.success("取消成功") : Result.error("取消失败");
     }
@@ -228,7 +226,7 @@ public class DanAssessmentController {
     @Operation(summary = "获取用户的预约列表")
     @PostMapping("/appointment/user")
     public Result<List<Map<String, Object>>> getUserAppointments(@RequestBody Map<String, Object> body) {
-        Long userId = body.get("userId") != null ? Long.valueOf(body.get("userId").toString()) : null;
+        Long userId = ParamUtils.getLong(body.get("userId"));
         if (userId == null) return Result.error("userId 不能为空");
         List<AssessmentAppointment> list = appointmentService.getByUserId(userId);
         List<Map<String, Object>> result = new java.util.ArrayList<>();
@@ -278,14 +276,13 @@ public class DanAssessmentController {
         if (familyId == null) {
             return Result.noFamily("请先创建或加入家庭");
         }
-        Long memberId = body.get("memberId") != null ? Long.valueOf(body.get("memberId").toString()) : currentMemberId;
-        Long guideId = Long.valueOf(body.get("guideId").toString());
-        Long packageId = body.get("packageId") != null ? Long.valueOf(body.get("packageId").toString()) : null;
+        Long memberId = ParamUtils.getLong(body.get("memberId"), currentMemberId);
+        Long guideId = ParamUtils.getLong(body.get("guideId"));
+        Long packageId = ParamUtils.getLong(body.get("packageId"));
         String guideName = (String) body.get("guideName");
         String packageName = (String) body.get("packageName");
-        Long totalPrice = body.get("totalPrice") != null ? Long.valueOf(body.get("totalPrice").toString()) : 0L;
-        Long discountAmount = body.get("discountAmount") != null
-                ? Long.valueOf(body.get("discountAmount").toString()) : 0L;
+        Long totalPrice = ParamUtils.getLong(body.get("totalPrice"), 0L);
+        Long discountAmount = ParamUtils.getLong(body.get("discountAmount"), 0L);
 
         AssessmentOrder order = orderService.createOrder(familyId, userId, memberId,
                 guideId, packageId, guideName, packageName, totalPrice, discountAmount);
@@ -298,8 +295,7 @@ public class DanAssessmentController {
                                                 @RequestAttribute("userId") Long userId) {
         String orderNo = (String) body.get("orderNo");
         String payType = (String) body.get("payType");
-        Long appointmentId = body.get("appointmentId") != null
-                ? Long.valueOf(body.get("appointmentId").toString()) : null;
+        Long appointmentId = ParamUtils.getLong(body.get("appointmentId"));
 
         // testMode 兼容:mock 直接标记已付,跳过虚拟支付(保留现有模拟逻辑)
         if (testMode) {
@@ -383,7 +379,7 @@ public class DanAssessmentController {
     @PostMapping("/report/confirm")
     public Result<String> confirmReport(@RequestBody Map<String, Object> body,
                                          @RequestAttribute("userId") Long userId) {
-        Long draftId = body.get("draftId") != null ? Long.valueOf(body.get("draftId").toString()) : null;
+        Long draftId = ParamUtils.getLong(body.get("draftId"));
         if (draftId == null) {
             return Result.error("draftId 不能为空");
         }
@@ -399,7 +395,7 @@ public class DanAssessmentController {
     @Operation(summary = "获取某孩子某维度的 DAN 报告列表")
     @PostMapping("/report/child")
     public Result<List<DanAssessmentResult>> getChildDanReports(@RequestBody Map<String, Object> body) {
-        Long memberId = body.get("memberId") != null ? Long.valueOf(body.get("memberId").toString()) : null;
+        Long memberId = ParamUtils.getLong(body.get("memberId"));
         String dimension = (String) body.get("dimension");
         if (memberId == null || dimension == null) {
             return Result.error("memberId 和 dimension 不能为空");

+ 2 - 1
cfc-backend/src/main/java/com/etotem/cfc/controller/DanReportController.java

@@ -11,6 +11,7 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "DAN报告管理(独立化)", description = "DAN PDF报告上传/解析/确认独立流程")
 @RestController
@@ -67,7 +68,7 @@ public class DanReportController {
 
     @PostMapping("/list")
     public Result<List<DanReportUploadVO>> list(@RequestBody Map<String, Object> body) {
-        Long memberId = body.get("memberId") != null ? Long.valueOf(body.get("memberId").toString()) : null;
+        Long memberId = ParamUtils.getLong(body.get("memberId"));
         String dimension = (String) body.get("dimension");
         return uploadService.listByMember(memberId, dimension);
     }

+ 3 - 4
cfc-backend/src/main/java/com/etotem/cfc/controller/DistributionInviteController.java

@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "销售邀请", description = "服务商销售邀请码和小程序端接口")
 @RestController
@@ -29,8 +30,7 @@ public class DistributionInviteController {
     public Result<String> generate(
             @RequestAttribute("userId") Long userId,
             @RequestBody Map<String, Object> params) {
-        Long systemId = params.get("systemId") != null
-                ? Long.valueOf(params.get("systemId").toString()) : null;
+        Long systemId = ParamUtils.getLong(params.get("systemId"));
         if (systemId == null) return Result.error("systemId不能为空");
         return distributionService.generateInviteCode(systemId, userId);
     }
@@ -79,8 +79,7 @@ public class DistributionInviteController {
     public Result<Map<String, Object>> myPosition(
             @RequestAttribute("userId") Long userId,
             @RequestBody Map<String, Object> params) {
-        Long systemId = params.get("systemId") != null
-                ? Long.valueOf(params.get("systemId").toString()) : null;
+        Long systemId = ParamUtils.getLong(params.get("systemId"));
         if (systemId == null) return Result.error("systemId不能为空");
         return distributionService.getUserPosition(systemId, userId);
     }

+ 2 - 3
cfc-backend/src/main/java/com/etotem/cfc/controller/EmiReportController.java

@@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "EMI心理报告", description = "EMI心理四维评估(情绪/韧性/压力应对/自我认知)")
 @RestController
@@ -23,9 +24,7 @@ public class EmiReportController {
     @PostMapping("/latest")
     public Result<EmiReportDTO> getLatestReport(@RequestBody Map<String, Object> body,
                                                 @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = body.get("memberId") != null
-                ? Long.valueOf(body.get("memberId").toString())
-                : currentMemberId;
+        Long memberId = ParamUtils.getLong(body.get("memberId"), currentMemberId);
         if (memberId == null) {
             return Result.error("memberId不能为空");
         }

+ 12 - 22
cfc-backend/src/main/java/com/etotem/cfc/controller/EnergyController.java

@@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.util.*;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "家庭能量沙盘", description = "家庭五维能量数据接口")
 @RestController
@@ -127,8 +128,7 @@ public class EnergyController {
         if (params == null) {
             return Result.error("请求体不能为空");
         }
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         if (memberId == null) {
             return Result.error("memberId不能为空");
         }
@@ -148,8 +148,7 @@ public class EnergyController {
             @RequestBody Map<String, Object> params,
             @RequestAttribute(value = "familyId", required = false) Long familyId,
             @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         if (memberId == null) {
             return Result.error("memberId不能为空");
         }
@@ -175,12 +174,9 @@ public class EnergyController {
             @RequestBody Map<String, Object> params,
             @RequestAttribute(value = "familyId", required = false) Long familyId,
             @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
-        Long taskId = params.get("taskId") != null
-                ? Long.valueOf(params.get("taskId").toString()) : null;
-        Long amount = params.get("amount") != null
-                ? Long.valueOf(params.get("amount").toString()) : null;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
+        Long taskId = ParamUtils.getLong(params.get("taskId"));
+        Long amount = ParamUtils.getLong(params.get("amount"));
         String dimensionCode = (String) params.get("dimensionCode");
 
         if (memberId == null || taskId == null || amount == null) {
@@ -203,12 +199,9 @@ public class EnergyController {
             @RequestBody Map<String, Object> params,
             @RequestAttribute(value = "familyId", required = false) Long familyId,
             @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
-        Long wishId = params.get("wishId") != null
-                ? Long.valueOf(params.get("wishId").toString()) : null;
-        Long amount = params.get("amount") != null
-                ? Long.valueOf(params.get("amount").toString()) : null;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
+        Long wishId = ParamUtils.getLong(params.get("wishId"));
+        Long amount = ParamUtils.getLong(params.get("amount"));
 
         if (memberId == null || wishId == null || amount == null) {
             return Result.error("memberId、wishId和amount不能为空");
@@ -231,8 +224,7 @@ public class EnergyController {
             @RequestAttribute(value = "familyId", required = false) Long familyId,
             @RequestAttribute("userId") Long userId) {
         String sourceType = (String) params.get("sourceType");
-        Long sourceId = params.get("sourceId") != null
-                ? Long.valueOf(params.get("sourceId").toString()) : null;
+        Long sourceId = ParamUtils.getLong(params.get("sourceId"));
         String sourceName = (String) params.get("sourceName");
 
         if (sourceType == null || sourceId == null) {
@@ -256,8 +248,7 @@ public class EnergyController {
     @PostMapping("/score-history")
     public Result<List<com.etotem.cfc.entity.FiveDimensionScore>> getScoreHistory(
             @RequestBody Map<String, Object> params) {
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : null;
+        Long memberId = ParamUtils.getLong(params.get("memberId"));
         String memberType = (String) params.get("memberType");
         if (memberId == null || memberType == null) {
             return Result.error("memberId和memberType不能为空");
@@ -299,8 +290,7 @@ public class EnergyController {
     public Result<MemberEnergyDTO> getWealthDetail(
             @RequestBody Map<String, Object> params,
             @RequestAttribute("userId") Long userId) {
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : null;
+        Long memberId = ParamUtils.getLong(params.get("memberId"));
         String memberType = (String) params.get("memberType");
 
         if (memberId == null || memberType == null) {

+ 3 - 4
cfc-backend/src/main/java/com/etotem/cfc/controller/FamilyChallengeController.java

@@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/health/challenge")
@@ -43,8 +44,7 @@ public class FamilyChallengeController {
         if (currentMemberId == null) {
             return Result.error("未识别当前成员");
         }
-        Long challengeId = params.get("challengeId") != null
-                ? Long.valueOf(params.get("challengeId").toString()) : null;
+        Long challengeId = ParamUtils.getLong(params.get("challengeId"));
         int delta = params.get("delta") != null
                 ? Integer.parseInt(params.get("delta").toString()) : 0;
         return familyChallengeService.updateProgress(challengeId, currentMemberId, delta);
@@ -56,8 +56,7 @@ public class FamilyChallengeController {
         if (currentMemberId == null) {
             return Result.error("未识别当前成员");
         }
-        Long challengeId = params.get("challengeId") != null
-                ? Long.valueOf(params.get("challengeId").toString()) : null;
+        Long challengeId = ParamUtils.getLong(params.get("challengeId"));
         String action = params.get("action") != null ? params.get("action").toString() : null;
         return familyChallengeService.respondChallenge(challengeId, currentMemberId, action);
     }

+ 5 - 8
cfc-backend/src/main/java/com/etotem/cfc/controller/FamilyPlatformBalanceController.java

@@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 /**
  * 家庭平台积分(CF值)接口
@@ -62,8 +63,7 @@ public class FamilyPlatformBalanceController {
         if (user == null || user.getFamilyId() == null) {
             return Result.error("请先加入家庭");
         }
-        Long couponId = params.get("couponId") != null
-                ? Long.valueOf(params.get("couponId").toString()) : null;
+        Long couponId = ParamUtils.getLong(params.get("couponId"));
         if (couponId == null) return Result.error("couponId不能为空");
         try {
             familyPlatformPointsService.exchangeCouponByCf(user.getFamilyId(), couponId, userId);
@@ -79,8 +79,7 @@ public class FamilyPlatformBalanceController {
     public Result<Map<String, Object>> adminBalance(@RequestBody Map<String, Object> params,
                                                      @RequestAttribute("role") String role) {
         if (!"admin".equals(role)) return Result.error("无权限");
-        Long familyId = params.get("familyId") != null
-                ? Long.valueOf(params.get("familyId").toString()) : null;
+        Long familyId = ParamUtils.getLong(params.get("familyId"));
         if (familyId == null) return Result.error("familyId不能为空");
         return Result.success(familyPlatformPointsService.getBalance(familyId));
     }
@@ -90,8 +89,7 @@ public class FamilyPlatformBalanceController {
     public Result<Page<FamilyPlatformBalanceLog>> adminLogs(@RequestBody Map<String, Object> params,
                                                              @RequestAttribute("role") String role) {
         if (!"admin".equals(role)) return Result.error("无权限");
-        Long familyId = params.get("familyId") != null
-                ? Long.valueOf(params.get("familyId").toString()) : null;
+        Long familyId = ParamUtils.getLong(params.get("familyId"));
         int page = params.get("page") != null ? ((Number) params.get("page")).intValue() : 1;
         int size = params.get("size") != null ? ((Number) params.get("size")).intValue() : 20;
         if (familyId == null) return Result.error("familyId不能为空");
@@ -104,8 +102,7 @@ public class FamilyPlatformBalanceController {
                                        @RequestAttribute("role") String role,
                                        @RequestAttribute("userId") Long adminId) {
         if (!"admin".equals(role)) return Result.error("无权限");
-        Long familyId = params.get("familyId") != null
-                ? Long.valueOf(params.get("familyId").toString()) : null;
+        Long familyId = ParamUtils.getLong(params.get("familyId"));
         Integer amount = params.get("amount") != null
                 ? ((Number) params.get("amount")).intValue() : 0;
         String remark = (String) params.get("remark");

+ 5 - 4
cfc-backend/src/main/java/com/etotem/cfc/controller/GameRecordController.java

@@ -10,6 +10,7 @@ import javax.annotation.Resource;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "游戏记录管理", description = "游戏记录与统计相关接口")
 @RestController
@@ -22,7 +23,7 @@ public class GameRecordController {
     @Operation(summary = "保存游戏记录")
     @PostMapping("/record")
     public Result<Map<String, Object>> saveRecord(@RequestBody Map<String, Object> body) {
-        Long memberId = Long.valueOf(body.get("memberId").toString());
+        Long memberId = ParamUtils.getLong(body.get("memberId"));
         String gameCode = (String) body.get("gameCode");
         Integer score = body.get("score") != null
                 ? Integer.valueOf(body.get("score").toString()) : null;
@@ -39,7 +40,7 @@ public class GameRecordController {
     @Operation(summary = "获取游戏记录历史")
     @PostMapping("/history")
     public Result<Map<String, Object>> getHistory(@RequestBody Map<String, Object> body) {
-        Long memberId = Long.valueOf(body.get("memberId").toString());
+        Long memberId = ParamUtils.getLong(body.get("memberId"));
         String gameCode = (String) body.get("gameCode");
         Integer page = body.get("page") != null
                 ? Integer.valueOf(body.get("page").toString()) : 1;
@@ -51,14 +52,14 @@ public class GameRecordController {
     @Operation(summary = "获取各游戏最佳成绩")
     @PostMapping("/best")
     public Result<List<Map<String, Object>>> getBestScores(@RequestBody Map<String, Object> body) {
-        Long memberId = Long.valueOf(body.get("memberId").toString());
+        Long memberId = ParamUtils.getLong(body.get("memberId"));
         return Result.success(gameRecordService.getBestScores(memberId));
     }
 
     @Operation(summary = "获取游戏统计概览")
     @PostMapping("/stats")
     public Result<Map<String, Object>> getStats(@RequestBody Map<String, Object> body) {
-        Long memberId = Long.valueOf(body.get("memberId").toString());
+        Long memberId = ParamUtils.getLong(body.get("memberId"));
         return Result.success(gameRecordService.getStats(memberId));
     }
 

+ 3 - 4
cfc-backend/src/main/java/com/etotem/cfc/controller/HealthAlertController.java

@@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "健康预警", description = "P1-2 健康行为智能预警")
 @RestController
@@ -23,16 +24,14 @@ public class HealthAlertController {
     @PostMapping("/list")
     public Result<List<HealthAlert>> list(@RequestBody Map<String, Object> params,
                                           @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         return Result.success(healthAlertService.getActiveAlerts(memberId));
     }
 
     @Operation(summary = "关闭预警")
     @PostMapping("/dismiss")
     public Result<String> dismiss(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null
-                ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) return Result.error("id不能为空");
         healthAlertService.dismiss(id);
         return Result.success("ok");

+ 5 - 8
cfc-backend/src/main/java/com/etotem/cfc/controller/HealthCheckinController.java

@@ -11,6 +11,7 @@ import javax.annotation.Resource;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 /**
  * 健康打卡接口 — 身体维度日常打卡记录
@@ -29,8 +30,7 @@ public class HealthCheckinController {
             @RequestBody Map<String, Object> params,
             @RequestAttribute("userId") Long userId,
             @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         String yearMonth = (String) params.get("yearMonth");
         List<HealthCheckin> list = healthCheckinService.getCheckins(userId, memberId, yearMonth);
         return Result.success(list);
@@ -44,8 +44,7 @@ public class HealthCheckinController {
             @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
         HealthCheckin checkin = new HealthCheckin();
         checkin.setUserId(userId);
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         checkin.setChildId(memberId);
         if (memberId == null) {
             return Result.error("memberId不能为空");
@@ -82,8 +81,7 @@ public class HealthCheckinController {
     @Operation(summary = "删除打卡记录")
     @PostMapping("/delete")
     public Result<String> delete(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null
-                ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) {
             return Result.error("id不能为空");
         }
@@ -97,8 +95,7 @@ public class HealthCheckinController {
             @RequestBody Map<String, Object> params,
             @RequestAttribute(value = "userId", required = false) Long userId,
             @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         long total = healthCheckinService.countCheckins(memberId);
         java.util.Map<String, Object> stats = new java.util.HashMap<String, Object>();
         stats.put("totalCheckins", total);

+ 3 - 4
cfc-backend/src/main/java/com/etotem/cfc/controller/HealthCircleController.java

@@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/health/circle")
@@ -56,8 +57,7 @@ public class HealthCircleController {
         if (familyId == null) {
             return Result.noFamily("请先创建或加入家庭");
         }
-        Long circleId = params.get("circleId") != null
-                ? Long.valueOf(params.get("circleId").toString()) : null;
+        Long circleId = ParamUtils.getLong(params.get("circleId"));
         return healthCircleService.leaveCircle(circleId, familyId);
     }
 
@@ -68,8 +68,7 @@ public class HealthCircleController {
         if (familyId == null) {
             return Result.noFamily("请先创建或加入家庭");
         }
-        Long circleId = params.get("circleId") != null
-                ? Long.valueOf(params.get("circleId").toString()) : null;
+        Long circleId = ParamUtils.getLong(params.get("circleId"));
         return Result.success(healthCircleService.getCircleRanking(circleId));
     }
 }

+ 3 - 4
cfc-backend/src/main/java/com/etotem/cfc/controller/HealthDimensionController.java

@@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "健康维度", description = "七维健康指标查询与录入")
 @RestController
@@ -26,8 +27,7 @@ public class HealthDimensionController {
             @RequestBody Map<String, Object> params,
             @RequestAttribute("userId") Long userId,
             @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         if (memberId == null) {
             return Result.error("memberId不能为空");
         }
@@ -65,8 +65,7 @@ public class HealthDimensionController {
             @RequestBody Map<String, Object> params,
             @RequestAttribute("userId") Long userId,
             @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         String dimension = (String) params.get("dimension");
         int limit = params.get("limit") != null
                 ? Integer.parseInt(params.get("limit").toString()) : 10;

+ 2 - 1
cfc-backend/src/main/java/com/etotem/cfc/controller/HealthExerciseController.java

@@ -13,6 +13,7 @@ import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import com.etotem.cfc.util.SortUtil;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "运动打卡")
 @RestController
@@ -26,7 +27,7 @@ public class HealthExerciseController {
     @PostMapping("/list")
     public Result<List<HealthExerciseRecord>> list(@RequestBody Map<String, Object> params,
                                                    @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = params.get("memberId") != null ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         if (memberId == null) return Result.error("memberId不能为空");
         LambdaQueryWrapper<HealthExerciseRecord> wrapper = new LambdaQueryWrapper<HealthExerciseRecord>()
                 .eq(HealthExerciseRecord::getMemberId, memberId)

+ 5 - 8
cfc-backend/src/main/java/com/etotem/cfc/controller/HealthGrowthRecordController.java

@@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "健康生长记录", description = "儿童生长记录(身高/体重/BMI/头围等)")
 @RestController
@@ -22,8 +23,7 @@ public class HealthGrowthRecordController {
     @Operation(summary = "获取生长记录列表")
     @PostMapping("/list")
     public Result<List<HealthGrowthRecord>> list(@RequestBody Map<String, Object> params) {
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : null;
+        Long memberId = ParamUtils.getLong(params.get("memberId"));
         if (memberId == null) {
             return Result.error("memberId不能为空");
         }
@@ -33,8 +33,7 @@ public class HealthGrowthRecordController {
     @Operation(summary = "获取生长记录详情")
     @PostMapping("/detail")
     public Result<HealthGrowthRecord> detail(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null
-                ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) {
             return Result.error("id不能为空");
         }
@@ -51,8 +50,7 @@ public class HealthGrowthRecordController {
     @Operation(summary = "更新生长记录")
     @PostMapping("/update")
     public Result<HealthGrowthRecord> update(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null
-                ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) {
             return Result.error("id不能为空");
         }
@@ -66,8 +64,7 @@ public class HealthGrowthRecordController {
     @Operation(summary = "删除生长记录")
     @PostMapping("/delete")
     public Result<String> delete(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null
-                ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) {
             return Result.error("id不能为空");
         }

+ 3 - 4
cfc-backend/src/main/java/com/etotem/cfc/controller/HealthInteractionController.java

@@ -6,6 +6,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/health/interact")
@@ -22,12 +23,10 @@ public class HealthInteractionController {
         if (familyId == null) {
             return Result.noFamily("请先创建或加入家庭");
         }
-        Long toUserId = params.get("toUserId") != null
-                ? Long.valueOf(params.get("toUserId").toString()) : null;
+        Long toUserId = ParamUtils.getLong(params.get("toUserId"));
         String actionType = params.get("actionType") != null
                 ? params.get("actionType").toString() : null;
-        Long actionId = params.get("actionId") != null
-                ? Long.valueOf(params.get("actionId").toString()) : null;
+        Long actionId = ParamUtils.getLong(params.get("actionId"));
         return healthInteractionService.like(userId, toUserId, actionType, actionId, familyId);
     }
 }

+ 2 - 1
cfc-backend/src/main/java/com/etotem/cfc/controller/HealthKnowledgeBaseController.java

@@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
 import java.util.*;
+import com.etotem.cfc.util.ParamUtils;
 
 @Slf4j
 @Tag(name = "健康知识库")
@@ -82,7 +83,7 @@ public class HealthKnowledgeBaseController {
     @Operation(summary = "删除知识库条目")
     @PostMapping("/delete")
     public Result delete(@RequestBody Map<String, Object> params) {
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         healthKnowledgeBaseService.removeById(id);
         return Result.success();
     }

+ 2 - 1
cfc-backend/src/main/java/com/etotem/cfc/controller/HealthMealController.java

@@ -14,6 +14,7 @@ import java.util.List;
 import java.util.Map;
 import com.etotem.cfc.service.PointsService;
 import com.etotem.cfc.util.SortUtil;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "饮食打卡")
 @RestController
@@ -31,7 +32,7 @@ public class HealthMealController {
     public Result<List<HealthMealRecord>> list(
             @RequestBody Map<String, Object> params,
             @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = params.get("memberId") != null ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         if (memberId == null) return Result.error("memberId不能为空");
         LambdaQueryWrapper<HealthMealRecord> wrapper = new LambdaQueryWrapper<HealthMealRecord>()
                 .eq(HealthMealRecord::getMemberId, memberId)

+ 2 - 1
cfc-backend/src/main/java/com/etotem/cfc/controller/HealthMeditationController.java

@@ -13,6 +13,7 @@ import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import com.etotem.cfc.util.SortUtil;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "冥想打卡")
 @RestController
@@ -25,7 +26,7 @@ public class HealthMeditationController {
     @Operation(summary = "获取冥想打卡列表")
     @PostMapping("/list")
     public Result<List<HealthMeditationRecord>> list(@RequestBody Map<String, Object> params) {
-        Long memberId = params.get("memberId") != null ? Long.valueOf(params.get("memberId").toString()) : null;
+        Long memberId = ParamUtils.getLong(params.get("memberId"));
         if (memberId == null) return Result.error("memberId不能为空");
         LambdaQueryWrapper<HealthMeditationRecord> wrapper = new LambdaQueryWrapper<HealthMeditationRecord>()
                 .eq(HealthMeditationRecord::getMemberId, memberId)

+ 2 - 1
cfc-backend/src/main/java/com/etotem/cfc/controller/HealthPlanController.java

@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "健康方案", description = "健康方案生成与管理")
 @RestController
@@ -70,7 +71,7 @@ public class HealthPlanController {
     @Operation(summary = "查询方案详情")
     @PostMapping("/detail")
     public Result<HealthPlan> detail(@RequestBody Map<String, Object> params, @RequestAttribute("userId") Long userId) {
-        Long planId = params.get("planId") != null ? Long.valueOf(params.get("planId").toString()) : null;
+        Long planId = ParamUtils.getLong(params.get("planId"));
         if (planId == null) return Result.error("planId不能为空");
         HealthPlan plan = healthPlanService.getPlanDetail(planId);
         if (plan == null) return Result.error("方案不存在");

+ 56 - 73
cfc-backend/src/main/java/com/etotem/cfc/controller/HealthReportController.java

@@ -68,6 +68,7 @@ import java.util.UUID;
 
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.client.RestTemplate;
+import com.etotem.cfc.util.ParamUtils;
 
 /**
  * 健康检测报告接口 — 体检报告/菌群检测报告的录入与查询
@@ -164,8 +165,7 @@ public class HealthReportController {
             return Result.noFamily("请先创建或加入家庭");
         }
 
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         if (memberId == null) {
             return Result.error("memberId不能为空");
         }
@@ -245,8 +245,7 @@ public class HealthReportController {
         if (familyId == null) {
             return Result.noFamily("请先创建或加入家庭");
         }
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         if (memberId == null) {
             return Result.error("memberId不能为空");
         }
@@ -263,8 +262,7 @@ public class HealthReportController {
             @RequestBody Map<String, Object> params,
             @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId,
             @RequestAttribute(value = "familyId", required = false) Long familyId) {
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         if (memberId != null) {
             List<HealthReport> reports = healthReportService.getUserReports(memberId);
             return Result.success(reports);
@@ -308,8 +306,7 @@ public class HealthReportController {
     @PostMapping("/indicator/list")
     public Result<List<HealthIndicator>> listIndicators(
             @RequestBody Map<String, Object> params) {
-        Long reportId = params.get("reportId") != null
-                ? Long.valueOf(params.get("reportId").toString()) : null;
+        Long reportId = ParamUtils.getLong(params.get("reportId"));
         if (reportId == null) {
             return Result.error("reportId不能为空");
         }
@@ -325,8 +322,7 @@ public class HealthReportController {
     public Result<List<HealthIndicator>> getBodyDetail(
             @RequestBody Map<String, Object> params,
             @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         if (memberId == null) {
             return Result.error("memberId不能为空");
         }
@@ -341,8 +337,7 @@ public class HealthReportController {
     @PostMapping("/report/detail")
     public Result<Map<String, Object>> getReportDetail(
             @RequestBody Map<String, Object> params) {
-        Long reportId = params.get("reportId") != null
-                ? Long.valueOf(params.get("reportId").toString()) : null;
+        Long reportId = ParamUtils.getLong(params.get("reportId"));
         if (reportId == null) {
             return Result.error("reportId不能为空");
         }
@@ -359,13 +354,11 @@ public class HealthReportController {
             @RequestBody Map<String, Object> params,
             @RequestAttribute("userId") Long userId) {
 
-        Long reportId = params.get("reportId") != null
-                ? Long.valueOf(params.get("reportId").toString()) : null;
+        Long reportId = ParamUtils.getLong(params.get("reportId"));
         if (reportId == null) {
             return Result.error("reportId不能为空");
         }
-        Long subjectId = params.get("subjectId") != null
-                ? Long.valueOf(params.get("subjectId").toString()) : null;
+        Long subjectId = ParamUtils.getLong(params.get("subjectId"));
         if (subjectId == null) {
             return Result.error("subjectId不能为空");
         }
@@ -550,8 +543,7 @@ public class HealthReportController {
             @RequestAttribute(value = "familyId", required = false) Long familyId,
             @RequestAttribute("userId") Long userId) {
 
-        Long draftId = params.get("draftId") != null
-                ? Long.valueOf(params.get("draftId").toString()) : null;
+        Long draftId = ParamUtils.getLong(params.get("draftId"));
         if (draftId == null) {
             return Result.error("draftId不能为空");
         }
@@ -876,15 +868,14 @@ public class HealthReportController {
             @RequestAttribute("userId") Long userId) {
 
         if ("tongue".equals(type)) {
-            Long recordId = Long.valueOf(params.get("recordId").toString());
+            Long recordId = ParamUtils.getLong(params.get("recordId"));
             @SuppressWarnings("unchecked")
             List<Map<String, Object>> indicators = (List<Map<String, Object>>) params.getOrDefault("indicators", null);
             Map<String, Object> result = tongueDiagnosisService.confirm(recordId, indicators);
             return Result.success(result);
         }
 
-        Long draftId = params.get("draftId") != null
-                ? Long.valueOf(params.get("draftId").toString()) : null;
+        Long draftId = ParamUtils.getLong(params.get("draftId"));
         if (draftId == null) {
             return Result.error("draftId不能为空");
         }
@@ -909,8 +900,7 @@ public class HealthReportController {
                 payload = objectMapper.readValue(payloadJson, ParsedReportPayload.Payload.class);
             }
 
-            Long subjectId = params.get("subjectId") != null
-                    ? Long.valueOf(params.get("subjectId").toString()) : null;
+            Long subjectId = ParamUtils.getLong(params.get("subjectId"));
 
             HealthReport report = buildReportFromPayload(draft, payload, subjectId);
 
@@ -998,13 +988,12 @@ public class HealthReportController {
             @RequestAttribute("userId") Long userId) {
 
         if ("tongue".equals(type)) {
-            Long recordId = Long.valueOf(params.get("recordId").toString());
+            Long recordId = ParamUtils.getLong(params.get("recordId"));
             tongueDiagnosisService.discard(recordId);
             return Result.success("草稿已删除");
         }
 
-        Long draftId = params.get("draftId") != null
-                ? Long.valueOf(params.get("draftId").toString()) : null;
+        Long draftId = ParamUtils.getLong(params.get("draftId"));
         if (draftId == null) {
             return Result.error("draftId不能为空");
         }
@@ -1028,10 +1017,8 @@ public class HealthReportController {
     @PostMapping("/report/bind")
     public Result<String> bindReport(
             @RequestBody Map<String, Object> params) {
-        Long reportId = params.get("reportId") != null
-                ? Long.valueOf(params.get("reportId").toString()) : null;
-        Long subjectId = params.get("subjectId") != null
-                ? Long.valueOf(params.get("subjectId").toString()) : null;
+        Long reportId = ParamUtils.getLong(params.get("reportId"));
+        Long subjectId = ParamUtils.getLong(params.get("subjectId"));
         if (reportId == null || subjectId == null) {
             return Result.error("reportId和subjectId不能为空");
         }
@@ -1060,10 +1047,8 @@ public class HealthReportController {
     @PostMapping("/report/permission/add")
     public Result<String> addReportPermission(
             @RequestBody Map<String, Object> params) {
-        Long reportId = params.get("reportId") != null
-                ? Long.valueOf(params.get("reportId").toString()) : null;
-        Long targetUserId = params.get("userId") != null
-                ? Long.valueOf(params.get("userId").toString()) : null;
+        Long reportId = ParamUtils.getLong(params.get("reportId"));
+        Long targetUserId = ParamUtils.getLong(params.get("userId"));
         if (reportId == null || targetUserId == null) {
             return Result.error("reportId和userId不能为空");
         }
@@ -1078,10 +1063,8 @@ public class HealthReportController {
     @PostMapping("/report/permission/remove")
     public Result<String> removeReportPermission(
             @RequestBody Map<String, Object> params) {
-        Long reportId = params.get("reportId") != null
-                ? Long.valueOf(params.get("reportId").toString()) : null;
-        Long targetUserId = params.get("userId") != null
-                ? Long.valueOf(params.get("userId").toString()) : null;
+        Long reportId = ParamUtils.getLong(params.get("reportId"));
+        Long targetUserId = ParamUtils.getLong(params.get("userId"));
         if (reportId == null || targetUserId == null) {
             return Result.error("reportId和userId不能为空");
         }
@@ -1096,10 +1079,8 @@ public class HealthReportController {
     @PostMapping("/report/permission/check")
     public Result<Boolean> checkReportPermission(
             @RequestBody Map<String, Object> params) {
-        Long reportId = params.get("reportId") != null
-                ? Long.valueOf(params.get("reportId").toString()) : null;
-        Long targetUserId = params.get("userId") != null
-                ? Long.valueOf(params.get("userId").toString()) : null;
+        Long reportId = ParamUtils.getLong(params.get("reportId"));
+        Long targetUserId = ParamUtils.getLong(params.get("userId"));
         if (reportId == null || targetUserId == null) {
             return Result.error("reportId和userId不能为空");
         }
@@ -1111,13 +1092,11 @@ public class HealthReportController {
     @PostMapping("/nutrition/deficiency")
     public Result<List<NutritionDeficiencyRecord>> getDeficiencyAnalysis(
             @RequestBody Map<String, Object> params) {
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : null;
+        Long memberId = ParamUtils.getLong(params.get("memberId"));
         if (memberId == null) {
             return Result.error("memberId不能为空");
         }
-        Long reportId = params.get("reportId") != null
-                ? Long.valueOf(params.get("reportId").toString()) : null;
+        Long reportId = ParamUtils.getLong(params.get("reportId"));
         List<NutritionDeficiencyRecord> records = nutritionDeficiencyService.analyzeDeficiency(memberId, reportId);
         return Result.success(records);
     }
@@ -1126,8 +1105,7 @@ public class HealthReportController {
     @PostMapping("/nutrition/profile")
     public Result<Map<String, Object>> getNutritionProfile(
             @RequestBody Map<String, Object> params) {
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : null;
+        Long memberId = ParamUtils.getLong(params.get("memberId"));
         if (memberId == null) {
             return Result.error("memberId不能为空");
         }
@@ -1139,8 +1117,7 @@ public class HealthReportController {
     @PostMapping("/nutrition/deficiency-summary")
     public Result<Map<String, Object>> getDeficiencySummary(
             @RequestBody Map<String, Object> params) {
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : null;
+        Long memberId = ParamUtils.getLong(params.get("memberId"));
         if (memberId == null) {
             return Result.error("memberId不能为空");
         }
@@ -1152,8 +1129,7 @@ public class HealthReportController {
     @PostMapping("/nutrition/trend")
     public Result<Map<String, Object>> getReportTrendData(
             @RequestBody Map<String, Object> params) {
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : null;
+        Long memberId = ParamUtils.getLong(params.get("memberId"));
         if (memberId == null) {
             return Result.error("memberId不能为空");
         }
@@ -1165,8 +1141,7 @@ public class HealthReportController {
     @PostMapping("/analysis")
     public Result<Map<String, Object>> getHealthAnalysis(
             @RequestBody Map<String, Object> params) {
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : null;
+        Long memberId = ParamUtils.getLong(params.get("memberId"));
         if (memberId == null) {
             return Result.error("memberId不能为空");
         }
@@ -1203,7 +1178,7 @@ public class HealthReportController {
     @Operation(summary = "删除指标-营养素映射")
     @PostMapping("/nutrition/mapping/delete")
     public Result<?> deleteMapping(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) {
             return Result.error("id不能为空");
         }
@@ -1214,8 +1189,7 @@ public class HealthReportController {
     @Operation(summary = "获取食材推荐列表")
     @PostMapping("/foods")
     public Result<List<Food>> listFoods(@RequestBody Map<String, Object> params) {
-        Long reportId = params.get("reportId") != null
-                ? Long.valueOf(params.get("reportId").toString()) : null;
+        Long reportId = ParamUtils.getLong(params.get("reportId"));
         if (reportId == null) {
             return Result.error("reportId不能为空");
         }
@@ -1230,8 +1204,7 @@ public class HealthReportController {
     @PostMapping("/report/archive")
     public Result<String> archiveReport(
             @RequestBody Map<String, Object> params) {
-        Long reportId = params.get("reportId") != null
-                ? Long.valueOf(params.get("reportId").toString()) : null;
+        Long reportId = ParamUtils.getLong(params.get("reportId"));
         if (reportId == null) {
             return Result.error("reportId不能为空");
         }
@@ -1239,6 +1212,23 @@ public class HealthReportController {
         return Result.success("报告已归档");
     }
 
+    /**
+     * 批量归档报告(软删除)— 管理端选中删除
+     */
+    @Operation(summary = "批量归档健康报告(软删除)")
+    @PostMapping("/report/archive-batch")
+    public Result<String> archiveReportsBatch(
+            @RequestBody Map<String, Object> params,
+            @RequestAttribute(value = "role", required = false) String role) {
+        @SuppressWarnings("unchecked")
+        List<Long> reportIds = (List<Long>) params.get("reportIds");
+        if (reportIds == null || reportIds.isEmpty()) {
+            return Result.error("reportIds不能为空");
+        }
+        int archived = healthReportService.archiveReportsBatch(reportIds);
+        return Result.success("已归档 " + archived + " 份报告");
+    }
+
     @Operation(summary = "获取家庭成员食材推荐(含完整营养数据)")
     @PostMapping("/foods/by-family")
     public Result<Map<String, Object>> getFoodsByFamily(@RequestAttribute(value = "familyId", required = false) Long familyId) {
@@ -1321,8 +1311,7 @@ public class HealthReportController {
         String gender = (String) params.get("gender");
         Object ageObj = params.get("age");
         Integer age = ageObj != null ? Integer.parseInt(ageObj.toString()) : null;
-        Long draftId = params.get("draftId") != null
-                ? Long.valueOf(params.get("draftId").toString()) : null;
+        Long draftId = ParamUtils.getLong(params.get("draftId"));
 
         if (name == null || name.trim().isEmpty()) {
             return Result.error("姓名不能为空");
@@ -1380,10 +1369,8 @@ public class HealthReportController {
     public Result<Map<String, Object>> auditConfirm(
             @RequestBody Map<String, Object> params,
             @RequestAttribute("userId") Long auditorId) {
-        Long draftId = params.get("draftId") != null
-                ? Long.valueOf(params.get("draftId").toString()) : null;
-        Long subjectId = params.get("subjectId") != null
-                ? Long.valueOf(params.get("subjectId").toString()) : null;
+        Long draftId = ParamUtils.getLong(params.get("draftId"));
+        Long subjectId = ParamUtils.getLong(params.get("subjectId"));
 
         if (draftId == null) {
             return Result.error("draftId不能为空");
@@ -1405,8 +1392,7 @@ public class HealthReportController {
     @PostMapping("/report/audit/discard")
     public Result<String> auditDiscard(
             @RequestBody Map<String, Object> params) {
-        Long draftId = params.get("draftId") != null
-                ? Long.valueOf(params.get("draftId").toString()) : null;
+        Long draftId = ParamUtils.getLong(params.get("draftId"));
 
         if (draftId == null) {
             return Result.error("draftId不能为空");
@@ -1844,8 +1830,7 @@ public class HealthReportController {
         if (contentObj == null || contentObj.toString().trim().isEmpty()) {
             return Result.error("反馈内容不能为空");
         }
-        Long reportId = params.get("reportId") != null
-                ? Long.valueOf(params.get("reportId").toString()) : null;
+        Long reportId = ParamUtils.getLong(params.get("reportId"));
         String type = params.get("type") != null ? params.get("type").toString() : "其他";
         String content = contentObj.toString().trim();
         if (content.length() > 500) {
@@ -1973,10 +1958,8 @@ public class HealthReportController {
             return Result.error("无权限");
         }
 
-        Long draftId = params.get("draftId") != null
-                ? Long.valueOf(params.get("draftId").toString()) : null;
-        Long subjectId = params.get("subjectId") != null
-                ? Long.valueOf(params.get("subjectId").toString()) : null;
+        Long draftId = ParamUtils.getLong(params.get("draftId"));
+        Long subjectId = ParamUtils.getLong(params.get("subjectId"));
 
         if (draftId == null) {
             return Result.error("draftId不能为空");

+ 3 - 4
cfc-backend/src/main/java/com/etotem/cfc/controller/HealthScoreController.java

@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "健康积分", description = "P2-1 身份重塑系统")
 @RestController
@@ -25,8 +26,7 @@ public class HealthScoreController {
     @PostMapping("/info")
     public Result<Map<String, Object>> info(@RequestBody Map<String, Object> params,
                                             @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         return Result.success(healthLevelService.getMemberLevelInfo(memberId));
     }
 
@@ -34,8 +34,7 @@ public class HealthScoreController {
     @PostMapping("/streak")
     public Result<Integer> streak(@RequestBody Map<String, Object> params,
                                   @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         return Result.success(healthScoreService.calculateStreakDays(memberId));
     }
 }

+ 2 - 1
cfc-backend/src/main/java/com/etotem/cfc/controller/HealthSleepController.java

@@ -13,6 +13,7 @@ import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import com.etotem.cfc.util.SortUtil;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "睡眠打卡")
 @RestController
@@ -26,7 +27,7 @@ public class HealthSleepController {
     @PostMapping("/list")
     public Result<List<HealthSleepRecord>> list(@RequestBody Map<String, Object> params,
                                                 @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = params.get("memberId") != null ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         if (memberId == null) return Result.error("memberId不能为空");
         LambdaQueryWrapper<HealthSleepRecord> wrapper = new LambdaQueryWrapper<HealthSleepRecord>()
                 .eq(HealthSleepRecord::getMemberId, memberId)

+ 2 - 2
cfc-backend/src/main/java/com/etotem/cfc/controller/HealthTimelineController.java

@@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "健康时间线", description = "P2-1 我的健康故事")
 @RestController
@@ -23,8 +24,7 @@ public class HealthTimelineController {
     @PostMapping("/list")
     public Result<List<HealthTimelineEvent>> list(@RequestBody Map<String, Object> params,
                                                   @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         int limit = params.get("limit") != null
                 ? Integer.parseInt(params.get("limit").toString()) : 20;
         return Result.success(healthTimelineService.getTimeline(memberId, limit));

+ 2 - 1
cfc-backend/src/main/java/com/etotem/cfc/controller/HealthWaterController.java

@@ -13,6 +13,7 @@ import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import com.etotem.cfc.util.SortUtil;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "喝水打卡")
 @RestController
@@ -26,7 +27,7 @@ public class HealthWaterController {
     @PostMapping("/list")
     public Result<List<HealthWaterRecord>> list(@RequestBody Map<String, Object> params,
                                                 @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = params.get("memberId") != null ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         if (memberId == null) return Result.error("memberId不能为空");
         LambdaQueryWrapper<HealthWaterRecord> wrapper = new LambdaQueryWrapper<HealthWaterRecord>()
                 .eq(HealthWaterRecord::getMemberId, memberId)

+ 3 - 3
cfc-backend/src/main/java/com/etotem/cfc/controller/MealRecommendController.java

@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.text.SimpleDateFormat;
 import java.util.*;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "\u98df\u8c31\u63a8\u8350", description = "\u4e2a\u6027\u5316\u98df\u8c31\u63a8\u8350\u4e0e\u996e\u98df\u8bb0\u5f55")
 @Slf4j
@@ -72,8 +73,7 @@ public class MealRecommendController {
     public Result<Food> replace(
             @RequestAttribute("userId") Long userId,
             @RequestBody Map<String, Object> params) {
-        Long foodId = params.get("foodId") != null
-                ? Long.valueOf(params.get("foodId").toString()) : null;
+        Long foodId = ParamUtils.getLong(params.get("foodId"));
         if (foodId == null) {
             return Result.error("foodId\u4e0d\u80fd\u4e3a\u7a7a");
         }
@@ -92,7 +92,7 @@ public class MealRecommendController {
             @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
         MealLog logEntry = new MealLog();
         logEntry.setUserId(userId);
-        Long memberId = params.get("memberId") != null ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         if (memberId != null) {
             logEntry.setChildId(memberId);
         }

+ 3 - 2
cfc-backend/src/main/java/com/etotem/cfc/controller/MembershipController.java

@@ -22,6 +22,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "会员管理", description = "会员等级、支付相关接口")
 @RestController
@@ -184,7 +185,7 @@ public class MembershipController {
         String levelCode = params.getOrDefault("levelCode", "FAMILY").toString();
         String paymentType = params.getOrDefault("paymentType", "yearly").toString();
         String period = params.getOrDefault("period", "yearly").toString();
-        Long couponId = params.get("couponId") != null ? Long.valueOf(params.get("couponId").toString()) : null;
+        Long couponId = ParamUtils.getLong(params.get("couponId"));
 
         PaymentOrderDTO order = membershipService.createOrder(userId, familyId, levelCode, paymentType, period, couponId);
         return Result.success(order);
@@ -225,7 +226,7 @@ public class MembershipController {
         String levelCode = params.get("levelCode").toString();
         String paymentType = params.get("paymentType").toString();
         String period = params.get("period") != null ? params.get("period").toString() : "yearly";
-        Long couponId = params.get("couponId") != null ? Long.valueOf(params.get("couponId").toString()) : null;
+        Long couponId = ParamUtils.getLong(params.get("couponId"));
 
         PaymentOrderDTO order = membershipService.createOrder(userId, familyId, levelCode, paymentType, period, couponId);
 

+ 5 - 8
cfc-backend/src/main/java/com/etotem/cfc/controller/MicroActionController.java

@@ -12,6 +12,7 @@ import javax.annotation.Resource;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 /**
  * 微行动接口 — 有效启动:最小行为单元(1秒完成)
@@ -36,8 +37,7 @@ public class MicroActionController {
             @RequestBody Map<String, Object> params,
             @RequestAttribute("userId") Long userId,
             @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         String dimensionCode = params.get("dimensionCode") != null
                 ? params.get("dimensionCode").toString() : null;
         MicroAction action;
@@ -61,10 +61,8 @@ public class MicroActionController {
             @RequestBody Map<String, Object> params,
             @RequestAttribute("userId") Long userId,
             @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
-        Long actionId = params.get("actionId") != null
-                ? Long.valueOf(params.get("actionId").toString()) : null;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
+        Long actionId = ParamUtils.getLong(params.get("actionId"));
         if (memberId == null) {
             return Result.error("memberId不能为空");
         }
@@ -84,8 +82,7 @@ public class MicroActionController {
     public Result<Map<String, Object>> checkToday(
             @RequestBody Map<String, Object> params,
             @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         boolean completed = memberId != null && microActionService.hasCompletedToday(memberId);
 
         Map<String, Object> result = new HashMap<>();

+ 2 - 2
cfc-backend/src/main/java/com/etotem/cfc/controller/PackageLogisticsController.java

@@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RestController;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 /**
  * 套餐物流 — 改版v1(B19)
@@ -35,8 +36,7 @@ public class PackageLogisticsController {
     public Result<Boolean> update(@RequestAttribute("userId") Long userId,
                                   @RequestAttribute(value = "role", required = false) String role,
                                   @RequestBody Map<String, Object> params) {
-        Long orderId = params.get("orderId") != null
-                ? Long.valueOf(params.get("orderId").toString()) : null;
+        Long orderId = ParamUtils.getLong(params.get("orderId"));
         if (orderId == null) {
             return Result.error("orderId 不能为空");
         }

+ 6 - 5
cfc-backend/src/main/java/com/etotem/cfc/controller/PackagePaymentController.java

@@ -12,6 +12,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "任务模板支付", description = "任务模板购买支付接口")
 @RestController
@@ -39,9 +40,9 @@ public class PackagePaymentController {
         if (familyId == null) {
             return Result.noFamily("请先创建或加入家庭");
         }
-        Long packageId = Long.valueOf(params.get("packageId").toString());
+        Long packageId = ParamUtils.getLong(params.get("packageId"));
         String payMethod = params.get("payMethod") != null ? params.get("payMethod").toString() : "wechat";
-        Long couponId = params.get("couponId") != null ? Long.valueOf(params.get("couponId").toString()) : null;
+        Long couponId = ParamUtils.getLong(params.get("couponId"));
         
         PackageOrder order = packagePaymentService.createOrder(userId, familyId, packageId, payMethod, couponId);
         return Result.success(order);
@@ -53,7 +54,7 @@ public class PackagePaymentController {
     @Operation(summary = "获取微信支付参数")
     @PostMapping("/wechat params")
     public Result<Map<String, Object>> getWechatPayParams(@RequestBody Map<String, Object> params) {
-        Long orderId = Long.valueOf(params.get("orderId").toString());
+        Long orderId = ParamUtils.getLong(params.get("orderId"));
         String openid = params.get("openid").toString();
         
         Map<String, Object> payParams = packagePaymentService.createWechatPayOrder(orderId, openid);
@@ -91,8 +92,8 @@ public class PackagePaymentController {
     @Operation(summary = "支付成功后应用任务模板")
     @PostMapping("/apply")
     public Result<TaskPlanInstance> applyAfterPayment(@RequestBody Map<String, Object> params) {
-        Long orderId = Long.valueOf(params.get("orderId").toString());
-        Long memberId = Long.valueOf(params.get("memberId").toString());
+        Long orderId = ParamUtils.getLong(params.get("orderId"));
+        Long memberId = ParamUtils.getLong(params.get("memberId"));
         java.util.List<Long> selectedItemIds = null;
         if (params.get("selectedItemIds") instanceof java.util.List) {
             selectedItemIds = new java.util.ArrayList<>();

+ 4 - 3
cfc-backend/src/main/java/com/etotem/cfc/controller/PointsExchangeController.java

@@ -15,6 +15,7 @@ import javax.annotation.Resource;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/points/exchange")
@@ -34,7 +35,7 @@ public class PointsExchangeController {
 
     @PostMapping("/product/detail")
     public Result<PointsExchangeProduct> getProductDetail(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) {
             return Result.error("商品ID不能为空");
         }
@@ -45,8 +46,8 @@ public class PointsExchangeController {
     @PostMapping("/submit")
     public Result<PointsExchangeRecord> exchangeProduct(@RequestBody Map<String, Object> params,
                                                           @RequestAttribute("userId") Long userId) {
-        Long productId = params.get("productId") != null ? Long.valueOf(params.get("productId").toString()) : null;
-        Long memberId = params.get("memberId") != null ? Long.valueOf(params.get("memberId").toString()) : null;
+        Long productId = ParamUtils.getLong(params.get("productId"));
+        Long memberId = ParamUtils.getLong(params.get("memberId"));
         Integer quantity = params.get("quantity") != null ? Integer.valueOf(params.get("quantity").toString()) : 1;
         if (productId == null) {
             return Result.error("商品ID不能为空");

+ 2 - 2
cfc-backend/src/main/java/com/etotem/cfc/controller/ProblemPackageController.java

@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 /**
  * 问题域套餐 — 改版v1(套餐详情:介绍/使用方式/包含检测/任务模板/奖励说明)
@@ -30,8 +31,7 @@ public class ProblemPackageController {
     @Operation(summary = "套餐详情(名称/介绍/周期/包含任务模板/奖励说明)")
     @PostMapping("/detail")
     public Result<Map<String, Object>> detail(@RequestBody Map<String, Object> params) {
-        Long packageId = params.get("packageId") != null
-                ? Long.valueOf(params.get("packageId").toString()) : null;
+        Long packageId = ParamUtils.getLong(params.get("packageId"));
         if (packageId == null) {
             return Result.error("packageId 不能为空");
         }

+ 3 - 4
cfc-backend/src/main/java/com/etotem/cfc/controller/ProblemSurveyController.java

@@ -29,6 +29,7 @@ import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import com.etotem.cfc.util.ParamUtils;
 
 /**
  * 专项调研 — 改版v1(提交调研 → 汇总 resultTags → 推荐产品 → 存快照 → 推进旅程)
@@ -58,12 +59,10 @@ public class ProblemSurveyController {
     public Result<Map<String, Object>> submit(@RequestAttribute("userId") Long userId,
                                               @RequestAttribute(value = "familyId", required = false) Long familyId,
                                               @RequestBody Map<String, Object> params) {
-        Long surveyTemplateId = params.get("surveyTemplateId") != null
-                ? Long.valueOf(params.get("surveyTemplateId").toString()) : null;
+        Long surveyTemplateId = ParamUtils.getLong(params.get("surveyTemplateId"));
         String problemDomainCode = params.get("problemDomainCode") != null
                 ? params.get("problemDomainCode").toString() : null;
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : null;
+        Long memberId = ParamUtils.getLong(params.get("memberId"));
         Object answersObj = params.get("answers");
 
         SurveyTemplate template = surveyTemplateId != null ? surveyTemplateMapper.selectById(surveyTemplateId) : null;

+ 2 - 2
cfc-backend/src/main/java/com/etotem/cfc/controller/PromotionController.java

@@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/promotion")
@@ -25,8 +26,7 @@ public class PromotionController {
             return Result.noFamily("请先创建或加入家庭");
         }
         String inviteCode = params.get("inviteCode") != null ? params.get("inviteCode").toString() : null;
-        Long promoterFamilyId = params.get("promoterFamilyId") != null
-                ? Long.valueOf(params.get("promoterFamilyId").toString()) : null;
+        Long promoterFamilyId = ParamUtils.getLong(params.get("promoterFamilyId"));
         if (inviteCode == null || promoterFamilyId == null) {
             return Result.error("邀请码和推广方家庭ID不能为空");
         }

+ 3 - 2
cfc-backend/src/main/java/com/etotem/cfc/controller/PromotionMaterialController.java

@@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "promotion materials", description = "推广素材中心")
 @RestController
@@ -34,7 +35,7 @@ public class PromotionMaterialController {
     @Operation(summary = "get material detail")
     @PostMapping("/detail")
     public Result<PromotionMaterial> detail(@RequestBody Map<String, Object> params) {
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         PromotionMaterial material = promotionMaterialService.getById(id);
         if (material == null) return Result.error("素材不存在");
         return Result.success(material);
@@ -67,7 +68,7 @@ public class PromotionMaterialController {
     @Operation(summary = "delete material (admin)")
     @PostMapping("/delete")
     public Result<Void> delete(@RequestBody Map<String, Object> params) {
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         promotionMaterialService.deleteMaterial(id);
         return Result.success(null);
     }

+ 2 - 1
cfc-backend/src/main/java/com/etotem/cfc/controller/RecommendController.java

@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.util.Date;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "推荐系统", description = "个性化内容推荐接口")
 @RestController
@@ -49,7 +50,7 @@ public class RecommendController {
     public Result<String> track(@RequestBody Map<String, Object> params,
                                 @RequestAttribute(value = "userId", required = false) Long userId) {
         String contentType = (String) params.get("contentType");
-        Long contentId = params.get("contentId") != null ? Long.valueOf(params.get("contentId").toString()) : null;
+        Long contentId = ParamUtils.getLong(params.get("contentId"));
         String action = (String) params.get("action");
         if (contentType == null || contentId == null || action == null) {
             return Result.error("参数不完整");

+ 2 - 1
cfc-backend/src/main/java/com/etotem/cfc/controller/ReportStatsController.java

@@ -18,6 +18,7 @@ import javax.annotation.Resource;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "统计报表", description = "统一数据统计与报表接口")
 @RestController
@@ -39,7 +40,7 @@ public class ReportStatsController {
     @Operation(summary = "孩子数据概览")
     @PostMapping("/child/overview")
     public Result<Map<String, Object>> childOverview(@RequestBody Map<String, Object> body) {
-        Long memberId = Long.valueOf(body.get("memberId").toString());
+        Long memberId = ParamUtils.getLong(body.get("memberId"));
         Map<String, Object> result = new HashMap<>();
 
         // 基础信息

+ 5 - 8
cfc-backend/src/main/java/com/etotem/cfc/controller/ReportSurveyController.java

@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 /**
  * 报告调研问卷接口 — 上传报告后自动生成的问卷管理
@@ -29,10 +30,8 @@ public class ReportSurveyController {
     public Result<ReportSurvey> createSurvey(
             @RequestBody Map<String, Object> params,
             @RequestAttribute("userId") Long userId) {
-        Long reportId = params.get("reportId") != null
-                ? Long.valueOf(params.get("reportId").toString()) : null;
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : null;
+        Long reportId = ParamUtils.getLong(params.get("reportId"));
+        Long memberId = ParamUtils.getLong(params.get("memberId"));
         if (reportId == null || memberId == null) {
             return Result.error("reportId和childId不能为空");
         }
@@ -47,8 +46,7 @@ public class ReportSurveyController {
     @PostMapping("/submit")
     public Result<ReportSurvey> submitSurvey(
             @RequestBody Map<String, Object> params) {
-        Long surveyId = params.get("surveyId") != null
-                ? Long.valueOf(params.get("surveyId").toString()) : null;
+        Long surveyId = ParamUtils.getLong(params.get("surveyId"));
         String surveyData = params.get("surveyData") != null
                 ? params.get("surveyData").toString() : null;
         if (surveyId == null || surveyData == null) {
@@ -65,8 +63,7 @@ public class ReportSurveyController {
     @PostMapping("/status")
     public Result<Map<String, Object>> getSurveyStatus(
             @RequestBody Map<String, Object> params) {
-        Long reportId = params.get("reportId") != null
-                ? Long.valueOf(params.get("reportId").toString()) : null;
+        Long reportId = ParamUtils.getLong(params.get("reportId"));
         if (reportId == null) {
             return Result.error("reportId不能为空");
         }

+ 3 - 6
cfc-backend/src/main/java/com/etotem/cfc/controller/ReviewController.java

@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/review")
@@ -29,9 +30,7 @@ public class ReviewController {
 
     @PostMapping("/order/detail")
     public Result<ReviewOrderResponse> getReviewOrderDetail(@RequestBody java.util.Map<String, Object> params) {
-        Long orderId = params != null && params.get("orderId") != null
-                ? Long.valueOf(params.get("orderId").toString())
-                : null;
+        Long orderId = params != null ? ParamUtils.getLong(params.get("orderId")) : null;
         if (orderId == null) {
             return Result.error("orderId is required");
         }
@@ -41,9 +40,7 @@ public class ReviewController {
 
     @PostMapping("/order/status")
     public Result<ReviewStatusResponse> getReviewStatus(@RequestBody java.util.Map<String, Object> params) {
-        Long orderId = params != null && params.get("orderId") != null
-                ? Long.valueOf(params.get("orderId").toString())
-                : null;
+        Long orderId = params != null ? ParamUtils.getLong(params.get("orderId")) : null;
         if (orderId == null) {
             return Result.error("orderId is required");
         }

+ 3 - 2
cfc-backend/src/main/java/com/etotem/cfc/controller/ServiceRoleApplicationController.java

@@ -19,6 +19,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "服务角色申请", description = "统一服务角色申请入口")
 @RestController
@@ -98,7 +99,7 @@ public class ServiceRoleApplicationController {
     @Operation(summary = "管理端: 批准申请")
     public Result adminApprove(@RequestBody Map<String, Object> params,
                                @RequestAttribute("userId") Long adminId) {
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         return serviceRoleApplicationService.approve(id, adminId);
     }
 
@@ -106,7 +107,7 @@ public class ServiceRoleApplicationController {
     @Operation(summary = "管理端: 驳回申请")
     public Result adminReject(@RequestBody Map<String, Object> params,
                               @RequestAttribute("userId") Long adminId) {
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         String reason = params.get("reason") != null ? params.get("reason").toString() : "";
         return serviceRoleApplicationService.reject(id, reason, adminId);
     }

+ 4 - 3
cfc-backend/src/main/java/com/etotem/cfc/controller/ShareController.java

@@ -13,6 +13,7 @@ import javax.servlet.http.HttpServletRequest;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "内容分享", description = "文章/商品分享推荐接口")
 @RestController
@@ -43,7 +44,7 @@ public class ShareController {
         }
 
         String targetType = params.get("targetType").toString();
-        Long targetId = Long.valueOf(params.get("targetId").toString());
+        Long targetId = ParamUtils.getLong(params.get("targetId"));
         String shareChannel = params.get("shareChannel") != null
             ? params.get("shareChannel").toString() : "wechat";
         String title = params.get("title") != null ? params.get("title").toString() : "";
@@ -55,7 +56,7 @@ public class ShareController {
     @Operation(summary = "记录分享点击")
     @PostMapping("/click")
     public Result<Void> recordClick(@RequestBody Map<String, Object> params) {
-        Long shareEventId = Long.valueOf(params.get("shareEventId").toString());
+        Long shareEventId = ParamUtils.getLong(params.get("shareEventId"));
         shareService.recordClick(shareEventId);
         return Result.success(null);
     }
@@ -64,7 +65,7 @@ public class ShareController {
     @PostMapping("/read")
     public Result<Map<String, Object>> recordRead(HttpServletRequest request,
                                                    @RequestBody Map<String, Object> params) {
-        Long shareEventId = Long.valueOf(params.get("shareEventId").toString());
+        Long shareEventId = ParamUtils.getLong(params.get("shareEventId"));
         Long readerId = getUserId(request);
         String readerIp = request.getRemoteAddr();
         int duration = params.get("duration") != null

+ 7 - 9
cfc-backend/src/main/java/com/etotem/cfc/controller/SurveyController.java

@@ -12,6 +12,7 @@ import javax.annotation.Resource;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "定期调研", description = "小程序端定期调研接口")
 @RestController
@@ -27,8 +28,7 @@ public class SurveyController {
             @RequestBody Map<String, Object> params,
             @RequestAttribute("userId") Long userId,
             @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         return Result.success(surveyService.getSurveyStatus(userId, memberId));
     }
 
@@ -44,12 +44,11 @@ public class SurveyController {
             @RequestBody Map<String, Object> params,
             @RequestAttribute("userId") Long userId,
             @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
-        Long templateId = Long.valueOf(params.get("templateId").toString());
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
+        Long templateId = ParamUtils.getLong(params.get("templateId"));
         String answersJson = (String) params.get("answersJson");
-        Date ps = params.get("periodStart") != null ? new Date(Long.valueOf(params.get("periodStart").toString())) : null;
-        Date pe = params.get("periodEnd") != null ? new Date(Long.valueOf(params.get("periodEnd").toString())) : null;
+        Date ps = params.get("periodStart") != null ? new Date(ParamUtils.getLong(params.get("periodStart"))) : null;
+        Date pe = params.get("periodEnd") != null ? new Date(ParamUtils.getLong(params.get("periodEnd"))) : null;
         return Result.success(surveyService.submitSurvey(userId, memberId, templateId, answersJson, ps, pe));
     }
 
@@ -59,8 +58,7 @@ public class SurveyController {
             @RequestBody Map<String, Object> params,
             @RequestAttribute("userId") Long userId,
             @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         return Result.success(surveyService.getSurveyHistory(userId, memberId));
     }
 }

+ 6 - 5
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminActivityController.java

@@ -7,6 +7,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 /**
  * 后台活动管理接口
@@ -43,7 +44,7 @@ public class AdminActivityController {
      */
     @PostMapping("/detail")
     public Result<Activity> detail(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) return Result.error("id不能为空");
         Activity activity = activityAdminService.getDetail(id);
         if (activity == null) return Result.error("活动不存在");
@@ -52,7 +53,7 @@ public class AdminActivityController {
 
     @PostMapping("/submit-review")
     public Result<String> submitReview(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) return Result.error("id不能为空");
         activityAdminService.submitForReview(id);
         return Result.success("已提交审核");
@@ -61,7 +62,7 @@ public class AdminActivityController {
     @PostMapping("/audit")
     public Result<String> audit(@RequestBody Map<String, Object> params,
                                 @RequestAttribute("userId") Long adminId) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         String action = (String) params.get("action");
         String rejectReason = (String) params.get("rejectReason");
         if (id == null || action == null) return Result.error("id和action不能为空");
@@ -71,7 +72,7 @@ public class AdminActivityController {
 
     @PostMapping("/withdraw")
     public Result<String> withdraw(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) return Result.error("id不能为空");
         activityAdminService.withdraw(id);
         return Result.success("已撤回");
@@ -79,7 +80,7 @@ public class AdminActivityController {
 
     @PostMapping("/re-draft")
     public Result<String> reDraft(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) return Result.error("id不能为空");
         activityAdminService.reDraft(id);
         return Result.success("已转为草稿");

+ 2 - 1
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminActivityRegistrationController.java

@@ -5,6 +5,7 @@ import com.etotem.cfc.service.ActivityRegistrationService;
 import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/admin/activity")
@@ -16,7 +17,7 @@ public class AdminActivityRegistrationController {
         if (!"admin".equals(role) && !"activity_admin".equals(role)) {
             return Result.error("无权限:仅活动管理员可查看报名");
         }
-        Long activityId = params.get("activityId") != null ? Long.valueOf(params.get("activityId").toString()) : null;
+        Long activityId = ParamUtils.getLong(params.get("activityId"));
         String status = (String) params.get("status");
         if (activityId == null) return Result.error("活动ID不能为空");
         return registrationService.getRegistrationsByActivity(activityId, status);

+ 4 - 3
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminAfterSalesController.java

@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/admin/shop/after-sales")
@@ -28,14 +29,14 @@ public class AdminAfterSalesController {
 
     @PostMapping("/detail")
     public Result<AfterSalesRequest> detail(@RequestBody Map<String, Object> params) {
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         return afterSalesService.adminDetail(id);
     }
 
     @PostMapping("/review")
     public Result<String> review(@RequestBody Map<String, Object> params,
                                  @RequestAttribute("userId") Long adminId) {
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         String action = (String) params.get("action");
         String rejectReason = (String) params.get("rejectReason");
         return afterSalesService.review(id, action, rejectReason, adminId);
@@ -43,7 +44,7 @@ public class AdminAfterSalesController {
 
     @PostMapping("/complete")
     public Result<String> complete(@RequestBody Map<String, Object> params) {
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         return afterSalesService.complete(id);
     }
 }

+ 16 - 15
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminArticleController.java

@@ -16,6 +16,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import com.etotem.cfc.util.SortUtil;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/admin/articles")
@@ -39,12 +40,12 @@ public class AdminArticleController {
     @PostMapping("/list")
     public Result<Page<Article>> list(@RequestBody Map<String, Object> body) {
         String status = (String) body.get("status");
-        Long categoryId = body.get("categoryId") != null ? Long.valueOf(body.get("categoryId").toString()) : null;
+        Long categoryId = ParamUtils.getLong(body.get("categoryId"));
         String keyword = (String) body.get("keyword");
         String contentType = (String) body.get("contentType");
         Integer difficultyLevel = body.get("difficultyLevel") != null ? Integer.valueOf(body.get("difficultyLevel").toString()) : null;
         String dimensionCode = (String) body.get("dimensionCode");
-        Long tagId = body.get("tagId") != null ? Long.valueOf(body.get("tagId").toString()) : null;
+        Long tagId = ParamUtils.getLong(body.get("tagId"));
         String auditStatus = (String) body.get("auditStatus");
         int page = body.get("page") != null ? Integer.parseInt(body.get("page").toString()) : 1;
         int size = body.get("size") != null ? Integer.parseInt(body.get("size").toString()) : 20;
@@ -73,7 +74,7 @@ public class AdminArticleController {
         article.setTitle((String) body.get("title"));
         article.setContent((String) body.get("content"));
         if (body.get("categoryId") != null && !body.get("categoryId").toString().trim().isEmpty()) {
-            article.setCategoryId(Long.valueOf(body.get("categoryId").toString()));
+            article.setCategoryId(ParamUtils.getLong(body.get("categoryId")));
         }
         article.setSummary((String) body.get("summary"));
         article.setCoverImage((String) body.get("coverImage"));
@@ -137,7 +138,7 @@ public class AdminArticleController {
             return Result.error("文章内容包含敏感信息,更新失败");
         }
 
-        Long articleId = body.get("id") != null ? Long.valueOf(body.get("id").toString()) : null;
+        Long articleId = ParamUtils.getLong(body.get("id"));
         if (articleId != null) {
             Article existing = articleService.getById(articleId);
             if (existing != null && !"draft".equals(existing.getStatus())
@@ -150,7 +151,7 @@ public class AdminArticleController {
         article.setTitle((String) body.get("title"));
         article.setContent((String) body.get("content"));
         if (body.get("categoryId") != null && !body.get("categoryId").toString().trim().isEmpty()) {
-            article.setCategoryId(Long.valueOf(body.get("categoryId").toString()));
+            article.setCategoryId(ParamUtils.getLong(body.get("categoryId")));
         }
         article.setSummary((String) body.get("summary"));
         article.setCoverImage((String) body.get("coverImage"));
@@ -199,7 +200,7 @@ public class AdminArticleController {
         if (body.get("id") == null) {
             return Result.error("缺少文章ID");
         }
-        Long id = Long.valueOf(body.get("id").toString());
+        Long id = ParamUtils.getLong(body.get("id"));
         Article article = articleService.getById(id);
         if (article == null) {
             return Result.error("文章不存在");
@@ -209,7 +210,7 @@ public class AdminArticleController {
 
     @PostMapping("/delete")
     public Result<String> delete(@RequestBody Map<String, Object> body) {
-        Long id = Long.valueOf(body.get("id").toString());
+        Long id = ParamUtils.getLong(body.get("id"));
         articleService.delete(id);
         return Result.success("删除成功");
     }
@@ -226,7 +227,7 @@ public class AdminArticleController {
         if (body.get("id") == null) {
             return Result.error("缺少文章ID");
         }
-        Long id = Long.valueOf(body.get("id").toString());
+        Long id = ParamUtils.getLong(body.get("id"));
         String status = (String) body.get("status");
         articleService.toggleStatus(id, status);
         return Result.success("操作成功");
@@ -234,7 +235,7 @@ public class AdminArticleController {
 
     @PostMapping("/toggle-featured")
     public Result<String> toggleFeatured(@RequestBody Map<String, Object> body) {
-        Long id = Long.valueOf(body.get("id").toString());
+        Long id = ParamUtils.getLong(body.get("id"));
         int isFeatured = Integer.parseInt(body.get("isFeatured").toString());
         articleService.toggleFeatured(id, isFeatured);
         return Result.success("操作成功");
@@ -243,7 +244,7 @@ public class AdminArticleController {
     @PostMapping("/audit")
     public Result<String> audit(@RequestBody Map<String, Object> body,
                                  @RequestAttribute("userId") Long adminId) {
-        Long articleId = Long.valueOf(body.get("id").toString());
+        Long articleId = ParamUtils.getLong(body.get("id"));
         String auditStatus = (String) body.get("auditStatus");
         String auditReason = (String) body.get("auditReason");
         if (!"approved".equals(auditStatus) && !"rejected".equals(auditStatus)) {
@@ -262,7 +263,7 @@ public class AdminArticleController {
 
     @PostMapping("/submit-review")
     public Result<String> submitReview(@RequestBody Map<String, Object> body) {
-        Long id = body.get("id") != null ? Long.valueOf(body.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(body.get("id"));
         if (id == null) return Result.error("缺少文章ID");
         try {
             articleService.submitForReview(id);
@@ -274,7 +275,7 @@ public class AdminArticleController {
 
     @PostMapping("/withdraw")
     public Result<String> withdraw(@RequestBody Map<String, Object> body) {
-        Long id = body.get("id") != null ? Long.valueOf(body.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(body.get("id"));
         if (id == null) return Result.error("缺少文章ID");
         try {
             articleService.withdraw(id);
@@ -286,7 +287,7 @@ public class AdminArticleController {
 
     @PostMapping("/re-draft")
     public Result<String> reDraft(@RequestBody Map<String, Object> body) {
-        Long id = body.get("id") != null ? Long.valueOf(body.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(body.get("id"));
         if (id == null) return Result.error("缺少文章ID");
         try {
             articleService.reDraft(id);
@@ -326,7 +327,7 @@ public class AdminArticleController {
 
     @PostMapping("/comments/list")
     public Result<Page<Map<String, Object>>> commentList(@RequestBody Map<String, Object> body) {
-        Long articleId = body.get("articleId") != null ? Long.valueOf(body.get("articleId").toString()) : null;
+        Long articleId = ParamUtils.getLong(body.get("articleId"));
         String status = (String) body.get("status");
         int page = body.get("page") != null ? Integer.parseInt(body.get("page").toString()) : 1;
         int size = body.get("size") != null ? Integer.parseInt(body.get("size").toString()) : 20;
@@ -352,7 +353,7 @@ public class AdminArticleController {
 
     @PostMapping("/categories/delete")
     public Result<String> categoryDelete(@RequestBody Map<String, Object> body) {
-        Long id = Long.valueOf(body.get("id").toString());
+        Long id = ParamUtils.getLong(body.get("id"));
         articleCategoryService.delete(id);
         return Result.success("删除成功");
     }

+ 4 - 9
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminButlerController.java

@@ -16,6 +16,7 @@ import javax.annotation.Resource;
 import java.util.HashMap;
 import java.util.Map;
 import com.etotem.cfc.util.SortUtil;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/admin/butler")
@@ -74,9 +75,7 @@ public class AdminButlerController {
             return Result.error("权限不足");
         }
 
-        Long userId = params.get("userId") != null
-                ? Long.valueOf(params.get("userId").toString())
-                : null;
+        Long userId = ParamUtils.getLong(params.get("userId"));
         String action = (String) params.get("action");
         String reason = (String) params.getOrDefault("reason", "");
 
@@ -101,12 +100,8 @@ public class AdminButlerController {
             return Result.error("权限不足");
         }
 
-        Long profileId = params.get("profileId") != null
-                ? Long.valueOf(params.get("profileId").toString())
-                : null;
-        Long memberId = params.get("memberId") != null
-                ? Long.valueOf(params.get("memberId").toString())
-                : null;
+        Long profileId = ParamUtils.getLong(params.get("profileId"));
+        Long memberId = ParamUtils.getLong(params.get("memberId"));
 
         if (profileId == null || memberId == null) {
             return Result.error("profileId和memberId不能为空");

+ 3 - 2
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminCategoryController.java

@@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/admin/shop/category")
@@ -31,7 +32,7 @@ public class AdminCategoryController {
 
     @PostMapping("/delete")
     public Result<String> delete(@RequestBody Map<String, Object> body) {
-        Long id = Long.valueOf(body.get("id").toString());
+        Long id = ParamUtils.getLong(body.get("id"));
         return productCategoryService.delete(id);
     }
 
@@ -42,7 +43,7 @@ public class AdminCategoryController {
 
     @PostMapping("/toggle")
     public Result<String> toggle(@RequestBody Map<String, Object> body) {
-        Long id = Long.valueOf(body.get("id").toString());
+        Long id = ParamUtils.getLong(body.get("id"));
         return productCategoryService.toggle(id);
     }
 }

+ 3 - 2
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminCfValueController.java

@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/admin/cf-value")
@@ -26,7 +27,7 @@ public class AdminCfValueController {
 
     @PostMapping("/balance")
     public Result<Map<String, Object>> getBalance(@RequestBody Map<String, Object> params) {
-        Long userId = params.get("userId") != null ? Long.valueOf(params.get("userId").toString()) : null;
+        Long userId = ParamUtils.getLong(params.get("userId"));
         if (userId == null) {
             return Result.error("userId不能为空");
         }
@@ -36,7 +37,7 @@ public class AdminCfValueController {
 
     @PostMapping("/logs")
     public Result<Page<PlatformBalanceLog>> getLogs(@RequestBody Map<String, Object> params) {
-        Long userId = params.get("userId") != null ? Long.valueOf(params.get("userId").toString()) : null;
+        Long userId = ParamUtils.getLong(params.get("userId"));
         if (userId == null) {
             return Result.error("userId不能为空");
         }

+ 4 - 9
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminCommissionController.java

@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.util.HashMap;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/admin/commission")
@@ -38,9 +39,7 @@ public class AdminCommissionController {
     @PostMapping("/audit")
     public Result<String> audit(@RequestAttribute("userId") Long adminId,
                                 @RequestBody Map<String, Object> params) {
-        Long requestId = params.get("requestId") != null
-                ? Long.valueOf(params.get("requestId").toString())
-                : null;
+        Long requestId = ParamUtils.getLong(params.get("requestId"));
         String status = (String) params.get("status");
         String remark = (String) params.get("remark");
         if (requestId == null) {
@@ -60,9 +59,7 @@ public class AdminCommissionController {
 
     @PostMapping("/update-profit-rate")
     public Result<String> updateProfitRate(@RequestBody Map<String, Object> params) {
-        Long productId = params.get("productId") != null
-                ? Long.valueOf(params.get("productId").toString())
-                : null;
+        Long productId = ParamUtils.getLong(params.get("productId"));
         Integer profitRate = params.get("profitRate") != null
                 ? Integer.valueOf(params.get("profitRate").toString())
                 : null;
@@ -96,9 +93,7 @@ public class AdminCommissionController {
 
     @PostMapping("/refunds/cancel")
     public Result<String> cancelRefund(@RequestBody Map<String, Object> params) {
-        Long refundId = params.get("refundId") != null
-                ? Long.valueOf(params.get("refundId").toString())
-                : null;
+        Long refundId = ParamUtils.getLong(params.get("refundId"));
         if (refundId == null) {
             return Result.error("refundId不能为空");
         }

+ 5 - 4
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminController.java

@@ -24,6 +24,7 @@ import java.util.Map;
 import java.util.ArrayList;
 import java.util.Collections;
 import com.etotem.cfc.util.SortUtil;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/admin")
@@ -1420,8 +1421,8 @@ public class AdminController {
 
     @PostMapping("/assessment/change-guide")
     public Result<Void> changeAssessmentGuide(@RequestBody Map<String, Object> body) {
-        Long appointmentId = body.get("orderId") != null ? Long.valueOf(body.get("orderId").toString()) : null;
-        Long guideId = body.get("guideId") != null ? Long.valueOf(body.get("guideId").toString()) : null;
+        Long appointmentId = ParamUtils.getLong(body.get("orderId"));
+        Long guideId = ParamUtils.getLong(body.get("guideId"));
         if (appointmentId == null || guideId == null) {
             return Result.error("appointmentId 和 guideId 不能为空");
         }
@@ -1449,8 +1450,8 @@ public class AdminController {
 
     @PostMapping("/assessment/assign-guide")
     public Result<Void> assignGuide(@RequestBody Map<String, Object> body) {
-        Long appointmentId = body.get("appointmentId") != null ? Long.valueOf(body.get("appointmentId").toString()) : null;
-        Long guideId = body.get("guideId") != null ? Long.valueOf(body.get("guideId").toString()) : null;
+        Long appointmentId = ParamUtils.getLong(body.get("appointmentId"));
+        Long guideId = ParamUtils.getLong(body.get("guideId"));
         if (appointmentId == null || guideId == null) {
             return Result.error("appointmentId 和 guideId 不能为空");
         }

+ 5 - 4
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminCouponController.java

@@ -14,6 +14,7 @@ import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import com.etotem.cfc.util.SortUtil;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/admin/coupon")
@@ -67,7 +68,7 @@ public class AdminCouponController {
         if (!"admin".equals(role)) {
             return Result.error("无权限");
         }
-        Long couponId = Long.valueOf(params.get("couponId").toString());
+        Long couponId = ParamUtils.getLong(params.get("couponId"));
         Object userIdsObj = params.get("userIds");
         if (userIdsObj instanceof List) {
             List<?> userIds = (List<?>) userIdsObj;
@@ -84,7 +85,7 @@ public class AdminCouponController {
         if (!"admin".equals(role)) {
             return Result.error("无权限");
         }
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         couponMapper.deleteById(id);
         return Result.success("删除成功");
     }
@@ -95,8 +96,8 @@ public class AdminCouponController {
         if (!"admin".equals(role)) {
             return Result.error("无权限");
         }
-        Long userId = params.get("userId") != null ? Long.valueOf(params.get("userId").toString()) : null;
-        Long couponId = params.get("couponId") != null ? Long.valueOf(params.get("couponId").toString()) : null;
+        Long userId = ParamUtils.getLong(params.get("userId"));
+        Long couponId = ParamUtils.getLong(params.get("couponId"));
         LambdaQueryWrapper<CouponGrantLog> wrapper = new LambdaQueryWrapper<>();
         if (userId != null) {
             wrapper.eq(CouponGrantLog::getUserId, userId);

+ 3 - 2
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminDiscountController.java

@@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/admin/shop/discount")
@@ -37,13 +38,13 @@ public class AdminDiscountController {
 
     @PostMapping("/toggle")
     public Result<String> toggle(@RequestBody Map<String, Object> body) {
-        Long id = Long.valueOf(body.get("id").toString());
+        Long id = ParamUtils.getLong(body.get("id"));
         return discountService.toggle(id);
     }
 
     @PostMapping("/delete")
     public Result<String> delete(@RequestBody Map<String, Object> body) {
-        Long id = Long.valueOf(body.get("id").toString());
+        Long id = ParamUtils.getLong(body.get("id"));
         return discountService.delete(id);
     }
 }

+ 8 - 7
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminDistributionController.java

@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "管理端-销售管理")
 @RestController
@@ -44,7 +45,7 @@ public class AdminDistributionController {
     @Operation(summary = "启用/禁用销售体系")
     @PostMapping("/system/toggle")
     public Result<String> toggleSystem(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) return Result.error("id不能为空");
         return distributionService.toggleSystem(id);
     }
@@ -52,17 +53,17 @@ public class AdminDistributionController {
     @Operation(summary = "销售关系列表")
     @PostMapping("/relation/list")
     public Result<List<DistributionRelation>> listRelations(@RequestBody Map<String, Object> params) {
-        Long systemId = params.get("systemId") != null ? Long.valueOf(params.get("systemId").toString()) : null;
-        Long userId = params.get("userId") != null ? Long.valueOf(params.get("userId").toString()) : null;
+        Long systemId = ParamUtils.getLong(params.get("systemId"));
+        Long userId = ParamUtils.getLong(params.get("userId"));
         return distributionService.listRelations(systemId, userId);
     }
 
     @Operation(summary = "添加销售关系")
     @PostMapping("/relation/add")
     public Result<Void> addRelation(@RequestBody Map<String, Object> params) {
-        Long systemId = params.get("systemId") != null ? Long.valueOf(params.get("systemId").toString()) : null;
-        Long userId = params.get("userId") != null ? Long.valueOf(params.get("userId").toString()) : null;
-        Long parentId = params.get("parentId") != null ? Long.valueOf(params.get("parentId").toString()) : null;
+        Long systemId = ParamUtils.getLong(params.get("systemId"));
+        Long userId = ParamUtils.getLong(params.get("userId"));
+        Long parentId = ParamUtils.getLong(params.get("parentId"));
         if (systemId == null) return Result.error("systemId不能为空");
         if (userId == null) return Result.error("userId不能为空");
         return distributionService.addRelation(systemId, userId, parentId);
@@ -71,7 +72,7 @@ public class AdminDistributionController {
     @Operation(summary = "移除销售关系")
     @PostMapping("/relation/remove")
     public Result<String> removeRelation(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) return Result.error("id不能为空");
         return distributionService.removeRelation(id);
     }

+ 3 - 2
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminEnergyBehaviorConfigController.java

@@ -12,6 +12,7 @@ import javax.annotation.Resource;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "管理端-能量行为配置")
 @RestController
@@ -32,7 +33,7 @@ public class AdminEnergyBehaviorConfigController {
     @Operation(summary = "获取单个能量行为配置")
     @PostMapping("/detail")
     public Result<EnergyBehaviorConfig> detail(@RequestBody Map<String, Object> params) {
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         EnergyBehaviorConfig config = behaviorConfigMapper.selectById(id);
         if (config == null) return Result.error("配置不存在");
         return Result.success(config);
@@ -51,7 +52,7 @@ public class AdminEnergyBehaviorConfigController {
     @Operation(summary = "切换启用/禁用状态")
     @PostMapping("/toggle")
     public Result<String> toggle(@RequestBody Map<String, Object> params) {
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         EnergyBehaviorConfig config = behaviorConfigMapper.selectById(id);
         if (config == null) return Result.error("配置不存在");
         config.setEnabled(config.getEnabled() != null && config.getEnabled() == 1 ? 0 : 1);

+ 2 - 1
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminEnergyConfigController.java

@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
 import java.util.*;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "管理端 - 五行能量配置")
 @RestController
@@ -88,7 +89,7 @@ public class AdminEnergyConfigController {
     @Operation(summary = "删除能量来源配置")
     @PostMapping("/source-delete")
     public Result<String> sourceDelete(@RequestBody Map<String, Object> params) {
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         energySourceConfigMapper.deleteById(id);
         return Result.success("删除成功");
     }

+ 3 - 2
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminEnergyRuleController.java

@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.time.LocalDateTime;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/admin/energy-rule")
@@ -61,7 +62,7 @@ public class AdminEnergyRuleController {
 
     @PostMapping("/delete")
     public Result<Void> delete(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) return Result.error("id不能为空");
         energyRuleMapper.deleteById(id);
         return Result.success(null);
@@ -69,7 +70,7 @@ public class AdminEnergyRuleController {
 
     @PostMapping("/toggle")
     public Result<Void> toggle(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) return Result.error("id不能为空");
         EnergyRule rule = energyRuleMapper.selectById(id);
         if (rule == null) return Result.error("规则不存在");

+ 4 - 3
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminFoodController.java

@@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.util.*;
 import java.util.stream.Collectors;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "\u7ba1\u7406\u7aef-\u98df\u6750\u7ba1\u7406")
 @RestController
@@ -84,7 +85,7 @@ public class AdminFoodController {
     @Operation(summary = "\u5220\u9664\u98df\u6750")
     @PostMapping("/delete")
     public Result<String> delete(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) return Result.error("id\u4e0d\u80fd\u4e3a\u7a7a");
         foodService.delete(id);
         return Result.success("ok");
@@ -93,7 +94,7 @@ public class AdminFoodController {
     @Operation(summary = "\u98df\u6750\u8be6\u60c5\uff08\u542b\u5e94\u5b63\u6708\u4efd\uff09")
     @PostMapping("/detail")
     public Result<Map<String, Object>> detail(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) return Result.error("id\u4e0d\u80fd\u4e3a\u7a7a");
         Map<String, Object> result = foodService.getDetailWithMonths(id);
         if (result == null) return Result.error("\u98df\u6750\u4e0d\u5b58\u5728");
@@ -103,7 +104,7 @@ public class AdminFoodController {
     @Operation(summary = "\u4fdd\u5b58\u5e94\u5b63\u6708\u4efd")
     @PostMapping("/saveMonths")
     public Result<String> saveMonths(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) return Result.error("id\u4e0d\u80fd\u4e3a\u7a7a");
         @SuppressWarnings("unchecked")
         List<Integer> months = params.get("months") != null

+ 4 - 9
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminGrowthArchiveProductController.java

@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 /**
  * 管理端-成长档案关联商品配置控制器
@@ -27,9 +28,7 @@ public class AdminGrowthArchiveProductController {
     @Operation(summary = "保存成长档案关联商品规则")
     @PostMapping("/save")
     public Result<String> save(@RequestBody Map<String, Object> params) {
-        Long productId = params.get("productId") != null
-                ? Long.valueOf(params.get("productId").toString())
-                : null;
+        Long productId = ParamUtils.getLong(params.get("productId"));
         Integer status = params.get("status") != null
                 ? Integer.valueOf(params.get("status").toString())
                 : null;
@@ -49,9 +48,7 @@ public class AdminGrowthArchiveProductController {
     @Operation(summary = "成长档案关联商品规则详情")
     @PostMapping("/detail")
     public Result<GrowthArchiveProduct> detail(@RequestBody Map<String, Object> params) {
-        Long productId = params.get("productId") != null
-                ? Long.valueOf(params.get("productId").toString())
-                : null;
+        Long productId = ParamUtils.getLong(params.get("productId"));
         if (productId == null) {
             return Result.error("productId不能为空");
         }
@@ -61,9 +58,7 @@ public class AdminGrowthArchiveProductController {
     @Operation(summary = "删除成长档案关联商品规则")
     @PostMapping("/delete")
     public Result<String> delete(@RequestBody Map<String, Object> params) {
-        Long productId = params.get("productId") != null
-                ? Long.valueOf(params.get("productId").toString())
-                : null;
+        Long productId = ParamUtils.getLong(params.get("productId"));
         if (productId == null) {
             return Result.error("productId不能为空");
         }

+ 16 - 18
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminInventoryController.java

@@ -12,6 +12,7 @@ import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "管理端-库存管理")
 @RestController
@@ -27,7 +28,7 @@ public class AdminInventoryController {
     @PostMapping("/inbound/create")
     public Result<Map<String, Object>> createInbound(@RequestBody Map<String, Object> params,
                                                       @RequestAttribute("userId") Long adminId) {
-        Long supplierId = params.get("supplierId") != null ? Long.valueOf(params.get("supplierId").toString()) : null;
+        Long supplierId = ParamUtils.getLong(params.get("supplierId"));
         String supplierName = (String) params.get("supplierName");
         String remark = (String) params.get("remark");
         Integer totalAmount = params.get("totalAmount") != null ? Integer.valueOf(params.get("totalAmount").toString()) : null;
@@ -55,7 +56,7 @@ public class AdminInventoryController {
     @Operation(summary = "入库单详情")
     @PostMapping("/inbound/detail")
     public Result<Map<String, Object>> detailInbound(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) return Result.error("id不能为空");
         return inventoryService.detailInboundOrder(id);
     }
@@ -64,7 +65,7 @@ public class AdminInventoryController {
     @PostMapping("/inbound/confirm")
     public Result<String> confirmInbound(@RequestBody Map<String, Object> params,
                                           @RequestAttribute("userId") Long adminId) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) return Result.error("id不能为空");
         return inventoryService.confirmInbound(id, adminId);
     }
@@ -72,7 +73,7 @@ public class AdminInventoryController {
     @Operation(summary = "取消入库单")
     @PostMapping("/inbound/cancel")
     public Result<String> cancelInbound(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) return Result.error("id不能为空");
         return inventoryService.cancelInbound(id);
     }
@@ -84,8 +85,8 @@ public class AdminInventoryController {
     public Result<Map<String, Object>> listTransactions(@RequestBody Map<String, Object> params) {
         int page = params.get("page") != null ? ((Number) params.get("page")).intValue() : 1;
         int size = params.get("size") != null ? ((Number) params.get("size")).intValue() : 20;
-        Long productId = params.get("productId") != null ? Long.valueOf(params.get("productId").toString()) : null;
-        Long skuId = params.get("skuId") != null ? Long.valueOf(params.get("skuId").toString()) : null;
+        Long productId = ParamUtils.getLong(params.get("productId"));
+        Long skuId = ParamUtils.getLong(params.get("skuId"));
         String type = (String) params.get("type");
         String startDate = (String) params.get("startDate");
         String endDate = (String) params.get("endDate");
@@ -98,8 +99,8 @@ public class AdminInventoryController {
     @PostMapping("/counting/create")
     public Result<String> createCounting(@RequestBody Map<String, Object> params,
                                           @RequestAttribute("userId") Long adminId) {
-        Long productId = params.get("productId") != null ? Long.valueOf(params.get("productId").toString()) : null;
-        Long skuId = params.get("skuId") != null ? Long.valueOf(params.get("skuId").toString()) : null;
+        Long productId = ParamUtils.getLong(params.get("productId"));
+        Long skuId = ParamUtils.getLong(params.get("skuId"));
         Integer actualStock = params.get("actualStock") != null ? Integer.valueOf(params.get("actualStock").toString()) : null;
         String remark = (String) params.get("remark");
         if (productId == null) return Result.error("productId不能为空");
@@ -111,7 +112,7 @@ public class AdminInventoryController {
     @PostMapping("/counting/confirm")
     public Result<String> confirmCounting(@RequestBody Map<String, Object> params,
                                            @RequestAttribute("userId") Long adminId) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) return Result.error("id不能为空");
         return inventoryService.confirmCounting(id, adminId);
     }
@@ -138,7 +139,7 @@ public class AdminInventoryController {
     @Operation(summary = "商品库存详情")
     @PostMapping("/product/stock")
     public Result<Map<String, Object>> productStock(@RequestBody Map<String, Object> params) {
-        Long productId = params.get("productId") != null ? Long.valueOf(params.get("productId").toString()) : null;
+        Long productId = ParamUtils.getLong(params.get("productId"));
         if (productId == null) return Result.error("productId不能为空");
         return inventoryService.getProductStock(productId);
     }
@@ -148,8 +149,7 @@ public class AdminInventoryController {
     @Operation(summary = "配置套餐商品组成")
     @PostMapping("/bundle/items")
     public Result<String> saveBundleItems(@RequestBody Map<String, Object> params) {
-        Long bundleProductId = params.get("bundleProductId") != null
-                ? Long.valueOf(params.get("bundleProductId").toString()) : null;
+        Long bundleProductId = ParamUtils.getLong(params.get("bundleProductId"));
         if (bundleProductId == null) return Result.error("bundleProductId不能为空");
         @SuppressWarnings("unchecked")
         List<Map<String, Object>> items = (List<Map<String, Object>>) params.get("items");
@@ -159,8 +159,7 @@ public class AdminInventoryController {
     @Operation(summary = "查询套餐商品组成")
     @PostMapping("/bundle/items/list")
     public Result<List<ProductBundleItem>> listBundleItems(@RequestBody Map<String, Object> params) {
-        Long bundleProductId = params.get("bundleProductId") != null
-                ? Long.valueOf(params.get("bundleProductId").toString()) : null;
+        Long bundleProductId = ParamUtils.getLong(params.get("bundleProductId"));
         if (bundleProductId == null) return Result.error("bundleProductId不能为空");
         return inventoryService.listBundleItems(bundleProductId);
     }
@@ -168,8 +167,7 @@ public class AdminInventoryController {
     @Operation(summary = "检查套餐库存")
     @PostMapping("/bundle/check-stock")
     public Result<String> checkBundleStock(@RequestBody Map<String, Object> params) {
-        Long bundleProductId = params.get("bundleProductId") != null
-                ? Long.valueOf(params.get("bundleProductId").toString()) : null;
+        Long bundleProductId = ParamUtils.getLong(params.get("bundleProductId"));
         Integer quantity = params.get("quantity") != null
                 ? Integer.valueOf(params.get("quantity").toString()) : 1;
         if (bundleProductId == null) return Result.error("bundleProductId不能为空");
@@ -182,8 +180,8 @@ public class AdminInventoryController {
     @PostMapping("/outbound/create")
     public Result<String> createManualOutbound(@RequestBody Map<String, Object> params,
                                                 @RequestAttribute("userId") Long adminId) {
-        Long productId = params.get("productId") != null ? Long.valueOf(params.get("productId").toString()) : null;
-        Long skuId = params.get("skuId") != null ? Long.valueOf(params.get("skuId").toString()) : null;
+        Long productId = ParamUtils.getLong(params.get("productId"));
+        Long skuId = ParamUtils.getLong(params.get("skuId"));
         Integer quantity = params.get("quantity") != null ? Integer.valueOf(params.get("quantity").toString()) : null;
         String reason = params.get("reason") != null ? params.get("reason").toString() : null;
         String remark = (String) params.get("remark");

+ 3 - 2
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminNoticeController.java

@@ -12,6 +12,7 @@ import javax.annotation.Resource;
 import java.util.Date;
 import java.util.List;
 import com.etotem.cfc.util.SortUtil;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "公告管理", description = "平台公告的增删改查")
 @RestController
@@ -90,7 +91,7 @@ public class AdminNoticeController {
     @Operation(summary = "删除公告(软删)")
     @PostMapping("/delete")
     public Result<String> delete(@RequestBody java.util.Map<String, Object> body) {
-        Long id = Long.valueOf(body.get("id").toString());
+        Long id = ParamUtils.getLong(body.get("id"));
         Notice notice = noticeMapper.selectById(id);
         if (notice == null) return Result.error("公告不存在");
         notice.setStatus("deleted");
@@ -102,7 +103,7 @@ public class AdminNoticeController {
     @Operation(summary = "置顶(将指定公告移到最前)")
     @PostMapping("/pin")
     public Result<String> pin(@RequestBody java.util.Map<String, Object> body) {
-        Long id = Long.valueOf(body.get("id").toString());
+        Long id = ParamUtils.getLong(body.get("id"));
         Notice notice = noticeMapper.selectById(id);
         if (notice == null) return Result.error("公告不存在");
         notice.setCreatedAt(new Date());

+ 90 - 0
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminNotificationTemplateController.java

@@ -0,0 +1,90 @@
+package com.etotem.cfc.controller.admin;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.etotem.cfc.common.Result;
+import com.etotem.cfc.entity.NotificationTemplate;
+import com.etotem.cfc.mapper.NotificationTemplateMapper;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 管理端-通知模板 CRUD(改版v1,W3)
+ * report_ready / reward_granted / system 文案配置,支持占位符 {domainName} {reward}
+ */
+@Tag(name = "管理端-通知模板", description = "通知模板 CRUD 管理")
+@RestController
+@RequestMapping("/api/admin/notification-template")
+public class AdminNotificationTemplateController {
+
+    @Resource
+    private NotificationTemplateMapper notificationTemplateMapper;
+
+    @Operation(summary = "通知模板列表")
+    @PostMapping("/list")
+    public Result<List<NotificationTemplate>> list() {
+        LambdaQueryWrapper<NotificationTemplate> wrapper = new LambdaQueryWrapper<NotificationTemplate>()
+                .orderByAsc(NotificationTemplate::getType)
+                .orderByAsc(NotificationTemplate::getId);
+        return Result.success(notificationTemplateMapper.selectList(wrapper));
+    }
+
+    @Operation(summary = "新增/更新通知模板")
+    @PostMapping("/save")
+    public Result<NotificationTemplate> save(@RequestBody NotificationTemplate template, @RequestAttribute("userId") Long userId) {
+        if (template.getType() == null || template.getType().isEmpty()) {
+            return Result.error("类型不能为空");
+        }
+        if (template.getTitle() == null || template.getTitle().isEmpty()) {
+            return Result.error("标题不能为空");
+        }
+        if (template.getContent() == null || template.getContent().isEmpty()) {
+            return Result.error("内容不能为空");
+        }
+        // 类型唯一性校验
+        NotificationTemplate exists = notificationTemplateMapper.selectOne(
+                new LambdaQueryWrapper<NotificationTemplate>()
+                        .eq(NotificationTemplate::getType, template.getType())
+                        .last("LIMIT 1"));
+        if (exists != null && (template.getId() == null || !exists.getId().equals(template.getId()))) {
+            return Result.error("类型已存在: " + template.getType());
+        }
+
+        Date now = new Date();
+        if (template.getId() == null) {
+            if (template.getStatus() == null) {
+                template.setStatus(1);
+            }
+            if (template.getChannels() == null || template.getChannels().isEmpty()) {
+                template.setChannels("in_app");
+            }
+            template.setCreatedAt(now);
+            template.setUpdatedAt(now);
+            notificationTemplateMapper.insert(template);
+        } else {
+            template.setUpdatedAt(now);
+            notificationTemplateMapper.updateById(template);
+        }
+        return Result.success(template);
+    }
+
+    @Operation(summary = "删除通知模板")
+    @PostMapping("/delete")
+    public Result<Void> delete(@RequestBody Map<String, Object> params, @RequestAttribute("userId") Long userId) {
+        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        if (id == null) {
+            return Result.error("缺少 id");
+        }
+        notificationTemplateMapper.deleteById(id);
+        return Result.success(null);
+    }
+}

+ 4 - 3
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminPeriodicServiceController.java

@@ -12,6 +12,7 @@ import javax.annotation.Resource;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "管理端-周期性服务配置")
 @RestController
@@ -32,7 +33,7 @@ public class AdminPeriodicServiceController {
     @Operation(summary = "获取单个周期性服务配置")
     @PostMapping("/detail")
     public Result<PeriodicService> detail(@RequestBody Map<String, Object> params) {
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         PeriodicService config = periodicServiceMapper.selectById(id);
         if (config == null) return Result.error("配置不存在");
         return Result.success(config);
@@ -61,7 +62,7 @@ public class AdminPeriodicServiceController {
     @Operation(summary = "删除周期性服务配置")
     @PostMapping("/delete")
     public Result<String> delete(@RequestBody Map<String, Object> params) {
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         periodicServiceMapper.deleteById(id);
         return Result.success("删除成功");
     }
@@ -69,7 +70,7 @@ public class AdminPeriodicServiceController {
     @Operation(summary = "切换启用/禁用状态")
     @PostMapping("/toggle")
     public Result<String> toggle(@RequestBody Map<String, Object> params) {
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         PeriodicService config = periodicServiceMapper.selectById(id);
         if (config == null) return Result.error("配置不存在");
         config.setEnabled(config.getEnabled() != null && config.getEnabled() == 1 ? 0 : 1);

+ 2 - 1
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminPlanRuleController.java

@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.util.List;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "管理端-方案规则", description = "方案生成规则 CRUD")
 @RestController
@@ -34,7 +35,7 @@ public class AdminPlanRuleController {
     @Operation(summary = "删除规则")
     @PostMapping("/delete")
     public Result<Void> delete(@RequestBody java.util.Map<String, Object> params) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) return Result.error("id不能为空");
         ruleService.deleteRule(id);
         return Result.success(null);

+ 2 - 1
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminProblemDomainController.java

@@ -16,6 +16,7 @@ import javax.annotation.Resource;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 /**
  * 管理端-问题域 CRUD(改版v1,W1)
@@ -83,7 +84,7 @@ public class AdminProblemDomainController {
     @Operation(summary = "删除问题域")
     @PostMapping("/delete")
     public Result<Void> delete(@RequestBody Map<String, Object> params, @RequestAttribute("userId") Long userId) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) {
             return Result.error("缺少 id");
         }

+ 6 - 15
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminProductController.java

@@ -17,6 +17,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
 import com.etotem.cfc.util.SortUtil;
+import com.etotem.cfc.util.ParamUtils;
 
 /**
  * 管理端-商品管理控制器
@@ -93,9 +94,7 @@ if (params.get("distributionSystemId") != null) {
     @Operation(summary = "审核商品")
     @PostMapping("/review")
     public Result<String> review(@RequestBody Map<String, Object> params) {
-        Long productId = params.get("productId") != null
-                ? Long.valueOf(params.get("productId").toString())
-                : null;
+        Long productId = ParamUtils.getLong(params.get("productId"));
         String action = (String) params.get("action");
         String reason = (String) params.get("reason");
 
@@ -112,9 +111,7 @@ if (params.get("distributionSystemId") != null) {
     @Operation(summary = "商品上下架")
     @PostMapping("/shelve")
     public Result<String> shelve(@RequestBody Map<String, Object> params) {
-        Long productId = params.get("productId") != null
-                ? Long.valueOf(params.get("productId").toString())
-                : null;
+        Long productId = ParamUtils.getLong(params.get("productId"));
         Boolean shelve = params.get("shelve") != null
                 ? (Boolean) params.get("shelve")
                 : null;
@@ -132,9 +129,7 @@ if (params.get("distributionSystemId") != null) {
     @Operation(summary = "商品详情")
     @PostMapping("/detail")
     public Result<ProductDTO> detail(@RequestBody Map<String, Object> params) {
-        Long productId = params.get("productId") != null
-                ? Long.valueOf(params.get("productId").toString())
-                : null;
+        Long productId = ParamUtils.getLong(params.get("productId"));
         if (productId == null) {
             return Result.error("productId不能为空");
         }
@@ -166,9 +161,7 @@ if (params.get("distributionSystemId") != null) {
     @Operation(summary = "复制商品")
     @PostMapping("/copy")
     public Result<ProductDTO> copy(@RequestBody Map<String, Object> params) {
-        Long productId = params.get("productId") != null
-                ? Long.valueOf(params.get("productId").toString())
-                : null;
+        Long productId = ParamUtils.getLong(params.get("productId"));
         if (productId == null) {
             return Result.error("productId不能为空");
         }
@@ -178,9 +171,7 @@ if (params.get("distributionSystemId") != null) {
     @Operation(summary = "删除商品")
     @PostMapping("/delete")
     public Result<String> delete(@RequestBody Map<String, Object> params) {
-        Long productId = params.get("productId") != null
-                ? Long.valueOf(params.get("productId").toString())
-                : null;
+        Long productId = ParamUtils.getLong(params.get("productId"));
         if (productId == null) {
             return Result.error("productId不能为空");
         }

+ 5 - 4
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminProductPpointController.java

@@ -13,6 +13,7 @@ import javax.annotation.Resource;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/admin/product-ppoint")
@@ -26,7 +27,7 @@ public class AdminProductPpointController {
         int page = params.get("page") != null ? ((Number) params.get("page")).intValue() : 1;
         int size = params.get("size") != null ? ((Number) params.get("size")).intValue() : 20;
         String keyword = (String) params.get("keyword");
-        Long productId = params.get("productId") != null ? Long.valueOf(params.get("productId").toString()) : null;
+        Long productId = ParamUtils.getLong(params.get("productId"));
         @SuppressWarnings("unchecked")
         List<Map<String, String>> sortSpecs = params.get("sort") != null
                 ? (List<Map<String, String>>) params.get("sort")
@@ -39,7 +40,7 @@ public class AdminProductPpointController {
 
     @PostMapping("/save")
     public Result<Void> save(@RequestBody Map<String, Object> params) {
-        Long productId = Long.valueOf(params.get("productId").toString());
+        Long productId = ParamUtils.getLong(params.get("productId"));
         Integer ppoint = Integer.valueOf(params.get("ppoint").toString());
         String startDateStr = (String) params.get("startDate");
         String endDateStr = (String) params.get("endDate");
@@ -68,14 +69,14 @@ public class AdminProductPpointController {
 
     @PostMapping("/delete")
     public Result<Void> delete(@RequestBody Map<String, Object> params) {
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         ppointService.deleteById(id);
         return Result.success(null);
     }
 
     @PostMapping("/by-product")
     public Result<List<ProductPpoint>> byProduct(@RequestBody Map<String, Object> params) {
-        Long productId = Long.valueOf(params.get("productId").toString());
+        Long productId = ParamUtils.getLong(params.get("productId"));
         List<ProductPpoint> records = ppointService.getByProductId(productId);
         return Result.success(records);
     }

+ 4 - 3
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminPromotionTierController.java

@@ -14,6 +14,7 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/admin/promotion-tier")
@@ -37,7 +38,7 @@ public class AdminPromotionTierController {
 
     @PostMapping("/get")
     public Result<PromotionTierConfig> get(@RequestBody Map<String, Object> params) {
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         return Result.success(configMapper.selectById(id));
     }
 
@@ -59,7 +60,7 @@ public class AdminPromotionTierController {
 
     @PostMapping("/delete")
     public Result<String> delete(@RequestBody Map<String, Object> params) {
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         configMapper.deleteById(id);
         return Result.success("已删除");
     }
@@ -72,7 +73,7 @@ public class AdminPromotionTierController {
 
     @PostMapping("/user-tier")
     public Result<Map<String, Object>> getUserTier(@RequestBody Map<String, Object> params) {
-        Long userId = Long.valueOf(params.get("userId").toString());
+        Long userId = ParamUtils.getLong(params.get("userId"));
         PromotionTier tier = promotionTierService.getCurrentTier(userId);
         String evaluatedTier = evalService.evaluateTier(userId);
         Map<String, Object> result = new HashMap<>();

+ 2 - 1
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminRecipeController.java

@@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "\u7ba1\u7406\u7aef-\u98df\u8c31\u7ba1\u7406")
 @RestController
@@ -43,7 +44,7 @@ public class AdminRecipeController {
     @Operation(summary = "\u5220\u9664\u98df\u8c31")
     @PostMapping("/delete")
     public Result<String> delete(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) return Result.error("id\u4e0d\u80fd\u4e3a\u7a7a");
         recipeService.delete(id);
         return Result.success("ok");

+ 2 - 1
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminSeasonalController.java

@@ -11,6 +11,7 @@ import javax.annotation.Resource;
 import java.time.LocalDate;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "\u7ba1\u7406\u7aef-\u5e94\u5b63\u98df\u6750\u914d\u7f6e")
 @RestController
@@ -41,7 +42,7 @@ public class AdminSeasonalController {
     @Operation(summary = "\u5220\u9664\u5e94\u5b63\u6620\u5c04")
     @PostMapping("/delete")
     public Result<String> delete(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) return Result.error("id\u4e0d\u80fd\u4e3a\u7a7a");
         seasonalFoodService.delete(id);
         return Result.success("ok");

+ 2 - 1
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminSupplierController.java

@@ -14,6 +14,7 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 import com.etotem.cfc.util.SortUtil;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "管理端-电商供应商管理")
 @RestController
@@ -68,7 +69,7 @@ public class AdminSupplierController {
     @Operation(summary = "删除供应商")
     @PostMapping("/delete")
     public Result<String> delete(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) return Result.error("id不能为空");
         ecomSupplierMapper.deleteById(id);
         return Result.success("ok");

+ 2 - 1
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminSurveyController.java

@@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "管理端-调研模板", description = "调研模板管理")
 @RestController
@@ -35,7 +36,7 @@ public class AdminSurveyController {
     @Operation(summary = "删除调研模板")
     @PostMapping("/delete")
     public Result<Void> delete(@RequestBody Map<String, Object> params, @RequestAttribute("userId") Long userId) {
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         surveyService.deleteTemplate(id, userId);
         return Result.success(null);
     }

+ 5 - 4
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminUnlockGateController.java

@@ -16,6 +16,7 @@ import javax.annotation.Resource;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 /**
  * 管理端:通关解锁关卡配置
@@ -76,7 +77,7 @@ public class AdminUnlockGateController {
     @PostMapping("/sort")
     public Result<Boolean> sort(@RequestBody List<Map<String, Object>> sortList) {
         for (Map<String, Object> item : sortList) {
-            Long id = Long.valueOf(item.get("id").toString());
+            Long id = ParamUtils.getLong(item.get("id"));
             Integer sortOrder = Integer.valueOf(item.get("sortOrder").toString());
             UnlockGate gate = unlockGateMapper.selectById(id);
             if (gate != null) {
@@ -91,7 +92,7 @@ public class AdminUnlockGateController {
     @Operation(summary = "启停关卡")
     @PostMapping("/toggle")
     public Result<Boolean> toggle(@RequestBody Map<String, Object> body) {
-        Long id = Long.valueOf(body.get("id").toString());
+        Long id = ParamUtils.getLong(body.get("id"));
         Integer enabled = Integer.valueOf(body.get("enabled").toString());
         UnlockGate gate = unlockGateMapper.selectById(id);
         if (gate == null) return Result.error("关卡不存在");
@@ -105,7 +106,7 @@ public class AdminUnlockGateController {
     @PostMapping("/reset-family")
     @Transactional
     public Result<Boolean> resetFamily(@RequestBody Map<String, Object> body) {
-        Long familyId = Long.valueOf(body.get("familyId").toString());
+        Long familyId = ParamUtils.getLong(body.get("familyId"));
         // 删除该家庭所有进度记录,使其重新开始
         familyGateProgressMapper.delete(
                 new LambdaQueryWrapper<FamilyGateProgress>().eq(FamilyGateProgress::getFamilyId, familyId));
@@ -115,7 +116,7 @@ public class AdminUnlockGateController {
     @Operation(summary = "查看某家庭关卡进度")
     @PostMapping("/family-progress")
     public Result<List<FamilyGateProgress>> getFamilyProgress(@RequestBody Map<String, Object> body) {
-        Long familyId = Long.valueOf(body.get("familyId").toString());
+        Long familyId = ParamUtils.getLong(body.get("familyId"));
         List<FamilyGateProgress> list = familyGateProgressMapper.selectList(
                 new LambdaQueryWrapper<FamilyGateProgress>().eq(FamilyGateProgress::getFamilyId, familyId));
         return Result.success(list);

+ 2 - 3
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminVendorController.java

@@ -12,6 +12,7 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 import com.etotem.cfc.util.SortUtil;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/admin/vendor")
@@ -60,9 +61,7 @@ public class AdminVendorController {
      */
     @PostMapping("/review")
     public Result<String> review(@RequestBody Map<String, Object> params) {
-        Long userId = params.get("userId") != null
-                ? Long.valueOf(params.get("userId").toString())
-                : null;
+        Long userId = ParamUtils.getLong(params.get("userId"));
         String vendorStatus = (String) params.get("vendorStatus");
         String rejectReason = (String) params.getOrDefault("rejectReason", "");
 

+ 11 - 10
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminVirtualTeamController.java

@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "管理端-虚拟团队管理")
 @RestController
@@ -43,7 +44,7 @@ public class AdminVirtualTeamController {
     @Operation(summary = "启用/禁用销售体系")
     @PostMapping("/toggle")
     public Result<String> toggle(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) return Result.error("id不能为空");
         return distributionService.toggleSystem(id);
     }
@@ -51,7 +52,7 @@ public class AdminVirtualTeamController {
     @Operation(summary = "团队成员列表(含用户信息)")
     @PostMapping("/members")
     public Result<List<Map<String, Object>>> members(@RequestBody Map<String, Object> params) {
-        Long systemId = params.get("systemId") != null ? Long.valueOf(params.get("systemId").toString()) : null;
+        Long systemId = ParamUtils.getLong(params.get("systemId"));
         if (systemId == null) return Result.error("systemId不能为空");
         return distributionService.getTeamMembers(systemId);
     }
@@ -59,9 +60,9 @@ public class AdminVirtualTeamController {
     @Operation(summary = "添加团队成员")
     @PostMapping("/add-member")
     public Result<Void> addMember(@RequestBody Map<String, Object> params) {
-        Long systemId = params.get("systemId") != null ? Long.valueOf(params.get("systemId").toString()) : null;
-        Long userId = params.get("userId") != null ? Long.valueOf(params.get("userId").toString()) : null;
-        Long parentId = params.get("parentId") != null ? Long.valueOf(params.get("parentId").toString()) : null;
+        Long systemId = ParamUtils.getLong(params.get("systemId"));
+        Long userId = ParamUtils.getLong(params.get("userId"));
+        Long parentId = ParamUtils.getLong(params.get("parentId"));
         if (systemId == null) return Result.error("systemId不能为空");
         if (userId == null) return Result.error("userId不能为空");
         return distributionService.addRelation(systemId, userId, parentId);
@@ -70,7 +71,7 @@ public class AdminVirtualTeamController {
     @Operation(summary = "移除团队成员")
     @PostMapping("/remove-member")
     public Result<String> removeMember(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) return Result.error("id不能为空");
         return distributionService.removeRelation(id);
     }
@@ -78,8 +79,8 @@ public class AdminVirtualTeamController {
     @Operation(summary = "调整成员位置/上级")
     @PostMapping("/update-member")
     public Result<String> updateMember(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
-        Long parentId = params.get("parentId") != null ? Long.valueOf(params.get("parentId").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
+        Long parentId = ParamUtils.getLong(params.get("parentId"));
         if (id == null) return Result.error("id不能为空");
         return distributionService.updateMemberTeam(id, params.containsKey("parentId") ? parentId : null);
     }
@@ -87,7 +88,7 @@ public class AdminVirtualTeamController {
     @Operation(summary = "用户所属团队列表")
     @PostMapping("/user-teams")
     public Result<List<DistributionSystem>> userTeams(@RequestBody Map<String, Object> params) {
-        Long userId = params.get("userId") != null ? Long.valueOf(params.get("userId").toString()) : null;
+        Long userId = ParamUtils.getLong(params.get("userId"));
         if (userId == null) return Result.error("userId不能为空");
         return distributionService.getUserTeams(userId);
     }
@@ -95,7 +96,7 @@ public class AdminVirtualTeamController {
     @Operation(summary = "团队树形结构")
     @PostMapping("/tree")
     public Result<List<Map<String, Object>>> tree(@RequestBody Map<String, Object> params) {
-        Long systemId = params.get("systemId") != null ? Long.valueOf(params.get("systemId").toString()) : null;
+        Long systemId = ParamUtils.getLong(params.get("systemId"));
         if (systemId == null) return Result.error("systemId不能为空");
         return distributionService.getTeamTree(systemId);
     }

+ 5 - 4
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/CommissionDistController.java

@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 /**
  * P点分润记录管理
@@ -31,8 +32,8 @@ public class CommissionDistController {
     public Result<Page<CommissionDistLog>> list(@RequestBody Map<String, Object> params) {
         int page = params.get("page") != null ? ((Number) params.get("page")).intValue() : 1;
         int size = params.get("size") != null ? ((Number) params.get("size")).intValue() : 20;
-        Long buyerId = params.get("buyerId") != null ? Long.valueOf(params.get("buyerId").toString()) : null;
-        Long levelUserId = params.get("levelUserId") != null ? Long.valueOf(params.get("levelUserId").toString()) : null;
+        Long buyerId = ParamUtils.getLong(params.get("buyerId"));
+        Long levelUserId = ParamUtils.getLong(params.get("levelUserId"));
 
         Page<CommissionDistLog> pageParam = new Page<>(page, size);
         Page<CommissionDistLog> result = commissionDistService.adminPage(pageParam, buyerId, levelUserId);
@@ -44,7 +45,7 @@ public class CommissionDistController {
      */
     @PostMapping("/user-logs")
     public Result<List<CommissionDistLog>> userLogs(@RequestBody Map<String, Object> params) {
-        Long userId = Long.valueOf(params.get("userId").toString());
+        Long userId = ParamUtils.getLong(params.get("userId"));
         List<CommissionDistLog> logs = commissionDistService.getUserDistLogs(userId, 1, 50);
         return Result.success(logs);
     }
@@ -54,7 +55,7 @@ public class CommissionDistController {
      */
     @PostMapping("/user-total")
     public Result<Integer> userTotal(@RequestBody Map<String, Object> params) {
-        Long userId = Long.valueOf(params.get("userId").toString());
+        Long userId = ParamUtils.getLong(params.get("userId"));
         int total = commissionDistService.getTotalDistributedPpoint(userId);
         return Result.success(total);
     }

+ 2 - 1
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/EcomSupplierController.java

@@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "管理端-电商供应商")
 @RestController
@@ -49,7 +50,7 @@ public class EcomSupplierController {
     @Operation(summary = "删除供应商")
     @PostMapping("/delete")
     public Result<String> delete(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         return supplierService.delete(id);
     }
 }

+ 3 - 2
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/FamilyAttributeController.java

@@ -7,6 +7,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/family/attributes")
@@ -23,7 +24,7 @@ public class FamilyAttributeController {
 
     @PostMapping("/get")
     public Result<FamilyMemberAttributes> get(@RequestBody Map<String, Object> params) {
-        Long memberId = Long.valueOf(params.get("memberId").toString());
+        Long memberId = ParamUtils.getLong(params.get("memberId"));
         String memberType = (String) params.get("memberType");
         FamilyMemberAttributes attr = familyMemberAttributeService.getByMember(memberId, memberType);
         return Result.success(attr);
@@ -31,7 +32,7 @@ public class FamilyAttributeController {
 
     @PostMapping("/calculate")
     public Result<FamilyMemberAttributes> calculate(@RequestBody Map<String, Object> params) {
-        Long memberId = Long.valueOf(params.get("memberId").toString());
+        Long memberId = ParamUtils.getLong(params.get("memberId"));
         String memberType = (String) params.get("memberType");
 
         FamilyMemberAttributes attrs = familyMemberAttributeService.getByMember(memberId, memberType);

+ 3 - 2
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/FileRecordController.java

@@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.util.*;
 import java.util.stream.Collectors;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/admin/file-record")
@@ -119,7 +120,7 @@ public class FileRecordController {
     public Result<String> update(@RequestBody Map<String, Object> params,
                                  @RequestAttribute("role") String role) {
         if (!"admin".equals(role)) return Result.error("无权限");
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         FileRecord record = fileRecordMapper.selectById(id);
         if (record == null) return Result.error("文件不存在");
         if (params.get("description") != null) record.setDescription(params.get("description").toString());
@@ -142,7 +143,7 @@ public class FileRecordController {
     public Result<String> deleteFile(@RequestBody Map<String, Object> params,
                                      @RequestAttribute("role") String role) {
         if (!"admin".equals(role)) return Result.error("无权限");
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         FileRecord record = fileRecordMapper.selectById(id);
         if (record == null) return Result.error("文件不存在");
         try { storageService.deleteFile(record.getUrl()); }

+ 3 - 2
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/IndicatorAdminController.java

@@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/admin/indicator")
@@ -42,7 +43,7 @@ public class IndicatorAdminController {
 
     @PostMapping("/delete")
     public Result<?> delete(@RequestBody Map<String, Object> params) {
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         indicatorService.deleteDefinition(id);
         return Result.success("删除成功");
     }
@@ -50,7 +51,7 @@ public class IndicatorAdminController {
     @PostMapping("/values/list")
     public Result<?> listValues(@RequestBody Map<String, Object> params) {
         String sourceType = (String) params.get("sourceType");
-        Long sourceId = Long.valueOf(params.get("sourceId").toString());
+        Long sourceId = ParamUtils.getLong(params.get("sourceId"));
         List<IndicatorValue> values = indicatorService.listValues(sourceType, sourceId);
         return Result.success(values);
     }

+ 10 - 9
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/PpointConfigAdminController.java

@@ -15,6 +15,7 @@ import javax.annotation.Resource;
 import java.text.SimpleDateFormat;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 /**
  * P点配置管理(品类级比例 + 商品级固定值)
@@ -45,7 +46,7 @@ public class PpointConfigAdminController {
 
     @PostMapping("/category/save")
     public Result<Void> categorySave(@RequestBody Map<String, Object> params) {
-        Long categoryId = Long.valueOf(params.get("categoryId").toString());
+        Long categoryId = ParamUtils.getLong(params.get("categoryId"));
         Integer ratio = Integer.valueOf(params.get("ratio").toString());
         String startDateStr = (String) params.get("startDate");
         String endDateStr = (String) params.get("endDate");
@@ -74,14 +75,14 @@ public class PpointConfigAdminController {
 
     @PostMapping("/category/delete")
     public Result<Void> categoryDelete(@RequestBody Map<String, Object> params) {
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         ppointConfigService.deleteCategoryRatio(id);
         return Result.success(null);
     }
 
     @PostMapping("/category/by-category")
     public Result<List<CategoryPpoint>> categoryByCategory(@RequestBody Map<String, Object> params) {
-        Long categoryId = Long.valueOf(params.get("categoryId").toString());
+        Long categoryId = ParamUtils.getLong(params.get("categoryId"));
         List<CategoryPpoint> records = ppointConfigService.getByCategoryId(categoryId);
         return Result.success(records);
     }
@@ -93,7 +94,7 @@ public class PpointConfigAdminController {
         int page = params.get("page") != null ? ((Number) params.get("page")).intValue() : 1;
         int size = params.get("size") != null ? ((Number) params.get("size")).intValue() : 20;
         String keyword = (String) params.get("keyword");
-        Long productId = params.get("productId") != null ? Long.valueOf(params.get("productId").toString()) : null;
+        Long productId = ParamUtils.getLong(params.get("productId"));
 
         Page<ProductPpoint> pageParam = new Page<>(page, size);
         Map<String, Object> result = ppointService.adminList(pageParam, keyword, productId, null);
@@ -102,7 +103,7 @@ public class PpointConfigAdminController {
 
     @PostMapping("/product/save")
     public Result<Void> productSave(@RequestBody Map<String, Object> params) {
-        Long productId = Long.valueOf(params.get("productId").toString());
+        Long productId = ParamUtils.getLong(params.get("productId"));
         Integer ppoint = Integer.valueOf(params.get("ppoint").toString());
         String startDateStr = (String) params.get("startDate");
         String endDateStr = (String) params.get("endDate");
@@ -131,14 +132,14 @@ public class PpointConfigAdminController {
 
     @PostMapping("/product/delete")
     public Result<Void> productDelete(@RequestBody Map<String, Object> params) {
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         ppointService.deleteById(id);
         return Result.success(null);
     }
 
     @PostMapping("/product/by-product")
     public Result<List<ProductPpoint>> productByProduct(@RequestBody Map<String, Object> params) {
-        Long productId = Long.valueOf(params.get("productId").toString());
+        Long productId = ParamUtils.getLong(params.get("productId"));
         List<ProductPpoint> records = ppointService.getByProductId(productId);
         return Result.success(records);
     }
@@ -150,8 +151,8 @@ public class PpointConfigAdminController {
      */
     @PostMapping("/effective")
     public Result<Integer> getEffectivePpoint(@RequestBody Map<String, Object> params) {
-        Long productId = Long.valueOf(params.get("productId").toString());
-        Long categoryId = params.get("categoryId") != null ? Long.valueOf(params.get("categoryId").toString()) : null;
+        Long productId = ParamUtils.getLong(params.get("productId"));
+        Long categoryId = ParamUtils.getLong(params.get("categoryId"));
         int ppoint = ppointConfigService.getEffectivePpoint(productId, categoryId);
         return Result.success(ppoint);
     }

+ 5 - 4
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/ServiceContentController.java

@@ -15,6 +15,7 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @Tag(name = "服务内容管理", description = "系统服务内容CRUD")
 @RestController
@@ -30,7 +31,7 @@ public class ServiceContentController {
     @PostMapping("/list")
     @Operation(summary = "获取服务内容列表")
     public Result<List<ServiceContent>> list(@RequestBody Map<String, Object> params) {
-        Long typeId = params.get("typeId") != null ? Long.valueOf(params.get("typeId").toString()) : null;
+        Long typeId = ParamUtils.getLong(params.get("typeId"));
         String status = params.get("status") != null ? params.get("status").toString() : null;
 
         LambdaQueryWrapper<ServiceContent> wrapper = new LambdaQueryWrapper<>();
@@ -62,7 +63,7 @@ public class ServiceContentController {
     @PostMapping("/{id}")
     @Operation(summary = "获取服务内容详情")
     public Result<ServiceContent> getById(@RequestBody Map<String, Object> params) {
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         ServiceContent content = serviceContentService.getById(id);
         return content != null ? Result.success(content) : Result.error("不存在");
     }
@@ -80,7 +81,7 @@ public class ServiceContentController {
     @PostMapping("/update")
     @Operation(summary = "更新服务内容")
     public Result<ServiceContent> update(@RequestBody Map<String, Object> params) {
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         ServiceContent serviceContent = new ServiceContent();
         serviceContent.setId(id);
         serviceContent.setTitle(params.get("title") != null ? params.get("title").toString() : null);
@@ -98,7 +99,7 @@ public class ServiceContentController {
     @PostMapping("/delete")
     @Operation(summary = "删除服务内容")
     public Result<Void> delete(@RequestBody Map<String, Object> params) {
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         boolean success = serviceContentService.deleteContent(id);
         return success ? Result.success(null) : Result.error("删除失败");
     }

+ 4 - 9
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/SupplierProductController.java

@@ -18,6 +18,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
+import com.etotem.cfc.util.ParamUtils;
 
 /**
  * 供应商管理员 - 商品管理控制器
@@ -140,9 +141,7 @@ public class SupplierProductController {
             return Result.error("您没有关联的供应商体系");
         }
 
-        Long productId = params.get("productId") != null
-                ? Long.valueOf(params.get("productId").toString())
-                : null;
+        Long productId = ParamUtils.getLong(params.get("productId"));
         if (productId == null) {
             return Result.error("productId不能为空");
         }
@@ -168,9 +167,7 @@ public class SupplierProductController {
             return Result.error("您没有关联的供应商体系");
         }
 
-        Long productId = params.get("productId") != null
-                ? Long.valueOf(params.get("productId").toString())
-                : null;
+        Long productId = ParamUtils.getLong(params.get("productId"));
         if (productId == null) {
             return Result.error("productId不能为空");
         }
@@ -196,9 +193,7 @@ public class SupplierProductController {
             return Result.error("您没有关联的供应商体系");
         }
 
-        Long productId = params.get("productId") != null
-                ? Long.valueOf(params.get("productId").toString())
-                : null;
+        Long productId = ParamUtils.getLong(params.get("productId"));
         Boolean shelve = params.get("shelve") != null
                 ? (Boolean) params.get("shelve")
                 : null;

+ 21 - 20
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/SupplyHierarchyController.java

@@ -21,6 +21,7 @@ import java.util.List;
 import java.util.HashSet;
 import java.util.HashSet;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/admin/supply-hierarchy")
@@ -41,9 +42,9 @@ public class SupplyHierarchyController {
     @PostMapping("/set")
     public Result<Void> setHierarchy(@RequestBody Map<String, Object> params) {
         try {
-            Long systemId = params.get("systemId") != null ? Long.valueOf(params.get("systemId").toString()) : null;
-            Long parentId = params.get("parentId") != null ? Long.valueOf(params.get("parentId").toString()) : null;
-            Long childId = params.get("childId") != null ? Long.valueOf(params.get("childId").toString()) : null;
+            Long systemId = ParamUtils.getLong(params.get("systemId"));
+            Long parentId = ParamUtils.getLong(params.get("parentId"));
+            Long childId = ParamUtils.getLong(params.get("childId"));
             if (systemId == null || parentId == null || childId == null) {
                 return Result.error("参数不完整");
             }
@@ -59,8 +60,8 @@ public class SupplyHierarchyController {
     @PostMapping("/remove")
     public Result<Void> removeRelation(@RequestBody Map<String, Object> params) {
         try {
-            Long systemId = params.get("systemId") != null ? Long.valueOf(params.get("systemId").toString()) : null;
-            Long childId = params.get("childId") != null ? Long.valueOf(params.get("childId").toString()) : null;
+            Long systemId = ParamUtils.getLong(params.get("systemId"));
+            Long childId = ParamUtils.getLong(params.get("childId"));
             if (systemId == null || childId == null) {
                 return Result.error("参数不完整");
             }
@@ -73,8 +74,8 @@ public class SupplyHierarchyController {
 
     @PostMapping("/direct-children")
     public Result<List<User>> getDirectChildren(@RequestBody Map<String, Object> params) {
-        Long systemId = params.get("systemId") != null ? Long.valueOf(params.get("systemId").toString()) : null;
-        Long parentId = params.get("parentId") != null ? Long.valueOf(params.get("parentId").toString()) : null;
+        Long systemId = ParamUtils.getLong(params.get("systemId"));
+        Long parentId = ParamUtils.getLong(params.get("parentId"));
         if (systemId == null || parentId == null) {
             return Result.error("参数不完整");
         }
@@ -84,8 +85,8 @@ public class SupplyHierarchyController {
 
     @PostMapping("/all-children")
     public Result<List<User>> getAllChildren(@RequestBody Map<String, Object> params) {
-        Long systemId = params.get("systemId") != null ? Long.valueOf(params.get("systemId").toString()) : null;
-        Long parentId = params.get("parentId") != null ? Long.valueOf(params.get("parentId").toString()) : null;
+        Long systemId = ParamUtils.getLong(params.get("systemId"));
+        Long parentId = ParamUtils.getLong(params.get("parentId"));
         if (systemId == null || parentId == null) {
             return Result.error("参数不完整");
         }
@@ -95,8 +96,8 @@ public class SupplyHierarchyController {
 
     @PostMapping("/parent")
     public Result<User> getParent(@RequestBody Map<String, Object> params) {
-        Long systemId = params.get("systemId") != null ? Long.valueOf(params.get("systemId").toString()) : null;
-        Long userId = params.get("userId") != null ? Long.valueOf(params.get("userId").toString()) : null;
+        Long systemId = ParamUtils.getLong(params.get("systemId"));
+        Long userId = ParamUtils.getLong(params.get("userId"));
         if (systemId == null || userId == null) {
             return Result.error("参数不完整");
         }
@@ -106,8 +107,8 @@ public class SupplyHierarchyController {
 
     @PostMapping("/parent-chain")
     public Result<List<User>> getParentChain(@RequestBody Map<String, Object> params) {
-        Long systemId = params.get("systemId") != null ? Long.valueOf(params.get("systemId").toString()) : null;
-        Long userId = params.get("userId") != null ? Long.valueOf(params.get("userId").toString()) : null;
+        Long systemId = ParamUtils.getLong(params.get("systemId"));
+        Long userId = ParamUtils.getLong(params.get("userId"));
         if (systemId == null || userId == null) {
             return Result.error("参数不完整");
         }
@@ -117,7 +118,7 @@ public class SupplyHierarchyController {
 
     @PostMapping("/tree")
     public Result<List<Map<String, Object>>> getTree(@RequestBody Map<String, Object> params) {
-        Long systemId = params.get("systemId") != null ? Long.valueOf(params.get("systemId").toString()) : null;
+        Long systemId = ParamUtils.getLong(params.get("systemId"));
         if (systemId == null) {
             return Result.error("systemId 不能为空");
         }
@@ -181,8 +182,8 @@ public class SupplyHierarchyController {
 
     @PostMapping("/my")
     public Result<Map<String, Object>> getMyRelation(@RequestBody Map<String, Object> params) {
-        Long systemId = params.get("systemId") != null ? Long.valueOf(params.get("systemId").toString()) : null;
-        Long userId = params.get("userId") != null ? Long.valueOf(params.get("userId").toString()) : null;
+        Long systemId = ParamUtils.getLong(params.get("systemId"));
+        Long userId = ParamUtils.getLong(params.get("userId"));
         if (systemId == null || userId == null) {
             return Result.error("参数不完整");
         }
@@ -197,7 +198,7 @@ public class SupplyHierarchyController {
 
     @PostMapping("/change-requests")
     public Result<List<SupplyHierarchyChangeRequest>> getChangeRequests(@RequestBody Map<String, Object> params) {
-        Long systemId = params.get("systemId") != null ? Long.valueOf(params.get("systemId").toString()) : null;
+        Long systemId = ParamUtils.getLong(params.get("systemId"));
         String status = (String) params.get("status");
         List<SupplyHierarchyChangeRequest> requests = supplyHierarchyService.getChangeRequests(systemId, status);
         return Result.success(requests);
@@ -206,8 +207,8 @@ public class SupplyHierarchyController {
     @PostMapping("/change/apply")
     public Result<Void> applyChange(@RequestBody Map<String, Object> params) {
         try {
-            Long systemId = params.get("systemId") != null ? Long.valueOf(params.get("systemId").toString()) : null;
-            Long targetParentId = params.get("targetParentId") != null ? Long.valueOf(params.get("targetParentId").toString()) : null;
+            Long systemId = ParamUtils.getLong(params.get("systemId"));
+            Long targetParentId = ParamUtils.getLong(params.get("targetParentId"));
             String reason = (String) params.get("reason");
             if (systemId == null || targetParentId == null) {
                 return Result.error("参数不完整");
@@ -224,7 +225,7 @@ public class SupplyHierarchyController {
     @PostMapping("/change/review")
     public Result<Void> reviewChange(@RequestBody Map<String, Object> params) {
         try {
-            Long requestId = params.get("requestId") != null ? Long.valueOf(params.get("requestId").toString()) : null;
+            Long requestId = ParamUtils.getLong(params.get("requestId"));
             String status = (String) params.get("status");
             String rejectReason = (String) params.get("rejectReason");
             if (requestId == null || status == null) {

+ 4 - 4
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/SupplySettlementController.java

@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/admin/supply-settlement")
@@ -33,7 +34,7 @@ public class SupplySettlementController {
      */
     @PostMapping("/detail")
     public Result<SupplySettlement> detail(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) {
             return Result.error("id不能为空");
         }
@@ -45,8 +46,7 @@ public class SupplySettlementController {
      */
     @PostMapping("/detail-items")
     public Result<List<SupplySettlementDetail>> detailItems(@RequestBody Map<String, Object> params) {
-        Long settlementId = params.get("settlementId") != null
-                ? Long.valueOf(params.get("settlementId").toString()) : null;
+        Long settlementId = ParamUtils.getLong(params.get("settlementId"));
         if (settlementId == null) {
             return Result.error("settlementId不能为空");
         }
@@ -66,7 +66,7 @@ public class SupplySettlementController {
      */
     @PostMapping("/confirm")
     public Result<Void> confirm(@RequestBody Map<String, Object> params) {
-        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) {
             return Result.error("id不能为空");
         }

+ 8 - 7
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/SupplySystemController.java

@@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/admin/supply-system")
@@ -40,13 +41,13 @@ public class SupplySystemController {
 
     @PostMapping("/detail")
     public Result<SupplySystem> detail(@RequestBody Map<String, Object> params) {
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         return Result.success(supplySystemService.detail(id));
     }
 
     @PostMapping("/toggle-status")
     public Result<Void> toggleStatus(@RequestBody Map<String, Object> params) {
-        Long id = Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         boolean success = supplySystemService.toggleStatus(id);
         return success ? Result.success(null) : Result.error("操作失败");
     }
@@ -69,27 +70,27 @@ public class SupplySystemController {
 
     @PostMapping("/member/list")
     public Result<List<SupplySystemMember>> memberList(@RequestBody Map<String, Object> params) {
-        Long systemId = Long.valueOf(params.get("systemId").toString());
+        Long systemId = ParamUtils.getLong(params.get("systemId"));
         return Result.success(supplySystemService.memberList(systemId));
     }
 
     @PostMapping("/member/add")
     public Result<SupplySystemMember> addMember(@RequestBody Map<String, Object> params) {
-        Long systemId = Long.valueOf(params.get("systemId").toString());
-        Long userId = Long.valueOf(params.get("userId").toString());
+        Long systemId = ParamUtils.getLong(params.get("systemId"));
+        Long userId = ParamUtils.getLong(params.get("userId"));
         return Result.success(supplySystemService.addMember(systemId, userId));
     }
 
     @PostMapping("/member/remove")
     public Result<Void> removeMember(@RequestBody Map<String, Object> params) {
-        Long memberId = Long.valueOf(params.get("memberId").toString());
+        Long memberId = ParamUtils.getLong(params.get("memberId"));
         boolean success = supplySystemService.removeMember(memberId);
         return success ? Result.success(null) : Result.error("移除失败");
     }
 
     @PostMapping("/member/change-role")
     public Result<Void> changeRole(@RequestBody Map<String, Object> params) {
-        Long memberId = Long.valueOf(params.get("memberId").toString());
+        Long memberId = ParamUtils.getLong(params.get("memberId"));
         String role = (String) params.get("role");
         boolean success = supplySystemService.changeRole(memberId, role);
         return success ? Result.success(null) : Result.error("角色变更失败");

+ 2 - 1
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/VirtualGoodsConfigAdminController.java

@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import com.etotem.cfc.util.ParamUtils;
 
 @RestController
 @RequestMapping("/api/admin/virtual-goods")
@@ -45,7 +46,7 @@ public class VirtualGoodsConfigAdminController {
         if (!"admin".equals(role)) {
             return Result.error("无权限");
         }
-        Long id = params.get("id") == null ? null : Long.valueOf(params.get("id").toString());
+        Long id = ParamUtils.getLong(params.get("id"));
         if (id == null) {
             return Result.error("参数错误");
         }

部分文件因为文件数量过多而无法显示