package com.yf.exam.modules.user.book.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.yf.exam.core.api.ApiRest; import com.yf.exam.core.api.controller.BaseController; import com.yf.exam.core.api.dto.BaseIdRespDTO; import com.yf.exam.core.api.dto.BaseIdsReqDTO; import com.yf.exam.core.api.dto.PagingReqDTO; import com.yf.exam.modules.user.book.dto.UserBookDTO; import com.yf.exam.modules.user.book.service.UserBookService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; /** *

* 错题本控制器,处理与错题本相关的HTTP请求 *

* * @author 聪明笨狗 * @since 2020-05-27 17:56 */ @Api(tags={"错题本"}) @RestController @RequestMapping("/exam/api/user/wrong-book") public class UserBookController extends BaseController { /** * 注入错题本服务类,用于处理错题本相关的业务逻辑 */ @Autowired private UserBookService baseService; /** * 批量删除错题本记录 * @param reqDTO 包含要删除记录ID列表的请求对象 * @return 操作结果的统一响应对象 */ @ApiOperation(value = "批量删除") @RequestMapping(value = "/delete", method = { RequestMethod.POST}) public ApiRest delete(@RequestBody BaseIdsReqDTO reqDTO) { // 根据传入的ID列表删除对应的错题本记录 baseService.removeByIds(reqDTO.getIds()); // 返回操作成功的响应 return super.success(); } /** * 分页查找错题本记录 * @param reqDTO 包含分页信息和查询条件的请求对象 * @return 包含分页结果的统一响应对象 */ @ApiOperation(value = "分页查找") @RequestMapping(value = "/paging", method = { RequestMethod.POST}) public ApiRest> paging(@RequestBody PagingReqDTO reqDTO) { // 调用服务层方法进行分页查询,并将结果转换为UserBookDTO对象 IPage page = baseService.paging(reqDTO); // 返回包含分页结果的成功响应 return super.success(page); } /** * 查找下一个错题记录,每次最多返回200条数据 * @param reqDTO 包含考试ID和当前题目ID的请求对象 * @return 包含下一个题目ID的统一响应对象 */ @ApiOperation(value = "查找列表") @RequestMapping(value = "/next", method = { RequestMethod.POST}) public ApiRest nextQu(@RequestBody UserBookDTO reqDTO) { // 调用服务层方法查找下一个错题的题目ID String quId = baseService.findNext(reqDTO.getExamId(), reqDTO.getQuId()); // 将下一个题目ID封装到响应对象中并返回成功响应 return super.success(new BaseIdRespDTO(quId)); } }