From 5892979b102725c0d354e104d3b34775b9dfe5b7 Mon Sep 17 00:00:00 2001 From: wangxy <1356089412@qq.com> Date: Tue, 9 Jul 2024 10:05:37 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E9=94=99=E9=A2=98=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/exam/UserBookController.java | 12 ++++++++ .../controller/manager/UserBookManager.java | 29 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/exam/UserBookController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/exam/UserBookController.java index 2da7639..196f2db 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/exam/UserBookController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/exam/UserBookController.java @@ -1,7 +1,11 @@ package com.ruoyi.web.controller.exam; +import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.system.domain.exam.dto.ExamDTO; import com.ruoyi.system.domain.userbook.dto.UserBookDTO; import com.ruoyi.web.controller.manager.UserBookManager; import io.swagger.annotations.Api; @@ -59,5 +63,13 @@ public class UserBookController extends BaseController { } + @ApiOperation("查找列表") + @PostMapping("/next") + @ResponseBody + public AjaxResult next(@RequestBody UserBookDTO reqDTO) { + return AjaxResult.success(userBookManager.findNext(reqDTO.getExamId(),reqDTO.getQuId())); + } + + } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/manager/UserBookManager.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/manager/UserBookManager.java index 39f13ba..aa3613b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/manager/UserBookManager.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/manager/UserBookManager.java @@ -9,6 +9,7 @@ import com.ruoyi.system.domain.userbook.dto.UserBookDTO; import com.ruoyi.system.service.ElQuService; import com.ruoyi.system.service.ElUserBookService; import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; import javax.annotation.Resource; import java.util.Date; @@ -96,6 +97,34 @@ public class UserBookManager { } + public String findNext(String examId, String quId) { + Integer sort = 999999; + if(Objects.nonNull(quId)){ + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.lambda() + .eq(ElUserBook::getUserId, ShiroUtils.getUserId()) + .eq(ElUserBook::getExamId, examId) + .eq(ElUserBook::getQuId, quId); + wrapper.last(" ORDER BY `sort` DESC"); + ElUserBook last = userBookService.getOne(wrapper, false); + if(last!=null){ + sort = last.getSort(); + } + } + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.lambda() + .eq(ElUserBook::getUserId, ShiroUtils.getUserId()) + .eq(ElUserBook::getExamId, examId) + .lt(ElUserBook::getSort, sort); + wrapper.last(" ORDER BY `sort` DESC"); + ElUserBook next = userBookService.getOne(wrapper, false); + if(next != null){ + return next.getQuId(); + } + return null; + } + +