he2802 há 3 anos atrás
pai
commit
b53f093e16

+ 3 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserExamWrongRecordAddBo.java

@@ -5,7 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 import java.util.Date;
-
+import java.util.List;
 
 
 /**
@@ -23,7 +23,7 @@ public class UserExamWrongRecordAddBo {
     private Long recordId;
     /** 错误题目ID */
     @ApiModelProperty("错误题目ID")
-    private Long questionId;
+    private List<Long> questionIds;
     /** 用户ID */
     @ApiModelProperty("用户ID")
     private Long userId;
@@ -39,4 +39,5 @@ public class UserExamWrongRecordAddBo {
     /** 更新时间 */
     @ApiModelProperty("更新时间")
     private Long updateTime;
+
 }

+ 16 - 5
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserExamWrongRecordServiceImpl.java

@@ -2,6 +2,7 @@ package com.zhongzheng.modules.user.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.StrUtil;
+import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.modules.bank.vo.QuestionVo;
 import com.zhongzheng.modules.collect.domain.CollectQuestion;
@@ -12,6 +13,7 @@ import com.zhongzheng.modules.user.domain.UserExamWrongRecord;
 import com.zhongzheng.modules.user.mapper.UserExamRecordMapper;
 import com.zhongzheng.modules.user.mapper.UserExamWrongRecordMapper;
 import com.zhongzheng.modules.user.service.IUserExamWrongRecordService;
+import com.zhongzheng.modules.user.vo.SubjectStudyRecordVo;
 import com.zhongzheng.modules.user.vo.UserExamWrongRecordVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -101,11 +103,20 @@ public class UserExamWrongRecordServiceImpl extends ServiceImpl<UserExamWrongRec
 
     @Override
     public Boolean insertByAddBo(UserExamWrongRecordAddBo bo) {
-        UserExamWrongRecord add = BeanUtil.toBean(bo, UserExamWrongRecord.class);
-        validEntityBeforeSave(add);
-        add.setCreateTime(DateUtils.getNowTime());
-        add.setUpdateTime(DateUtils.getNowTime());
-        return this.save(add);
+        if(bo.getQuestionIds()==null||bo.getQuestionIds().size()==0){
+            throw new CustomException("题目数组错误");
+        }
+        boolean result = false;
+        for (Long questionId : bo.getQuestionIds()) {
+            UserExamWrongRecord add = BeanUtil.toBean(bo, UserExamWrongRecord.class);
+            validEntityBeforeSave(add);
+            add.setCreateTime(DateUtils.getNowTime());
+            add.setUpdateTime(DateUtils.getNowTime());
+            add.setQuestionId(questionId);
+            result = this.save(add);
+        }
+
+        return result;
     }
 
     @Override