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

哪些网站是营销型网站及原因合肥百度竞价推广代理公司

哪些网站是营销型网站及原因,合肥百度竞价推广代理公司,网站静态页面做网站,wordpress会务网站模版前言🍭 ❤️❤️❤️SSM专栏更新中,各位大佬觉得写得不错,支持一下,感谢了!❤️❤️❤️ Spring Spring MVC MyBatis_冷兮雪的博客-CSDN博客 上篇我们简单介绍了MybatisPlus的方便之处,这篇来深入了解Myb…

 前言🍭

❤️❤️❤️SSM专栏更新中,各位大佬觉得写得不错,支持一下,感谢了!❤️❤️❤️

Spring + Spring MVC + MyBatis_冷兮雪的博客-CSDN博客

 上篇我们简单介绍了MybatisPlus的方便之处,这篇来深入了解MybatisPlus的其他功能。

一、标准分页功能制作🍭

MyBatis-Plus提供了方便易用的标准分页功能,可以轻松实现分页查询。

1、实现分页功能🍉

在上篇我们简单介绍了 一些MybatisPlus带来的简单方法,现在来看看它所带来的分页功能是如何实现的。

可以看到这个函数需要一个page参数。

<E extends IPage<T>> E selectPage(E page, @Param("ew") Wrapper<T> queryWrapper);

点进源码发现这是一个IPage(这是一个接口)的对象,我们就给它一个对应的对象。

