From d2a1957ec40c70c696ab3260d7f7df90c4539589 Mon Sep 17 00:00:00 2001
From: whywhyo <1511349576@qq.com>
Date: 星期五, 21 七月 2023 15:33:31 +0800
Subject: [PATCH] 1254

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfContactController.java |   56 +++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 41 insertions(+), 15 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfContactController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfContactController.java
index 548a05b..d461ea6 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfContactController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfContactController.java
@@ -9,6 +9,8 @@
 import com.ruoyi.common.utils.ServletUtils;
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.domain.ZfContact;
+import com.ruoyi.domain.excel.ZfCollectionExcelBean;
+import com.ruoyi.domain.excel.ZfContactExcelBean;
 import com.ruoyi.service.ZfContactService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.bind.annotation.*;
@@ -17,6 +19,7 @@
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 
 import static com.ruoyi.common.core.page.TableSupport.PAGE_NUM;
@@ -41,24 +44,46 @@
     public AjaxResult listAll(ZfContact zfContact){
         Integer pageNum = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1);
         Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10);
-        return zfContactService.selectContactList(zfContact, pageNum, pageSize);
+        return zfContactService.selectDataList(zfContact, pageNum, pageSize);
     }
 
+    /**
+     * 鑾峰彇瀵煎叆妯℃澘
+     */
+    @PostMapping("/model")
+    public void getExportModel(HttpServletResponse response){
+        List<ZfContactExcelBean> list = Collections.singletonList(new ZfContactExcelBean());
+        ExcelUtil<ZfContactExcelBean> util = new ExcelUtil<>(ZfContactExcelBean.class);
+        util.exportExcel(response,list,"閫氳褰曞鍏ユā鏉�");
+    }
+
+//    /**
+//     * 瀵煎嚭閫氳褰曡褰曞垪琛�
+//     */
+////    @PreAuthorize("@ss.hasPermi('system:property:export')")
+//    @Log(title = "閫氳褰曡褰�", businessType = BusinessType.EXPORT)
+//    @PostMapping("/export")
+//    public void export(HttpServletResponse response, ZfContact zfContact)
+//    {
+//        List<ZfContact> list = zfContactService.selectByCondition(zfContact);
+//        log.info("瀵煎嚭璁板綍涓�:{}",list);
+//        ExcelUtil<ZfContact> util = new ExcelUtil<>(ZfContact.class);
+//        util.exportExcel(response, list, "閫氳褰曡褰曟暟鎹�");
+//    }
 
     /**
      * 瀵煎嚭閫氳褰曡褰曞垪琛�
      */
 //    @PreAuthorize("@ss.hasPermi('system:property:export')")
     @Log(title = "閫氳褰曡褰�", businessType = BusinessType.EXPORT)
-    @PostMapping("/export")
-    public void export(HttpServletResponse response, ZfContact zfContact)
+    @PostMapping("/export/{ids}")
+    public void export(HttpServletResponse response, @PathVariable Long[] ids)
     {
-        List<ZfContact> list = zfContactService.selectByCondition(zfContact);
+        List<ZfContact> list = zfContactService.selectByIds(ids);
         log.info("瀵煎嚭璁板綍涓�:{}",list);
         ExcelUtil<ZfContact> util = new ExcelUtil<>(ZfContact.class);
         util.exportExcel(response, list, "閫氳褰曡褰曟暟鎹�");
     }
-
     /**
      * 瀵煎叆閫氳褰曡褰曞垪琛�
      */
@@ -66,13 +91,14 @@
     @PostMapping("/importData")
     public AjaxResult importData(@RequestParam("excelImport") MultipartFile file) throws Exception
     {
-        ExcelUtil<ZfContact> util = new ExcelUtil<>(ZfContact.class);
-        List<ZfContact> eventList = util.importExcel(file.getInputStream());
-        log.info("閫氳褰曞垪琛ㄤ负锛歿}",eventList);
-        if (zfContactService.saveBatch(eventList)) {
-            return AjaxResult.success("瀵煎叆鏁版嵁鎴愬姛");
-        }
-        return AjaxResult.error("瀵煎叆鏁版嵁澶辫触");
+//        ExcelUtil<ZfContact> util = new ExcelUtil<>(ZfContact.class);
+//        List<ZfContact> eventList = util.importExcel(file.getInputStream());
+//        log.info("閫氳褰曞垪琛ㄤ负锛歿}",eventList);
+//        if (zfContactService.saveBatch(eventList)) {
+//            return AjaxResult.success("瀵煎叆鏁版嵁鎴愬姛");
+//        }
+//        return AjaxResult.error("瀵煎叆鏁版嵁澶辫触");
+        return zfContactService.importExcel(file);
     }
 
     /**
@@ -93,7 +119,7 @@
     @PostMapping
     public AjaxResult add(@RequestBody ZfContact zfContact)
     {
-        return toAjax(zfContactService.save(zfContact));
+        return (zfContactService.addData(zfContact));
     }
 
     /**
@@ -104,7 +130,7 @@
     @PutMapping
     public AjaxResult edit(@RequestBody ZfContact zfContact)
     {
-        return toAjax(zfContactService.updateById(zfContact));
+        return zfContactService.updateData(zfContact);
     }
 //
     /**
@@ -115,7 +141,7 @@
     @DeleteMapping("/{ids}")
     public AjaxResult remove(@PathVariable Long[] ids)
     {
-        return toAjax(zfContactService.removeByIds(Arrays.asList(ids)));
+        return zfContactService.deleteData(ids);
     }
 
 

--
Gitblit v1.9.1