Skip to content

Commit

Permalink
fix(work):完善错题本逻辑,修复一些已知问题
Browse files Browse the repository at this point in the history
  • Loading branch information
besscroft committed Sep 13, 2023
1 parent e25d0fc commit 59a44c3
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,11 @@ public CommonResult<Void> actions(@RequestBody @Valid ActionsParam param) {
return CommonResult.success(MessageConstants.SUCCESS);
}

@PostMapping("/failActions")
@Operation(summary = "错题本单词反馈接口")
public CommonResult<Void> failActions(@RequestBody @Valid ActionsParam param) {
bookService.failActions(param);
return CommonResult.success(MessageConstants.SUCCESS);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,10 @@ public interface BookService {
*/
void actions(ActionsParam param);

/**
* 错题本行为处理
* @param param 参数
*/
void failActions(ActionsParam param);

}
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ public Book getBook(GetBookParam param) {

@Override
public Book getWord() {
// TODO 优化
// TODO 进度完成后,无法获取单词的问题,业务调整
long userId = StpUtil.getLoginIdAsLong();
UserBookDictVo userDict = userBookDictService.getUserDict();
Assert.notNull(userDict, "还未选择词典!");
Expand All @@ -75,7 +73,6 @@ public Book getWord() {

@Override
public Book getWorkWord() {
// TODO 优化
long userId = StpUtil.getLoginIdAsLong();
UserBookDictVo userDict = userBookDictService.getUserDict();
Assert.notNull(userDict, "还未选择词典!");
Expand Down Expand Up @@ -141,4 +138,17 @@ public void actions(ActionsParam param) {
redisTemplate.delete(CacheConstants.TODAY + userId);
}

@Override
@Transactional(rollbackFor = Exception.class)
public void failActions(ActionsParam param) {
long userId = StpUtil.getLoginIdAsLong();
Word word = wordMapper.selectByWordJsonId(param.getWordJsonId());
UserWrongWord wrongWord = userWrongWordMapper.selectByUserIdAndBookIdAndWordId(userId, param.getBookId(), word.getId());
if (Objects.equals(param.getState(), 0)) {
wrongWord.setFailCount(wrongWord.getFailCount() + 1);
}
wrongWord.setUpdateTime(LocalDateTime.now());
userWrongWordMapper.updateById(wrongWord);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@
user_id = #{userId}
AND
book_id = #{bookId}
AND
state = 0
ORDER BY state, update_time
LIMIT 1
</select>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
user_id = #{userId}
AND
book_id = #{bookId}
<!-- TODO 查询条件补全 -->
ORDER BY update_time, create_time
LIMIT 1
</select>

Expand Down
2 changes: 1 addition & 1 deletion heming-web/pages/practise.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const handleActions = async (state: number) => {
data.actionsParam.bookId = wordInfo.value.bookId
data.actionsParam.wordRank = wordInfo.value.wordRank
data.actionsParam.headWord = wordInfo.value.headWord
const json = await nuxtApp.$api.post('/@api/book/actions', {
const json = await nuxtApp.$api.post('/@api/book/failActions', {
json: data.actionsParam
}).json();
if (json.code === 200) {
Expand Down

0 comments on commit 59a44c3

Please sign in to comment.