Sfoglia il codice sorgente

fix(backend): 修复 ContactHelpLogService Map.of() Java9+ 语法及 Comparator 类型推断问题

iwt 1 settimana fa
parent
commit
13d41d55d2

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

@@ -1,6 +1,7 @@
 package com.etotem.cfc.controller;
 
 import com.etotem.cfc.common.Result;
+import com.etotem.cfc.dto.ContactHelpLogDTO;
 import com.etotem.cfc.service.ContactHelpLogService;
 import org.springframework.web.bind.annotation.*;
 
@@ -26,7 +27,7 @@ public class OctopusController {
 
     /** 新增帮助记录(被帮时调用) */
     @PostMapping("/add")
-    public Result<Object> addHelpLog(@RequestBody Map<String, Object> params,
+    public Result<ContactHelpLogDTO> addHelpLog(@RequestBody Map<String, Object> params,
                                      @RequestAttribute("userId") Long userId) {
         Long contactId = params.get("contactId") != null ?
                 Long.valueOf(params.get("contactId").toString()) : null;

+ 11 - 11
cfc-backend/src/main/java/com/etotem/cfc/service/ContactHelpLogService.java

@@ -170,17 +170,17 @@ public class ContactHelpLogService {
                 .reduce(BigDecimal.ZERO, BigDecimal::add);
 
         Map<String, Object> result = new LinkedHashMap<>();
-        result.put("contact", Map.of(
-                "id", contact.getId(),
-                "name", contact.getName(),
-                "avatar", contact.getAvatar(),
-                "relationshipType", contact.getRelationshipType()
-        ));
-        result.put("summary", Map.of(
-                "helpCount", totalCount,
-                "totalAmount", totalAmount,
-                "lastHelpedAt", logs.isEmpty() ? null : logs.get(0).getHappenedAt()
-        ));
+        Map<String, Object> contactMap = new HashMap<>();
+        contactMap.put("id", contact.getId());
+        contactMap.put("name", contact.getName());
+        contactMap.put("avatar", contact.getAvatar());
+        contactMap.put("relationshipType", contact.getRelationshipType());
+        result.put("contact", contactMap);
+        Map<String, Object> summaryMap = new HashMap<>();
+        summaryMap.put("helpCount", totalCount);
+        summaryMap.put("totalAmount", totalAmount);
+        summaryMap.put("lastHelpedAt", logs.isEmpty() ? null : logs.get(0).getHappenedAt());
+        result.put("summary", summaryMap);
         result.put("records", logs);
         return Result.success(result);
     }