日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区

您的位置:首頁技術(shù)文章
文章詳情頁

VUE+SpringBoot實現(xiàn)分頁功能

瀏覽:21日期:2022-09-29 08:03:48

本文主要介紹一下 Vue + SpringBoot 中如何實現(xiàn)一個分頁列表數(shù)據(jù)。

1、效果展示

VUE+SpringBoot實現(xiàn)分頁功能

2、VUE代碼

VUE之視圖定義

<el-row> <el-table:data='tableData'style='width: 100%'><el-table-column v-for='(data,index) in tableHeader' :key='index' :prop='data.prop' :label='data.label' :min- :align='data.align'></el-table-column><el-table-column label='操作' min-width='240'> <template slot-scope='scope'><el-button type='success' size='mini' @click='toRecharge(scope)'>充值</el-button><el-button size='mini' @click='toView(scope)'>查看</el-button><el-button type='primary' size='mini' @click='toEdit(scope)'>修改</el-button><el-button type='danger' size='mini' @click='deleteCard(scope)'>刪除</el-button> </template></el-table-column> </el-table> <br> <el-pagination@size-change='handleSizeChange'@current-change='handleCurrentChange':current-page='pagination.pageIndex':page-sizes='[5, 10, 20, 30, 40]':page-size=pagination.pageSizelayout='total, sizes, prev, pager, next, jumper':total=pagination.total> </el-pagination></el-row>

重點說明:

數(shù)據(jù)類型定義:

tableData:定義后臺數(shù)據(jù)模型定義。

tableHeader:定義表格與后臺數(shù)據(jù)綁定關(guān)系。

pagination:定義分頁數(shù)據(jù)模型,主要包含(pageIndex:當(dāng)前頁,pageSize:頁大小, total:總記錄數(shù))

方法定義:

handleSizeChange:更新頁大小

handleCurrentChange:更新當(dāng)前頁

VUE之模型定義(data)

tableData: [],pagination: { pageIndex: 1, pageSize: 10, total: 0,},tableHeader: [ {prop: ’sid’,label: ’編號’,align: ’left’ }, {prop: ’password’,label: ’密碼’,align: ’left’ }, {prop: ’state’,label: ’狀態(tài)’,align: ’left’ }, {prop: ’money’,label: ’金額’,align: ’left’ }, {prop: ’studentSid’,label: ’學(xué)生SID’,align: ’left’ } ]

VUE之?dāng)?shù)據(jù)初始化

VUE 方法定義:請求后臺數(shù)據(jù)接口加載相關(guān)數(shù)據(jù)(method)

