From 3eda21a5a601c808b4e7ef7bd56535de96e3d7ed Mon Sep 17 00:00:00 2001
From: feige <feige@qq.com>
Date: 星期三, 17 五月 2023 11:45:18 +0800
Subject: [PATCH] 添加了两个导出接口一个是选择了id的,一个是没有选择的

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfPetNoteController.java |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfPetNoteController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfPetNoteController.java
index 4e2f4a6..b018a3e 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfPetNoteController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfPetNoteController.java
@@ -8,6 +8,7 @@
 import com.ruoyi.common.enums.BusinessType;
 import com.ruoyi.common.utils.ServletUtils;
 import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.domain.ZfPet;
 import com.ruoyi.domain.ZfPetNote;
 import com.ruoyi.domain.ZfProperty;
 import com.ruoyi.service.ZfPetNoteService;
@@ -20,6 +21,7 @@
 import javax.servlet.http.HttpServletResponse;
 import javax.websocket.server.PathParam;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 
 import static com.ruoyi.common.core.page.TableSupport.PAGE_NUM;
@@ -55,6 +57,18 @@
         return zfPetNoteService.getAllPetNoteByPetId(pid);
     }
 
+
+    /**
+     * 鑾峰彇瀵煎叆妯℃澘
+     */
+    @PostMapping("/model")
+    public void getExportModel(HttpServletResponse response){
+        List<ZfPetNote> list = Collections.singletonList(new ZfPetNote());
+        ExcelUtil<ZfPetNote> util = new ExcelUtil<>(ZfPetNote.class);
+        util.exportExcel(response,list,"榄呭疇澶囧繕褰曞鍏ユā鏉�");
+    }
+
+
     /**
      * 瀵煎嚭榄呭疇澶囧繕褰曡褰曞垪琛�
      */
@@ -73,11 +87,14 @@
      * 瀵煎叆榄呭疇澶囧繕褰曡褰曞垪琛�
      */
     @Log(title = "鐢ㄦ埛绠$悊", businessType = BusinessType.IMPORT)
-    @PostMapping("/importData")
-    public AjaxResult importData(@RequestParam("excelImport") MultipartFile file) throws Exception
+    @PostMapping("/importData/{pid}")
+    public AjaxResult importData(@RequestParam("excelImport") MultipartFile file,@PathVariable Long pid) throws Exception
     {
         ExcelUtil<ZfPetNote> util = new ExcelUtil<>(ZfPetNote.class);
         List<ZfPetNote> eventList = util.importExcel(file.getInputStream());
+        for (ZfPetNote zfPetNote : eventList) {
+            zfPetNote.setPid(pid);
+        }
         log.info("榄呭疇澶囧繕褰曞垪琛ㄤ负锛歿}",eventList);
 
         if (zfPetNoteService.saveBatch(eventList)) {
@@ -104,7 +121,7 @@
     @PostMapping
     public AjaxResult add(@RequestBody ZfPetNote zfPetNote)
     {
-        return toAjax(zfPetNoteService.save(zfPetNote));
+        return zfPetNoteService.mySave(zfPetNote);
     }
 
     /**

--
Gitblit v1.9.1