瀏覽代碼

添加导出报告header

梅杰 6 年之前
父節點
當前提交
976def6482
共有 1 個文件被更改,包括 8 次插入4 次删除
  1. 8 4
      src/main/java/com/mooctest/service/FinalReportService.java

+ 8 - 4
src/main/java/com/mooctest/service/FinalReportService.java

@@ -10,12 +10,12 @@ import com.mooctest.util.HttpUtil;
 import com.mooctest.util.ReportUtil;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
 import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestTemplate;
 
-import java.sql.Timestamp;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
@@ -77,9 +77,13 @@ public class FinalReportService {
     public String getExportReportAddr(TaskDTO task) {
         List<FinalReport> finalReports = finalReportDao.findByExamIdAndCaseId(task.getExamId(), task.getCaseId());
 
-        RestTemplate rt = HttpUtil.getRestTemplate();
+        HttpHeaders headers = new HttpHeaders();
+        headers.set("Content-Type", "application/json");
+
         JSONObject reportJson = genJsonForExport(task, finalReports);
-        String url = rt.postForObject(reportExportAddr, reportJson.toJSONString(), String.class);
+        HttpEntity<String> request = new HttpEntity<>(reportJson.toJSONString(), headers);
+        RestTemplate rt = HttpUtil.getRestTemplate();
+        String url = rt.postForObject(reportExportAddr, request, String.class);
         return url;
     }