当前位置:网站首页>Project training of Software College of Shandong University - Innovation Training - network security shooting range experimental platform (VII)
Project training of Software College of Shandong University - Innovation Training - network security shooting range experimental platform (VII)
2022-04-23 19:40:00 【Scrambled eggs with tomatoes without eggs!】
Catalog
Two 、Vue The paging component ——el-pagination
3、 ... and 、mybatis Pagination ——selectPage
Preface : This blog mainly explains the paging function in the forum part
One 、Forum Paging function
In the forum function , Users will post more and more comments , As a result, more and more front-end interfaces will be displayed , in other words card More and more .
For ease of reading , Improve the speed of database query and page rendering , I used paging to render .
The interface is as follows :
At present, four are displayed on each page , Now total 10 strip , So there are three pages .
Two 、Vue The paging component ——el-pagination
The paging component is <el-pagination/>, Usage is as follows :
<el-pagination
v-model:currentPage="currentPage"
:page-size="pageSize"
:disabled="disabled"
:background="background"
layout="total, prev, pager, next"
:total="totalpage"
@size-change="handleSizeChange"
@current-change="load"
style="padding-top: 20px"
/>
The initial bound data is :
return {
formatTooltip,
goto_write,
search:'',
currentPage:1,
pageSize:4,
totalpage:0,
forumlist:[],
};
The rendering method is :
load(){
request.get("/forum/page",{
params:{
pageNum:this.currentPage,
pageSize:this.pageSize,
search:this.search
}
}).then(res =>{
this.forumlist=res.data.records
this.totalpage=res.data.total
})
},
The rendering method will <el-card> What is needed in forumlist Data binding
<el-space direction="vertical" style="text-align: left">
<el-card v-for="(forum,i) in forumlist" :key="i" class="box-card" style="width: 1200px;background-color: #99a9bf" shadow="hover">
<template #header>
<div class="card-header">
<span style="font-weight:bold">{
{ forum.title }}</span>
</div>
</template>
<div class="text item">
{
{ forum.content }}
</div>
<div class="text item" style="margin-top: 20px">
{
{ forum.username }}
</div>
<div class="text item" style="text-align: right">
{
{ forum.time }}
</div>
</el-card>
</el-space>
3、 ... and 、mybatis Pagination ——selectPage
In the writing of back-end code , First, write the entity class Forum.java
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@TableName("forum")
public class Forum {
@TableId(type = IdType.AUTO)
private Integer forumid;
private String title;
private String content;
private Integer username;
private String time;
private Integer state;
}
ForumController.java
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sducsrp.csrp.common.Result;
import com.sducsrp.csrp.entity.Forum;
import com.sducsrp.csrp.mapper.ForumMapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@RestController
@RequestMapping("/forum")
public class ForumController {
@Resource
ForumMapper forumMapper;
@GetMapping("/page")
public Result findpage(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "5") Integer pageSize,
@RequestParam(defaultValue = "") String search){
Page<Forum> forumPage=forumMapper.selectPage(new Page<>(pageNum,pageSize), Wrappers.<Forum>lambdaQuery().like(Forum::getForumid,search));
return Result.success(forumPage);
}
}
among , The most important code is :
@GetMapping("/page")
public Result findpage(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "5") Integer pageSize,
@RequestParam(defaultValue = "") String search){
Page<Forum> forumPage=forumMapper.selectPage(new Page<>(pageNum,pageSize), Wrappers.<Forum>lambdaQuery().like(Forum::getForumid,search));
return Result.success(forumPage);
}
This is a mybatis Paging function of , Both query function
Parameters respectively ask the number of query pages 、 Page size 、 And the query content .
版权声明
本文为[Scrambled eggs with tomatoes without eggs!]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231929365664.html
边栏推荐
- An example of using JNI to directly access surface data
- Kubernetes introduction to mastery - ktconnect (full name: kubernetes toolkit connect) is a small tool based on kubernetes environment to improve the efficiency of local test joint debugging.
- Scrum Patterns之理解各种团队模式
- Easy mock local deployment (you need to experience three times in a crowded time. Li Zao will do the same as me. Love is like a festival mock)
- MySQL数据库 - 单表查询(二)
- An algorithm problem was encountered during the interview_ Find the mirrored word pairs in the dictionary
- 对普通bean进行Autowired字段注入
- 精简CUDA教程——CUDA Driver API
- 2021-2022-2 ACM training team weekly Programming Competition (8) problem solution
- MySQL lock
猜你喜欢
FFT物理意义: 1024点FFT就是1024个实数,实际进入fft的输入是1024个复数(虚部为0),输出也是1024个复数,有效的数据是前512个复数
MySQL syntax collation (2)
Intuitive understanding of the essence of two-dimensional rotation
Build intelligent garbage classification applet based on Zero
Mfcc: Mel frequency cepstrum coefficient calculation of perceived frequency and actual frequency conversion
[transfer] summary of new features of js-es6 (one picture)
Garbage collector and memory allocation strategy
Scrum Patterns之理解各种团队模式
OpenHarmony开源开发者成长计划,寻找改变世界的开源新生力!
Deep learning -- Summary of Feature Engineering
随机推荐
深度学习环境搭建步骤—gpu
Kubernetes入门到精通-裸机LoadBalence 80 443 端口暴露注意事项
数据分析学习目录
ESP8266-入门第一篇
How to use go code to compile Pb generated by proto file with protoc Compiler Go file
uIP1. 0 actively sent problem understanding
A simple (redisson based) distributed synchronization tool class encapsulation
C6748 software simulation and hardware test - with detailed FFT hardware measurement time
The most detailed network counting experiment in history (2) -- rip experiment of layer 3 switch
图书管理数据库系统设计
深度分析数据恢复原理——那些数据可以恢复那些不可以数据恢复软件
考试系统进入试卷优化思路
MySQL数据库 - 数据库和表的基本操作(二)
OpenHarmony开源开发者成长计划,寻找改变世界的开源新生力!
Why is the hexadecimal printf output of C language sometimes with 0xff and sometimes not
Codeforces Round #783 (Div. 2) D题解
Strange passion
OpenHarmony开源开发者成长计划,寻找改变世界的开源新生力!
[report] Microsoft: application of deep learning methods in speech enhancement
Application of DCT transform