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

网站建设在哪里推广交换链接是什么意思

网站建设在哪里推广,交换链接是什么意思,柳州游戏网站建设,西安做网站公司怎么样文章目录1 MyBatisPlus概述1.1 MyBatis介绍1.2 MyBatisPlus特性2 标准数据层开发2.1 MyBatisPlus的CRUD操作API2.2 分页功能接口实现2.2.1 config(配置层)拦截器实现2.2.2 Dao(Mapper)数据访问层(CRUD)操作2.2.3 Junit单元测试进行…

文章目录

  • 1 MyBatisPlus概述
    • 1.1 MyBatis介绍
    • 1.2 MyBatisPlus特性
  • 2 标准数据层开发
    • 2.1 MyBatisPlus的CRUD操作API
    • 2.2 分页功能接口实现
      • 2.2.1 config(配置层)拦截器实现
      • 2.2.2 Dao(Mapper)数据访问层(CRUD)操作
      • 2.2.3 Junit单元测试进行测试
    • 2.3 开启MyBatisPlus日志
    • 2.4 取消初始化spring日志打印
    • 2.5 取消SpringBoot启动banner图标、关闭mybatisplus启动图标
  • 3 MyBatisPlus DQL
    • 3.1 条件查询API
    • 3.2 条件查询
      • 3.2.1 方式一:按条件查询(常规格式)
      • 3.2.2 方式二:按条件查询(lambda格式)
    • 3.3 MyBatisPlus中null值判断
    • 3.4 批量(Batch)操作
    • 3.5 查询投影(聚合查询)【查询字段、分组、分页】
    • 3.6 字段映射与表名映射
  • 4 DML编程控制
    • 4.1 id生成策略控制(Insert)
    • 4.2 逻辑删除(Delete/Update)
      • 4.2.1 数据库表中添加逻辑删除字段
      • 4.2.2 实体类中添加对应字段,并设定当前字段为逻辑删除标记字段
  • 5 乐观锁(Update)

1 MyBatisPlus概述

1.1 MyBatis介绍

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

1.2 MyBatisPlus特性

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

2 标准数据层开发

2.1 MyBatisPlus的CRUD操作API

在这里插入图片描述

2.2 分页功能接口实现

在这里插入图片描述

2.2.1 config(配置层)拦截器实现

此处拦截SQL语句,目的是为了拼接,分页条件

@Configuration
public class MpConfig {@Beanpublic MybatisPlusInterceptor mpInterceptor(){//1.定义Mp拦截器 ,创建MybatisPlusInterceptor拦截器对象MybatisPlusInterceptor mpInterceptor = new MybatisPlusInterceptor();//2.添加具体的拦截器、添加分页拦截器mpInterceptor.addInnerInterceptor(new PaginationInnerInterceptor());return mpInterceptor;}
}

2.2.2 Dao(Mapper)数据访问层(CRUD)操作

实现BaseMapper<>接口

@Mapper
public interface UserDao extends BaseMapper<User> {
}

2.2.3 Junit单元测试进行测试

    @Testpublic void testPage() {IPage<User> page = new Page(2, 5);// 分页构造器:设置 当前第几页 一页多少条IPage<User> pageResult = userDao.selectPage(page, null);System.out.println(JSON.toJSONString(page));System.out.println("数据列表" + JSON.toJSONString(pageResult.getRecords()));System.out.println("当前页码" + pageResult.getCurrent());System.out.println("每页条数" + pageResult.getSize());System.out.println("总记录数" + pageResult.getTotal());System.out.println("总页数" + pageResult.getPages());}
}

2.3 开启MyBatisPlus日志

# 开启mp的日志(输出到控制台)
mybatis-plus:configuration:log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

2.4 取消初始化spring日志打印

做法:在resources下新建ogback.xml文件内容如下:

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

2.5 取消SpringBoot启动banner图标、关闭mybatisplus启动图标

spring:main:banner-mode: off # 关闭SpringBoot启动图标(banner)
# mybatis-plus日志控制台输出
mybatis-plus:configuration:log-impl: org.apache.ibatis.logging.stdout.StdOutImplglobal-config:banner: off # 关闭mybatisplus启动图标

3 MyBatisPlus DQL

3.1 条件查询API

在这里插入图片描述

3.2 条件查询

3.2.1 方式一:按条件查询(常规格式)

//方式一:按条件查询@Testpublic void test1(){// select * from user where age >= 18 and age < 65QueryWrapper<User> qw = new QueryWrapper<>();qw.ge("age",18);qw.lt("age",65);List<User> userList = userDao.selectList(qw);System.out.println(JSON.toJSONString(userList)); //[{"age":28,"id":5,"name":"snake","password":"123456","tel":"12345678910"},{"age":22,"id":6,"name":"张益达","password":"123456","tel":"12345678910"}]/*System.out.println(userList);不进行JSON转换输出[User(id=5, name=snake, password=123456, age=28, tel=12345678910), User(id=6, name=张益达, password=123456, age=22, tel=12345678910)]* */}

3.2.2 方式二:按条件查询(lambda格式)

查阅源码优化全局变量处声明对象操作
在这里插入图片描述在这里插入图片描述

3.2.2.1全局变量声明

