<?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.store.mapper.FsArticleCateMapper">

    <resultMap type="FsArticleCate" id="FsArticleCateResult">
        <result property="cateId"    column="cate_id"    />
        <result property="cateName"    column="cate_name"    />
        <result property="status"    column="status"    />
        <result property="sort"    column="sort"    />
        <result property="isDel"    column="is_del"    />
    </resultMap>

    <sql id="selectFsArticleCateVo">
        select cate_id, cate_name, status,sort, is_del from fs_article_cate
    </sql>

    <select id="selectFsArticleCateList" parameterType="FsArticleCate" resultMap="FsArticleCateResult">
        <include refid="selectFsArticleCateVo"/>
        <where>
            <if test="cateName != null  and cateName != ''"> and cate_name like concat('%', #{cateName}, '%')</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="isDel != null "> and is_del = #{isDel}</if>
        </where>
        order by cate_id desc
    </select>

    <select id="selectFsArticleCateById" parameterType="Long" resultMap="FsArticleCateResult">
        <include refid="selectFsArticleCateVo"/>
        where cate_id = #{cateId}
    </select>

    <insert id="insertFsArticleCate" parameterType="FsArticleCate" useGeneratedKeys="true" keyProperty="cateId">
        insert into fs_article_cate
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="cateName != null">cate_name,</if>
            <if test="status != null">status,</if>
            <if test="sort != null">sort,</if>
            <if test="isDel != null">is_del,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="cateName != null">#{cateName},</if>
            <if test="status != null">#{status},</if>
            <if test="sort != null">#{sort},</if>
            <if test="isDel != null">#{isDel},</if>
         </trim>
    </insert>

    <update id="updateFsArticleCate" parameterType="FsArticleCate">
        update fs_article_cate
        <trim prefix="SET" suffixOverrides=",">
            <if test="cateName != null">cate_name = #{cateName},</if>
            <if test="status != null">status = #{status},</if>
            <if test="sort != null">sort = #{sort},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
        </trim>
        where cate_id = #{cateId}
    </update>

    <delete id="deleteFsArticleCateById" parameterType="Long">
        delete from fs_article_cate where cate_id = #{cateId}
    </delete>

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

</mapper>
