|
@@ -18,10 +18,12 @@ import com.qmth.boot.api.constant.ApiConstant;
|
|
import com.qmth.boot.core.collection.PageResult;
|
|
import com.qmth.boot.core.collection.PageResult;
|
|
import com.qmth.boot.core.exception.StatusException;
|
|
import com.qmth.boot.core.exception.StatusException;
|
|
import com.qmth.exam.reserve.bean.PagerReq;
|
|
import com.qmth.exam.reserve.bean.PagerReq;
|
|
|
|
+import com.qmth.exam.reserve.bean.login.LoginUser;
|
|
import com.qmth.exam.reserve.bean.studentimport.StudentImportTaskVO;
|
|
import com.qmth.exam.reserve.bean.studentimport.StudentImportTaskVO;
|
|
import com.qmth.exam.reserve.controller.BaseController;
|
|
import com.qmth.exam.reserve.controller.BaseController;
|
|
import com.qmth.exam.reserve.entity.StudentImportTaskEntity;
|
|
import com.qmth.exam.reserve.entity.StudentImportTaskEntity;
|
|
import com.qmth.exam.reserve.enums.ImportStatus;
|
|
import com.qmth.exam.reserve.enums.ImportStatus;
|
|
|
|
+import com.qmth.exam.reserve.enums.Role;
|
|
import com.qmth.exam.reserve.service.StudentImportTaskService;
|
|
import com.qmth.exam.reserve.service.StudentImportTaskService;
|
|
import com.qmth.exam.reserve.util.ResourceUtil;
|
|
import com.qmth.exam.reserve.util.ResourceUtil;
|
|
|
|
|
|
@@ -49,21 +51,20 @@ public class StudentImportTaskController extends BaseController {
|
|
exportFile("考生信息导入模板.xlsx", ResourceUtil.getStream("templates/studentImport.xlsx"));
|
|
exportFile("考生信息导入模板.xlsx", ResourceUtil.getStream("templates/studentImport.xlsx"));
|
|
}
|
|
}
|
|
|
|
|
|
- @Aac(strict = false, auth = false)
|
|
|
|
@ApiOperation(value = "考生信息导入")
|
|
@ApiOperation(value = "考生信息导入")
|
|
@PostMapping(value = "/upload")
|
|
@PostMapping(value = "/upload")
|
|
public void upload(MultipartFile file) {
|
|
public void upload(MultipartFile file) {
|
|
- // LoginUser user = this.curLoginUser();
|
|
|
|
- // if (!Role.ADMIN.equals(user.getRole())) {
|
|
|
|
- // throw new StatusException("没有权限");
|
|
|
|
- // }
|
|
|
|
|
|
+ LoginUser user = this.curLoginUser();
|
|
|
|
+ if (!Role.ADMIN.equals(user.getRole())) {
|
|
|
|
+ throw new StatusException("没有权限");
|
|
|
|
+ }
|
|
LambdaQueryWrapper<StudentImportTaskEntity> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<StudentImportTaskEntity> wrapper = new LambdaQueryWrapper<>();
|
|
wrapper.eq(StudentImportTaskEntity::getStatus, ImportStatus.RUNNING.toString());
|
|
wrapper.eq(StudentImportTaskEntity::getStatus, ImportStatus.RUNNING.toString());
|
|
StudentImportTaskEntity exists = studentImportService.getOne(wrapper);
|
|
StudentImportTaskEntity exists = studentImportService.getOne(wrapper);
|
|
if (exists != null)
|
|
if (exists != null)
|
|
throw new StatusException("正在导入,请稍后再试");
|
|
throw new StatusException("正在导入,请稍后再试");
|
|
try {
|
|
try {
|
|
- studentImportService.importStudent(1l, file.getOriginalFilename(), file.getInputStream());
|
|
|
|
|
|
+ studentImportService.importStudent(user.getId(), file.getOriginalFilename(), file.getInputStream());
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
throw new StatusException("文件读取出错", e);
|
|
throw new StatusException("文件读取出错", e);
|
|
}
|
|
}
|