<?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.qw.mapper.QwWorkLinkMapper">

    <resultMap type="QwWorkLink" id="QwWorkLinkResult">
        <result property="id"    column="id"    />
        <result property="linkName"    column="link_name"    />
        <result property="linkId"    column="link_id"    />
        <result property="url"    column="url"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectQwWorkLinkVo">
        select id, link_name, link_id, url, create_time, create_by, update_by, update_time, remark from qw_work_link
    </sql>

    <select id="selectQwWorkLinkList" parameterType="QwWorkLink" resultMap="QwWorkLinkResult">
        <include refid="selectQwWorkLinkVo"/>
        <where>
            <if test="linkName != null  and linkName != ''"> and link_name like concat('%', #{linkName}, '%')</if>
            <if test="linkId != null  and linkId != ''"> and link_id = #{linkId}</if>
            <if test="url != null  and url != ''"> and url = #{url}</if>
        </where>
    </select>
    <select id="selectQwWorkLinkListAll" parameterType="QwWorkLink" resultMap="QwWorkLinkResult">
        <include refid="selectQwWorkLinkVo"/>
        <where>
            <if test="linkName != null  and linkName != ''"> and link_name like concat('%', #{linkName}, '%')</if>
            <if test="linkId != null  and linkId != ''"> and link_id = #{linkId}</if>
            <if test="url != null  and url != ''"> and url = #{url}</if>
        </where>
    </select>


    <select id="selectQwWorkLinkById" parameterType="Long" resultMap="QwWorkLinkResult">
        <include refid="selectQwWorkLinkVo"/>
        where id = #{id}
    </select>

    <insert id="insertQwWorkLink" parameterType="QwWorkLink" useGeneratedKeys="true" keyProperty="id">
        insert into qw_work_link
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="linkName != null">link_name,</if>
            <if test="linkId != null">link_id,</if>
            <if test="url != null">url,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</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="linkName != null">#{linkName},</if>
            <if test="linkId != null">#{linkId},</if>
            <if test="url != null">#{url},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateQwWorkLink" parameterType="QwWorkLink">
        update qw_work_link
        <trim prefix="SET" suffixOverrides=",">
            <if test="linkName != null">link_name = #{linkName},</if>
            <if test="linkId != null">link_id = #{linkId},</if>
            <if test="url != null">url = #{url},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</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="deleteQwWorkLinkById" parameterType="Long">
        delete from qw_work_link where id = #{id}
    </delete>

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