当前位置: 首页 > wzjs >正文

宜宾做网站广告投放是做什么的

宜宾做网站,广告投放是做什么的,网易企业邮箱客服电话,asp.net 网站开发视频【MyBatisPlus】MyBatisPlus介绍与使用 文章目录 【MyBatisPlus】MyBatisPlus介绍与使用 1、什么MyBatisPlus2、MyBatisPlus的CRUD操作3、MyBatisPlus分页使用 1、什么MyBatisPlus MyBatisPlus(简称MP)是基于MyBatis框架基础上开发的增强型工具&…
【MyBatisPlus】MyBatisPlus介绍与使用

文章目录
      • 【MyBatisPlus】MyBatisPlus介绍与使用
        • 1、什么MyBatisPlus
        • 2、MyBatisPlus的CRUD操作
        • 3、MyBatisPlus分页使用
1、什么MyBatisPlus

MyBatisPlus(简称MP)是基于MyBatis框架基础上开发的增强型工具,旨在简化开发、提高效率

  • 官网:https://baomidou.com/

MyBatisPlus特性:

  • 无侵入:只做增强不做改变,不会对现有工程产生影响
  • 强大的 CRUD 操作:内置通用 Mapper,少量配置即可实现单表CRUD 操作(如果只做单表增删查改不需要你写任何的sql)
  • 支持 Lambda:编写查询条件无需担心字段写错
  • 支持主键自动生成
  • 内置分页插件
  • ……

常见的开发方式:

  • 基于MyBatis使用MyBatisPlus
  • 基于Spring使用MyBatisPlus
  • 基于SpringBoot使用MyBatisPlus
2、MyBatisPlus的CRUD操作

使用mybatisplus的步骤

1. 导入mp的启动器
2. 编写application.yml文件,配置数据源,打印日志
3. 编写mapper接口,Mapper接口需要基础BaseMapper接口,BaseMapper接口需要指定操作的是哪个实体类。
4. 在启动类中扫描的Mapper包
5. 测试使用

正如官网所言:mybatis-plus在mybatis的基础上只做增强不做改变,因此只需把mybatis的依赖换成mybatis-plus的依赖

      <!-- mybatis-plus的驱动包 -->
<dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>3.4.2</version>
</dependency>

**注意:**这是mybatis-plus依赖,真正使用起来肯定是根据项目添加,如:mysql驱动、lombok等。

编写application.yml文件,配置数据源

mybatis-plus:configuration:log-impl: org.apache.ibatis.logging.stdout.StdOutImplmap-underscore-to-camel-case: true

编写mapper接口,Mapper接口需要基础BaseMapper接口,BaseMapper接口需要指定操作的是哪个实体类。

public interface UserMapper extends BaseMapper<User> { //这里操作的是User这个实体类}

mybatis-plus为我们提供了一些标准数据层的CRUD功能,这些功能省去了我们自定义接口,也与我们自定义接口有部分差异,如下表:

功能

自定义接口

MP接口

新增

boolean save(T t)

int insert(T t)

删除

boolean delete(int id)

int deleteById(Serializable id)

修改

boolean update(T t)

int updateById(T t)

根据id查询

T getById(int id)

T selectById(Serializable id)

查询全部

List getAll()

List selectList()

分页查询

PageInfo getAll(int page, int size)

IPage selectPage(IPage page)

按条件查询

List getAll(Condition condition)

IPage selectPage(Wrapper queryWrapper)

新增

    /*** 增加*/@Testpublic void testInsert(){User user = new User();user.setName("小林");user.setGender("男");user.setPassword("root");user.setAge(19);user.setTel("18000110011");userMapper.insert(user);}

删除

    /*** 删除*/@Testpublic void testRemove(){userMapper.deleteById(1480751909521403906L);}

更新

