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

阿里服务器怎么做网站服务器网站建设需要哪些信息

阿里服务器怎么做网站服务器,网站建设需要哪些信息,南乐网站建设电话,厚街镇网站建设公司目录 1. MybatisPlus 的基本功能2. 基本用法3. MybatisPlus 的配置4. MybatisPlus 的实体类、Mapper 接口、Service 类和 Controller 类 MybatisPlus 是一个功能强大的 MyBatis 增强工具#xff0c;它提供了丰富的特性来简化操作数据库的代码。它主要用于简化 JDBC 操作#… 目录 1. MybatisPlus 的基本功能2. 基本用法3. MybatisPlus 的配置4. MybatisPlus 的实体类、Mapper 接口、Service 类和 Controller 类 MybatisPlus 是一个功能强大的 MyBatis 增强工具它提供了丰富的特性来简化操作数据库的代码。它主要用于简化 JDBC 操作节省开发时间并能够自动化完成所有的 CRUD 代码。 MybatisPlus官网https://baomidou.com/ 1. MybatisPlus 的基本功能 提供丰富的 CRUD 方法包括insert、selectById、selectBatchIds、update、delete 等。提供乐观锁功能支持版本号管理。提供查询条件生成器简化查询条件的编写。提供代码生成器自动生成实体类、Mapper 接口、Service 类、Controller 类等。支持多种数据库类型如MySQL、Oracle、SQL Server 等。 2. 基本用法 (1) 分页插件 MybatisPlus 的分页逻辑底层是通过分页插件来完成的。分页插件的实现原理主要是基于 MyBatis 的动态 SQL 生成通过 Mybatis 的 count 和 offset 的实现来实现分页功能。 (2) 自动装配 MybatisPlus 提供了自动装配功能可以自动根据实体类生成对应的 Mapper 接口、Service 类和 Controller 类。自动装配的实现原理是基于 Mybatis 的 XML 配置文件通过解析 XML 文件生成对应的 Java 代码。 (3) 条件查询 MybatisPlus 提供了丰富的查询方法如 eq、ne、gt、ge、lt、le、like 等。这些查询方法底层是通过 MyBatis 的动态 SQL 生成来实现的通过拼接 SQL 语句来实现条件查询。 eq等于 用于查询字段值等于指定值的记录。 ListUser users userMapper.selectList(new QueryWrapperUser().eq(age, 18)); ne不等于 用于查询字段值不等于指定值的记录。 ListUser users userMapper.selectList(new QueryWrapperUser().ne(age, 18)); gt大于 用于查询字段值大于指定值的记录。 ListUser users userMapper.selectList(new QueryWrapperUser().gt(age, 18)); ge大于等于 用于查询字段值大于等于指定值的记录。 ListUser users userMapper.selectList(new QueryWrapperUser().ge(age, 18)); lt小于 用于查询字段值小于指定值的记录。 ListUser users userMapper.selectList(new QueryWrapperUser().lt(age, 18)); le小于等于 用于查询字段值小于等于指定值的记录。 ListUser users userMapper.selectList(new QueryWrapperUser().le(age, 18)); like模糊查询 用于根据指定的字符串进行模糊查询。可以指定匹配前缀、后缀或指定多个字符。 // 匹配前缀 ListUser users userMapper.selectList(new QueryWrapperUser().like(name, zhang%)); // 匹配后缀 ListUser users userMapper.selectList(new QueryWrapperUser().like(name, %zhang)); // 匹配多个字符 ListUser users userMapper.selectList(new QueryWrapperUser().like(name, z%a%)); 3. MybatisPlus 的配置 在 Spring Boot 项目中我们可以通过以下步骤来配置 MybatisPlus 在 pom.xml 文件中添加 MybatisPlus 的依赖 dependency groupIdcom.baomidou/groupId artifactIdmybatis-plus-boot-starter/artifactId version3.4.3.1/version /dependency 在 application.properties 文件中配置 MybatisPlus mybatis-plus.mapper-locationsclasspath:mapper/*.xml mybatis-plus.type-aliases-packagecom.example.demo.entity mybatis-plus.global-config.id-typeauto mybatis-plus.global-config.db-config.logic-delete-value1 mybatis-plus.global-config.db-config.logic-not-delete-value0 4. MybatisPlus 的实体类、Mapper 接口、Service 类和 Controller 类 实体类Entity实体类是用于映射数据库表的通常包含了表的字段以及对应的 getter 和 setter 方法。例如假设有一个用户表user那么对应的实体类可能如下 package com.example.demo.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; TableName(user) public class User { TableId(type IdType.AUTO) private Long id; private String name; private Integer age; private String email;// getter 和 setter 方法 }Mapper 接口Mapper 接口用于定义与数据库表相关的操作。例如对于用户表user对应的 Mapper 接口可能如下 package com.example.demo.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.example.demo.entity.User; import org.apache.ibatis.annotations.Mapper; Mapper public interface UserMapper extends BaseMapperUser { }Service 类Service 类用于处理业务逻辑。它通常包含了一些与数据库操作相关的方法。例如对于用户表user对应的 Service 类可能如下 package com.example.demo.service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.example.demo.entity.User; import com.example.demo.mapper.UserMapper; import org.springframework.stereotype.Service; Service public class UserService extends ServiceImplUserMapper, User { }Controller 类Controller 类用于处理 HTTP 请求。它通常包含了一些与数据库操作相关的方法。例如对于用户表user对应的 Controller 类可能如下 package com.example.demo.controller; import com.example.demo.entity.User; import com.example.demo.service.UserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; RestController RequestMapping(/user) public class UserController { Autowired private UserService userService;GetMapping public ListUser getUsers() { return userService.list(); }GetMapping(/{id}) public User getUserById(PathVariable Long id) { return userService.getById(id); }PostMapping public void addUser(RequestBody User user) { userService.save(user); }PutMapping(/{id}) public void updateUser(PathVariable Long id, RequestBody User user) { userService.updateById(id, user); }DeleteMapping(/{id}) public void deleteUser(PathVariable Long id) { userService.removeById(id); } }
http://www.w-s-a.com/news/632426/

