1
whywhyo
2023-05-13 150b8d2d049ceb69cb301d12c38aae190c21a05c
1
2个文件已修改
33 ■■■■■ 已修改文件
ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfPetController.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfPetNoteController.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfPetController.java
@@ -9,6 +9,7 @@
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.domain.ZfPet;
import com.ruoyi.domain.excel.ZfEconomyExcelBean;
import com.ruoyi.service.ZfPetService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
@@ -17,6 +18,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;
@@ -45,6 +47,16 @@
    }
    /**
     * 获取导入模板
     */
    @GetMapping("/model")
    public void getExportModel(HttpServletResponse response){
        List<ZfPet> list = Collections.singletonList(new ZfPet());
        ExcelUtil<ZfPet> util = new ExcelUtil<>(ZfPet.class);
        util.exportExcel(response,list,"魅宠记录数据");
    }
    /**
     * 导出魅宠记录列表
     */
//    @PreAuthorize("@ss.hasPermi('system:property:export')")
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);
    }
    /**
     * 获取导入模板
     */
    @GetMapping("/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)) {