diff --git a/src/main/java/com/subsidy/controller/ExerciseDictController.java b/src/main/java/com/subsidy/controller/ExerciseDictController.java index bbf5b36..e79a973 100644 --- a/src/main/java/com/subsidy/controller/ExerciseDictController.java +++ b/src/main/java/com/subsidy/controller/ExerciseDictController.java @@ -16,10 +16,8 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.CachePut; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; /** *

@@ -74,4 +72,17 @@ public class ExerciseDictController { return ResponseData.generateCreatedResponse(0,exerciseDictService.getPaperExercise(getPaperExerciseDTO)); } + @PostMapping("judge") + @ApiOperation("判断题 file ") + public ResponseVO judge(@RequestParam("file") MultipartFile file,Long paperId,Long courseId){ + return ResponseData.generateCreatedResponse(0,exerciseDictService.judge(file,paperId,courseId)); + } + + @PostMapping("select") + @ApiOperation("选择题 file") + public ResponseVO select(@RequestParam("file") MultipartFile file,Long paperId,Long courseId){ + return ResponseData.generateCreatedResponse(0,exerciseDictService.select(file,paperId,courseId)); + } + + } diff --git a/src/main/java/com/subsidy/dto/exercise/JudgeDTO.java b/src/main/java/com/subsidy/dto/exercise/JudgeDTO.java new file mode 100644 index 0000000..53c0d4b --- /dev/null +++ b/src/main/java/com/subsidy/dto/exercise/JudgeDTO.java @@ -0,0 +1,22 @@ +package com.subsidy.dto.exercise; + +import com.subsidy.util.excel.ExcelColumnUtil; +import lombok.Data; + +@Data +public class JudgeDTO { + + @ExcelColumnUtil(value = "序号", col = 1) + private Integer id; + + @ExcelColumnUtil(value = "题目", col = 2) + private String title; + + @ExcelColumnUtil(value = "题目类型", col = 3) + private String exerciseType; + + @ExcelColumnUtil(value = "答案(填“是”或者“否”)", col = 4) + private String answer; + + +} diff --git a/src/main/java/com/subsidy/dto/exercise/SelectDTO.java b/src/main/java/com/subsidy/dto/exercise/SelectDTO.java new file mode 100644 index 0000000..df42473 --- /dev/null +++ b/src/main/java/com/subsidy/dto/exercise/SelectDTO.java @@ -0,0 +1,34 @@ +package com.subsidy.dto.exercise; + +import com.subsidy.util.excel.ExcelColumnUtil; +import lombok.Data; + +@Data +public class SelectDTO { + + @ExcelColumnUtil(value = "序号", col = 1) + private Integer id; + + @ExcelColumnUtil(value = "题目", col = 2) + private String title; + + @ExcelColumnUtil(value = "题目类型", col = 3) + private String exerciseType; + + @ExcelColumnUtil(value = "选项A", col = 4) + private String answerA; + + @ExcelColumnUtil(value = "选项B", col = 5) + private String answerB; + + @ExcelColumnUtil(value = "选项C", col = 6) + private String answerC; + + @ExcelColumnUtil(value = "选项D", col = 7) + private String answerD; + + @ExcelColumnUtil(value = "正确答案(多选的答案用英文逗号隔开)", col = 8) + private String rightAnswer; + + +} diff --git a/src/main/java/com/subsidy/model/RenshejuHistoryDO.java b/src/main/java/com/subsidy/model/RenshejuHistoryDO.java index d6a1567..4b499c4 100644 --- a/src/main/java/com/subsidy/model/RenshejuHistoryDO.java +++ b/src/main/java/com/subsidy/model/RenshejuHistoryDO.java @@ -40,5 +40,9 @@ public class RenshejuHistoryDO extends BaseModel { */ private Object outputParam; + /** + * 备注 + */ + private String remarkNote; } diff --git a/src/main/java/com/subsidy/service/ExerciseDictService.java b/src/main/java/com/subsidy/service/ExerciseDictService.java index 44a7f5f..b8e8368 100644 --- a/src/main/java/com/subsidy/service/ExerciseDictService.java +++ b/src/main/java/com/subsidy/service/ExerciseDictService.java @@ -8,6 +8,7 @@ import com.subsidy.model.CourseDictDO; import com.subsidy.model.ExerciseDictDO; import com.baomidou.mybatisplus.extension.service.IService; import com.subsidy.vo.course.ExerciseVO; +import org.springframework.web.multipart.MultipartFile; import java.util.List; @@ -30,4 +31,8 @@ public interface ExerciseDictService extends IService { Long submit(SubmitDTO submitDTO); IPage getPaperExercise(GetPaperExerciseDTO getPaperExerciseDTO); + + String judge(MultipartFile multipartFile,Long paperId,Long courseId); + + String select(MultipartFile multipartFile,Long paperId,Long courseId); } diff --git a/src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java b/src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java index d41bd34..0029f4b 100644 --- a/src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java @@ -1396,7 +1396,7 @@ public class AdministerServiceImpl extends ServiceImpl @@ -133,4 +145,68 @@ public class ExerciseDictServiceImpl extends ServiceImpl { + ExerciseDictDO exerciseDictDO = new ExerciseDictDO(); + exerciseDictDO.setTitle("

"+s.getTitle()+"

"); + exerciseDictDO.setRightAnswer(s.getAnswer()); + exerciseDictDO.setExerciseType(s.getExerciseType()); + exerciseDictDO.setDifficulty("适中"); + exerciseDictDO.setPaperId(paperId); + exerciseDictDO.setCourseId(courseId); + exerciseDictDO.setOrderNo(s.getId()); + this.baseMapper.insert(exerciseDictDO); + }); + } catch (Exception e) { + e.printStackTrace(); + throw new HttpException(10001); + } + return ConstantUtils.ADD_SUCCESS; + } + + public String select(MultipartFile multipartFile,Long paperId,Long courseId){ + + try { + ExcelUtil.readExcel(null, SelectDTO.class, multipartFile).forEach(s -> { + ExerciseDictDO exerciseDictDO = new ExerciseDictDO(); + exerciseDictDO.setTitle("

"+s.getTitle()+"

"); + exerciseDictDO.setOrderNo(s.getId()); + exerciseDictDO.setExerciseType(s.getExerciseType()); + //选项 + StringBuffer items = new StringBuffer(); + items.append("["); + items.append("{\"label\":\"

").append(s.getAnswerA()).append("

\",\"value\":\"A\"},"); + items.append("{\"label\":\"

").append(s.getAnswerB()).append("

\",\"value\":\"B\"},"); + items.append("{\"label\":\"

").append(s.getAnswerC()).append("

\",\"value\":\"C\"},"); + items.append("{\"label\":\"

").append(s.getAnswerD()).append("

\",\"value\":\"D\"}]"); + exerciseDictDO.setItems(items.toString()); + + if ("单选题".equals(s.getExerciseType())){ + exerciseDictDO.setRightAnswer(s.getRightAnswer()); + }else { + String[] answers = s.getRightAnswer().split(","); + StringBuffer answer = new StringBuffer(); + answer.append("["); + int i = 0; + for (String split : answers){ + answer.append("\"").append(split).append("\""); + if(i!=answers.length-1){ + answer.append(","); + } + i++; + } + answer.append("]"); + exerciseDictDO.setRightAnswer(answer.toString()); + } + this.baseMapper.insert(exerciseDictDO); + }); + } catch (Exception e) { + e.printStackTrace(); + throw new HttpException(10001); + } + return ConstantUtils.ADD_SUCCESS; + } + } diff --git a/src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java b/src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java index 5e4fd45..edbabeb 100644 --- a/src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java @@ -79,6 +79,7 @@ public class RenSheJuServiceImpl implements RenSheJuService { answerClassIds.stream().forEach(x -> classIds.add(x)); imageClassIds.stream().forEach(x -> classIds.add(x)); + try { if (classIds.size() > 0) { for (Long classId : classIds) { @@ -166,6 +167,7 @@ public class RenSheJuServiceImpl implements RenSheJuService { List result = new ArrayList<>(); +// List vodClassIds = new ArrayList<>(); try { for (Long classId : vodClassIds) { diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index 7ab97b0..427c151 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -11,7 +11,7 @@ spring.server.port=23457 #spring.datasource.username=devloper #spring.datasource.password=dev@1553$ -# 数据源配置 8.0数据库 +# 数据源配置 spring.datasource.url=jdbc:mysql://139.224.253.21:3306/subsidy?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8 spring.datasource.type=com.alibaba.druid.pool.DruidDataSource spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index cc0c047..71c7dba 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,5 +1,5 @@ # 环境配置 -spring.profiles.active=prod +spring.profiles.active=dev #和CPU数 spring.server.acceptorThreadCount=600 spring.server.minSpareThreads=100 diff --git a/src/main/resources/mapper/ImageCheckRecordMapper.xml b/src/main/resources/mapper/ImageCheckRecordMapper.xml index e0f1a9b..97091a8 100644 --- a/src/main/resources/mapper/ImageCheckRecordMapper.xml +++ b/src/main/resources/mapper/ImageCheckRecordMapper.xml @@ -22,7 +22,7 @@