18118724055@163.com před 1 dnem
rodič
revize
901a50031c

+ 4 - 0
java/storlead-mail/storlead-mail-api/src/main/java/com/storlead/mail/webclient/support/MailRemoteHttpSupport.java

@@ -99,6 +99,10 @@ public class MailRemoteHttpSupport {
         return token;
     }
 
+    /**
+     * POST JSON。body 会原样序列化:List 会变成 {@code [1,2,3]},只适合 B 端 {@code @RequestBody}。
+     * B 端若是 {@code @RequestParam("ids") List<Long>},请用 {@link #postForm(String, Object)} + {@link #formOf}。
+     */
     public Result<?> postJson(String path, Object body) {
         try {
             return mailWebClient.post()

+ 5 - 5
java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/client/MarketEmailsClient.java

@@ -25,11 +25,11 @@ public class MarketEmailsClient {
     private final MailRemoteHttpSupport http;
 
     public Result<?> emailList(List<Long> ids) {
-        // B 服务 /mkt/list_by_ids 是 @RequestBody List<Long>(consumes=application/json,见其 swagger),
-        // 必须走 JSON;发 form-urlencoded 会被 B 端 HttpMediaTypeNotSupportedException 拒绝,
-        // 其全局异常处理器把它包成 HTTP 200 + Result(900000, "Content type ... not supported") 透传回来。
-        // 另外:不能调 postForm(path, ids)——toForm 里 objectMapper.convertValue(list, Map) 对 List 直接抛异常。
-        return http.postJson(MailRemoteApiConstants.MKT_LIST_BY_IDS, ids);
+        // B 服务是 @RequestParam("ids") List<Long>,必须按 form 重复 key:ids=2&ids=3。
+        // 不能 postJson 直接传 List:body 会变成 [2,3],B 端当成字符串 "[2, 3]" 再按逗号拆,
+        // 得到 "[2" 和 " 3]",转不成 Long,表现为 list size 正确但元素全是 null。
+        // 也不能 postForm(path, ids):toForm 会对 List 做 convertValue(..., Map) 抛异常。
+        return http.postForm(MailRemoteApiConstants.MKT_LIST_BY_IDS, http.formOf("ids", ids));
     }
 
     /**