<?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.diaoyun.zion.chinafrica.dao.TbCfGoodstypeDao">

    <resultMap type="com.diaoyun.zion.chinafrica.entity.TbCfGoodstypeEntity" id="tbCfGoodstypeMap">
        <result property="goodstypeId" column="goodstype_id"/>
        <result property="goodstypeTitle" column="goodstype_title"/>
        <result property="goodstypeSort" column="goodstype_sort"/>
        <result property="goodstypeUrl" column="goodstype_url"/>
    </resultMap>

    <select id="queryObject" resultType="com.diaoyun.zion.chinafrica.entity.TbCfGoodstypeEntity">
		select
			`goodstype_id`,
			`goodstype_title`,
			`goodstype_sort`,
			`goodstype_url`
		from tb_cf_goodstype
		where goodstype_id = #{id}
	</select>

    <select id="queryList" resultType="com.diaoyun.zion.chinafrica.entity.TbCfGoodstypeEntity">
        select
        `goodstype_id`,
        `goodstype_title`,
        `goodstype_sort`,
        `goodstype_url`
        from tb_cf_goodstype
        WHERE 1=1
        <if test="name != null and name.trim() != ''">
            AND name LIKE concat('%',#{name},'%')
        </if>
        <choose>
            <when test="sidx != null and sidx.trim() != ''">
                order by ${sidx} ${order}
            </when>
            <otherwise>
                order by goodstype_sort asc
            </otherwise>
        </choose>
        <if test="offset != null and limit != null">
            limit #{offset}, #{limit}
        </if>
    </select>

    <select id="queryTotal" resultType="int">
        select count(*) from tb_cf_goodstype
        WHERE 1=1
        <if test="name != null and name.trim() != ''">
            AND name LIKE concat('%',#{name},'%')
        </if>
    </select>

    <insert id="save" parameterType="com.diaoyun.zion.chinafrica.entity.TbCfGoodstypeEntity">
		insert into tb_cf_goodstype(
			`goodstype_id`,
			`goodstype_title`,
			`goodstype_sort`,
			`goodstype_url`)
		values(
			#{goodstypeId},
			#{goodstypeTitle},
			#{goodstypeSort},
			#{goodstypeUrl})
	</insert>

    <update id="update" parameterType="com.diaoyun.zion.chinafrica.entity.TbCfGoodstypeEntity">
        update tb_cf_goodstype
        <set>
            <if test="goodstypeTitle != null">`goodstype_title` = #{goodstypeTitle},</if>
            <if test="goodstypeSort != null">`goodstype_sort` = #{goodstypeSort}</if>
            <if test="goodstypeUrl != null">`goodstype_url` = #{goodstypeUrl}</if>
        </set>
        where goodstype_id = #{goodstypeId}
    </update>

    <delete id="delete">
		delete from tb_cf_goodstype where goodstype_id = #{value}
	</delete>

    <delete id="deleteBatch">
        delete from tb_cf_goodstype where goodstype_id in
        <foreach item="goodstypeId" collection="array" open="(" separator="," close=")">
            #{goodstypeId}
        </foreach>
    </delete>
    <select id="queryCategoryTwo" resultType="com.diaoyun.zion.chinafrica.entity.TbCfGoodstwotypeEntity">
		select * from tb_cf_goodstwotype where goodstype_id=#{cid}
	</select>
    <select id="queryDescription" resultType="com.diaoyun.zion.chinafrica.entity.TbCfDescripitonEntity">
		select * from tb_cf_descripiton where goodstwotype_id=#{ctwoid}
	</select>
</mapper>