|
|
@@ -1,6 +1,7 @@
|
|
|
package org.springblade.client.corps.controller;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import io.swagger.annotations.Api;
|
|
|
@@ -11,6 +12,7 @@ import org.springblade.client.corps.excel.CorpsExcel;
|
|
|
import org.springblade.client.corps.excel.CorpsImport;
|
|
|
import org.springblade.client.corps.service.ICorpsDescService;
|
|
|
import org.springblade.client.entity.CorpsDesc;
|
|
|
+import org.springblade.client.goods.excel.GoodsExcel;
|
|
|
import org.springblade.client.vo.CorpsDescVO;
|
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
|
import org.springblade.core.excel.util.ExcelUtil;
|
|
|
@@ -22,7 +24,10 @@ import org.springblade.core.tool.utils.Func;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 客户详情 控制器
|
|
|
@@ -141,9 +146,30 @@ public class CorpsDescController extends BladeController {
|
|
|
@PostMapping("/import-desc")
|
|
|
@ApiOperationSupport(order = 12)
|
|
|
@ApiOperation(value = "导入客户资料", notes = "传入excel")
|
|
|
- public R importUser(MultipartFile file) {
|
|
|
- CorpsImport corpsImport = new CorpsImport(corpsDescService,false);
|
|
|
- ExcelUtil.save(file, corpsImport, CorpsExcel.class);
|
|
|
+ public R importUser(MultipartFile file,String typeId) {
|
|
|
+ List<CorpsExcel> excelList = ExcelUtil.read(file, CorpsExcel.class);
|
|
|
+ if(CollectionUtils.isEmpty(excelList))
|
|
|
+ {
|
|
|
+ throw new SecurityException("数据不能为空");
|
|
|
+ }
|
|
|
+ excelList.forEach(e->{
|
|
|
+ e.setTypeId(typeId);
|
|
|
+ });
|
|
|
+ corpsDescService.importUser(excelList,false);
|
|
|
return R.success("操作成功");
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出模板
|
|
|
+ */
|
|
|
+ @GetMapping("/export-template")
|
|
|
+ @ApiOperationSupport(order = 9)
|
|
|
+ @ApiOperation(value = "导出模板")
|
|
|
+ public void exportPrice(HttpServletResponse response) {
|
|
|
+ List<CorpsExcel> list = new ArrayList<>();
|
|
|
+ ExcelUtil.export(response, "客户导入模板", "客户导入数据表", list, CorpsExcel.class);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|