创建UserController测试类

package com.cppdy.controller;

import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.cppdy.entity.User;
import com.cppdy.mapper.UserMapper; @RestController
@RequestMapping("user")
public class UserController { @Autowired
private UserMapper userMapper; @RequestMapping("getUserById")
public Object getUserById(int id) { return userMapper.selectById(id);
} @RequestMapping("deleteUserById")
public Object deleteUserById(int id) { return userMapper.deleteById(id);
} @RequestMapping("getUser")
public Object getUser() {
//适配器
Wrapper<User> wrapper=new EntityWrapper<>();
wrapper.like("username", "测试");
//倒序
wrapper.orderBy("id", false);
return userMapper.selectList(wrapper);
} @RequestMapping("selectPage")
public Object selectPage(int pageNum,int pageSize) {
//适配器
Wrapper<User> wrapper=new EntityWrapper<>(); RowBounds rowBounds=new RowBounds((pageNum-1)*pageSize,pageSize); return userMapper.selectPage(rowBounds, wrapper);
} }

MybatisPlus使用介绍的更多相关文章

  1. MyBatis-Plus 使用说明介绍

    先看一下和MyBatis 不同点说明: @GetMapping("/select_sql") public Object getUserBySql() { User user=ne ...

  2. MyBatis 进阶,MyBatis-Plus!(基于 Springboot 演示)

    这一篇从一个入门的基本体验介绍,再到对于 CRUD 的一个详细介绍,在介绍过程中将涉及到的一些问题,例如逐渐策略,自动填充,乐观锁等内容说了一下,只选了一些重要的内容,还有一些没提及到,具体可以参考官 ...

  3. springboot系列七:springboot 集成 MyBatis、事物配置及使用、druid 数据源、druid 监控使用

    一.MyBatis和druid简介 MyBatis 是一款优秀的持久层框架,它支持定制化 SQL.存储过程以及高级映射.MyBatis 避免了几乎所有的 JDBC 代码和手动设置参数以及获取结果集.M ...

  4. Springboot日记——核心编码篇

    背景吐槽:想要让自己进阶一下,一定要有个可以拿出来秀的东西,所以要尝试写一个属于自己的网站或者平台.因此,我大概的看了一下springboot+Mybatis-plus+... 框架介绍 通常 SSM ...

  5. nalu,在java中使用lambda查询数据库

    不忘初心 最开始接触写代码的时候,用的是C井,查数据库直接硬编码sql,挺难受的. 后来学习到EntityFramework,用起来是真香,都是强类型,各种智能提示,代码写起来极度舒适,效率起飞. 最 ...

  6. 关于写SpringBoot+Mybatisplus+Shiro项目的经验分享一:简单介绍

    这次我尝试写一个原创的项目 the_game 框架选择: SpringBoot+Mybatisplus+Shiro 首先是简单的介绍(素材灵感来自英雄联盟) 5个关键的表: admin(管理员): l ...

  7. Mybatis-Plus介绍

    Mybatis-Plus介绍 Mybatis-Plus概念 Mybatis-Plus介绍 官网https://mybatis-plus/或https://mp.baomidou.com/ mybati ...

  8. MyBatis-Plus分页——PageHelper和IPage介绍

    两个都用于分页,常用的应该是PageHelper了,理解了一下源码后发现IPage比PageHelper好用. 使用方法是 PageHelper.startPage()然后后边写sql就可以. 紧接着 ...

  9. springboot集成mybatisplus

    介绍: Mybatis-Plus(简称MP)是一个 Mybatis 的增强工具,在 Mybatis 的基础上只做增强不做改变,为简化开发.提高效率而生.(摘自mybatis-plus官网)Mybati ...

随机推荐

  1. :target方法实现切换

    <!DOCTYPE HTML><html><head> <title>:target切换</title> <meta charset= ...

  2. 第24月第30天 scrapy《TensorFlow机器学习项目实战》项目记录

    1.Scrapy https://www.imooc.com/learn/1017 https://github.com/pythonsite/spider/tree/master/jobboleSp ...

  3. linqjs

    Project Descriptionlinq.js - LINQ for JavaScript Features implement all .NET 4.0 methods and many ex ...

  4. Python 转路由之uplink

    项目描述 1.为客制化的Web API接口建立可重用的对象 2.可以与Requests,asyncio和Twisted 快速开始 Uplink把你的HTTP API接口转化成一个Python的类 fr ...

  5. McQueenRPC源码阅读

    1.server 2.client 3.消息格式

  6. E - Emptying the Baltic Kattis - emptyingbaltic (dijkstra堆优化)

    题目链接: E - Emptying the Baltic Kattis - emptyingbaltic 题目大意:n*m的地图, 每个格子有一个海拔高度, 当海拔<0的时候有水. 现在在(x ...

  7. Spring整合Web项目原理-理解不了,忽略

  8. 【运维】Dell R710如何做Raid0与Raid5

    [写在前面]         这次是在戴尔服务器R710上面尝试的做Raid0和Raid5,亲测成功.         因为创建Raid0与Raid5的方式是一样的,所以就以创建Raid5为例. 1, ...

  9. dubbo源码分析8——服务暴露概述

    从上文中可知,com.alibaba.dubbo.config.spring.ServiceBean类是负责解析<dubbo:service/>的配置的,下面是它的类图 从类图上可知它继承 ...

  10. C实战:项目构建Make,Automake,CMake【转】

    转自:https://blog.csdn.net/dc_726/article/details/48978849 版权声明:本文为博主原创文章,未经博主允许不得转载.欢迎访问 http://blog. ...