|
|
@@ -0,0 +1,136 @@
|
|
|
+package com.fs.his.controller;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
+import com.fs.his.dto.MemberExcelDTO;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import com.fs.common.annotation.Log;
|
|
|
+import com.fs.common.core.controller.BaseController;
|
|
|
+import com.fs.common.core.domain.AjaxResult;
|
|
|
+import com.fs.common.enums.BusinessType;
|
|
|
+import com.fs.his.domain.FsImportMember;
|
|
|
+import com.fs.his.service.IFsImportMemberService;
|
|
|
+import com.fs.common.utils.poi.ExcelUtil;
|
|
|
+import com.fs.common.core.page.TableDataInfo;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 导入会员Controller
|
|
|
+ *
|
|
|
+ * @author fs
|
|
|
+ * @date 2026-05-25
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/importMember/importMember")
|
|
|
+public class FsImportMemberController extends BaseController
|
|
|
+{
|
|
|
+ @Autowired
|
|
|
+ private IFsImportMemberService fsImportMemberService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询导入会员列表
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('importMember:importMember:list')")
|
|
|
+ @GetMapping("/list")
|
|
|
+ public TableDataInfo list(FsImportMember fsImportMember)
|
|
|
+ {
|
|
|
+ startPage();
|
|
|
+ List<FsImportMember> list = fsImportMemberService.selectFsImportMemberList(fsImportMember);
|
|
|
+ return getDataTable(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出导入会员列表
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('importMember:importMember:export')")
|
|
|
+ @Log(title = "导入会员", businessType = BusinessType.EXPORT)
|
|
|
+ @GetMapping("/export")
|
|
|
+ public AjaxResult export(FsImportMember fsImportMember)
|
|
|
+ {
|
|
|
+ List<FsImportMember> list = fsImportMemberService.selectFsImportMemberList(fsImportMember);
|
|
|
+ ExcelUtil<FsImportMember> util = new ExcelUtil<FsImportMember>(FsImportMember.class);
|
|
|
+ return util.exportExcel(list, "导入会员数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取导入会员详细信息
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('importMember:importMember:query')")
|
|
|
+ @GetMapping(value = "/{id}")
|
|
|
+ public AjaxResult getInfo(@PathVariable("id") Long id)
|
|
|
+ {
|
|
|
+ return AjaxResult.success(fsImportMemberService.selectFsImportMemberById(id));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增导入会员
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('importMember:importMember:add')")
|
|
|
+ @Log(title = "导入会员", businessType = BusinessType.INSERT)
|
|
|
+ @PostMapping
|
|
|
+ public AjaxResult add(@RequestBody FsImportMember fsImportMember)
|
|
|
+ {
|
|
|
+ return toAjax(fsImportMemberService.insertFsImportMember(fsImportMember));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改导入会员
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('importMember:importMember:edit')")
|
|
|
+ @Log(title = "导入会员", businessType = BusinessType.UPDATE)
|
|
|
+ @PutMapping
|
|
|
+ public AjaxResult edit(@RequestBody FsImportMember fsImportMember)
|
|
|
+ {
|
|
|
+ return toAjax(fsImportMemberService.updateFsImportMember(fsImportMember));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除导入会员
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('importMember:importMember:remove')")
|
|
|
+ @Log(title = "导入会员", businessType = BusinessType.DELETE)
|
|
|
+ @DeleteMapping("/{ids}")
|
|
|
+ public AjaxResult remove(@PathVariable Long[] ids)
|
|
|
+ {
|
|
|
+ return toAjax(fsImportMemberService.deleteFsImportMemberByIds(ids));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("/import")
|
|
|
+ public AjaxResult importMember(@RequestParam("file") MultipartFile file) {
|
|
|
+ if (file.isEmpty()) {
|
|
|
+ return AjaxResult.error("文件不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 校验文件类型
|
|
|
+ String filename = file.getOriginalFilename();
|
|
|
+ if (filename == null || (!filename.endsWith(".xlsx") && !filename.endsWith(".xls"))) {
|
|
|
+ return AjaxResult.error("请上传Excel文件(.xlsx或.xls)");
|
|
|
+ }
|
|
|
+ Map<String, Object> map = fsImportMemberService.importExcel(file);
|
|
|
+ return AjaxResult.success("导入成功", map);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/template")
|
|
|
+ public void downloadTemplate(HttpServletResponse response) throws IOException {
|
|
|
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
+ String fileName = URLEncoder.encode("用户导入模板", "UTF-8");
|
|
|
+ response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
|
|
|
+
|
|
|
+ // 创建模板,只有表头
|
|
|
+ List<MemberExcelDTO> list = new ArrayList<>();
|
|
|
+ EasyExcel.write(response.getOutputStream(), MemberExcelDTO.class)
|
|
|
+ .sheet("模板")
|
|
|
+ .doWrite(list);
|
|
|
+ }
|
|
|
+}
|