当前位置:网站首页>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
边栏推荐
- MySQL syntax collation
- 【webrtc】Add x264 encoder for CEF/Chromium
- The difference between underline and dot of golang import package
- 视频理解-Video Understanding
- OpenHarmony开源开发者成长计划,寻找改变世界的开源新生力!
- Kubernetes entry to mastery - bare metal loadbalance 80 443 port exposure precautions
- 音频编辑生成软件
- Redis core technology and practice 1 - start with building a simple key value database simplekv
- Strange passion
- How to select the third-party package of golang
猜你喜欢
Openharmony open source developer growth plan, looking for new open source forces that change the world!
Is meituan, a profit-making company with zero foundation, hungry? Coupon CPS applet (with source code)
【webrtc】Add x264 encoder for CEF/Chromium
Prefer composition to inheritance
The platinum library cannot search the debug process records of some projection devices
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.
Unity创建超写实三维场景的一般步骤
Garbage collector and memory allocation strategy
Kubernetes入门到精通-KtConnect(全称Kubernetes Toolkit Connect)是一款基于Kubernetes环境用于提高本地测试联调效率的小工具。
@Mapperscan and @ mapper
随机推荐
MySQL数据库 - 单表查询(二)
DevOps集成-Jenkins 服务的环境变量和构建工具 Tools
5 minutes to achieve wechat cloud applet payment function (including source code)
What is a message queue
php参考手册String(7.2千字)
Scrum Patterns之理解各种团队模式
MySQL数据库 - 连接查询
Efficient serial port cyclic buffer receiving processing idea and code 2
Redis core technology and practice 1 - start with building a simple key value database simplekv
Codeworks round 783 (Div. 2) d problem solution
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)
数据库查询 - 选课系统
Hot reload debugging
Data analysis learning directory
Openlayers 5.0 discrete aggregation points
Kubernetes入门到精通-在 Kubernetes 上安装 OpenELB
LPC1768 关于延时Delay时间与不同等级的优化对比
Some speculation about the decline of adults' language learning ability
MySQL数据库 - 单表查询(一)
【webrtc】Add x264 encoder for CEF/Chromium