|
|
|
@ -1,137 +1,129 @@
|
|
|
|
|
// 导入所需的包
|
|
|
|
|
package com.yf.exam.modules.qu.controller;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
import com.yf.exam.core.api.ApiRest;
|
|
|
|
|
import com.yf.exam.core.api.controller.BaseController;
|
|
|
|
|
import com.yf.exam.core.api.dto.BaseIdReqDTO;
|
|
|
|
|
import com.yf.exam.core.api.dto.BaseIdRespDTO;
|
|
|
|
|
import com.yf.exam.core.api.dto.BaseIdsReqDTO;
|
|
|
|
|
import com.yf.exam.core.api.dto.PagingReqDTO;
|
|
|
|
|
import com.yf.exam.core.exception.ServiceException;
|
|
|
|
|
import com.yf.exam.core.utils.BeanMapper;
|
|
|
|
|
import com.yf.exam.core.utils.excel.ExportExcel;
|
|
|
|
|
import com.yf.exam.core.utils.excel.ImportExcel;
|
|
|
|
|
import com.yf.exam.modules.qu.dto.QuDTO;
|
|
|
|
|
import com.yf.exam.modules.qu.dto.export.QuExportDTO;
|
|
|
|
|
import com.yf.exam.modules.qu.dto.ext.QuDetailDTO;
|
|
|
|
|
import com.yf.exam.modules.qu.dto.request.QuQueryReqDTO;
|
|
|
|
|
import com.yf.exam.modules.qu.entity.Qu;
|
|
|
|
|
import com.yf.exam.modules.qu.service.QuService;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
|
|
|
import org.apache.shiro.authz.annotation.RequiresRoles;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; // 用于构建查询条件
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; // 用于分页
|
|
|
|
|
import com.google.common.collect.Lists; // 用于操作列表
|
|
|
|
|
import com.yf.exam.core.api.ApiRest; // API响应封装类
|
|
|
|
|
import com.yf.exam.core.api.controller.BaseController; // 基础控制器类
|
|
|
|
|
import com.yf.exam.core.api.dto.BaseIdReqDTO; // 基础ID请求DTO
|
|
|
|
|
import com.yf.exam.core.api.dto.BaseIdRespDTO; // 基础ID响应DTO
|
|
|
|
|
import com.yf.exam.core.api.dto.BaseIdsReqDTO; // 基础ID数组请求DTO
|
|
|
|
|
import com.yf.exam.core.api.dto.PagingReqDTO; // 分页请求DTO
|
|
|
|
|
import com.yf.exam.core.exception.ServiceException; // 自定义服务异常
|
|
|
|
|
import com.yf.exam.core.utils.BeanMapper; // Bean映射工具
|
|
|
|
|
import com.yf.exam.core.utils.excel.ExportExcel; // 导出Excel工具
|
|
|
|
|
import com.yf.exam.core.utils.excel.ImportExcel; // 导入Excel工具
|
|
|
|
|
import com.yf.exam.modules.qu.dto.QuDTO; // 问题DTO
|
|
|
|
|
import com.yf.exam.modules.qu.dto.export.QuExportDTO; // 问题导出DTO
|
|
|
|
|
import com.yf.exam.modules.qu.dto.ext.QuDetailDTO; // 问题详情DTO
|
|
|
|
|
import com.yf.exam.modules.qu.dto.request.QuQueryReqDTO; // 问题查询请求DTO
|
|
|
|
|
import com.yf.exam.modules.qu.entity.Qu; // 问题实体类
|
|
|
|
|
import com.yf.exam.modules.qu.service.QuService; // 问题服务类
|
|
|
|
|
import io.swagger.annotations.Api; // Swagger API注释
|
|
|
|
|
import io.swagger.annotations.ApiOperation; // Swagger API操作注释
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; // 字符串操作工具类
|
|
|
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException; // 用于处理Excel格式异常
|
|
|
|
|
import org.apache.shiro.authz.annotation.RequiresRoles; // Shiro权限控制注解
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; // 自动注入依赖
|
|
|
|
|
import org.springframework.util.CollectionUtils; // 集合工具类
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody; // 请求体注解
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; // 请求映射注解
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod; // 请求方法类型注解
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam; // 请求参数注解
|
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody; // 响应体注解
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController; // REST控制器注解
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile; // 用于处理文件上传
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; // 用于处理HTTP响应
|
|
|
|
|
import java.io.IOException; // IO异常处理
|
|
|
|
|
import java.util.Arrays; // 数组工具类
|
|
|
|
|
import java.util.List; // 列表工具类
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <p>
|
|
|
|
|
* 问题题目控制器
|
|
|
|
|
* </p>
|
|
|
|
|
* 该控制器类负责管理题目相关的操作,包括添加、修改、删除、查询等
|
|
|
|
|
*
|
|
|
|
|
* @author 聪明笨狗
|
|
|
|
|
* @since 2020-05-25 13:25
|
|
|
|
|
*/
|
|
|
|
|
@Api(tags={"问题题目"})
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/exam/api/qu/qu")
|
|
|
|
|
@Api(tags={"问题题目"}) // Swagger注解,表示该控制器处理"问题题目"相关的请求
|
|
|
|
|
@RestController // Spring注解,表示这是一个RESTful API控制器
|
|
|
|
|
@RequestMapping("/exam/api/qu/qu") // 设置基础路径
|
|
|
|
|
public class QuController extends BaseController {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private QuService baseService;
|
|
|
|
|
private QuService baseService; // 自动注入问题服务类
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 添加或修改
|
|
|
|
|
* 添加或修改问题题目
|
|
|
|
|
*
|
|
|
|
|
* @param reqDTO
|
|
|
|
|
* @return
|
|
|
|
|
* @param reqDTO 请求的详细数据,包含问题题目的详细信息
|
|
|
|
|
* @return 返回操作结果
|
|
|
|
|
*/
|
|
|
|
|
@RequiresRoles("sa")
|
|
|
|
|
@ApiOperation(value = "添加或修改")
|
|
|
|
|
@RequestMapping(value = "/save", method = {RequestMethod.POST})
|
|
|
|
|
@RequiresRoles("sa") // 限制只有角色为"sa"的用户可以访问此方法
|
|
|
|
|
@ApiOperation(value = "添加或修改") // Swagger注解,描述该方法的功能
|
|
|
|
|
@RequestMapping(value = "/save", method = {RequestMethod.POST}) // POST请求,表示保存操作
|
|
|
|
|
public ApiRest<BaseIdRespDTO> save(@RequestBody QuDetailDTO reqDTO) {
|
|
|
|
|
baseService.save(reqDTO);
|
|
|
|
|
return super.success();
|
|
|
|
|
baseService.save(reqDTO); // 调用服务层保存或更新问题数据
|
|
|
|
|
return super.success(); // 返回成功响应
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 批量删除
|
|
|
|
|
* 批量删除问题题目
|
|
|
|
|
*
|
|
|
|
|
* @param reqDTO
|
|
|
|
|
* @return
|
|
|
|
|
* @param reqDTO 请求的ID数组,包含要删除的题目ID列表
|
|
|
|
|
* @return 返回操作结果
|
|
|
|
|
*/
|
|
|
|
|
@RequiresRoles("sa")
|
|
|
|
|
@ApiOperation(value = "批量删除")
|
|
|
|
|
@RequestMapping(value = "/delete", method = {RequestMethod.POST})
|
|
|
|
|
@RequiresRoles("sa") // 限制只有角色为"sa"的用户可以访问此方法
|
|
|
|
|
@ApiOperation(value = "批量删除") // Swagger注解,描述该方法的功能
|
|
|
|
|
@RequestMapping(value = "/delete", method = {RequestMethod.POST}) // POST请求,表示删除操作
|
|
|
|
|
public ApiRest edit(@RequestBody BaseIdsReqDTO reqDTO) {
|
|
|
|
|
//根据ID删除
|
|
|
|
|
baseService.delete(reqDTO.getIds());
|
|
|
|
|
return super.success();
|
|
|
|
|
baseService.delete(reqDTO.getIds()); // 调用服务层进行批量删除
|
|
|
|
|
return super.success(); // 返回成功响应
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查找详情
|
|
|
|
|
* 查找问题题目详情
|
|
|
|
|
*
|
|
|
|
|
* @param reqDTO
|
|
|
|
|
* @return
|
|
|
|
|
* @param reqDTO 请求的ID数据,包含要查找的题目ID
|
|
|
|
|
* @return 返回问题题目的详细信息
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation(value = "查找详情")
|
|
|
|
|
@RequestMapping(value = "/detail", method = {RequestMethod.POST})
|
|
|
|
|
@ApiOperation(value = "查找详情") // Swagger注解,描述该方法的功能
|
|
|
|
|
@RequestMapping(value = "/detail", method = {RequestMethod.POST}) // POST请求,表示获取详情操作
|
|
|
|
|
public ApiRest<QuDetailDTO> detail(@RequestBody BaseIdReqDTO reqDTO) {
|
|
|
|
|
QuDetailDTO dto = baseService.detail(reqDTO.getId());
|
|
|
|
|
return super.success(dto);
|
|
|
|
|
QuDetailDTO dto = baseService.detail(reqDTO.getId()); // 调用服务层获取问题题目详情
|
|
|
|
|
return super.success(dto); // 返回问题详情
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分页查找
|
|
|
|
|
* 分页查询问题题目
|
|
|
|
|
*
|
|
|
|
|
* @param reqDTO
|
|
|
|
|
* @return
|
|
|
|
|
* @param reqDTO 分页请求数据,包含查询条件和分页参数
|
|
|
|
|
* @return 返回分页结果
|
|
|
|
|
*/
|
|
|
|
|
@RequiresRoles("sa")
|
|
|
|
|
@ApiOperation(value = "分页查找")
|
|
|
|
|
@RequestMapping(value = "/paging", method = {RequestMethod.POST})
|
|
|
|
|
@RequiresRoles("sa") // 限制只有角色为"sa"的用户可以访问此方法
|
|
|
|
|
@ApiOperation(value = "分页查找") // Swagger注解,描述该方法的功能
|
|
|
|
|
@RequestMapping(value = "/paging", method = {RequestMethod.POST}) // POST请求,表示分页查询操作
|
|
|
|
|
public ApiRest<IPage<QuDTO>> paging(@RequestBody PagingReqDTO<QuQueryReqDTO> reqDTO) {
|
|
|
|
|
|
|
|
|
|
//分页查询并转换
|
|
|
|
|
IPage<QuDTO> page = baseService.paging(reqDTO);
|
|
|
|
|
|
|
|
|
|
return super.success(page);
|
|
|
|
|
IPage<QuDTO> page = baseService.paging(reqDTO); // 调用服务层进行分页查询
|
|
|
|
|
return super.success(page); // 返回分页结果
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导出excel文件
|
|
|
|
|
* 导出问题题目的Excel文件
|
|
|
|
|
*/
|
|
|
|
|
@RequiresRoles("sa")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
@RequestMapping(value = "/export")
|
|
|
|
|
@RequiresRoles("sa") // 限制只有角色为"sa"的用户可以访问此方法
|
|
|
|
|
@ResponseBody // 标明返回内容直接作为响应体
|
|
|
|
|
@RequestMapping(value = "/export") // 导出请求路径
|
|
|
|
|
public ApiRest exportFile(HttpServletResponse response, @RequestBody QuQueryReqDTO reqDTO) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 导出文件名
|
|
|
|
|
String fileName = "导出的试题-" + System.currentTimeMillis() + ".xlsx";
|
|
|
|
|
|
|
|
|
|
String fileName = "导出的试题-" + System.currentTimeMillis() + ".xlsx"; // 设置导出的文件名
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
int no = 0;
|
|
|
|
|
String quId = "";
|
|
|
|
|
List<QuExportDTO> list = baseService.listForExport(reqDTO);
|
|
|
|
|
List<QuExportDTO> list = baseService.listForExport(reqDTO); // 获取导出数据
|
|
|
|
|
for (QuExportDTO item : list) {
|
|
|
|
|
if (!quId.equals(item.getQId())) {
|
|
|
|
|
quId = item.getQId();
|
|
|
|
@ -144,135 +136,101 @@ public class QuController extends BaseController {
|
|
|
|
|
item.setQImage("");
|
|
|
|
|
item.setQVideo("");
|
|
|
|
|
}
|
|
|
|
|
item.setNo(String.valueOf(no));
|
|
|
|
|
item.setNo(String.valueOf(no)); // 设置题目序号
|
|
|
|
|
}
|
|
|
|
|
new ExportExcel("试题", QuExportDTO.class).setDataList(list).write(response, fileName).dispose();
|
|
|
|
|
return super.success();
|
|
|
|
|
new ExportExcel("试题", QuExportDTO.class).setDataList(list).write(response, fileName).dispose(); // 导出数据到Excel文件
|
|
|
|
|
return super.success(); // 返回成功响应
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
return failure(e.getMessage());
|
|
|
|
|
return failure(e.getMessage()); // 捕获异常并返回失败响应
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导入Excel
|
|
|
|
|
* 导入问题题目的Excel文件
|
|
|
|
|
*
|
|
|
|
|
* @param file
|
|
|
|
|
* @return
|
|
|
|
|
* @param file 上传的Excel文件
|
|
|
|
|
* @return 返回操作结果
|
|
|
|
|
*/
|
|
|
|
|
@RequiresRoles("sa")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
@RequestMapping(value = "/import")
|
|
|
|
|
@RequiresRoles("sa") // 限制只有角色为"sa"的用户可以访问此方法
|
|
|
|
|
@ResponseBody // 标明返回内容直接作为响应体
|
|
|
|
|
@RequestMapping(value = "/import") // 导入请求路径
|
|
|
|
|
public ApiRest importFile(@RequestParam("file") MultipartFile file) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
ImportExcel ei = new ImportExcel(file, 1, 0);
|
|
|
|
|
List<QuExportDTO> list = ei.getDataList(QuExportDTO.class);
|
|
|
|
|
|
|
|
|
|
// 校验数据
|
|
|
|
|
this.checkExcel(list);
|
|
|
|
|
|
|
|
|
|
// 导入数据条数
|
|
|
|
|
baseService.importExcel(list);
|
|
|
|
|
|
|
|
|
|
// 导入成功
|
|
|
|
|
return super.success();
|
|
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
|
|
} catch (InvalidFormatException e) {
|
|
|
|
|
|
|
|
|
|
} catch (IllegalAccessException e) {
|
|
|
|
|
|
|
|
|
|
} catch (InstantiationException e) {
|
|
|
|
|
|
|
|
|
|
ImportExcel ei = new ImportExcel(file, 1, 0); // 创建导入Excel对象
|
|
|
|
|
List<QuExportDTO> list = ei.getDataList(QuExportDTO.class); // 获取Excel中的数据列表
|
|
|
|
|
this.checkExcel(list); // 校验数据
|
|
|
|
|
baseService.importExcel(list); // 调用服务层进行导入操作
|
|
|
|
|
return super.success(); // 返回成功响应
|
|
|
|
|
} catch (IOException | InvalidFormatException | IllegalAccessException | InstantiationException e) {
|
|
|
|
|
return super.failure(); // 捕获各种异常并返回失败响应
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return super.failure();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 校验Excel
|
|
|
|
|
* 校验Excel文件中的数据
|
|
|
|
|
*
|
|
|
|
|
* @param list
|
|
|
|
|
* @throws Exception
|
|
|
|
|
* @param list 导入的题目数据列表
|
|
|
|
|
* @throws ServiceException 可能抛出服务异常
|
|
|
|
|
*/
|
|
|
|
|
private void checkExcel(List<QuExportDTO> list) throws ServiceException {
|
|
|
|
|
|
|
|
|
|
// 约定第三行开始导入
|
|
|
|
|
// 校验Excel数据的逻辑,检查每一行数据的有效性
|
|
|
|
|
int line = 3;
|
|
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
|
|
|
throw new ServiceException(1, "您导入的数据似乎是一个空表格!");
|
|
|
|
|
throw new ServiceException(1, "您导入的数据似乎是一个空表格!"); // 如果表格为空,抛出异常
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Integer quNo = null;
|
|
|
|
|
for (QuExportDTO item : list) {
|
|
|
|
|
|
|
|
|
|
System.out.println(item.getNo());
|
|
|
|
|
if (StringUtils.isBlank(item.getNo())) {
|
|
|
|
|
line++;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
System.out.println(item.getQContent());
|
|
|
|
|
Integer no;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
no = Integer.parseInt(item.getNo());
|
|
|
|
|
no = Integer.parseInt(item.getNo()); // 转换题目序号
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
line++;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (no == null) {
|
|
|
|
|
sb.append("第" + line + "行,题目序号不能为空!<br>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 校验题目内容和其他字段是否为空
|
|
|
|
|
if (quNo == null || !quNo.equals(no)) {
|
|
|
|
|
|
|
|
|
|
if (item.getQuType() == null) {
|
|
|
|
|
sb.append("第" + line + "行,题目类型不能为空<br>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(item.getQContent())) {
|
|
|
|
|
sb.append("第" + line + "行,题目内容不能为空<br>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(item.getRepoList())) {
|
|
|
|
|
sb.append("第" + line + "行,题目必须包含一个题库<br>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(item.getAIsRight())) {
|
|
|
|
|
sb.append("第" + line + "行,选项是否正确不能为空<br>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(item.getAContent()) && StringUtils.isBlank(item.getAImage())) {
|
|
|
|
|
sb.append("第" + line + "行,选项内容和选项图片必须有一个不为空<br>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
quNo = no;
|
|
|
|
|
line++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 存在错误
|
|
|
|
|
if (!"".equals(sb.toString())) {
|
|
|
|
|
throw new ServiceException(1, sb.toString());
|
|
|
|
|
throw new ServiceException(1, sb.toString()); // 如果有校验错误,抛出异常
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 下载导入试题数据模板
|
|
|
|
|
* 下载试题导入模板
|
|
|
|
|
*/
|
|
|
|
|
@ResponseBody
|
|
|
|
|
@RequestMapping(value = "import/template")
|
|
|
|
|
@RequestMapping(value = "import/template") // 导入模板下载路径
|
|
|
|
|
public ApiRest importFileTemplate(HttpServletResponse response) {
|
|
|
|
|
try {
|
|
|
|
|
String fileName = "试题导入模板.xlsx";
|
|
|
|
|
List<QuExportDTO> list = Lists.newArrayList();
|
|
|
|
|
|
|
|
|
|
String fileName = "试题导入模板.xlsx"; // 设置文件名
|
|
|
|
|
List<QuExportDTO> list = Lists.newArrayList(); // 创建模板数据列表
|
|
|
|
|
// 模板数据(包含问题内容、题型、选项等)
|
|
|
|
|
QuExportDTO l1 = new QuExportDTO();
|
|
|
|
|
l1.setNo("正式导入,请删除此说明行:数字,相同的数字表示同一题的序列");
|
|
|
|
|
l1.setQContent("问题内容");
|
|
|
|
@ -286,39 +244,17 @@ public class QuController extends BaseController {
|
|
|
|
|
l1.setAIsRight("只能填写0或1,0表示否,1表示是");
|
|
|
|
|
l1.setAAnalysis("这个项是正确的");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QuExportDTO l2 = new QuExportDTO();
|
|
|
|
|
l2.setQContent("找出以下可以被2整除的数(多选)");
|
|
|
|
|
l2.setQAnalysis("最基本的数学题,不做过多解析");
|
|
|
|
|
l2.setQuType("2");
|
|
|
|
|
l2.setNo("1");
|
|
|
|
|
l2.setAIsRight("1");
|
|
|
|
|
l2.setAContent("数字:2");
|
|
|
|
|
l2.setAAnalysis("2除以2=1,对的");
|
|
|
|
|
|
|
|
|
|
QuExportDTO l3 = new QuExportDTO();
|
|
|
|
|
l3.setNo("1");
|
|
|
|
|
l3.setAIsRight("0");
|
|
|
|
|
l3.setAContent("数字:3");
|
|
|
|
|
l3.setAAnalysis("3除以2=1.5,不能被整除");
|
|
|
|
|
|
|
|
|
|
QuExportDTO l4 = new QuExportDTO();
|
|
|
|
|
l4.setNo("1");
|
|
|
|
|
l4.setAIsRight("1");
|
|
|
|
|
l4.setAContent("数字:6");
|
|
|
|
|
l4.setAAnalysis("6除以2=3,对的");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 添加模板示例数据
|
|
|
|
|
list.add(l1);
|
|
|
|
|
list.add(l2);
|
|
|
|
|
list.add(l3);
|
|
|
|
|
list.add(l4);
|
|
|
|
|
|
|
|
|
|
// 导出模板文件
|
|
|
|
|
new ExportExcel("试题数据", QuExportDTO.class, 1).setDataList(list).write(response, fileName).dispose();
|
|
|
|
|
return super.success();
|
|
|
|
|
return super.success(); // 返回成功响应
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
return super.failure("导入模板下载失败!失败信息:"+e.getMessage());
|
|
|
|
|
return super.failure("导入模板下载失败!失败信息:"+e.getMessage()); // 返回失败响应
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|