    /*** 更新*/@Testpublic void testUpdate(){User user =new User();user.setId(7L);user.setName("张小炮");  //注意: 生成update语句设置的字段为非空字段。userMapper.updateById(user); //update user set xx=xx ,xxx=xx ,xx=xx where id =xx}

查询全部

    @Testpublic void testUserList(){List<User> users = userMapper.selectList(null);for (User user : users) {System.out.println(user);}}

条件查询

    /*** 条件查询*/@Testpublic void testFindByCondition(){//QueryWrapper代表就是条件QueryWrapper<User> queryWrapper  = new QueryWrapper<>();//添加条件//queryWrapper.lt()  greater than 小于//queryWrapper.le()  greater equal 小于等于//queryWrapper.ge()  greater equal 大于等于//queryWrapper.eq()  equal 等于//queryWrapper.gt()  greater than 大于queryWrapper.gt("age",18);List<User> userList = userMapper.selectList(queryWrapper);System.out.println("用户列表:"+ userList);}
3、MyBatisPlus分页使用

功能

MP接口

分页查询

IPage selectPage(IPage page)

如果需要使用到mybatis-plus的分页功能,必须存在一个配置类该配置类创建Mybatis的拦截器,这个拦截器的作用就是在你执行selectPage的方法的时候对sql进行拦截,然后拼接limit语句实现分页。

设置分页拦截器作为Spring管理的bean

  1. 在config包下创建一个配置类:MybatisPlusConfig

  2. 在类上添加@Configuration

  3. 编写方法

    1. 方法上使用@Bean注解:添加MybatisPlusInterceptor对象到容器中
    2. 创建MybatisPlusInterceptor拦截器对象
    3. 添加内部分页拦截器:创建PaginationInnerInterceptor

    @Configuration
    public class MybatisPlusInterceptorConfig {

    /*** 创建MybatisPlusInterceptor拦截器封装里面分页拦截器PaginationInnerInterceptor* 作用:实现对mp内置分页方法拦截增强,实现分页2条sql语句原理* @return*/
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor());return mybatisPlusInterceptor;
    }
    

    }

在测试类中执行分页查询

  1. 创建分页对象,前面是接口IPage,后面是实现类Page(第几页,每页大小)

  2. 调用selectPage方法,传入page对象,无需接收返回值

  3. 获取分页结果

    @Test
    public void testPage(){//查询第一页,每页3条数据//1、创建Page对象,构造函数传入当前页码和每页显示多少条数据Page<User> page = new Page<>(1, 3); //当前页1  页面大小是3//2、执行selectPage方法page = userMapper.selectPage(page,null);//3、获取分页数据System.out.println("总条数:" + page.getTotal());List<User> records = page.getRecords();for (User record : records) {System.out.println(record);}//4、获取当前页System.out.println("当前页:" + page.getCurrent());System.out.println("每页大小:" + page.getSize());
    }
    
http://www.dtcms.com/wzjs/496956.html

相关文章:

  • 昆山网站建设培训班seo+网站排名
  • 品牌网站策划企业网站模板免费
  • 如何在谷歌做网站外链win7优化设置
  • 个人网站 如何做推广百度搜索引擎优化的养成良好心态
  • 怎么做网站赌博百度网站打不开
  • 翻译网站平台建设朋友圈广告投放
  • 地方网站如何做竞价优化方案怎么写
  • 河南省建设工程标准定额管理网站什么是营销渠道
  • 图书网站建设论文服务营销7p理论
  • 南京网站设计制作公司排名榜网络舆情监测中心
  • 网站开发需求用什么软件沈阳seo关键词排名优化软件
  • 网络营销产品有哪些特点网站seo优化怎么做
  • 个人能做网站吗石家庄百度快照优化排名
  • wordpress做网站过程免费seo
  • 网站优化标题seo是什么服务器
  • 做的网站百度搜不到公司想做网络推广贵不
  • 常州地区网页制作公司昆明排名优化
  • 网上外贸网站怎么做百度网盘怎么提取别人资源
  • 正能量不良网站直接进入网站seo关键词优化排名
  • 抖音网站建设的基本情况渠道网官网
  • 可以做动画的网站有哪些关键词首页优化
  • 教育网站建设做排名优化
  • 越秀做网站鞍山seo外包
  • 昆明有哪些帮忙做网站的公司汽车网络营销推广方案
  • tp类似wordpress搜索引擎优化简称
  • 做h5好的网站南昌seo外包公司
  • 网站统计页面模板wordpress建站
  • 深圳app客户端做网站百度关键词如何优化
  • 婚纱摄影网站制作东莞seo外包
  • 网站的建设可以起到什么作用是什么原因网络广告的形式有哪些?