|
@@ -4,8 +4,11 @@ import com.qmth.boot.api.annotation.Aac;
|
|
|
import com.qmth.boot.api.constant.ApiConstant;
|
|
|
import com.qmth.boot.core.collection.PageResult;
|
|
|
import com.qmth.boot.core.exception.StatusException;
|
|
|
+import com.qmth.boot.tools.excel.ExcelWriter;
|
|
|
+import com.qmth.boot.tools.excel.enums.ExcelType;
|
|
|
import com.qmth.exam.reserve.bean.Constants;
|
|
|
import com.qmth.exam.reserve.bean.login.LoginUser;
|
|
|
+import com.qmth.exam.reserve.bean.student.StudentExportVO;
|
|
|
import com.qmth.exam.reserve.bean.student.StudentReq;
|
|
|
import com.qmth.exam.reserve.bean.student.StudentVO;
|
|
|
import com.qmth.exam.reserve.controller.BaseController;
|
|
@@ -14,11 +17,16 @@ import com.qmth.exam.reserve.service.StudentService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
|
|
|
@RestController
|
|
@@ -27,6 +35,8 @@ import java.util.Objects;
|
|
|
@Aac(strict = false, auth = true)
|
|
|
public class StudentAdminController extends BaseController {
|
|
|
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(StudentAdminController.class);
|
|
|
+
|
|
|
@Autowired
|
|
|
private StudentService studentService;
|
|
|
|
|
@@ -88,5 +98,29 @@ public class StudentAdminController extends BaseController {
|
|
|
return Constants.ASYNC_TIPS;
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "导出考生")
|
|
|
+ @PostMapping(value = "/export")
|
|
|
+ public void exportExceptionMessage(@RequestBody StudentReq req, HttpServletResponse response) {
|
|
|
+ LoginUser loginUser = this.curLoginUser();
|
|
|
+ if (loginUser.getRole().equals(Role.TEACHING)) {
|
|
|
+ req.setTeachingId(loginUser.getCategoryId());
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ String fileName = URLEncoder.encode(System.currentTimeMillis() + "", "UTF-8");
|
|
|
+ response.setHeader("Content-Disposition", "inline; filename=" + fileName + ".xlsx");
|
|
|
+ response.setContentType("application/vnd.ms-excel");
|
|
|
+ ExcelWriter writer = ExcelWriter.create(ExcelType.XLSX);
|
|
|
+ List<StudentExportVO> exportList = studentService.exportPage(req);
|
|
|
+ if (exportList == null || exportList.isEmpty()) {
|
|
|
+ throw new StatusException("无考生信息");
|
|
|
+ }
|
|
|
+ writer.writeObjects("考生信息", null, StudentExportVO.class, exportList.iterator());
|
|
|
+ writer.output(response.getOutputStream());
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.error(e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|