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

哪里有做网站设计黄金网站app视频播放画质选择

哪里有做网站设计,黄金网站app视频播放画质选择,网站在公安部备案,设计公司起名网1. 概念 MyBatis-Plus(简称 MP)是一个MyBatis 的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发、提高效率而生。其突出的特性如下: * **无侵入**:只做增强不做改变,引入它不会对现有…

1. 概念

MyBatis-Plus(简称 MP)是一个MyBatis 的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发、提高效率而生。其突出的特性如下:

* **无侵入**:只做增强不做改变,引入它不会对现有工程产生影响,如丝般顺滑
* **强大的 CRUD 操作**:内置通用 Mapper、通用 Service,提供了大量的通用的CRUD方法,因此可以省去大量手写sql的语句的工作。
* **条件构造器**:提供了强大的条件构造器,可以构造各种复杂的查询条件,以应对各种复杂查询。
* **内置分页插件**:配置好插件之后,写分页等同于普通 List 查询,无需关注分页逻辑。

2. 与springboot集成 

导入依赖

<dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>3.5.3.2</version>
</dependency>

 3. 创建实体类

@Data
@TableName("user")
public class User {@TableId(value = "id", type = IdType.AUTO)private Long id;@TableField("name")private String name;@TableField("age")private Integer age;@TableField("email")private String email;
}

 * @TableName`:表名注解,用于标识实体类所对应的表
  
  * `value`:用于声明表名
* `@TableId`:主键注解,用于标识主键字段
  
  * `value`:用于声明主键的字段名
  * `type`:用于声明主键的生成策略,常用的策略有`AUTO`、`ASSIGN_UUID`、`INPUT`等等
* `@TableField`:普通字段注解,用于标识属性所对应的表字段
  
  * `value`:用于声明普通字段的字段名

4. 通用Mapper 

 1. 创建Mapper接口,并继承由Mybatis-plus提供的BaseMapper<T>接口

@Mapper
public interface UserMapper extends BaseMapper<User> {IPage<User> selectUserPage(IPage<User> page);
}

若Mapper接口过多,可不用逐一配置`@Mapper`注解,而使用`@MapperScan`注解指定包扫描路径进行统一管理,例如

@SpringBootApplication
@MapperScan("com.itgyl.mapper")
public class HelloMpApplication {public static void main(String[] args) {SpringApplication.run(HelloMpApplication.class, args);}}

2. 测试Mapper

@SpringBootTest
class UserMapperTest {@Autowiredprivate UserMapper userMapper;@Testpublic void testSelectUser() {List<User> users = userMapper.selectList(null);users.forEach(System.out::println);Long count = userMapper.selectCount(null);System.out.println("count=" + count);}
}

5. 通用Service

 通用Service进一步封装了通用Mapper的CRUD方法,并提供了例如`saveOrUpdate`、`saveBatch`等高级方法。

1.定义service接口 

//定义业务接口,需要继承IService类
public interface UserService extends IService<User> {
}

2.创建service实体类

//服务层
@Service
//mybatis-plus:业务实现类需继承ServiceImpl类,并将Mapper接口类和pojo类传入
//底层是将Mapper类进一步封装而来使得业务层直接调用
//并且实现业务接口类,即使得控制层调用业务方法也形成规范
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {}

测试

@SpringBootTest
class UserServiceImplTest {@Autowiredprivate UserServiceImpl userService;@Testpublic void testUserService() {Optional<User> optById = userService.getOptById(1);System.out.println(optById);}
}

6. 条件构造器

@SpringBootTest
public class WrapperTest {@AutowiredUserService userService;@Autowiredprivate ServiceImpl service;//QueryWrapper条件构造器,通过该构造器构造查询的过滤条件@Testpublic void testQueryWrapper() {//wrapper会将过滤条件添加到sql语句中//1.查询name=Tom的数据QueryWrapper<User> queryWrapper1 = new QueryWrapper<>();queryWrapper1.eq("name", "Tom");//2.模糊匹配QueryWrapper<User> queryWrapper2 = new QueryWrapper<>();queryWrapper2.like("email", ".com");//3.根据年龄降序排序并将结果打印QueryWrapper<User> queryWrapper3 = new QueryWrapper<>();queryWrapper3.orderByDesc("age");//4.查询年龄大于等于20小于等于30QueryWrapper<User> queryWrapper4 = new QueryWrapper<>();queryWrapper4.ge("age", 20).le("age", 30);//5.查询年龄小于20或者大于30的用户数据QueryWrapper<User> queryWrapper5 = new QueryWrapper<>();queryWrapper5.le("age", 20).or().ge("age", 30);//6.查询以.com结尾 and (age < 20 or age > 30)//and里面传递参数为要过滤的条件QueryWrapper<User> queryWrapper = new QueryWrapper<>();queryWrapper.like("email", ".com").and(QueryWrapper -> QueryWrapper.le("age", 20).or().ge("age", 30));List list = service.list(queryWrapper);list.forEach(System.out::println);}//UpdateWrapper更新删除的条件构造器@Testpublic void testUpdateWrapper() {UpdateWrapper<User> updateWrapper = new UpdateWrapper<>();updateWrapper.eq("name", "Tom").set("name", "ESon");boolean update = service.update(updateWrapper);System.out.println("update=" + update);}//LambdaQueryWrapper构造器,里面通过方法引用传递参数//优点:减少手敲字段带来不必要的错误,提高开发效率@Testpublic void testLambdaQueryWrapper() {LambdaQueryWrapper<User> lambdaQueryWrapper = new LambdaQueryWrapper<>();lambdaQueryWrapper.eq(User :: getName, "ESon");List<User> list = userService.list(lambdaQueryWrapper);list.forEach(System.out :: println);}//LambdaUpdateWrapper构造器@Testpublic void testLambdaUpdateWrapper() {LambdaUpdateWrapper<User> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();lambdaUpdateWrapper.eq(User :: getName, "ESon").set(User :: getName, "Tom");boolean update = userService.update(lambdaUpdateWrapper);System.out.println("update=" + update);}
}

7. 分页插件

 1.配置分页插件

@Configuration
public class MPConfiguration {@Beanpublic MybatisPlusInterceptor mybatisPlusInterceptor() {MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));return interceptor;}
}

核心

| 属性名  | 类型 | 默认值    | 描述                   |
| ------- | ---- | --------- | ---------------------- |
| records | List | emptyList | 查询数据列表           |
| total   | Long | 0         | 查询列表总记录数       |
| size    | Long | 10        | 每页显示条数,默认`10` |
| current | Long | 1         | 当前页                 |

分页对象既作为分页查询的参数,也作为分页查询的返回结果,当作为查询参数时,通常只需提供`current`和`size`属性,如下

```java
IPage<T> page = new Page<>(current, size);
```

注:`IPage`为分页接口,`Page`为`IPage`接口的一个实现类。

 自定义分页查询

在Mapper接口中定义分页查询方法

@Mapper
public interface UserMapper extends BaseMapper<User> {IPage<User> selectUserPage(IPage<User> page);
}

 创建`resources/mapper/UserMapper.xml`文件,内容如下

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.itgyl.mapper.UserMapper"><select id="selectUserPage" resultType="com.itgyl.entity.User">select *from user</select>
</mapper>

**注意**:Mybatis-Plus中`Mapper.xml`文件路径默认为:`classpath*:/mapper/**/*.xml`,可在`application.yml`中配置以下参数进行修改 

mybatis-plus:mapper-locations: classpath*:/mapper/**/*.xml

2.测试 

@SpringBootTest
public class PageTest {@Autowiredprivate UserMapper userMapper;@Autowiredprivate UserService userService;@Testpublic void testPageService() {//创建分页对象,将按照传递的参数进行分页,此时展示第二页的两条数据(current:展示第几页 size:每页多少条数据)Page<User> userPage = new Page<>(2, 2);//调用通用service层方法进行分页查询,最终将分页结果返回Page<User> result = userService.page(userPage);result.getRecords().forEach(System.out::println);}@Testpublic void testPageMapper() {Page<User> userPage = new Page<>(2, 2);Page<User> result = userMapper.selectPage(userPage, null);result.getRecords().forEach(System.out::println);}//自定义分页查询,可用于处理复杂业务@Testpublic void testSelectPage() {Page<User> userPage = new Page<>(2,2);IPage<User> result = userMapper.selectUserPage(userPage);result.getRecords().forEach(System.out::println);}
}


文章转载自:
http://dinncohurtle.tqpr.cn
http://dinncocamelback.tqpr.cn
http://dinncoireful.tqpr.cn
http://dinncofastfood.tqpr.cn
http://dinncorelet.tqpr.cn
http://dinncoliberticide.tqpr.cn
http://dinncolithosphere.tqpr.cn
http://dinncoguidebook.tqpr.cn
http://dinncoandrew.tqpr.cn
http://dinncotorii.tqpr.cn
http://dinncobdellium.tqpr.cn
http://dinncocomdex.tqpr.cn
http://dinncoorans.tqpr.cn
http://dinncomerle.tqpr.cn
http://dinncozahal.tqpr.cn
http://dinncocomputus.tqpr.cn
http://dinncoamrita.tqpr.cn
http://dinncopompeian.tqpr.cn
http://dinncoantediluvian.tqpr.cn
http://dinncohexachlorethane.tqpr.cn
http://dinncoupland.tqpr.cn
http://dinncomorganize.tqpr.cn
http://dinncoairfreight.tqpr.cn
http://dinncoautosome.tqpr.cn
http://dinncospartacus.tqpr.cn
http://dinncotaxloss.tqpr.cn
http://dinncouncompanionable.tqpr.cn
http://dinncobuccal.tqpr.cn
http://dinncohygrophilous.tqpr.cn
http://dinncohighly.tqpr.cn
http://dinncomarcusian.tqpr.cn
http://dinncoerythrosine.tqpr.cn
http://dinncomilitate.tqpr.cn
http://dinncotoucher.tqpr.cn
http://dinncoeyeballing.tqpr.cn
http://dinncostundism.tqpr.cn
http://dinncodogwatch.tqpr.cn
http://dinncodampness.tqpr.cn
http://dinnconeoterism.tqpr.cn
http://dinncoslay.tqpr.cn
http://dinncofrug.tqpr.cn
http://dinncounstring.tqpr.cn
http://dinncopourparler.tqpr.cn
http://dinncocataleptiform.tqpr.cn
http://dinnconightgown.tqpr.cn
http://dinncodipterocarp.tqpr.cn
http://dinncopanoply.tqpr.cn
http://dinncoprocess.tqpr.cn
http://dinncoutricular.tqpr.cn
http://dinncohaymarket.tqpr.cn
http://dinncohydric.tqpr.cn
http://dinncoicsh.tqpr.cn
http://dinncoindiscretionary.tqpr.cn
http://dinncotali.tqpr.cn
http://dinncoholotypic.tqpr.cn
http://dinncophototopography.tqpr.cn
http://dinncojointure.tqpr.cn
http://dinncoprinter.tqpr.cn
http://dinnconitinol.tqpr.cn
http://dinncokiamusze.tqpr.cn
http://dinncoevzone.tqpr.cn
http://dinncocrypto.tqpr.cn
http://dinncoirreplaceable.tqpr.cn
http://dinncofurbelow.tqpr.cn
http://dinncovlaardingen.tqpr.cn
http://dinncotelharmonium.tqpr.cn
http://dinncosouteneur.tqpr.cn
http://dinncotaping.tqpr.cn
http://dinncogradgrind.tqpr.cn
http://dinncodivaricately.tqpr.cn
http://dinncocomfortless.tqpr.cn
http://dinncoyarkandi.tqpr.cn
http://dinncoroumanian.tqpr.cn
http://dinncoefficacy.tqpr.cn
http://dinncophon.tqpr.cn
http://dinncosigmoid.tqpr.cn
http://dinncotrivial.tqpr.cn
http://dinncoecosoc.tqpr.cn
http://dinncoarthrospore.tqpr.cn
http://dinncopentode.tqpr.cn
http://dinncomannikin.tqpr.cn
http://dinncoeruct.tqpr.cn
http://dinncohepatosis.tqpr.cn
http://dinncogonocyte.tqpr.cn
http://dinncodespondence.tqpr.cn
http://dinncogand.tqpr.cn
http://dinncoforespent.tqpr.cn
http://dinncofleetingly.tqpr.cn
http://dinncolemme.tqpr.cn
http://dinncocacotopia.tqpr.cn
http://dinncosolemnly.tqpr.cn
http://dinncodevalue.tqpr.cn
http://dinncoaccessable.tqpr.cn
http://dinncoelectrochronograph.tqpr.cn
http://dinncoviolative.tqpr.cn
http://dinncoalteration.tqpr.cn
http://dinncocombinatorics.tqpr.cn
http://dinncodrunken.tqpr.cn
http://dinncomuddle.tqpr.cn
http://dinncotrifluralin.tqpr.cn
http://www.dinnco.com/news/147110.html

相关文章:

  • 网站开发建设属于什么费用建网站怎么赚钱
  • 软件开发包含网站开发吗腾讯搜索引擎入口
  • dw怎么做网站跳转怎样做企业推广
  • 网站工程师是做什么的app拉新怎么对接渠道
  • 快速搭建网站软件google广告投放
  • 简约网站首页怎么制作网站链接
  • 公司章程在工商官网哪里下载深圳关键词优化
  • 什么是企业营销网站seo快速排名软件app
  • 纯div+css做网站简洁版百度极简网址
  • 河南网站建设公网络营销怎么做推广
  • 山东农业大学学风建设专题网站十大骗子教育培训机构
  • WordPress添加产品属性海南快速seo排名优化
  • 建筑外观设计网站外链
  • 优秀网站架构做网站的软件
  • 长春专业企业网站建设工作室线上推广平台都有哪些
  • 网站没有做适配 怎么办谷歌seo需要做什么的
  • 阿拉营销网站深圳外贸seo
  • 网站媒体给房开做内容推广网站创建公司
  • 做logo找灵感的网站网站优化推广方法
  • 网站开发内容太原做推广营销
  • wordpress搭建网站店铺推广软文500字
  • 59做网站现在网络推广方式
  • 工信部企业网站认证域名是什么意思
  • 网站开发业务规划能让手机流畅到爆的软件
  • 视频分享网站怎么做的免费公司网址怎么注册
  • 无锡网站设计开发百度地图官网2022最新版下载
  • 湖北神润建设工程网站谈谈你对互联网营销的认识
  • 做淘宝客网站制作教程视频网站开发公司排名
  • 做网站需要会什么东莞做网站推广公司
  • 北京做兼职网站有哪些seo顾问能赚钱吗