You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.7 KiB
48 lines
1.7 KiB
<?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.example.springbootstudy.dao.EmployeeDao">
|
|
<select id="getEmployees" resultType="com.example.springbootstudy.pojo.Employee">
|
|
select employee.id,name,sex,birthday,salary,phone,department.dept from employee,department where employee.dept_id = department.id;
|
|
</select>
|
|
|
|
<select id="getEmployeeById" resultType="com.example.springbootstudy.pojo.Employee">
|
|
select employee.id,name,sex,birthday,salary,phone,department.dept from employee,department where employee.dept_id = department.id and employee.id = #{id};
|
|
</select>
|
|
|
|
<insert id="addEmployee">
|
|
insert into employee values(#{id},#{name},#{sex},#{birthday},#{salary},#{phone},(select id from department where dept = #{dept}))
|
|
</insert>
|
|
|
|
<delete id="delEmployee" parameterType="java.lang.Integer">
|
|
delete from employee where employee.id = #{id};
|
|
</delete>
|
|
|
|
<update id="updateEmployee">
|
|
update employee
|
|
<set>
|
|
<if test="name != null">
|
|
name = #{name},
|
|
</if>
|
|
<if test="sex != null">
|
|
sex = #{sex},
|
|
</if>
|
|
<if test="birthday != null">
|
|
birthday = #{birthday},
|
|
</if>
|
|
<if test="salary != null">
|
|
salary = #{salary},
|
|
</if>
|
|
<if test="phone != null">
|
|
phone = #{phone},
|
|
</if>
|
|
<if test="dept != null">
|
|
dept_id = (select id from department where dept = #{dept}),
|
|
</if>
|
|
</set>
|
|
where employee.id = #{id};
|
|
</update>
|
|
|
|
</mapper> |