137 lines
6.8 KiB
XML
137 lines
6.8 KiB
XML
|
<?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.yanzhu.jh.work.mapper.WorkTrainMapper">
|
||
|
|
||
|
<resultMap type="WorkTrain" id="WorkTrainResult">
|
||
|
<result property="id" column="id" />
|
||
|
<result property="mainImage" column="main_image" />
|
||
|
<result property="trainType" column="train_type" />
|
||
|
<result property="trainNature" column="train_nature" />
|
||
|
<result property="trainParticipants" column="train_participants" />
|
||
|
<result property="beginDate" column="begin_date" />
|
||
|
<result property="endDate" column="end_date" />
|
||
|
<result property="trainContent" column="train_content" />
|
||
|
<result property="isDel" column="is_del" />
|
||
|
<result property="createBy" column="create_by" />
|
||
|
<result property="createTime" column="create_time" />
|
||
|
<result property="updateBy" column="update_by" />
|
||
|
<result property="updateTime" column="update_time" />
|
||
|
<result property="remark" column="remark" />
|
||
|
</resultMap>
|
||
|
|
||
|
<resultMap id="WorkTrainWorkTrainDeptResult" type="WorkTrain" extends="WorkTrainResult">
|
||
|
<collection property="workTrainDeptList" notNullColumn="sub_train_id" javaType="java.util.List" resultMap="WorkTrainDeptResult" />
|
||
|
</resultMap>
|
||
|
|
||
|
<resultMap type="WorkTrainDept" id="WorkTrainDeptResult">
|
||
|
<result property="trainId" column="sub_train_id" />
|
||
|
<result property="deptId" column="sub_dept_id" />
|
||
|
<result property="isMain" column="sub_is_main" />
|
||
|
</resultMap>
|
||
|
|
||
|
<sql id="selectWorkTrainVo">
|
||
|
select id, main_image, train_type, train_nature, train_participants, begin_date, end_date, train_content, is_del, create_by, create_time, update_by, update_time, remark from work_train
|
||
|
</sql>
|
||
|
|
||
|
<select id="selectWorkTrainList" parameterType="WorkTrain" resultMap="WorkTrainResult">
|
||
|
<include refid="selectWorkTrainVo"/>
|
||
|
<where>
|
||
|
<if test="trainType != null and trainType != ''"> and train_type = #{trainType}</if>
|
||
|
<if test="trainNature != null and trainNature != ''"> and train_nature = #{trainNature}</if>
|
||
|
<if test="isDel != null "> and is_del = #{isDel}</if>
|
||
|
</where>
|
||
|
</select>
|
||
|
|
||
|
<select id="selectWorkTrainById" parameterType="Long" resultMap="WorkTrainWorkTrainDeptResult">
|
||
|
select a.id, a.main_image, a.train_type, a.train_nature, a.train_participants, a.begin_date, a.end_date, a.train_content, a.is_del, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,
|
||
|
b.train_id as sub_train_id, b.dept_id as sub_dept_id, b.is_main as sub_is_main
|
||
|
from work_train a
|
||
|
left join work_train_dept b on b.train_id = a.id
|
||
|
where a.id = #{id}
|
||
|
</select>
|
||
|
|
||
|
<insert id="insertWorkTrain" parameterType="WorkTrain" useGeneratedKeys="true" keyProperty="id">
|
||
|
insert into work_train
|
||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||
|
<if test="mainImage != null">main_image,</if>
|
||
|
<if test="trainType != null">train_type,</if>
|
||
|
<if test="trainNature != null">train_nature,</if>
|
||
|
<if test="trainParticipants != null">train_participants,</if>
|
||
|
<if test="beginDate != null">begin_date,</if>
|
||
|
<if test="endDate != null">end_date,</if>
|
||
|
<if test="trainContent != null">train_content,</if>
|
||
|
<if test="isDel != null">is_del,</if>
|
||
|
<if test="createBy != null">create_by,</if>
|
||
|
<if test="createTime != null">create_time,</if>
|
||
|
<if test="updateBy != null">update_by,</if>
|
||
|
<if test="updateTime != null">update_time,</if>
|
||
|
<if test="remark != null">remark,</if>
|
||
|
</trim>
|
||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||
|
<if test="mainImage != null">#{mainImage},</if>
|
||
|
<if test="trainType != null">#{trainType},</if>
|
||
|
<if test="trainNature != null">#{trainNature},</if>
|
||
|
<if test="trainParticipants != null">#{trainParticipants},</if>
|
||
|
<if test="beginDate != null">#{beginDate},</if>
|
||
|
<if test="endDate != null">#{endDate},</if>
|
||
|
<if test="trainContent != null">#{trainContent},</if>
|
||
|
<if test="isDel != null">#{isDel},</if>
|
||
|
<if test="createBy != null">#{createBy},</if>
|
||
|
<if test="createTime != null">#{createTime},</if>
|
||
|
<if test="updateBy != null">#{updateBy},</if>
|
||
|
<if test="updateTime != null">#{updateTime},</if>
|
||
|
<if test="remark != null">#{remark},</if>
|
||
|
</trim>
|
||
|
</insert>
|
||
|
|
||
|
<update id="updateWorkTrain" parameterType="WorkTrain">
|
||
|
update work_train
|
||
|
<trim prefix="SET" suffixOverrides=",">
|
||
|
<if test="mainImage != null">main_image = #{mainImage},</if>
|
||
|
<if test="trainType != null">train_type = #{trainType},</if>
|
||
|
<if test="trainNature != null">train_nature = #{trainNature},</if>
|
||
|
<if test="trainParticipants != null">train_participants = #{trainParticipants},</if>
|
||
|
<if test="beginDate != null">begin_date = #{beginDate},</if>
|
||
|
<if test="endDate != null">end_date = #{endDate},</if>
|
||
|
<if test="trainContent != null">train_content = #{trainContent},</if>
|
||
|
<if test="isDel != null">is_del = #{isDel},</if>
|
||
|
<if test="createBy != null">create_by = #{createBy},</if>
|
||
|
<if test="createTime != null">create_time = #{createTime},</if>
|
||
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||
|
<if test="remark != null">remark = #{remark},</if>
|
||
|
</trim>
|
||
|
where id = #{id}
|
||
|
</update>
|
||
|
|
||
|
<delete id="deleteWorkTrainById" parameterType="Long">
|
||
|
delete from work_train where id = #{id}
|
||
|
</delete>
|
||
|
|
||
|
<delete id="deleteWorkTrainByIds" parameterType="String">
|
||
|
delete from work_train where id in
|
||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||
|
#{id}
|
||
|
</foreach>
|
||
|
</delete>
|
||
|
|
||
|
<delete id="deleteWorkTrainDeptByTrainIds" parameterType="String">
|
||
|
delete from work_train_dept where train_id in
|
||
|
<foreach item="trainId" collection="array" open="(" separator="," close=")">
|
||
|
#{trainId}
|
||
|
</foreach>
|
||
|
</delete>
|
||
|
|
||
|
<delete id="deleteWorkTrainDeptByTrainId" parameterType="Long">
|
||
|
delete from work_train_dept where train_id = #{trainId}
|
||
|
</delete>
|
||
|
|
||
|
<insert id="batchWorkTrainDept">
|
||
|
insert into work_train_dept( train_id, dept_id, is_main) values
|
||
|
<foreach item="item" index="index" collection="list" separator=",">
|
||
|
( #{item.trainId}, #{item.deptId}, #{item.isMain})
|
||
|
</foreach>
|
||
|
</insert>
|
||
|
</mapper>
|