|
@@ -3,6 +3,7 @@ package com.iden.bms.controller;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.iden.bms.service.CrowdService;
|
|
|
+import com.iden.bms.service.PersonService;
|
|
|
import com.iden.common.annotation.Permission;
|
|
|
import com.iden.common.exception.BDException;
|
|
|
import com.iden.common.logaspect.LogAnnotation;
|
|
@@ -20,6 +21,7 @@ import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.List;
|
|
@@ -38,6 +40,8 @@ public class CrowdController {
|
|
|
|
|
|
@Autowired
|
|
|
private CrowdService crowdService;
|
|
|
+ @Autowired
|
|
|
+ private PersonService personService;
|
|
|
|
|
|
@GetMapping("/listCrowd")
|
|
|
@ApiOperation(value = "人群列表分页 ")
|
|
@@ -61,6 +65,23 @@ public class CrowdController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @ApiOperation(value = "导入Excel")
|
|
|
+ @PostMapping(value = "/importWithExcel", headers = "content-type=multipart/form-data")
|
|
|
+ public Result<List<Long>> importWithExcel( @RequestHeader(name = "token") String token,
|
|
|
+ @RequestParam(value = "file") MultipartFile multipartFile) {
|
|
|
+ try {
|
|
|
+ List<Long> personIdList = personService.importWithExcel(multipartFile);
|
|
|
+ return Result.success("导入成功!",personIdList);
|
|
|
+ } catch (BDException e) {
|
|
|
+ log.error("导入人员列表出现异常",e);
|
|
|
+ return Result.error(e.getMessage());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("人员管理: 导入人员列表出现异常",e);
|
|
|
+ return Result.error("导入人员失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@PostMapping("/addCrowd")
|
|
|
@ApiOperation(value = "新增人群")
|
|
|
@LogAnnotation(
|
|
@@ -78,7 +99,9 @@ public class CrowdController {
|
|
|
return Result.error("名称已存在!");
|
|
|
} if (flag == 2) {
|
|
|
return Result.error("编码已存在!");
|
|
|
- } else if (flag == 0) {
|
|
|
+ } if (flag == 3) {
|
|
|
+ return Result.error("人员列表不能为空!");
|
|
|
+ } else if (flag == 0) {
|
|
|
return Result.success("新增成功!");
|
|
|
} else {
|
|
|
return Result.error("新增失败!");
|