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.
149 lines
8.3 KiB
149 lines
8.3 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="org.example.mapper.EmployeeMapper">
|
|
|
|
<resultMap type="Employee" id="EmployeeResult">
|
|
<result property="id" column="id" />
|
|
<result property="deptId" column="dept_id" />
|
|
<result property="jobId" column="job_id" />
|
|
<result property="name" column="name" />
|
|
<result property="cardId" column="card_id" />
|
|
<result property="address" column="address" />
|
|
<result property="postCode" column="post_code" />
|
|
<result property="tel" column="tel" />
|
|
<result property="phone" column="phone" />
|
|
<result property="qqNum" column="qq_num" />
|
|
<result property="email" column="email" />
|
|
<result property="sex" column="sex" />
|
|
<result property="party" column="party" />
|
|
<result property="birthday" column="birthday" />
|
|
<result property="race" column="race" />
|
|
<result property="education" column="education" />
|
|
<result property="speciality" column="speciality" />
|
|
<result property="hobby" column="hobby" />
|
|
<result property="remark" column="remark" />
|
|
<result property="createDate" column="create_date" />
|
|
<association property="dept" column="dept_id" select="org.example.mapper.DeptMapper.selectDeptById"></association>
|
|
<association property="job" column="job_id" select="org.example.mapper.JobMapper.selectJobById"></association>
|
|
</resultMap>
|
|
|
|
<sql id="selectEmployeeVo">
|
|
select id, dept_id, job_id, name, card_id, address, post_code, tel, phone, qq_num, email, sex, party, birthday, race, education, speciality, hobby, remark, create_date from employee
|
|
</sql>
|
|
|
|
<select id="selectEmployeeList" parameterType="Employee" resultMap="EmployeeResult">
|
|
<include refid="selectEmployeeVo"/>
|
|
<where>
|
|
<if test="deptId != null "> and dept_id = #{deptId}</if>
|
|
<if test="jobId != null "> and job_id = #{jobId}</if>
|
|
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
|
<if test="cardId != null and cardId != ''"> and card_id like concat('%', #{cardId}, '%')</if>
|
|
<if test="address != null and address != ''"> and address like concat('%', #{address}, '%')</if>
|
|
<if test="postCode != null and postCode != ''"> and post_code like concat('%', #{postCode}, '%')</if>
|
|
<if test="tel != null and tel != ''"> and tel like concat('%', #{tel}, '%')</if>
|
|
<if test="phone != null and phone != ''"> and phone like concat('%', #{phone}, '%')</if>
|
|
<if test="qqNum != null and qqNum != ''"> and qq_num = #{qqNum}</if>
|
|
<if test="email != null and email != ''"> and email = #{email}</if>
|
|
<if test="sex != null and sex !='' "> and sex = #{sex}</if>
|
|
<if test="party != null and party !='' "> and party = #{party}</if>
|
|
<if test="birthday != null "> and birthday = #{birthday}</if>
|
|
<if test="race != null and race != ''"> and race = #{race}</if>
|
|
<if test="education != null and education != ''"> and education = #{education}</if>
|
|
<if test="speciality != null and speciality != ''"> and speciality = #{speciality}</if>
|
|
<if test="hobby != null and hobby != ''"> and hobby = #{hobby}</if>
|
|
<if test="createDate != null "> and create_date = #{createDate}</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="selectEmployeeById" parameterType="Long" resultMap="EmployeeResult">
|
|
<include refid="selectEmployeeVo"/>
|
|
where id = #{id}
|
|
order by create_date desc
|
|
</select>
|
|
|
|
<insert id="insertEmployee" parameterType="Employee" useGeneratedKeys="true" keyProperty="id">
|
|
insert into employee
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="deptId != null">dept_id,</if>
|
|
<if test="jobId != null">job_id,</if>
|
|
<if test="name != null and name != ''">name,</if>
|
|
<if test="cardId != null and cardId != ''">card_id,</if>
|
|
<if test="address != null and address != ''">address,</if>
|
|
<if test="postCode != null and postCode != ''">post_code,</if>
|
|
<if test="tel != null">tel,</if>
|
|
<if test="phone != null and phone != ''">phone,</if>
|
|
<if test="qqNum != null and qqNum != ''">qq_num,</if>
|
|
<if test="email != null and email != ''">email,</if>
|
|
<if test="sex != null">sex,</if>
|
|
<if test="party != null">party,</if>
|
|
<if test="birthday != null">birthday,</if>
|
|
<if test="race != null and race != ''">race,</if>
|
|
<if test="education != null and education != ''">education,</if>
|
|
<if test="speciality != null and speciality != ''">speciality,</if>
|
|
<if test="hobby != null">hobby,</if>
|
|
<if test="remark != null">remark,</if>
|
|
<if test="createDate != null">create_date,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="deptId != null">#{deptId},</if>
|
|
<if test="jobId != null">#{jobId},</if>
|
|
<if test="name != null and name != ''">#{name},</if>
|
|
<if test="cardId != null and cardId != ''">#{cardId},</if>
|
|
<if test="address != null and address != ''">#{address},</if>
|
|
<if test="postCode != null and postCode != ''">#{postCode},</if>
|
|
<if test="tel != null">#{tel},</if>
|
|
<if test="phone != null and phone != ''">#{phone},</if>
|
|
<if test="qqNum != null and qqNum != ''">#{qqNum},</if>
|
|
<if test="email != null and email != ''">#{email},</if>
|
|
<if test="sex != null">#{sex},</if>
|
|
<if test="party != null">#{party},</if>
|
|
<if test="birthday != null">#{birthday},</if>
|
|
<if test="race != null and race != ''">#{race},</if>
|
|
<if test="education != null and education != ''">#{education},</if>
|
|
<if test="speciality != null and speciality != ''">#{speciality},</if>
|
|
<if test="hobby != null">#{hobby},</if>
|
|
<if test="remark != null">#{remark},</if>
|
|
<if test="createDate != null">#{createDate},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<update id="updateEmployee" parameterType="Employee">
|
|
update employee
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="deptId != null">dept_id = #{deptId},</if>
|
|
<if test="jobId != null">job_id = #{jobId},</if>
|
|
<if test="name != null and name != ''">name = #{name},</if>
|
|
<if test="cardId != null and cardId != ''">card_id = #{cardId},</if>
|
|
<if test="address != null and address != ''">address = #{address},</if>
|
|
<if test="postCode != null and postCode != ''">post_code = #{postCode},</if>
|
|
<if test="tel != null">tel = #{tel},</if>
|
|
<if test="phone != null and phone != ''">phone = #{phone},</if>
|
|
<if test="qqNum != null and qqNum != ''">qq_num = #{qqNum},</if>
|
|
<if test="email != null and email != ''">email = #{email},</if>
|
|
<if test="sex != null">sex = #{sex},</if>
|
|
<if test="party != null">party = #{party},</if>
|
|
<if test="birthday != null">birthday = #{birthday},</if>
|
|
<if test="race != null and race != ''">race = #{race},</if>
|
|
<if test="education != null and education != ''">education = #{education},</if>
|
|
<if test="speciality != null and speciality != ''">speciality = #{speciality},</if>
|
|
<if test="hobby != null">hobby = #{hobby},</if>
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
<if test="createDate != null">create_date = #{createDate},</if>
|
|
</trim>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<delete id="deleteEmployeeById" parameterType="Long">
|
|
delete from employee where id = #{id}
|
|
</delete>
|
|
|
|
<delete id="deleteEmployeeByIds" parameterType="String">
|
|
delete from employee where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</delete>
|
|
|
|
</mapper> |