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

太原网站建设制作公司哪家好wordpress h5

太原网站建设制作公司哪家好,wordpress h5,淘宝代运营多少钱一个月,网站全面推广方案文章目录 一、实战目标二、步骤概览1. 创建部门映射器接口2. 创建映射器配置文件3. 配置全局映射器4. 测试映射器接口 三、详细步骤1、创建部门映射器接口2、创建映射器配置文件3、配置全局映射器4、测试映射器接口 四、结语 一、实战目标 在本实战课程中#xff0c;我们将学… 文章目录 一、实战目标二、步骤概览1. 创建部门映射器接口2. 创建映射器配置文件3. 配置全局映射器4. 测试映射器接口 三、详细步骤1、创建部门映射器接口2、创建映射器配置文件3、配置全局映射器4、测试映射器接口 四、结语 一、实战目标 在本实战课程中我们将学习如何在Spring Boot项目中使用配置方式整合MyBatis框架并实现部门管理功能。 二、步骤概览 创建部门映射器接口创建映射器配置文件配置全局映射器测试映射器接口 1. 创建部门映射器接口 在net.huawei.hrsys_ssm.mapper包下创建DepartmentMapper接口使用Mapper注解标记。 2. 创建映射器配置文件 在resources/mapper目录下创建DepartmentMapper.xml定义SQL映射。 3. 配置全局映射器 在MyBatis配置文件中指定映射器配置文件位置和别名路径。 4. 测试映射器接口 创建TestDepartmentMapper类使用SpringBootTest注解进行测试。 三、详细步骤 1、创建部门映射器接口 Mapper public interface DepartmentMapper {int insert(Department department);int deleteById(int id);int update(Department department);Department findById(int id);ListDepartment findAll(); }2、创建映射器配置文件 DepartmentMapper.xml ?xml version1.0 encodingUTF-8 ? !DOCTYPE mapperPUBLIC -//mybatis.org//DTD Mapper 3.0//ENhttp://mybatis.org/dtd/mybatis-3-mapper.dtdmapper namespacenet.huawei.hrsys_ssm.mapper.DepartmentMapper!-- 插入部门记录 --insert idinsert parameterTypeDepartmentuseGeneratedKeystrue keyPropertyidinsert into department (name, number) values (#{name}, #{number});/insert!-- 删除部门记录 --delete iddeleteById parameterTypeintdelete from department where id #{id};/delete!-- 更新部门记录 --update idupdate parameterTypeDepartmentupdate department set name #{name}, number #{number} where id #{id};/update!-- 查询全部部门 --select idfindAll resultTypeDepartmentselect * from department;/select!-- 创建结果映射一个部门对应多个员工构成的集合 --resultMap idDepartmentWithEmployees typeDepartmentid propertyid columnid/result propertyname columnname/result propertynumber columnnumber/collection propertyemployees javaTypelist ofTypeEmployeeid propertyid columne_id/result propertyage columnage/result propertygender columngender/result propertyname columne_name/result propertynumber columne_number/result propertydepId columndep_id//collection/resultMap!-- 按标识符查询部门记录 --select idfindById resultMapDepartmentWithEmployeesselect d.*, e.id e_id, e.age, e.gender, e.name e_name, e.number e_number, e.dep_idfrom department d left outer join employee e on d.id e.dep_idwhere d.id #{id};/select /mapper3、配置全局映射器 mapper-locations: classpath:mapper/*.xml type-aliases-package: net.huawei.hrsys_ssm.bean4、测试映射器接口 package net.huawei.hrsys_ssm;import net.huawei.hrsys_ssm.bean.Department; import net.huawei.hrsys_ssm.mapper.DepartmentMapper; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest;import java.util.List;/*** 功能测试部门映射器接口* 作者华卫* 日期2024年09月25日*/ SpringBootTest public class TestDepartmentMapper {Autowired // 自动装配部门映射器private DepartmentMapper departmentMapper;Test // 测试查询全部部门public void testFindAll() {// 调用部门映射器的查询全部部门方法ListDepartment departments departmentMapper.findAll();// 利用Lambda表达式遍历部门列表departments.forEach(department - System.out.println(department));}Test // 测试按标识符查询部门public void testFindById() {// 定义标识符int id 1;// 调用部门映射器的按标识符查询部门方法Department department departmentMapper.findById(id);// 判断部门是否查询成功if (department ! null) {System.out.println(department);} else {System.out.println(标识符为[ id ]的部门不存在~);}}Test // 测试插入部门public void testInsert() {// 创建部门对象Department department new Department();// 设置部门对象属性department.setName(后勤部);department.setNumber(5);// 调用部门映射器的插入方法int count departmentMapper.insert(department);// 判断部门是否插入成功if (count 0) {System.out.println(恭喜部门记录插入成功~);System.out.println(插入的记录 departmentMapper.findById(5));} else {System.out.println(遗憾部门记录插入失败~);}}Test // 测试更新部门public void testUpdate() {// 查询id为5的部门Department department departmentMapper.findById(5);// 输出更新前记录System.out.println(记录更新前 department);// 设置部门对象属性department.setName(保卫部);department.setNumber(555);// 调用部门映射器的更新部门方法int count departmentMapper.update(department);// 判断部门是否更新成功if (count 0) {System.out.println(恭喜部门记录更新成功~);// 输出更新后记录System.out.println(记录更新后 departmentMapper.findById(5));} else {System.out.println(遗憾部门记录更新失败~);}}Test // 测试按标识符删除员工public void testDeleteById() {// 输出待删除记录System.out.println(待删除记录 departmentMapper.findById(5));// 调用部门映射器的按标识符删除部门方法int count departmentMapper.deleteById(5);// 判断部门是否删除成功if (count 0) {System.out.println(恭喜部门记录删除成功~);} else {System.out.println(遗憾部门记录删除失败~);}} }四、结语 通过本课程你将掌握Spring Boot与MyBatis的整合并能够实现部门管理的CRUD操作。
http://www.hkea.cn/news/14327077/