init () {var self = this this.$axios({ method:’post’, url:’/card/findPage’, data:{'page':this.pagination.pageIndex,'limit':this.pagination.pageSize}, headers:{’Content-Type’:’application/json;charset=utf-8’ //改這里就好了 }}).then(res => { console.log(res); self.pagination.total = res.data.data.total_count; self.tableData = res.data.data.list; }) .catch(function (error) { console.log(error) })},handleSizeChange(val) {this.pagination.pageSize = val;this.pagination.pageIndex = 1;this.init();},handleCurrentChange(val) {this.pagination.pageIndex = val;this.init();},

VUE 聲明周期函數(shù)定義:調(diào)用VUE的方法定義,完成數(shù)據(jù)初始化過程.

在VUE聲明周期函數(shù)mounted ()中,調(diào)用init ,完成數(shù)據(jù)初始化過程。

mounted: function () { this.init() }3、SpringBoot 代碼

entity 定義

package com.zzg.entity; import java.math.BigDecimal;import java.util.Date; import org.springframework.format.annotation.DateTimeFormat; import com.fasterxml.jackson.annotation.JsonFormat;import com.zzg.common.BaseModel; public class TCard extends BaseModel { /** * */ private static final long serialVersionUID = 1035674221133528445L; private Integer sid; private String password; private String state; private BigDecimal money;@DateTimeFormat(pattern='yyyy-MM-dd') @JsonFormat(pattern='yyyy-MM-dd',timezone='GMT+8') private Date starTime; @DateTimeFormat(pattern='yyyy-MM-dd') @JsonFormat(pattern='yyyy-MM-dd',timezone='GMT+8') private Date endTime; private Integer studentSid; public Integer getSid() {return sid; } public void setSid(Integer sid) {this.sid = sid; } public String getPassword() {return password; } public void setPassword(String password) {this.password = password == null ? null : password.trim(); } public String getState() {return state; } public void setState(String state) {this.state = state == null ? null : state.trim(); } public BigDecimal getMoney() {return money; } public void setMoney(BigDecimal money) {this.money = money; } public Date getStarTime() {return starTime; } public void setStarTime(Date starTime) {this.starTime = starTime; } public Date getEndTime() {return endTime; } public void setEndTime(Date endTime) {this.endTime = endTime; } public Integer getStudentSid() {return studentSid; } public void setStudentSid(Integer studentSid) {this.studentSid = studentSid; }}

mapper定義

package com.zzg.mapper; import java.util.List;import java.util.Map; import com.zzg.entity.TCard; public interface TCardMapper { int deleteByPrimaryKey(Integer sid); int insert(TCard record); int insertSelective(TCard record); TCard selectByPrimaryKey(Integer sid); int updateByPrimaryKeySelective(TCard record); int updateByPrimaryKey(TCard record); /** * 方法拓展 */ List<TCard> select(Map<String, Object> parame); Integer count(Map<String, Object> parame); void batchInsert(List<TCard> list); void batchUpdate(List<TCard> list);}

<?xml version='1.0' encoding='UTF-8'?><!DOCTYPE mapper PUBLIC '-//mybatis.org//DTD Mapper 3.0//EN' 'http://mybatis.org/dtd/mybatis-3-mapper.dtd'><mapper namespace='com.zzg.mapper.TCardMapper'> <resultMap type='com.zzg.entity.TCard'> <id column='sid' jdbcType='INTEGER' property='sid' /> <result column='password' jdbcType='VARCHAR' property='password' /> <result column='state' jdbcType='VARCHAR' property='state' /> <result column='money' jdbcType='DECIMAL' property='money' /> <result column='star_time' jdbcType='DATE' property='starTime' /> <result column='end_time' jdbcType='DATE' property='endTime' /> <result column='student_sid' jdbcType='INTEGER' property='studentSid' /> </resultMap> <sql id='Base_Column_List'> sid, password, state, money, star_time, end_time, student_sid </sql> <sql id='condition'> </sql> <select parameterType='map' resultMap='BaseResultMap'> select <include refid='Base_Column_List' /> from t_card where 1 = 1 <include refid='condition'></include> </select> <select parameterType='map' resultType='java.lang.Integer'> select count(1) from t_card where 1 = 1 <include refid='condition'></include> </select> <select parameterType='java.lang.Integer' resultMap='BaseResultMap'> select <include refid='Base_Column_List' /> from t_card where sid = #{sid,jdbcType=INTEGER} </select> <delete parameterType='java.lang.Integer'> delete from t_card where sid = #{sid,jdbcType=INTEGER} </delete> <insert parameterType='com.zzg.entity.TCard'> insert into t_card (sid, password, state, money, star_time, end_time, student_sid) values (#{sid,jdbcType=INTEGER}, #{password,jdbcType=VARCHAR}, #{state,jdbcType=VARCHAR}, #{money,jdbcType=DECIMAL}, #{starTime,jdbcType=DATE}, #{endTime,jdbcType=DATE}, #{studentSid,jdbcType=INTEGER}) </insert> <insert parameterType='com.zzg.entity.TCard'> insert into t_card <trim prefix='(' suffix=')' suffixOverrides=','> <if test='sid != null'>sid, </if> <if test='password != null'>password, </if> <if test='state != null'>state, </if> <if test='money != null'>money, </if> <if test='starTime != null'>star_time, </if> <if test='endTime != null'>end_time, </if> <if test='studentSid != null'>student_sid, </if> </trim> <trim prefix='values (' suffix=')' suffixOverrides=','> <if test='sid != null'>#{sid,jdbcType=INTEGER}, </if> <if test='password != null'>#{password,jdbcType=VARCHAR}, </if> <if test='state != null'>#{state,jdbcType=VARCHAR}, </if> <if test='money != null'>#{money,jdbcType=DECIMAL}, </if> <if test='starTime != null'>#{starTime,jdbcType=DATE}, </if> <if test='endTime != null'>#{endTime,jdbcType=DATE}, </if> <if test='studentSid != null'>#{studentSid,jdbcType=INTEGER}, </if> </trim> </insert> <update parameterType='com.zzg.entity.TCard'> update t_card <set> <if test='password != null'>password = #{password,jdbcType=VARCHAR}, </if> <if test='state != null'>state = #{state,jdbcType=VARCHAR}, </if> <if test='money != null'>money = #{money,jdbcType=DECIMAL}, </if> <if test='starTime != null'>star_time = #{starTime,jdbcType=DATE}, </if> <if test='endTime != null'>end_time = #{endTime,jdbcType=DATE}, </if> <if test='studentSid != null'>student_sid = #{studentSid,jdbcType=INTEGER}, </if> </set> where sid = #{sid,jdbcType=INTEGER} </update> <update parameterType='com.zzg.entity.TCard'> update t_card set password = #{password,jdbcType=VARCHAR}, state = #{state,jdbcType=VARCHAR}, money = #{money,jdbcType=DECIMAL}, star_time = #{starTime,jdbcType=DATE}, end_time = #{endTime,jdbcType=DATE}, student_sid = #{studentSid,jdbcType=INTEGER} where sid = #{sid,jdbcType=INTEGER} </update></mapper>

service 定義

package com.zzg.service; import java.util.List;import java.util.Map; import com.zzg.common.BaseService;import com.zzg.common.entity.PageDate;import com.zzg.common.entity.PageParam;import com.zzg.entity.TCard; public interface TCardService extends BaseService<TCard> { /** * 自定義分頁 * * @param parame * @param rb * @return */ public PageDate<TCard> selectPage(Map<String, Object> parame, PageParam rb); /** * 自定義查詢 * @param parame * @return */ public List<TCard> select(Map<String, Object> parame); /** * 自定義統(tǒng)計 * @param parame * @return */ public Integer count(Map<String, Object> parame); /** * 自定義批量插入 * @param list */ public void batchInsert(List<TCard> list); /** * 自定義批量更新 * @param list */ public void batchUpdate(List<TCard> list); /** * 充值記錄 * @param tCard */ public void recharge(TCard tCard); }

package com.zzg.service.impl; import java.math.BigDecimal;import java.util.List;import java.util.Map; import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service; import com.github.pagehelper.PageHelper;import com.github.pagehelper.PageInfo;import com.zzg.common.AbstractService;import com.zzg.common.entity.PageDate;import com.zzg.common.entity.PageParam;import com.zzg.entity.TCard;import com.zzg.mapper.TCardMapper;import com.zzg.service.TCardService; @Servicepublic class TCardServiceImpl extends AbstractService<TCard> implements TCardService { @Autowired TCardMapper mapper; public int insert(TCard record) { // TODO Auto-generated method stub return mapper.insert(record); } public int insertSelective(TCard record) { // TODO Auto-generated method stub return mapper.insertSelective(record); } public TCard selectByPrimaryKey(Integer sid) { // TODO Auto-generated method stub return mapper.selectByPrimaryKey(sid); } public int updateByPrimaryKeySelective(TCard record) { // TODO Auto-generated method stub return mapper.updateByPrimaryKeySelective(record); } public int updateByPrimaryKey(TCard record) { // TODO Auto-generated method stub return mapper.updateByPrimaryKey(record); } public void deleteByPrimaryKey(Integer sid) { // TODO Auto-generated method stub mapper.deleteByPrimaryKey(sid); } public PageDate<TCard> selectPage(Map<String, Object> parame, PageParam rb) { // TODO Auto-generated method stub PageHelper.startPage(rb.getPageNo(), rb.getLimit()); List<TCard> rs = mapper.select(parame); PageInfo<TCard> pageInfo = new PageInfo<TCard>(rs); return super.page(pageInfo.getList(), pageInfo.getPageNum(), pageInfo.getPageSize(), pageInfo.getTotal()); } public List<TCard> select(Map<String, Object> parame) { // TODO Auto-generated method stub return mapper.select(parame); } public Integer count(Map<String, Object> parame) { // TODO Auto-generated method stub return mapper.count(parame); } public void batchInsert(List<TCard> list) { // TODO Auto-generated method stub mapper.batchInsert(list); } public void batchUpdate(List<TCard> list) { // TODO Auto-generated method stub mapper.batchUpdate(list); } public void recharge(TCard tCard) { // TODO Auto-generated method stub TCard object = mapper.selectByPrimaryKey(tCard.getSid()); BigDecimal money = object.getMoney().add(tCard.getMoney()); object.setMoney(money); mapper.updateByPrimaryKeySelective(object); } }

controller定義

package com.zzg.controller; import java.util.List;import java.util.Map; import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.PathVariable;import org.springframework.web.bind.annotation.RequestBody;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.web.bind.annotation.ResponseBody;import com.zzg.common.AbstractController;import com.zzg.common.entity.PageDate;import com.zzg.common.entity.PageParam;import com.zzg.common.entity.Result;import com.zzg.entity.TCard;import com.zzg.service.TCardService; @Controller@RequestMapping('/api/card')public class CardController extends AbstractController { // 日志記錄 public static final Logger log = LoggerFactory.getLogger(CardController.class); @Autowired TCardService cardService; @RequestMapping(value = '/findPage', method = RequestMethod.POST) @ResponseBody public Result findPage(@RequestBody Map<String, Object> parame) { PageParam rb = super.initPageBounds(parame); PageDate<TCard> pageList = cardService.selectPage(parame, rb); return new Result().ok().setData(pageList); } @RequestMapping(value = '/find', method = RequestMethod.GET) @ResponseBody public Result find() { List<TCard> list = cardService.select(null); return new Result().ok().setData(list); } @RequestMapping(value = '/findBySid/{sid}', method = RequestMethod.GET) @ResponseBody public Result findBySid(@PathVariable('sid') Integer sid) { TCard object = cardService.selectByPrimaryKey(sid); return new Result().ok().setData(object); } @RequestMapping(value = '/deleteBySid/{sid}', method = RequestMethod.GET) @ResponseBody public Result deleteBySid(@PathVariable('sid') Integer sid) { cardService.deleteByPrimaryKey(sid); return new Result().ok(); } @RequestMapping(value = '/update', method = RequestMethod.POST) @ResponseBody public Result update(@RequestBody TCard card) { int num = cardService.updateByPrimaryKeySelective(card); if (num > 0) { return new Result().ok(); } return new Result().error('更新失敗'); } @RequestMapping(value = '/recharge', method = RequestMethod.POST) @ResponseBody public Result recharge(@RequestBody TCard card) { cardService.recharge(card); return new Result().error('充值成功'); } @RequestMapping(value = '/insert', method = RequestMethod.POST) @ResponseBody public Result insert(@RequestBody TCard card) { int num = cardService.insertSelective(card); if (num > 0) { return new Result().ok(); } return new Result().error('新增失敗'); }}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Spring
相關(guān)文章:
日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区
综合国产精品| 97人人精品| 偷拍精品精品一区二区三区| 国产欧美一区二区三区国产幕精品 | 福利视频一区| 亚洲精品伊人| 精品欧美日韩精品| 美女视频黄免费的久久| 国产欧美一区二区三区米奇| 久久成人一区| 中文字幕乱码亚洲无线精品一区| 爽好久久久欧美精品| 日韩精品视频一区二区三区| 国产亚洲一区二区三区啪| 国产日韩精品视频一区二区三区| 国产精品777777在线播放| 国产精品一区二区三区四区在线观看 | 鲁大师影院一区二区三区| 国产视频欧美| 欧美精品影院| 91精品国产自产在线观看永久∴| 91精品1区| 国产伦精品一区二区三区千人斩 | 亚洲一区免费| 国产伦精品一区二区三区视频| 国产成人久久精品麻豆二区| 人人精品亚洲| 亚洲深夜福利在线观看| 国产精品777777在线播放 | 国产伊人精品| 日韩电影二区| 精品网站999| 日韩区一区二| 日韩精品中文字幕第1页| 免费观看久久久4p| 色欧美自拍视频| 综合亚洲视频| 在线精品亚洲欧美日韩国产| 中文不卡在线| 欧美日韩亚洲在线观看| 老色鬼久久亚洲一区二区| 国产精品白浆| 亚洲另类视频| 免费精品国产的网站免费观看| 91成人精品在线| 亚洲一区二区三区四区五区午夜| 成人午夜亚洲| 国产精品欧美一区二区三区不卡| 99pao成人国产永久免费视频| 久久精品国产999大香线蕉| 亚洲另类av| 欧美日韩国产探花| 欧美日韩精品免费观看视欧美高清免费大片 | 岛国av在线播放| 国产精品免费精品自在线观看| 久久国产66| 最新亚洲激情| 亚洲视频www| 丝袜国产日韩另类美女| 久久久久久久久丰满| 久久久久欧美精品| 久久婷婷激情| 久久久亚洲一区| 欧美亚洲在线日韩| 久久麻豆精品| 久久美女精品| 好吊一区二区三区| 美女精品网站| 日本久久二区| 麻豆91在线播放| 国产白浆在线免费观看| 久久婷婷一区| 午夜在线视频观看日韩17c| 日本大胆欧美人术艺术动态| 一区二区三区四区在线观看国产日韩| 亚洲欧洲一区| 日本少妇一区二区| 国产在线不卡一区二区三区| 日韩在线短视频| 午夜在线视频一区二区区别 | 精品视频在线观看网站| 精品精品国产三级a∨在线| 91免费精品| 国产精品色网| 国产精品男女| 午夜欧美精品| 欧美亚洲一区二区三区| 四虎8848精品成人免费网站| 欧美日韩国产一区二区三区不卡| 巨乳诱惑日韩免费av| 国产激情欧美| 黄色亚洲免费| 久久av资源| 在线综合亚洲| 国产欧美日韩视频在线| 久久精品主播| 国产精品亚洲欧美| 99精品在线免费在线观看| 欧美在线黄色| 午夜久久美女| 国产精品毛片一区二区在线看| 亚洲一区二区三区高清不卡| 精品国产欧美日韩| 黄色网一区二区| 欧美 日韩 国产一区二区在线视频 | 巨乳诱惑日韩免费av| 黄色网一区二区| 97精品资源在线观看| 伊人久久成人| 日本不卡免费高清视频在线| 青草久久视频| 国产精品美女久久久| 日韩毛片视频| 麻豆久久久久久| 欧美在线精品一区| 亚洲久久一区| 丝袜亚洲精品中文字幕一区| 99久精品视频在线观看视频| 精品一区二区三区四区五区| 视频在线在亚洲| 色一区二区三区四区| 国产精品v亚洲精品v日韩精品| 亚久久调教视频| 丝袜美腿一区二区三区| 日韩一区二区免费看| 9色精品在线| 国产亚洲精品自拍| 欧美日韩国产探花| 国产精品婷婷| 一区二区亚洲视频| 亚洲免费福利一区| 日本成人一区二区| 亚洲资源网站| 日韩精品a在线观看91| 国产日韩免费| 国产极品一区| 精品一区二区三区中文字幕在线| 麻豆国产欧美一区二区三区| 你懂的亚洲视频| 国产一区二区三区精品在线观看| 精品中文字幕一区二区三区四区| 精品一区视频| 国产91精品对白在线播放| 欧美特黄一区| 日韩不卡一二三区| 高清精品久久| 免费视频国产一区| 伊人精品久久| 精品美女视频| 欧美 日韩 国产精品免费观看| 亚洲精品网址| 亚洲色图综合| 精品久久久网| 国产精品嫩草99av在线| 视频一区日韩精品| 精品成av人一区二区三区 | 嫩呦国产一区二区三区av| 免费高潮视频95在线观看网站| 亚洲精品国产偷自在线观看| 欧美日韩网址| 欧美不卡视频| 国产精品久一| 99视频+国产日韩欧美| 国产激情综合| 影院欧美亚洲| 国产精品九九| 石原莉奈在线亚洲二区| 老牛国内精品亚洲成av人片| 国产在线成人| 精品久久网站| 久久国产生活片100| 好吊视频一区二区三区四区| 卡一卡二国产精品| 中文字幕亚洲影视| 国产一区日韩欧美| 蜜臀国产一区| 老司机免费视频一区二区三区| 亚洲综合欧美| 日本欧美不卡| 国产精品多人| 亚洲性视频在线| 国产伊人精品| 亚洲精品在线影院| 国产精品.xx视频.xxtv| 日本不卡一二三区黄网| 亚洲色图网站| 男人的天堂亚洲一区| 黄色av一区| 91国语精品自产拍| 免费久久久久久久久| 久久久成人网| 国产中文一区| 日韩午夜av| 亚洲综合丁香| 亚洲深夜影院| 蜜桃视频一区二区三区| 视频精品一区二区| 亚洲日本三级| 欧美综合社区国产| 国产精品午夜一区二区三区|