This commit is contained in:
zhujunjieit 2019-01-13 23:35:32 +08:00
parent 1aa54e37cd
commit 20a71a467f
5 changed files with 48 additions and 24 deletions

View File

@ -75,6 +75,12 @@
<artifactId>hutool-all</artifactId> <artifactId>hutool-all</artifactId>
<version>4.2.1</version> <version>4.2.1</version>
</dependency> </dependency>
<!--fastjson-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.4</version>
</dependency>
<!-- 单表通用mapper --> <!-- 单表通用mapper -->
<dependency> <dependency>
<groupId>tk.mybatis</groupId> <groupId>tk.mybatis</groupId>

View File

@ -6,9 +6,13 @@ import com.ruoyi.exam.service.IExamPracticeQuestionService;
import com.ruoyi.exam.service.IExamPracticeService; import com.ruoyi.exam.service.IExamPracticeService;
import com.ruoyi.exam.service.IExamQuestionService; import com.ruoyi.exam.service.IExamQuestionService;
import com.ruoyi.exam.service.IExamUserErrorQuestionService; import com.ruoyi.exam.service.IExamUserErrorQuestionService;
import com.ruoyi.framework.jwt.JwtUtil;
import com.ruoyi.framework.web.base.BaseController; import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo; import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.util.EntityUtils;
import com.ruoyi.framework.web.util.ShiroUtils; import com.ruoyi.framework.web.util.ShiroUtils;
import com.ruoyi.system.domain.SysUser;
import com.ruoyi.system.service.ISysUserService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -35,6 +39,8 @@ public class ApiPracticeController extends BaseController {
@Autowired @Autowired
private IExamUserErrorQuestionService examUserErrorQuestionService; private IExamUserErrorQuestionService examUserErrorQuestionService;
@Autowired
private ISysUserService sysUserService;
@GetMapping("/v1/practice/list") @GetMapping("/v1/practice/list")
public AjaxResult list(ExamPractice examPractice) { public AjaxResult list(ExamPractice examPractice) {
@ -65,22 +71,25 @@ public class ApiPracticeController extends BaseController {
/** /**
* 保存错题记录 * 保存错题记录
* *
* @param questionId * @param questionIds
* @return * @return
* @description 练习时答错题就保存到错题记录中 * @description 练习时答错题就保存到错题记录中
* 传入问题id * 传入问题id
*/ */
@PostMapping("/v1/practice/answer") @PostMapping("/v1/practice/answer")
public AjaxResult answer(String questionId) { public AjaxResult answer(@RequestBody List<String> questionIds) {
for (String questionId : questionIds) {
ExamUserErrorQuestion examUserErrorQuestion = new ExamUserErrorQuestion(); ExamUserErrorQuestion examUserErrorQuestion = new ExamUserErrorQuestion();
examUserErrorQuestion.setExamQuestionId(Integer.parseInt(questionId)); examUserErrorQuestion.setExamQuestionId(Integer.parseInt(questionId));
examUserErrorQuestion.setVipUserId(Integer.parseInt(ShiroUtils.getUserId().toString())); SysUser sysUser = sysUserService.selectUserByLoginName( JwtUtil.getLoginName() );
examUserErrorQuestion.setCreateBy(ShiroUtils.getLoginName()); examUserErrorQuestion.setVipUserId(sysUser.getUserId().intValue());
examUserErrorQuestion.setCreateDate(new Date()); examUserErrorQuestion.setCreateBy(sysUser.getLoginName());
examUserErrorQuestion.setDelFlag("0"); examUserErrorQuestion.setCreateDate(new Date());
examUserErrorQuestionService.insert(examUserErrorQuestion); examUserErrorQuestion.setDelFlag("0");
examUserErrorQuestion.setUpdateBy(sysUser.getLoginName());
examUserErrorQuestion.setUpdateDate(new Date());
int insert = examUserErrorQuestionService.insertError( examUserErrorQuestion );
}
AjaxResult success = success("插入错题本成功"); AjaxResult success = success("插入错题本成功");
return success; return success;
} }

View File

@ -49,9 +49,9 @@ private static final long serialVersionUID = 1L;
} }
/** 设置会员代码 */ /** 设置会员代码 */
public void setVipUserId(Integer vipUserId) public void setVipUserId(Integer vipUserId)
{ {
this.vipUserId = vipUserId; this.vipUserId = vipUserId;
} }
/** 获取会员代码 */ /** 获取会员代码 */
public Integer getVipUserId() public Integer getVipUserId()

View File

@ -30,4 +30,6 @@ public interface IExamUserErrorQuestionService extends AbstractBaseService<ExamU
List<ExamUserErrorQuestionVO> selectExamUserErrorQuestionDetailPage(ExamUserErrorQuestion examUserErrorQuestion); List<ExamUserErrorQuestionVO> selectExamUserErrorQuestionDetailPage(ExamUserErrorQuestion examUserErrorQuestion);
int insertError(ExamUserErrorQuestion examUserErrorQuestion);
} }