相关文章:

  • 做网站软件A开头的wordpress主题是用什么开发出来的
  • 关于建设网站的情况说明书网络规划设计师学历低
  • 邢台做移动网站费用大连房地产网站建设
  • 网站设计ai公司邮箱签名模板
  • 桂林市临桂区城乡建设局网站县级部门和乡镇不能建网站建设
  • 商城网站建设运营合同书西安高校定制网站建设公司推荐
  • 杭州公司注销网站备案WordPress的MySQL宕
  • 厦门网站优化建设河南网站建设工作室
  • 无锡滨湖区建设局网站wordpress single page
  • 服务器怎样做网站呢深圳短视频seo搜索排名如何做
  • 网站标准尺寸做电脑网站宽度
  • 子目录创建网站网站建设实训心得php
  • 商务网站设计做h5网站
  • 装修公司网站php源码南宁建网站必荐云尚网络
  • html网站编辑器网站开发设计框图
  • 驾校网站模版如何提升网站搜索排名
  • win7下asp网站搭建创建网站的详细步骤
  • 常州网站关键词推广58网站怎么做才有客户问
  • 个人网站建设 免费沈阳企业关键词优化
  • 北京网站优化服务广州灰色优化网络公司
  • 重庆网站制作长沙wordpress如何关闭网站
  • 岳阳网站建设企业wordpress知识付费插件
  • 百度收录率高的网站淘大象关键词排名查询
  • 湖北手机网站制作wordpress播放网易云
  • 建设银行网站不能登录密码阳江招聘网站哪里最好找工作
  • 快速建站框架汕头政务发布
  • 网站设计建设专业服务网站建设需要做什么
  • 众创空间那个网站做的好漯河网站建设茂睿科技
  • 网站建设案例信息正规的徐州网站建设
  • 千山科技做网站好不好自在源码网官网