<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zsjt.szrz.dao.TbEmployeeDao">
<resultMap type="com.zsjt.szrz.entity.TbEmployee" id="TbEmployeeMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="age" column="age" jdbcType="INTEGER"/>
<result property="gender" column="gender" jdbcType="VARCHAR"/>
<result property="birthday" column="birthday" jdbcType="TIMESTAMP"/>
<result property="deptid" column="deptId" jdbcType="INTEGER"/>
</resultMap>
<!--查询所有员工加部门的resultMap-->
<resultMap type="com.zsjt.szrz.vo.QueryVo" id="queryMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="age" column="age" jdbcType="INTEGER"/>
<result property="gender" column="gender" jdbcType="VARCHAR"/>
<result property="birthday" column="birthday" jdbcType="TIMESTAMP"/>
<result property="deptid" column="deptId" jdbcType="INTEGER"/>
<!--这里是一对一的关联查询-->
<association property="tbDept" select="com.zsjt.szrz.dao.TbDeptDao.findById" column="deptid">
</association>
</resultMap>
<!--新增员工-->
<insert id="addEmployee">
insert into tb_employee(name, age, gender, birthday, deptid)
values (#{name}, #{age}, #{gender}, #{birthday}, #{deptid})
</insert>
<!--根据id修改-->
<update id="updateById">
update tb_employee
set name=#{name},
age=#{age},
gender=#{gender},
birthday=#{birthday},
deptid=#{deptid}
where id = #{id}
</update>
<!--删除员工-->
<delete id="deleteEmployeeById">
delete
from tb_employee
where id = #{id}
</delete>
<!--根据deptid查询,查询所有员工加部门-->
<select id="findAllQueryVo" resultMap="queryMap">
select *
from tb_employee
</select>
<!--数据回显 根据id查询-->
<select id="findById" resultType="com.zsjt.szrz.entity.TbEmployee">
select *
from tb_employee
where id = #{id}
</select>
<!--根据条件模糊查询-->
<select id="findByConditions" resultMap="queryMap">
select * from tb_employee
<where>
<if test="name!=null">
and name like concat("%",#{name},"%")
</if>
<if test="gender!=null">
and gender=#{gender}
</if>
<if test="age1!=0 and age2==0">
and age=#{age1}
</if>
<if test="age1==0 and age2!=0">
and age=#{age2}
</if>
<if test="age1!=0 and age2!=0">
and age between #{age1} and #{age2}
</if>
<if test="deptid!=0">
and deptid=#{deptid}
</if>
</where>
</select>
</mapper>
没有合适的资源?快使用搜索试试~ 我知道了~
mybatis_01szrz.rar
共25个文件
jar:8个
class:8个
jsp:4个
需积分: 9 0 下载量 141 浏览量
2022-02-07
00:10:17
上传
评论
收藏 7.23MB RAR 举报
温馨提示
mybatis_01szrz.rar
资源详情
资源评论
资源推荐
收起资源包目录
mybatis_01szrz.rar (25个子文件)
META-INF
MANIFEST.MF 96B
WEB-INF
web.xml 315B
classes
com
zsjt
szrz
dao
TbDeptDao.xml 604B
TbEmployeeDao.xml 3KB
TbDeptDao.class 189B
TbEmployeeDao.class 627B
servlet
EmployeeServlet.class 8KB
entity
TbDept.class 874B
TbEmployee.class 2KB
utils
MybatisUtils.class 1KB
vo
QueryConditionVo.class 1KB
QueryVo.class 2KB
applicationContext.xml 1KB
lib
javax.servlet.jsp-api-2.3.3.jar 53KB
standard-1.1.2.jar 384KB
javax.servlet-api-3.0.1.jar 83KB
mybatis-3.5.7.jar 1.66MB
jsqlparser-1.0.jar 356KB
mysql-connector-java-5.1.47.jar 984KB
jstl-1.2.jar 405KB
pagehelper-5.1.2.jar 77KB
add.jsp 1KB
index.jsp 332B
update.jsp 2KB
employee.jsp 4KB
共 25 条
- 1
qq_42570842
- 粉丝: 0
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 瑞萨RL78系列MCU设备文件
- Java电子商务平台案例介绍:实现商品展示、购物车、订单管理和支付功能
- yolov8初始化权重文件
- Nacos控制台简介.pdf
- 基于STM32与ESP8266的智能家居系统,以STM32为核心控制单元,通过传感器监测室内环境,结合微信小程序实现数据传输与远
- ChineseCalendar-1.0.5-SNAPSHOT.jar
- 基于Bagging集成学习方法的情绪分类预测模型研究(数据集+代码).rar
- nacos-server-2.3.0-BETA.zip
- 双11活动数据分析-商品销售数据、促销活动的信息、用户行为数据
- 基于记忆与模型协同过滤的电影推荐系统研究与实践(数据集+代码).rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0