<?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.course.mapper.FsCourseDomainNameMapper">

    <resultMap type="FsCourseDomainName" id="FsCourseDomainNameResult">
        <result property="id"    column="id"    />
        <result property="domainName"    column="domain_name"    />
        <result property="status"    column="status"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectFsCourseDomainNameVo">
        select id, domain_name, status, create_time, update_time from fs_course_domain_name
    </sql>

    <select id="selectFsCourseDomainNameList" parameterType="FsCourseDomainName" resultMap="FsCourseDomainNameResult">
        <include refid="selectFsCourseDomainNameVo"/>
        <where>
            <if test="domainName != null  and domainName != ''"> and domain_name like concat('%', #{domainName}, '%')</if>
            <if test="status != null "> and status = #{status}</if>
        </where>
    </select>

    <select id="selectFsCourseDomainNameById" parameterType="Long" resultMap="FsCourseDomainNameResult">
        <include refid="selectFsCourseDomainNameVo"/>
        where id = #{id}
    </select>

    <insert id="insertFsCourseDomainName" parameterType="FsCourseDomainName" useGeneratedKeys="true" keyProperty="id">
        insert into fs_course_domain_name
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="domainName != null">domain_name,</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="domainName != null">#{domainName},</if>
            <if test="status != null">#{status},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateFsCourseDomainName" parameterType="FsCourseDomainName">
        update fs_course_domain_name
        <trim prefix="SET" suffixOverrides=",">
            <if test="domainName != null">domain_name = #{domainName},</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="deleteFsCourseDomainNameById" parameterType="Long">
        delete from fs_course_domain_name where id = #{id}
    </delete>

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