<?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.xinelu.manage.mapper.info.InfoMapper">

    <resultMap type="Info" id="InfoResult">
        <result property="id" column="id"/>
        <result property="infoCategoryId" column="info_category_id"/>
        <result property="infoCategoryName" column="info_category_name"/>
        <result property="infoTitle" column="info_title"/>
        <result property="infoCode" column="info_code"/>
        <result property="infoContent" column="info_content"/>
        <result property="infoClickCount" column="info_click_count"/>
        <result property="infoJumpLink" column="info_jump_link"/>
        <result property="infoLargePictureUrl" column="info_large_picture_url"/>
        <result property="infoSort" column="info_sort"/>
        <result property="infoCreator" column="info_creator"/>
        <result property="infoCreateTime" column="info_create_time"/>
        <result property="infoReviser" column="info_reviser"/>
        <result property="infoModifyTime" column="info_modify_time"/>

    </resultMap>

    <sql id="selectInfoVo">
        select id,
               info_category_id,
               info_category_name,
               info_title,
               info_code,
               info_content,
               info_click_count,
               info_jump_link,
               info_large_picture_url,
               info_sort,
               info_creator,
               info_create_time,
               info_reviser,
               info_modify_time
        from info
    </sql>

    <select id="selectInfoList" parameterType="Info" resultMap="InfoResult">
        <include refid="selectInfoVo"/>
        <where>
            <if test="infoCategoryId != null ">
                and info_category_id = #{infoCategoryId}
            </if>
            <if test="infoCategoryName != null ">
                and info_category_name = #{infoCategoryName}
            </if>
            <if test="infoTitle != null  and infoTitle != ''">
                and info_title like concat('%', #{infoTitle}, '%')
            </if>
            <if test="infoCode != null  and infoCode != ''">
                and info_code like concat('%', #{infoCode}, '%')
            </if>
            <if test="infoContent != null  and infoContent != ''">
                and info_content = #{infoContent}
            </if>
            <if test="infoClickCount != null ">
                and info_click_count = #{infoClickCount}
            </if>
            <if test="infoJumpLink != null  and infoJumpLink != ''">
                and info_jump_link = #{infoJumpLink}
            </if>
            <if test="infoLargePictureUrl != null  and infoLargePictureUrl != ''">
                and info_large_picture_url = #{infoLargePictureUrl}
            </if>
            <if test="infoSort != null ">
                and info_sort = #{infoSort}
            </if>
            <if test="infoCreator != null  and infoCreator != ''">
                and info_creator = #{infoCreator}
            </if>
            <if test="infoCreateTime != null ">
                and info_create_time = #{infoCreateTime}
            </if>
            <if test="infoReviser != null  and infoReviser != ''">
                and info_reviser = #{infoReviser}
            </if>
            <if test="infoModifyTime != null ">
                and info_modify_time = #{infoModifyTime}
            </if>
        </where>
        order by info_sort
    </select>

    <select id="selectInfoById" parameterType="Long"
            resultMap="InfoResult">
        <include refid="selectInfoVo"/>
        where id = #{id}
    </select>

    <insert id="insertInfo" parameterType="Info" useGeneratedKeys="true"
            keyProperty="id">
        insert into info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="infoCategoryId != null">info_category_id,
            </if>
            <if test="infoCategoryName != null">info_category_name,
            </if>
            <if test="infoTitle != null">info_title,
            </if>
            <if test="infoCode != null">info_code,
            </if>
            <if test="infoContent != null">info_content,
            </if>
            <if test="infoClickCount != null">info_click_count,
            </if>
            <if test="infoJumpLink != null">info_jump_link,
            </if>
            <if test="infoLargePictureUrl != null">info_large_picture_url,
            </if>
            <if test="infoSort != null">info_sort,
            </if>
            <if test="infoCreator != null">info_creator,
            </if>
            <if test="infoCreateTime != null">info_create_time,
            </if>
            <if test="infoReviser != null">info_reviser,
            </if>
            <if test="infoModifyTime != null">info_modify_time,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="infoCategoryId != null">#{infoCategoryId},
            </if>
            <if test="infoCategoryName != null">#{infoCategoryName},
            </if>
            <if test="infoTitle != null">#{infoTitle},
            </if>
            <if test="infoCode != null">#{infoCode},
            </if>
            <if test="infoContent != null">#{infoContent},
            </if>
            <if test="infoClickCount != null">#{infoClickCount},
            </if>
            <if test="infoJumpLink != null">#{infoJumpLink},
            </if>
            <if test="infoLargePictureUrl != null">#{infoLargePictureUrl},
            </if>
            <if test="infoSort != null">#{infoSort},
            </if>
            <if test="infoCreator != null">#{infoCreator},
            </if>
            <if test="infoCreateTime != null">#{infoCreateTime},
            </if>
            <if test="infoReviser != null">#{infoReviser},
            </if>
            <if test="infoModifyTime != null">#{infoModifyTime},
            </if>
        </trim>
    </insert>

    <update id="updateInfo" parameterType="Info">
        update info
        <trim prefix="SET" suffixOverrides=",">
            <if test="infoCategoryId != null">info_category_id =
                #{infoCategoryId},
            </if>
            <if test="infoCategoryName != null">info_category_name =
                #{infoCategoryName},
            </if>
            <if test="infoTitle != null">info_title =
                #{infoTitle},
            </if>
            <if test="infoCode != null">info_code =
                #{infoCode},
            </if>
            <if test="infoContent != null">info_content =
                #{infoContent},
            </if>
            <if test="infoClickCount != null">info_click_count =
                #{infoClickCount},
            </if>
            <if test="infoJumpLink != null">info_jump_link =
                #{infoJumpLink},
            </if>
            <if test="infoLargePictureUrl != null">info_large_picture_url =
                #{infoLargePictureUrl},
            </if>
            <if test="infoSort != null">info_sort =
                #{infoSort},
            </if>
            <if test="infoCreator != null">info_creator =
                #{infoCreator},
            </if>
            <if test="infoCreateTime != null">info_create_time =
                #{infoCreateTime},
            </if>
            <if test="infoReviser != null">info_reviser =
                #{infoReviser},
            </if>
            <if test="infoModifyTime != null">info_modify_time =
                #{infoModifyTime},
            </if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteInfoById" parameterType="Long">
        delete
        from info
        where id = #{id}
    </delete>

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

    <select id="selectInfoByIds" resultMap="InfoResult">
        <include refid="selectInfoVo"/>
        where id in
        <foreach item="ids" collection="array" open="(" separator="," close=")">
            #{ids}
        </foreach>
    </select>

</mapper>