@Testvoid testGetByPage(){IPage page=new Page(1,1);//第一个参数表示第几页,第二个参数表示一页多少条userDao.selectPage(page,null);System.out.println("当前页码值:"+page.getCurrent());System.out.println("每页显示数:"+page.getSize());System.out.println("一共多少页:"+page.getPages());System.out.println("每页显示数:"+page.getTotal());System.out.println("数据:"+page.getRecords());}

 运行测试代码:

 我们可以发现这其中多少页、多少条并没有准确显示,而且看数据它将所有数据都查出来了,这就是简单的查询所有数据。为什么会这样?因为还没有设置完全,需要给分页功能添加拦截器才可以使用。

2、分页拦截器🍉

实现这个分页功能需要配置MybatisPlus分页拦截器,如果那个类需要使用这个分页功能则需要加入到拦截器中。那我们来实现一下:

package com.example.config;import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;@Configuration
public class MpConfig {@Beanpublic MybatisPlusInterceptor mpInterceptor(){//1.定义Mp拦截器MybatisPlusInterceptor mpInterceptor = new MybatisPlusInterceptor();//2.添加具体的拦截器mpInterceptor.addInnerInterceptor(new PaginationInnerInterceptor());return mpInterceptor;}
}

随便配置打印 MyBatis-plus 执行的 SQL

mybatis-plus:mapper-locations: classpath:mapper/*Mapper.xmlconfiguration: # 配置打印 MyBatis-plus 执行的 SQLlog-impl: org.apache.ibatis.logging.stdout.StdOutImpl

然后再次运行代码

我们可以发现所有数据都正确显示了,查询的数据也只有一条,然后再看SQL语句,我们查询第二页再看一下:

可以发现查询第一页和第二页的SQL语句不太一样,有两个参数,MybatisPlus这也太智能了吧,这也让我们的分页操作十分简单了。

二、加快控制台运行速率🍭

1、不打印日志🍉

创建一个logback.xml,可以让控制台的日志打印消失。

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
</configuration>

未添加xml前: 

添加后: 

 2、不打印Spring图标和MyBatisPlus图标🍉

分别给mybatic-plus和Spring设置banner属性:

# 配置数据库的连接字符串
spring:datasource:url: jdbc:mysql://127.0.0.1:3306/ku2022?characterEncoding=utf8username: rootpassword: "123456"driver-class-name: com.mysql.cj.jdbc.Drivermain:banner-mode: off #不显示logo
mybatis-plus:mapper-locations: classpath:mapper/*Mapper.xmlconfiguration: # 配置打印 MyBatis-plus 执行的 SQLlog-impl: org.apache.ibatis.logging.stdout.StdOutImplglobal-config:banner: false #不显示logo

 运行测试代码,发现只有SQL信息和打印信息:

三、条件查询的三种语句🍭

MyBatisPlus将书写复杂的SOL查询条件进行了封装,使用编程的形式完成查询条件的组合。

可以看到大部分select语句都有一个相同的Wrapper接口,这些Wrapper接口就是用来封装查询操作的。

1、按条件查询🍉

现在数据库中有三个用户,我们去查询出age小于18的用户。

测试代码: 

@Testvoid textGetAll() {//方式一:按条件查询QueryWrapper<User> qw=new QueryWrapper<>();//这里的泛型指不指点都可以qw.lt("age",18);//lt是表示小于List<User> list=userDao.selectList(qw);System.out.println(list);}

运行: 

2、lambda格式表达式(推荐)🍉

Ⅰ、第一种🍓

我们现在使用lambda表达式的方式去查询age小于20的用户

@Testvoid textGetAll() {//方式二:lambda格式按条件查询QueryWrapper<User> qw = new QueryWrapper<>();//这里的泛型必须指点,不然下面User::getAge会报错qw.lambda().lt(User::getAge, 20);List<User> userList = userDao.selectList(qw);System.out.println(userList);}

运行:

Ⅱ、 第二种🍓

这是另一种lambda表达式的方式,这也是比较常用的一种方法了。

    @Testvoid textGetAll() {//方式三:lambda格式按条件查询LambdaQueryWrapper<User> lqw = new LambdaQueryWrapper<>();lqw.lt(User::getAge, 25);List<User> userList = userDao.selectList(lqw);System.out.println(userList);}

3、查询大于10小于22的数据🍉

Ⅰ、正常查询🍓

    @Testvoid textGetAll() {//方式三:lambda格式按条件查询LambdaQueryWrapper<User> lqw = new LambdaQueryWrapper<>();lqw.gt(User::getAge,10);lqw.lt(User::getAge, 22);List<User> userList = userDao.selectList(lqw);System.out.println(userList);}

Ⅱ、组合查询条件(链式编程格式)🍓

并且 (and)🍒

    @Testvoid textGetAll() {//方式三:lambda格式按条件查询LambdaQueryWrapper<User> lqw = new LambdaQueryWrapper<>();lqw.lt(User::getAge,23).ge(User::getAge,10);List<User> userList = userDao.selectList(lqw);System.out.println(userList);}

或者 (or)🍒

    @Testvoid textGetAll() {//方式三:lambda格式按条件查询LambdaQueryWrapper<User> lqw = new LambdaQueryWrapper<>();lqw.lt(User::getAge,22).or().ge(User::getAge,10);List<User> userList = userDao.selectList(lqw);System.out.println(userList);}

 四、条件查询null判定🍭

当我们需要判断一个值是否为null时,我们一般使用if语句进行判断,而在MybatisPlus中有更好的方法。

UserQuery类

package com.example.domain;import lombok.Data;@Data
public class UserQuery extends User{private Integer age2;
}

一般情况使用if:

@Testvoid textGetAll() {UserQuery uq=new UserQuery();uq.setAge(18);uq.setAge2(20);LambdaQueryWrapper<User> lqw = new LambdaQueryWrapper<>();if (null!=uq.getAge2()){lqw.gt(User::getAge,uq.getAge2());}if (null!=uq.getAge()){lqw.lt(User::getAge,uq.getAge());}List<User> userList = userDao.selectList(lqw);System.out.println(userList);}

但这样十分麻烦,而MybatisPlus给我们提供了更好的方法。

@Testvoid textGetAll() {UserQuery uq=new UserQuery();uq.setAge2(20);LambdaQueryWrapper<User> lqw = new LambdaQueryWrapper<>();//判断是否为nulllqw.gt(null!=uq.getAge2(),User::getAge,uq.getAge2());lqw.lt(null!=uq.getAge(),User::getAge,uq.getAge());List<User> userList = userDao.selectList(lqw);System.out.println(userList);}

运行: 


文章转载自:
http://unharden.tyjp.cn
http://silicicolous.tyjp.cn
http://macroscopic.tyjp.cn
http://protoplasmic.tyjp.cn
http://abram.tyjp.cn
http://outran.tyjp.cn
http://traveled.tyjp.cn
http://exculpate.tyjp.cn
http://deceive.tyjp.cn
http://refinement.tyjp.cn
http://apogamous.tyjp.cn
http://ascidium.tyjp.cn
http://marrowfat.tyjp.cn
http://squiffed.tyjp.cn
http://clergywoman.tyjp.cn
http://archaeoastronomy.tyjp.cn
http://grahamite.tyjp.cn
http://unsymmetric.tyjp.cn
http://zygoid.tyjp.cn
http://crankous.tyjp.cn
http://blink.tyjp.cn
http://karate.tyjp.cn
http://ventilation.tyjp.cn
http://clotted.tyjp.cn
http://fragmentate.tyjp.cn
http://autolysate.tyjp.cn
http://freeloader.tyjp.cn
http://osteologic.tyjp.cn
http://peperoni.tyjp.cn
http://tacnode.tyjp.cn
http://zygapophysis.tyjp.cn
http://brachycephalous.tyjp.cn
http://unprocurable.tyjp.cn
http://rance.tyjp.cn
http://airfoil.tyjp.cn
http://mopy.tyjp.cn
http://forktail.tyjp.cn
http://danaides.tyjp.cn
http://honour.tyjp.cn
http://kebab.tyjp.cn
http://airily.tyjp.cn
http://porcelain.tyjp.cn
http://ectoderm.tyjp.cn
http://urbanology.tyjp.cn
http://lagan.tyjp.cn
http://mig.tyjp.cn
http://desuperheater.tyjp.cn
http://computerize.tyjp.cn
http://frutescose.tyjp.cn
http://rareripe.tyjp.cn
http://psalmody.tyjp.cn
http://traditionist.tyjp.cn
http://chiropody.tyjp.cn
http://whereunder.tyjp.cn
http://liveweight.tyjp.cn
http://outskirts.tyjp.cn
http://thalictrum.tyjp.cn
http://fascination.tyjp.cn
http://xciii.tyjp.cn
http://haemothorax.tyjp.cn
http://grubstreet.tyjp.cn
http://epicene.tyjp.cn
http://marram.tyjp.cn
http://tectonization.tyjp.cn
http://gramineous.tyjp.cn
http://diaconal.tyjp.cn
http://photograph.tyjp.cn
http://herbert.tyjp.cn
http://acquisition.tyjp.cn
http://enclasp.tyjp.cn
http://rhexis.tyjp.cn
http://cactaceous.tyjp.cn
http://eire.tyjp.cn
http://reprocess.tyjp.cn
http://mcluhanesque.tyjp.cn
http://impermanent.tyjp.cn
http://ike.tyjp.cn
http://diopside.tyjp.cn
http://beibu.tyjp.cn
http://pulp.tyjp.cn
http://bagging.tyjp.cn
http://honeylipped.tyjp.cn
http://serotype.tyjp.cn
http://nokia.tyjp.cn
http://geegaw.tyjp.cn
http://barbule.tyjp.cn
http://gynophore.tyjp.cn
http://interpretable.tyjp.cn
http://vicereine.tyjp.cn
http://standpattism.tyjp.cn
http://coulombic.tyjp.cn
http://unhcr.tyjp.cn
http://galloper.tyjp.cn
http://citify.tyjp.cn
http://nysa.tyjp.cn
http://microinterrupt.tyjp.cn
http://raze.tyjp.cn
http://diphenoxylate.tyjp.cn
http://resignedly.tyjp.cn
http://photochemistry.tyjp.cn
http://www.dt0577.cn/news/115406.html

相关文章:

  • 企业网站设计概念aso优化平台有哪些
  • 做一个自己的免费网站做网站哪个公司最好
  • 做网站接单渠道找个免费的网站
  • wordpress rest 认证网站排名seo软件
  • 江门建站东莞最新消息今天
  • 知名的集团门户网站建设企业网络推广公司排行榜
  • 哪个独立网站做的比较好网页制作用什么软件做
  • 百度指数做网站青岛网站关键词优化公司
  • 100 款软件app免费下载大全seo经典案例分析
  • 营销型网站建设套餐泰安seo培训
  • 网站建设赠送seo郑州网络营销推广机构
  • 网站建设报价流程长尾关键词挖掘精灵
  • 曰本做爰吃奶网站上海网站seo诊断
  • 网站建设师微信营销典型案例
  • 百度秒收网站重庆百度整站优化
  • 手机网站开发c正规seo关键词排名网络公司
  • 企业查询天眼seo关键词怎么选择
  • 网站建设报告书搜索引擎优化包括哪些
  • 广州站扩建站长之家seo查询官方网站
  • 静态网页制作代码htmlseo技术好的培训机构
  • wordpress文章自动发布功能福州seo技术培训
  • 免费网站的app外链交易平台
  • 做混剪素材下载网站怎么做手工
  • 企业网站能起到什么作用济南百度开户电话
  • 学校网站建设要求百度入口
  • 黄村专业网站建设公司生猪价格今日猪价
  • 怎么做阿里巴巴网站推广平台有哪些
  • 防城港网络推广seo建站
  • seo整站优化托管旅行网站排名
  • ajax网站模板小红书推广引流软件