feige
2024-06-16 3ad8fb4e7cc1391e8090f3da6ffa9c48690a12a3
ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfDoctorController.java
@@ -9,6 +9,7 @@
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.domain.ZfDoctor;
import com.ruoyi.domain.excel.ZfCollectionExcelBean;
import com.ruoyi.service.ZfDoctorService;
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;
@@ -44,6 +46,21 @@
        return zfDoctorService.selectDoctorList(zfDoctor, pageNum, pageSize);
    }
    @GetMapping("/type")
    public AjaxResult listType(){
        return zfDoctorService.listType();
    }
    /**
     * 获取导入模板
     */
    @PostMapping("/model")
    public void getExportModel(HttpServletResponse response){
        List<ZfDoctor> list = Collections.singletonList(new ZfDoctor());
        ExcelUtil<ZfDoctor> util = new ExcelUtil<>(ZfDoctor.class);
        util.exportExcel(response,list,"家庭小医生导入模板");
    }
    /**
     * 导出家庭小医生记录列表
@@ -58,7 +75,19 @@
        ExcelUtil<ZfDoctor> util = new ExcelUtil<>(ZfDoctor.class);
        util.exportExcel(response, list, "家庭小医生记录数据");
    }
    /**
     * 导出家庭小医生记录列表
     */
//    @PreAuthorize("@ss.hasPermi('system:property:export')")
    @Log(title = "家庭小医生记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export1/{ids}")
    public void export(HttpServletResponse response, @PathVariable Long[] ids)
    {
        List<ZfDoctor> list = zfDoctorService.selectByIds(ids);
        log.info("导出记录为:{}",list);
        ExcelUtil<ZfDoctor> util = new ExcelUtil<>(ZfDoctor.class);
        util.exportExcel(response, list, "家庭小医生记录数据");
    }
    /**
     * 导入家庭小医生记录列表
     */
@@ -66,14 +95,16 @@
    @PostMapping("/importData")
    public AjaxResult importData(@RequestParam("excelImport") MultipartFile file) throws Exception
    {
        ExcelUtil<ZfDoctor> util = new ExcelUtil<>(ZfDoctor.class);
        List<ZfDoctor> eventList = util.importExcel(file.getInputStream());
        log.info("家庭小医生列表为:{}",eventList);
//        ExcelUtil<ZfDoctor> util = new ExcelUtil<>(ZfDoctor.class);
//        List<ZfDoctor> eventList = util.importExcel(file.getInputStream());
//        log.info("家庭小医生列表为:{}",eventList);
//
//        if (zfDoctorService.saveBatch(eventList)) {
//            return AjaxResult.success("导入数据成功");
//        }
//        return AjaxResult.error("导入数据失败");
        if (zfDoctorService.saveBatch(eventList)) {
            return AjaxResult.success("导入数据成功");
        }
        return AjaxResult.error("导入数据失败");
        return zfDoctorService.importExcel(file);
    }
    /**
@@ -94,7 +125,7 @@
    @PostMapping
    public AjaxResult add(@RequestBody ZfDoctor zfDoctor)
    {
        return toAjax(zfDoctorService.save(zfDoctor));
        return zfDoctorService.addData(zfDoctor);
    }
    /**
@@ -105,7 +136,7 @@
    @PutMapping
    public AjaxResult edit(@RequestBody ZfDoctor zfDoctor)
    {
        return toAjax(zfDoctorService.updateById(zfDoctor));
        return zfDoctorService.updateData(zfDoctor);
    }
//
    /**
@@ -116,7 +147,7 @@
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zfDoctorService.removeByIds(Arrays.asList(ids)));
        return zfDoctorService.deleteData(ids);
    }
}