|
@@ -1,5 +1,8 @@
|
1
|
1
|
package com.huiju.estateagents.controller;
|
2
|
2
|
|
|
3
|
+import com.alibaba.fastjson.JSON;
|
|
4
|
+import com.alibaba.fastjson.JSONArray;
|
|
5
|
+import com.alibaba.fastjson.JSONObject;
|
3
|
6
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
4
|
7
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
5
|
8
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -18,6 +21,10 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
18
|
21
|
import org.springframework.web.bind.annotation.RestController;
|
19
|
22
|
import com.huiju.estateagents.base.BaseController;
|
20
|
23
|
|
|
24
|
+import java.time.LocalDateTime;
|
|
25
|
+import java.util.ArrayList;
|
|
26
|
+import java.util.List;
|
|
27
|
+
|
21
|
28
|
/**
|
22
|
29
|
* <p>
|
23
|
30
|
* 项目报表设置 前端控制器
|
|
@@ -42,7 +49,7 @@ public class TaBuildingReportController extends BaseController {
|
42
|
49
|
* @param pageSize
|
43
|
50
|
* @return
|
44
|
51
|
*/
|
45
|
|
- @RequestMapping(value="/taBuildingReport",method= RequestMethod.GET)
|
|
52
|
+ @RequestMapping(value="/admin/taBuildingReports",method= RequestMethod.GET)
|
46
|
53
|
public ResponseBean taBuildingReportList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
47
|
54
|
@RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize){
|
48
|
55
|
ResponseBean responseBean = new ResponseBean();
|
|
@@ -63,15 +70,25 @@ public class TaBuildingReportController extends BaseController {
|
63
|
70
|
|
64
|
71
|
/**
|
65
|
72
|
* 保存对象
|
66
|
|
- * @param taBuildingReport 实体对象
|
|
73
|
+ * @param jsonString
|
67
|
74
|
* @return
|
68
|
75
|
*/
|
69
|
|
- @RequestMapping(value="/taBuildingReport",method= RequestMethod.POST)
|
70
|
|
- public ResponseBean taBuildingReportAdd(@RequestBody TaBuildingReport taBuildingReport){
|
|
76
|
+ @RequestMapping(value="/admin/taBuildingReport/add",method= RequestMethod.POST)
|
|
77
|
+ public ResponseBean taBuildingReportAdd(@RequestBody String jsonString){
|
71
|
78
|
ResponseBean responseBean = new ResponseBean();
|
72
|
79
|
try {
|
73
|
|
- if (iTaBuildingReportService.save(taBuildingReport)){
|
74
|
|
- responseBean.addSuccess(taBuildingReport);
|
|
80
|
+ JSONArray jsonArray = JSONObject.parseObject(jsonString).getJSONArray("list");
|
|
81
|
+ List<TaBuildingReport> list = new ArrayList<>();
|
|
82
|
+ jsonArray.stream().forEach(e -> {
|
|
83
|
+ TaBuildingReport taBuildingReport = new TaBuildingReport();
|
|
84
|
+ taBuildingReport.setReportCode(e.toString());
|
|
85
|
+ taBuildingReport.setCreateDate(LocalDateTime.now());
|
|
86
|
+ list.add(taBuildingReport);
|
|
87
|
+ });
|
|
88
|
+ //先删除在添加
|
|
89
|
+ iTaBuildingReportService.deleteAll();
|
|
90
|
+ if (iTaBuildingReportService.saveBatch(list)){
|
|
91
|
+ responseBean.addSuccess("保存成功");
|
75
|
92
|
}else {
|
76
|
93
|
responseBean.addError("fail");
|
77
|
94
|
}
|