View File

@ -11,28 +11,28 @@ import com.ruoyi.exam.service.IExamUserErrorQuestionService;
import com.ruoyi.framework.web.base.AbstractBaseServiceImpl; import com.ruoyi.framework.web.base.AbstractBaseServiceImpl;
/** /**
* 我的错题 服务层实现 * 我的错题 服务层实现
* *
* @author zhujj * @author zhujj
* @date 2019-01-10 * @date 2019-01-10
*/ */
@Service @Service
public class ExamUserErrorQuestionServiceImpl extends AbstractBaseServiceImpl<ExamUserErrorQuestionMapper,ExamUserErrorQuestion> implements IExamUserErrorQuestionService public class ExamUserErrorQuestionServiceImpl extends AbstractBaseServiceImpl<ExamUserErrorQuestionMapper,ExamUserErrorQuestion> implements IExamUserErrorQuestionService
{ {
@Autowired @Autowired
private ExamUserErrorQuestionMapper examUserErrorQuestionMapper; private ExamUserErrorQuestionMapper examUserErrorQuestionMapper;
/** /**
* 查询我的错题列表 * 查询我的错题列表
* *
* @param examUserErrorQuestion 我的错题信息 * @param examUserErrorQuestion 我的错题信息
* @return 我的错题集合 * @return 我的错题集合
*/ */
@Override @Override
public List<ExamUserErrorQuestion> selectExamUserErrorQuestionList(ExamUserErrorQuestion examUserErrorQuestion) public List<ExamUserErrorQuestion> selectExamUserErrorQuestionList(ExamUserErrorQuestion examUserErrorQuestion)
{ {
return examUserErrorQuestionMapper.selectExamUserErrorQuestionList(examUserErrorQuestion); return examUserErrorQuestionMapper.selectExamUserErrorQuestionList(examUserErrorQuestion);
} }
@Override @Override
public List<ExamUserErrorQuestionVO> selectExamUserErrorQuestionDetailPage(ExamUserErrorQuestion examUserErrorQuestion) { public List<ExamUserErrorQuestionVO> selectExamUserErrorQuestionDetailPage(ExamUserErrorQuestion examUserErrorQuestion) {
@ -40,6 +40,13 @@ public class ExamUserErrorQuestionServiceImpl extends AbstractBaseServiceImpl<Ex
return examUserErrorQuestionMapper.selectExamUserErrorQuestionDetailPage(examUserErrorQuestion); return examUserErrorQuestionMapper.selectExamUserErrorQuestionDetailPage(examUserErrorQuestion);
} }
@Override
public int insertError(ExamUserErrorQuestion examUserErrorQuestion) {
return examUserErrorQuestionMapper.insert( examUserErrorQuestion );
}
/** /**
* 查询我的错题分页列表 * 查询我的错题分页列表
* *