xiangpei
2024-10-29 83953fac1e778b6de84efaa09bc6913fed2e0b12
Merge remote-tracking branch 'origin/master'
6个文件已修改
78 ■■■■ 已修改文件
src/docker/Dockerfile 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ycl/jxkg/controller/admin/UploadController.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ycl/jxkg/service/impl/ExamPaperServiceImpl.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ycl/jxkg/service/impl/ExamServiceImpl.java 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application-dev.yml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application-prod.yml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/docker/Dockerfile
@@ -10,10 +10,10 @@
COPY simsun.ttc /usr/share/fonts/
# easyExcel字体
RUN apk add fontconfig && apk add --update ttf-dejavu && fc-cache --force
# 同步docker内部的时间
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# 设置时区
ENV TZ=Asia/Shanghai
# 同步docker内部的时间
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
EXPOSE 8000
# 复制jar包到/user/local/java下
ARG JAR_FILE
src/main/java/com/ycl/jxkg/controller/admin/UploadController.java
@@ -14,6 +14,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
@@ -129,5 +130,37 @@
        }
    }
    @PostMapping("/img")
    public Result questionUploadAndReadExcel(MultipartFile file) {
        // 检查文件是否为空
        if (file == null || file.isEmpty()) {
            return Result.fail(500, "上传的文件为空");
        }
        String randomName = null;
        HashMap hashMap = new HashMap(2);
        try {
            // 获取文件名
            String originalFileName = StringUtils.cleanPath(file.getOriginalFilename());
            randomName = UUID.randomUUID().toString().replace("-", "") + originalFileName.substring(originalFileName.lastIndexOf("."));
            // 指定文件存储路径
            String uploadDir = ruoYiConfig.getUrl(); // 修改为您希望存储的目录
            // 如果目录不存在,则创建目录
            File dir = new File(uploadDir);
            if (!dir.exists()) {
                dir.mkdirs();
            }
            // 构建目标文件的路径
            String filePath = uploadDir + "/" + randomName;
            // 将文件保存到目标位置
            file.transferTo(new File(filePath));
            hashMap.put("name", originalFileName);
            hashMap.put("url", randomName);
        } catch (IOException e) {
            e.printStackTrace();
            // 返回失败响应
            return Result.fail(500, "文件上传失败");
        }
        userService.changePicture(getCurrentUser(), randomName);
        return Result.ok(hashMap);
    }
}
src/main/java/com/ycl/jxkg/service/impl/ExamPaperServiceImpl.java
@@ -46,6 +46,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
@@ -74,9 +75,12 @@
        examPaper.setScore(new BigDecimal(form.getScore()));
        //随机试卷
        if (ExamPaperTypeEnum.Random.getCode().equals(form.getPaperType())) {
            //校验题目数量
            //校验标题是否填写、校验题目数量
            List<PaperQuestionSettingDTO> questionSetting = form.getQuestionSetting();
            for (PaperQuestionSettingDTO settingDTO : questionSetting) {
                if(StringUtils.isEmpty(settingDTO.getTitle())){
                    return Result.fail(SystemCode.InnerError.getCode(),"标题不能为空");
                }
                Integer questionType = settingDTO.getQuestionType();
                for (PaperSettingItem item : settingDTO.getSettingList()) {
                    Integer num = item.getNum();
@@ -100,6 +104,12 @@
            return Result.ok();
        } else if (ExamPaperTypeEnum.Fixed.getCode().equals(form.getPaperType())) {
            //固定试卷
            List<PaperFixQuestionDTO> questionTitleList = form.getQuestionTitleList();
            for (PaperFixQuestionDTO dto : questionTitleList) {
                if(StringUtils.isEmpty(dto.getTitle())){
                    return Result.fail(SystemCode.InnerError.getCode(),"标题不能为空");
                }
            }
            examPaper.setContent(JSON.toJSONString(form.getQuestionTitleList()));
            baseMapper.insert(examPaper);
            return Result.ok();
@@ -116,6 +126,9 @@
                List<PaperSettingItem> settingList = settingDTO.getSettingList();
                List<PaperQuestion> questionList = new ArrayList<>();
                for (PaperSettingItem item : settingList) {
                    if(StringUtils.isEmpty(settingDTO.getTitle())){
                        return Result.fail(SystemCode.InnerError.getCode(),"标题不能为空");
                    }
                    Integer num = item.getNum();
                    Integer difficult = item.getDifficult();
                    //需要配置的题目数量为0则跳过
src/main/java/com/ycl/jxkg/service/impl/ExamServiceImpl.java
@@ -255,9 +255,9 @@
                .one();
        if (Objects.nonNull(hasJoin)) {
            // 允许提交后继续作答
//            if(ExamSubmitTempStatusEnum.finish.equals(hasJoin.getStatus())){
//                throw new RuntimeException("您已提交试卷,请勿重复作答");
//            }
            if(ExamSubmitTempStatusEnum.finish.equals(hasJoin.getStatus())){
                throw new RuntimeException("您已提交试卷,请勿重复作答");
            }
            StartExamVO startExamVO = new StartExamVO();
            startExamVO.setExamName(exam.getExamName());
            startExamVO.setId(hasJoin.getExamId());
@@ -382,7 +382,6 @@
                doQuestionVO.setQuestionType(item.getQuestionType());
                //增加题目分数
                doQuestionVO.setQuestionScore(question.getScore());
                // 题目副本
                QuestionAnswerCopyVO copy = new QuestionAnswerCopyVO();
                copy.setId(question.getId());
@@ -515,7 +514,6 @@
        ExamSubmitTemp one = new LambdaQueryChainWrapper<>(examSubmitTempMapper)
                .eq(ExamSubmitTemp::getExamId, submitData.getId())
                .eq(ExamSubmitTemp::getUserId, webContext.getCurrentUser().getId())
                .eq(ExamSubmitTemp::getDeleted, 0)
                .one();
        if (Objects.nonNull(one)) {
@@ -635,12 +633,14 @@
        for (PaperFixQuestionVO titleItem : titleItems) {
            for (DoQuestionVO doQuestionVO : titleItem.getQuestionList()) {
                Integer questionId = doQuestionVO.getId();
                Optional<QuestionAnswerCopyVO> first = answerList.stream().filter(answer -> questionId.equals(answer.getId())).findFirst();
                if (first.isPresent()) {
                    QuestionAnswerCopyVO answerCopyVO = first.get();
                    doQuestionVO.setQuestionAnswer(answerCopyVO.getCorrect());
                    doQuestionVO.setAnalyze(answerCopyVO.getAnalyze());
                    doQuestionVO.setDifficult(answerCopyVO.getDifficult());
                if(questionId!=null) {
                    Optional<QuestionAnswerCopyVO> first = answerList.stream().filter(answer -> questionId.equals(answer.getId())).findFirst();
                    if (first.isPresent()) {
                        QuestionAnswerCopyVO answerCopyVO = first.get();
                        doQuestionVO.setQuestionAnswer(answerCopyVO.getCorrect());
                        doQuestionVO.setAnalyze(answerCopyVO.getAnalyze());
                        doQuestionVO.setDifficult(answerCopyVO.getDifficult());
                    }
                }
            }
        }
src/main/resources/application-dev.yml
@@ -8,6 +8,7 @@
spring:
  config:
    # 教学资源访问路径
    url: http://localhost:8000
  datasource:
    url: jdbc:mysql://42.193.1.25:3306/xzs?useSSL=true&useUnicode=true&serverTimezone=GMT%2B8&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true&allowMultiQueries=true
src/main/resources/application-prod.yml
@@ -7,6 +7,7 @@
spring:
  config:
    # 教学资源访问路径
    url: http://25.30.6.246:8000
  datasource:
    driver-class-name: dm.jdbc.driver.DmDriver