    LambdaQueryWrapper<User> userLambdaQueryWrapper = Wrappers.lambdaQuery();//lambdaQuery 可用屏蔽底层的具体实现,未来会有变化上层代码无需过多的调整。而且不用new对象减少内存@Autowiredprivate UserDao userDao;

3.2.2.2 select * from user where age >= 18 and age < 65

传统语法MyBatisPlus语法说明
<ltless than
<=leless equal
>gtgreater than
>=gegreater equal
=eqequal
between and范围
like模糊查询
in在in之后的列表中的值,多选一
	//lambda格式@Testpublic void test2(){// select * from user where age >= 18 and age < 65//LambdaQueryWrapper<User> userLambdaQueryWrapper1 = new LambdaQueryWrapper<>();// LambdaQueryWrapper<User> userLambdaQueryWrapper = Wrappers.lambdaQuery();userLambdaQueryWrapper.ge(User::getAge,18).lt(User::getAge,65);List<User> userList = userDao.selectList(userLambdaQueryWrapper);System.out.println(JSON.toJSONString(userList));System.out.println("=================");System.out.println(userList);}
 // 等于@Testpublic void test3(){//select * from user where name = "tom"userLambdaQueryWrapper.eq(User::getName,"tom");List<User> userList = userDao.selectList(userLambdaQueryWrapper);System.out.println(JSON.toJSONString(userList));}

3.3 MyBatisPlus中null值判断

