|
@@ -11,6 +11,8 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import java.time.LocalDate;
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
@@ -50,22 +52,32 @@ public class ReportController {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 新增或编辑报告
|
|
* 新增或编辑报告
|
|
- * id 报告id 数组 编辑时需要指定
|
|
|
|
- * projectId 报告相关项目id 数组 新增时需要指定
|
|
|
|
|
|
+ * id 报告id 数组
|
|
|
|
+ * projectId 报告相关项目id 数组
|
|
* workingTime 工作时间 数组
|
|
* workingTime 工作时间 数组
|
|
* content 工作内容 数组
|
|
* content 工作内容 数组
|
|
- * createDate 报告日期 传一个即可
|
|
|
|
|
|
+ * createDate 报告日期 数组
|
|
*/
|
|
*/
|
|
-// @RequestMapping("/editReport")
|
|
|
|
-// public HttpRespMsg editReport2(Integer[] id, Integer[] projectId, Double[] workingTime, String[] content,
|
|
|
|
-// String createDate) {
|
|
|
|
-// List<Report> reportList = new ArrayList<>();
|
|
|
|
-// for (int i = 0; i < reportList.projectId; i++) {
|
|
|
|
-// reportList[i].setId(id[i]).setCreatorId(request.getHeader("Token")).setContent();
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// return reportService.editReport(reportList, request);
|
|
|
|
-// }
|
|
|
|
|
|
+ @RequestMapping("/editReport")
|
|
|
|
+ public HttpRespMsg editReport2(Integer[] id, Integer[] projectId, Double[] workingTime, String[] content,
|
|
|
|
+ String[] createDate) {
|
|
|
|
+ List<Report> reportList = new ArrayList<>();
|
|
|
|
+ for (int i = 0; i < id.length; i++) {
|
|
|
|
+ reportList.add(new Report()
|
|
|
|
+ .setId(id[i])
|
|
|
|
+ .setProjectId(projectId[i])
|
|
|
|
+ .setWorkingTime(workingTime[i])
|
|
|
|
+ .setContent(content[i])
|
|
|
|
+ .setCreateDate(LocalDate.parse(createDate[i], DateTimeFormatter.ofPattern("yyyy-MM-dd")))
|
|
|
|
+ .setCreatorId(request.getHeader("Token")));
|
|
|
|
+ if (createDate[i] == null || projectId[i] == null) {
|
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
|
+ httpRespMsg.setError("缺少数据");
|
|
|
|
+ return httpRespMsg;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return reportService.editReport(reportList);
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* 删除报告
|
|
* 删除报告
|