<?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.fs.company.mapper.CompanyTcmScheduleMapper">
    
    <resultMap type="CompanyTcmSchedule" id="CompanyTcmScheduleResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="createUserId"    column="create_user_id"    />
        <result property="updateUserId"    column="update_user_id"    />
        <result property="status"    column="status"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectCompanyTcmScheduleVo">
        select id, name, create_user_id, update_user_id, status, create_time, update_time from company_tcm_schedule
    </sql>

    <select id="selectCompanyTcmScheduleList" parameterType="CompanyTcmSchedule" resultMap="CompanyTcmScheduleResult">
        <include refid="selectCompanyTcmScheduleVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="createTime != null "> and create_time = #{createTime}</if>
        </where>
    </select>
    
    <select id="selectCompanyTcmScheduleById" parameterType="Long" resultMap="CompanyTcmScheduleResult">
        <include refid="selectCompanyTcmScheduleVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertCompanyTcmSchedule" parameterType="CompanyTcmSchedule" useGeneratedKeys="true" keyProperty="id">
        insert into company_tcm_schedule
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null and name != ''">name,</if>
            <if test="createUserId != null">create_user_id,</if>
            <if test="updateUserId != null">update_user_id,</if>
            <if test="status != null">status,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null and name != ''">#{name},</if>
            <if test="createUserId != null">#{createUserId},</if>
            <if test="updateUserId != null">#{updateUserId},</if>
            <if test="status != null">#{status},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateCompanyTcmSchedule" parameterType="CompanyTcmSchedule">
        update company_tcm_schedule
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="createUserId != null">create_user_id = #{createUserId},</if>
            <if test="updateUserId != null">update_user_id = #{updateUserId},</if>
            <if test="status != null">status = #{status},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCompanyTcmScheduleById" parameterType="Long">
        delete from company_tcm_schedule where id = #{id}
    </delete>

    <delete id="deleteCompanyTcmScheduleByIds" parameterType="String">
        delete from company_tcm_schedule where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    
</mapper>