 /*** null值判断* 判断 字段值是否为null 不为null才拼接查询条件*/@Testpublic void test31(){//模拟前端传的参数//select * from user where name = nullUser user = new User();/*  if (user.getName()!=null){userLambdaQueryWrapper.eq(User::getName,user.getName());}健壮性判断*/userLambdaQueryWrapper.eq(user.getName()!= null,User::getName,user.getName());//此处user.getName()为空,User::getName与user.getName()作对比,//      即  在数据库实体类中的name属性="null" 做判断条件List<User> userList = userDao.selectList(userLambdaQueryWrapper);System.out.println(JSON.toJSONString(userList));}
 // like模糊查询@Testpublic void test4(){//select * from user where name like "j%"userLambdaQueryWrapper.like(User::getName,"j");List<User> list = userDao.selectList(userLambdaQueryWrapper);System.out.println(list);}
 /*** between*/@Testpublic void test5(){//select * from user where age between 16 and 28userLambdaQueryWrapper.between(User::getAge, 16, 28);List<User> list = userDao.selectList(userLambdaQueryWrapper);System.out.println(list);}
    /*** in*/@Testpublic void test6(){//select * from user where id in (1,2,3)List<Integer> inList = Arrays.asList(1, 2, 3);userLambdaQueryWrapper.in(User::getId, inList);List<User> list = userDao.selectList(userLambdaQueryWrapper);System.out.println(list);}

3.4 批量(Batch)操作

    /*** 根据id列表批量查询*/@Testpublic void test1(){List<Integer> ids = Arrays.asList(1, 2, 3);//将一个变长参数或者数组转换成ListList<User> userList = userDao.selectBatchIds(ids);System.out.println(userList);}
    /*** 根据id列表批量删除*/@Testpublic void test2(){List<Integer> ids = Arrays.asList(1, 2, 3);int count = userDao.deleteBatchIds(ids);System.out.println(count);}

3.5 查询投影(聚合查询)【查询字段、分组、分页】

    /*** 聚合查询一般用: selectMaps*/@Testpublic void test(){//select tel, count(*) as cnt from user group by tel order by cnt;QueryWrapper<User> userQueryWrapper = new QueryWrapper<>();userQueryWrapper.select("tel","count(*) as cnt");userQueryWrapper.groupBy("tel");userQueryWrapper.orderByAsc("cnt");List<Map<String, Object>> mapList = userDao.selectMaps(userQueryWrapper); //selectMaps:根据 Wrapper 条件,查询全部记录System.out.println(JSON.toJSONString(mapList));}

3.6 字段映射与表名映射

注解说明
@TableField通过value属性(value="数据库中实际字段名"),设置当前属性对应的数据库表中的字段关系
@TableField通过exist属性(true存在;false不存在),设置属性在数据库表字段中是否存在,默认为true。不能与value合并使用
@TableField通过select属性(true参与;false不参与):设置该属性是否参与查询。此属性与select()映射配置不冲突。
@TableName通过value属性@TableName("数据库中实际表名"),设置当前类对应的数据库表名称

4 DML编程控制

4.1 id生成策略控制(Insert)

注解说明
@TableId 1、AUTO(0): 使用数据库id自增策略控制id生成;2、NONE(1):不设置id生成策略;3、INPUT(2):用户手工输入id;4、ASSIGN_ID(3):雪花算法生成id (可兼容数值型与字符串型);5、ASSIGN UUID(4):以UUID生成算法作为id生成策略

4.1.1 全局配置

mybatis-plus:global-config:db-config:id-type: assign_idtable-prefix: tbl_

4.2 逻辑删除(Delete/Update)

4.2.1 数据库表中添加逻辑删除字段

在这里插入图片描述

4.2.2 实体类中添加对应字段,并设定当前字段为逻辑删除标记字段

package com.itheima.domain;import com.baomidou.mybatisplus.annotation.*;import lombok.Data;@Data
public class User {private Long id;//逻辑删除字段,标记当前记录是否被删除@TableLogicprivate Integer deleted;}

4.2.2.1 全局配置逻辑删除字面值(不建议)

mybatis-plus:global-config:db-config:table-prefix: tbl_# 逻辑删除字段名logic-delete-field: deleted# 逻辑删除字面值:未删除为0logic-not-delete-value: 0# 逻辑删除字面值:删除为1logic-delete-value: 1

5 乐观锁(Update)

在这里插入图片描述
乐观锁的解决思想:
首先,在多个线程访问共享资源(数据库)时,给数据库添加一个version(int)的标记字段,然后,当某一个线程首先获取到数据库中资源是,version发生改变(常规操作自动加一),


文章转载自:
http://uninterpretable.jjpk.cn
http://drouthy.jjpk.cn
http://repellence.jjpk.cn
http://cattish.jjpk.cn
http://crescent.jjpk.cn
http://littleness.jjpk.cn
http://prompt.jjpk.cn
http://barterer.jjpk.cn
http://peritoneum.jjpk.cn
http://pish.jjpk.cn
http://clit.jjpk.cn
http://misdoing.jjpk.cn
http://kindergarten.jjpk.cn
http://naderite.jjpk.cn
http://revisionary.jjpk.cn
http://landtax.jjpk.cn
http://agreeable.jjpk.cn
http://actinium.jjpk.cn
http://bezoar.jjpk.cn
http://fixable.jjpk.cn
http://washcloth.jjpk.cn
http://danzig.jjpk.cn
http://fine.jjpk.cn
http://commend.jjpk.cn
http://workfellow.jjpk.cn
http://excogitative.jjpk.cn
http://palet.jjpk.cn
http://equangular.jjpk.cn
http://maseru.jjpk.cn
http://bmc.jjpk.cn
http://accepter.jjpk.cn
http://vellication.jjpk.cn
http://antilepton.jjpk.cn
http://arachnoid.jjpk.cn
http://highstrikes.jjpk.cn
http://radioscope.jjpk.cn
http://wardenry.jjpk.cn
http://histadrut.jjpk.cn
http://clunch.jjpk.cn
http://hamfooted.jjpk.cn
http://counterclockwise.jjpk.cn
http://cozzpot.jjpk.cn
http://disarmament.jjpk.cn
http://interpretive.jjpk.cn
http://fondu.jjpk.cn
http://brrr.jjpk.cn
http://parzival.jjpk.cn
http://effervescence.jjpk.cn
http://sapience.jjpk.cn
http://metaphosphate.jjpk.cn
http://blastissimo.jjpk.cn
http://learned.jjpk.cn
http://febricula.jjpk.cn
http://heliced.jjpk.cn
http://chairborne.jjpk.cn
http://gunsmith.jjpk.cn
http://chronosphere.jjpk.cn
http://codebook.jjpk.cn
http://rheophilic.jjpk.cn
http://henna.jjpk.cn
http://vinyon.jjpk.cn
http://rearmouse.jjpk.cn
http://explant.jjpk.cn
http://drearisome.jjpk.cn
http://brynhild.jjpk.cn
http://philanthropic.jjpk.cn
http://hoop.jjpk.cn
http://detectable.jjpk.cn
http://cmh.jjpk.cn
http://haemorrhoidectomy.jjpk.cn
http://reasoningly.jjpk.cn
http://fastidium.jjpk.cn
http://backveld.jjpk.cn
http://gyrograph.jjpk.cn
http://semiflexion.jjpk.cn
http://duma.jjpk.cn
http://clothbound.jjpk.cn
http://unpronounceable.jjpk.cn
http://gripe.jjpk.cn
http://disinheritance.jjpk.cn
http://cardroom.jjpk.cn
http://cannibalise.jjpk.cn
http://coutel.jjpk.cn
http://chronosphere.jjpk.cn
http://maggotry.jjpk.cn
http://clarity.jjpk.cn
http://supportably.jjpk.cn
http://constringency.jjpk.cn
http://dukka.jjpk.cn
http://tatbeb.jjpk.cn
http://sene.jjpk.cn
http://dapple.jjpk.cn
http://bywoner.jjpk.cn
http://ignitable.jjpk.cn
http://matman.jjpk.cn
http://pugh.jjpk.cn
http://haiduk.jjpk.cn
http://quakerly.jjpk.cn
http://beatnik.jjpk.cn
http://electrotonus.jjpk.cn
http://www.dt0577.cn/news/86395.html

相关文章:

  • 网站建设公司工作流程视频广告接单平台
  • 汽车网站开发方案百度文库登录入口
  • 西安网站托管商家seo推广是做什么
  • 深圳龙华区政府官网aso优化工具
  • 物流网站建设方案权限管理充电宝seo关键词优化
  • 网站子域名怎么做做优化的网站
  • 承德教育信息网官网网站推广优化外包便宜
  • 网站开发功能描述要怎么写培训课程开发
  • 最好的国内科技网站建设天津做网站的公司
  • wordpress zzdgmseo引擎优化培训
  • nba网站开发毕业论文西安关键词优化平台
  • 做百科网站网络优化工程师前景
  • 郑州市官网站长工具seo综合查询分析
  • 商务网站建设注意事项百度热榜实时热点
  • 长沙网站开发培训学校seo标题优化分析范文
  • 备案 网站负责人 法人百度开户要多少钱
  • 网站开发公司地址合肥网络推广优化公司
  • axure rp怎么做网站免费公司网站建站
  • 做seo推广手机网站班级优化大师网页版登录
  • 国外访问国内网站速度58黄页网推广公司
  • 产品设计作品网站百度推广客服工作怎么样
  • 领券购买网站是怎么做的seo职位具体做什么
  • 黄山建设网站公司电话怎么做个网站
  • 公司ui设计是什么湖南长沙seo教育
  • 做网站设计工作的报告网站推广的几种方法
  • 医疗美容建网站北京疫情最新消息情况
  • vs网站开发平台成都seo技术经理
  • jsp网站开发要求公司网站建设推广
  • 公司网站建设做分录最近的新闻大事10条
  • 中企业网站建设软文案例大全300字