From c022ce11e3c2dd8acad08836c0f1c143d10cbf93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E8=8B=B1=E6=9D=B0?= <327782001@qq.com> Date: Fri, 8 Sep 2023 17:08:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=B7=BB=E5=8A=A0=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InterviewQuestionController.java | 23 +++++++++++ .../entity/dto/InterviewQuestionDTO.java | 40 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 src/main/java/com/kwan/springbootkwan/entity/dto/InterviewQuestionDTO.java diff --git a/src/main/java/com/kwan/springbootkwan/controller/InterviewQuestionController.java b/src/main/java/com/kwan/springbootkwan/controller/InterviewQuestionController.java index 2efa728..0d00eee 100644 --- a/src/main/java/com/kwan/springbootkwan/controller/InterviewQuestionController.java +++ b/src/main/java/com/kwan/springbootkwan/controller/InterviewQuestionController.java @@ -5,7 +5,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.kwan.springbootkwan.entity.InterviewQuestion; import com.kwan.springbootkwan.entity.Result; +import com.kwan.springbootkwan.entity.dto.InterviewQuestionDTO; import com.kwan.springbootkwan.service.InterviewQuestionService; +import org.apache.commons.lang3.StringUtils; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -45,6 +47,27 @@ public class InterviewQuestionController { return Result.ok(this.interviewQuestionService.uploadFile(path)); } + /** + * 分页查询所有数据,本地缓存的使用 + * + * @return 所有数据 + */ + @GetMapping("/page") + public Result selectAll(@RequestParam Integer page + , @RequestParam Integer pageSize + , @RequestParam String question) { + Page pageParm = new Page<>(); + pageParm.setCurrent(page); + pageParm.setSize(pageSize); + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.orderByDesc("id"); + wrapper.eq("is_delete", 0); + if (StringUtils.isNotEmpty(question)) { + wrapper.like("question", question); + } + return Result.ok(InterviewQuestionDTO.Converter.INSTANCE.from(this.interviewQuestionService.page(pageParm, wrapper))); + } + /** * 分页查询所有数据 * diff --git a/src/main/java/com/kwan/springbootkwan/entity/dto/InterviewQuestionDTO.java b/src/main/java/com/kwan/springbootkwan/entity/dto/InterviewQuestionDTO.java new file mode 100644 index 0000000..605984b --- /dev/null +++ b/src/main/java/com/kwan/springbootkwan/entity/dto/InterviewQuestionDTO.java @@ -0,0 +1,40 @@ +package com.kwan.springbootkwan.entity.dto; + +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.kwan.springbootkwan.entity.InterviewQuestion; +import com.kwan.springbootkwan.mapstruct.FromConverter; +import lombok.Data; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; +import org.mapstruct.factory.Mappers; + +import java.util.Date; + +/** + * 面试题(InterviewQuestion)表实体类 + * + * @author makejava + * @since 2023-09-08 16:31:53 + */ +@Data +@SuppressWarnings("serial") +public class InterviewQuestionDTO extends Model { + //主键id + private Integer id; + //面试问题 + private String question; + //问题回答 + private String response; + //知识类型,先默认0,后面再区分 + private Integer type; + //创建时间 + private Date createTime; + //逻辑删除,0未删除,1已删除 + private Integer isDelete; + + @Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE) + public interface Converter extends FromConverter { + InterviewQuestionDTO.Converter INSTANCE = Mappers.getMapper(InterviewQuestionDTO.Converter.class); + } +} + -- GitLab