fix:添加查询

上级 c33612cd
......@@ -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<InterviewQuestion> pageParm = new Page<>();
pageParm.setCurrent(page);
pageParm.setSize(pageSize);
QueryWrapper<InterviewQuestion> 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)));
}
/**
* 分页查询所有数据
*
......
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<InterviewQuestionDTO> {
//主键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, InterviewQuestion> {
InterviewQuestionDTO.Converter INSTANCE = Mappers.getMapper(InterviewQuestionDTO.Converter.class);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册