diff --git a/src/main/java/com/kwan/springbootkwan/controller/InterviewQuestionController.java b/src/main/java/com/kwan/springbootkwan/controller/InterviewQuestionController.java index 2efa7285829c4d3be290b5eedcd1813329422b20..0d00eeec33b1192c1b6cc81b2dfd498f7955f515 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 0000000000000000000000000000000000000000..605984bfd70b3fdba80a4fa756b8cd487cdb9dfd --- /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); + } +} +