<?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.FsStoreProductPackageMapper">
    <resultMap type="FsStoreProductPackage" id="FsStoreProductPackageResult">
        <result property="packageId"    column="package_id"    />
        <result property="title"    column="title"    />
        <result property="descs"    column="descs"    />
        <result property="content"    column="content"    />
        <result property="imgUrl"    column="img_url"    />
        <result property="images"    column="images"    />
        <result property="products"    column="products"    />
        <result property="money"    column="money"    />
        <result property="payMoney"    column="pay_money"    />
        <result property="companyId"    column="company_id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="payType"    column="pay_type"    />
        <result property="limitCount"    column="limit_count"    />
        <result property="cateId"    column="cate_id"    />
        <result property="sort"    column="sort"    />
        <result property="status"    column="status"    />
    </resultMap>

    <sql id="selectFsStoreProductPackageVo">
        select package_id, title, descs, content, img_url,images, products, money, pay_money, company_id, dept_id,pay_type,limit_count,cate_id,sort,status from fs_store_product_package
    </sql>

    <select id="selectFsStoreProductPackageList" parameterType="FsStoreProductPackage" resultMap="FsStoreProductPackageResult">
        <include refid="selectFsStoreProductPackageVo"/>
        <where>
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="descs != null  and descs != ''"> and descs = #{descs}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="imgUrl != null  and imgUrl != ''"> and img_url = #{imgUrl}</if>
            <if test="products != null  and products != ''"> and products = #{products}</if>
            <if test="money != null "> and money = #{money}</if>
            <if test="payMoney != null "> and pay_money = #{payMoney}</if>
            <if test="companyId != null "> and company_id = #{companyId}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="packageId != null "> and package_id = #{packageId}</if>
            <if test="cateId != null "> and cate_id = #{cateId}</if>
            <if test="status != null "> and status = #{status}</if>
        </where>
    </select>



    <select id="selectFsStoreProductPackageById" parameterType="Long" resultMap="FsStoreProductPackageResult">
        <include refid="selectFsStoreProductPackageVo"/>
        where package_id = #{packageId}
    </select>

    <insert id="insertFsStoreProductPackage" parameterType="FsStoreProductPackage">
        insert into fs_store_product_package
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="packageId != null">package_id,</if>
            <if test="title != null">title,</if>
            <if test="descs != null">descs,</if>
            <if test="content != null">content,</if>
            <if test="imgUrl != null">img_url,</if>
            <if test="images != null">images,</if>
            <if test="products != null">products,</if>
            <if test="money != null">money,</if>
            <if test="payMoney != null">pay_money,</if>
            <if test="companyId != null">company_id,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="payType != null">pay_type,</if>
            <if test="limitCount != null">limit_count,</if>
            <if test="cateId != null">cate_id,</if>
            <if test="sort != null">sort,</if>
            <if test="status != null">status,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="packageId != null">#{packageId},</if>
            <if test="title != null">#{title},</if>
            <if test="descs != null">#{descs},</if>
            <if test="content != null">#{content},</if>
            <if test="imgUrl != null">#{imgUrl},</if>
            <if test="images != null">images,</if>
            <if test="products != null">#{products},</if>
            <if test="money != null">#{money},</if>
            <if test="payMoney != null">#{payMoney},</if>
            <if test="companyId != null">#{companyId},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="payType != null">#{payType},</if>
            <if test="limitCount != null">#{limitCount},</if>
            <if test="cateId != null">#{cateId},</if>
            <if test="sort != null">#{sort},</if>
            <if test="status != null">#{status},</if>
         </trim>
    </insert>

    <update id="updateFsStoreProductPackage" parameterType="FsStoreProductPackage">
        update fs_store_product_package
        <trim prefix="SET" suffixOverrides=",">
            <if test="title != null">title = #{title},</if>
            <if test="descs != null">descs = #{descs},</if>
            <if test="content != null">content = #{content},</if>
            <if test="imgUrl != null">img_url = #{imgUrl},</if>
            <if test="images != null">images = #{images},</if>
            <if test="products != null">products = #{products},</if>
            <if test="money != null">money = #{money},</if>
            <if test="payMoney != null">pay_money = #{payMoney},</if>
            <if test="companyId != null">company_id = #{companyId},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="payType != null">pay_type = #{payType},</if>
            <if test="limitCount != null">limit_count = #{limitCount},</if>
            <if test="cateId != null">cate_id = #{cateId},</if>
            <if test="sort != null">sort = #{sort},</if>
            <if test="status != null">status = #{status},</if>
        </trim>
        where package_id = #{packageId}
    </update>

    <delete id="deleteFsStoreProductPackageById" parameterType="Long">
        delete from fs_store_product_package where package_id = #{packageId}
    </delete>

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

    <update id="updateFsStoreProductPackages">
        update  fs_store_product_package set status = #{status} where package_id in
        <foreach item="packageId" collection="packageIds" open="(" separator="," close=")">
            #{packageId}
        </foreach>
    </update>

</mapper>

