当前位置:网站首页>Lecturer paging query_ Instructor condition query with page
Lecturer paging query_ Instructor condition query with page
2022-06-11 03:21:00 【The bright moon is always fresh】
Lecturer paging query
1、 Add the plug-in
/** * Paging plug-ins */
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor();
}
2、 Implementation method
@ApiOperation(value = " Query the instructor list in pages ")
@GetMapping("getTeacherPage/{current}/{limit}")
public R getTeacherPage(@PathVariable Long current,
@PathVariable Long limit){
Page<EduTeacher> page = new Page<>(current,limit);
teacherService.page(page,null);
List<EduTeacher> records = page.getRecords();
long total = page.getTotal();
//1、 Deposit in MAP
// Map<String,Object> map = new HashMap<>();
// map.put("list",records);
// map.put("total",total);
// return R.ok().data(map);
//2、 Directly joining together
return R.ok().data("list",records).data("total",total);
}
3、 test
Instructor condition query with paging
1、 Demand analysis

2、 Implementation interface
(1) establish VO object
@Data
public class TeacherQuery implements Serializable {
@ApiModelProperty(value = " Teacher's name , Fuzzy query ")
private String name;
@ApiModelProperty(value = " title 1 Senior lecturer 2 Chief lecturer ")
private Integer level;
@ApiModelProperty(value = " Query start time ", example = "2019-01-01 10:10:10")
private String begin;// Be careful , What we use here is String type , The data transmitted from the front end does not need type conversion
@ApiModelProperty(value = " Query end time ", example = "2019-12-01 10:10:10")
private String end;
}
(2) Implementation method
@ApiOperation(value = " Query the instructor list by page with conditions ")
@PostMapping("getTeacherPageVo/{current}/{limit}")
public R getTeacherPageVo(@PathVariable Long current,
@PathVariable Long limit,
@RequestBody TeacherQuery teacherQuery){
//@RequestBody hold json String into entity class
//1、 Get the query criteria
String name = teacherQuery.getName();
Integer level = teacherQuery.getLevel();
String begin = teacherQuery.getBegin();
String end = teacherQuery.getEnd();
//2、 Judge whether the condition is empty , If it is not empty, spell it sql
QueryWrapper<EduTeacher> wrapper = new QueryWrapper<>();
if(!StringUtils.isEmpty(name)){
wrapper.like("name",name);
}
if(!StringUtils.isEmpty(level)){
wrapper.eq("level",level);
}
if(!StringUtils.isEmpty(begin)){
wrapper.ge("gmt_create",begin);
}
if(!StringUtils.isEmpty(end)){
wrapper.le("gmt_create",end);
}
Page<EduTeacher> page = new Page<>(current,limit);
teacherService.page(page,wrapper);
List<EduTeacher> records = page.getRecords();
long total = page.getTotal();
//1、 Deposit in MAP
// Map<String,Object> map = new HashMap<>();
// map.put("list",records);
// map.put("total",total);
// return R.ok().data(map);
//2、 Directly joining together
return R.ok().data("list",records).data("total",total);
}
边栏推荐
- B_QuRT_User_Guide(16)
- Hqchart nailing applet tutorial 1- create a K-line diagram
- OPPO K9试水“捆绑销售”,消费者“赚了”还是“亏了”?
- pip 安装 qt5 。
- C language pointer
- VMware virtual machine IP, gateway settings. The virtual machine cannot be pinged to the Internet
- B_QuRT_User_Guide(18)
- Resolved: JDBC connection to MySQL failed with an error:'The last packet sent successfully to the server was 0 milliseconds ago. '
- PostgreSQL source code learning (21) -- fault recovery ② - transaction log initialization
- TweenMax五彩小球弹跳动画
猜你喜欢

Cygwin reports an error child_ info_ fork::abort: XXX. dll: Loaded to different address: parent(XXX) != child(XXX)

Go quick start of go language (I): the first go program

iQOO 8实测上手体验:王者归来,从不高调

three.js炫酷科技感背景h5动画

B_ QuRT_ User_ Guide(17)

Mazhiqiang: research progress and application of speech recognition technology -- RTC dev Meetup

HikariPool-1 - Shutdown initiated... HikariPool-1 - Shutdown completed.

名不副实的雅迪高端品牌VFLY,为何“不高端”?

PIP installation Qt5.

Correct posture of cocoscreator's native secondary development
随机推荐
PIP installation Qt5.
配置用命令行编译的环境-MSVC
亚马逊测评自养号,小白应该如何开始?
net::ERR_ FILE_ NOT_ Found error
pip 安装 qt5 。
The solution of invalid @data annotation in idea2018
Mazhiqiang: research progress and application of speech recognition technology -- RTC dev Meetup
Configuring the command line compiled environment -msvc
R生物信息学统计分析
Disk quota exceeded
Unity之数据持久化——Json
單片機通信數據延遲問題排查
C language pointer
Database design specification
B_QuRT_User_Guide(19)
PostgreSQL source code learning (XX) -- fault recovery ① - transaction log format
ArTalk | 如何用最小投入,构建国产超融合进化底座?
Log4j:error category option "1" not a decimal integer
HikariPool-1 - Shutdown initiated... HikariPool-1 - Shutdown completed.
ORA-00392 ORA-00312 错误处理