相关文章:

  • 企业网站带新闻发布功能的建站皋兰县建设局网站
  • 国内外做gif的网站wordpress数据库教程
  • 成都建站平台自己做一个网站需要多少钱
  • 景区旅游网站平台建设公司企业网站源码
  • 免费高清网站推荐喂来苏州网络科技有限公司
  • php做的大型网站有哪些备案博客域名做视频网站会怎么样
  • 去哪网站备案吗昭通网站建设
  • flash企业网站源码建筑材料采购网站
  • 网站可以换虚拟主机吗部门做网站优点
  • 如何做分类网站信息营销莱芜网页定制
  • 班级网站建设感想中国做视频网站有哪些
  • 做刷票的网站wordpress图片链接插件
  • 给客户做网站图片侵权沈阳做网站的地方
  • 网站开发步骤规划蓝天云免费空间主机
  • 网站字体规范wordpress找不到页面内容编辑
  • 静态网站建设参考文献茂名营销型网站制作公司
  • 君山区建设局网站风铃微网站怎么做
  • 购物网站销售管理合肥网络推广平台
  • 网站建设规划书txt微盘注册帐号
  • 小说网站开发实训报告企业网盘收费标准
  • mvc网站开发医疗医院网站建设
  • 天津市建设厅官方网站wordpress设置404
  • 贵阳好的网站建设免费正能量网站下载ww
  • 免费学习的网站平台自建站seo如何做
  • 海南三亚做网站公众号版面设计创意
  • 学校网站建设目的与意义合肥网页定制
  • 网站查询地址网站建设与维护费用
  • 做网站哪些软件比较好合肥外贸网站建设公司
  • 建网站需要哪些条件专业网站设计报价
  • 定制网站开发技术化妆品的网站布局设计图片大全