<?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.TbCfItemDescDao">

    <resultMap type="com.diaoyun.zion.chinafrica.entity.TbCfItemDescEntity" id="tbCfItemDescMap">
        <result property="itemId" column="item_id"/>
        <result property="itemDesc" column="item_desc"/>
        <result property="delFlag" column="del_flag"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>

    <select id="queryObject" resultType="com.diaoyun.zion.chinafrica.entity.TbCfItemDescEntity">
		select
			`item_id`,
			`item_desc`,
			`del_flag`,
			`create_time`,
			`update_time`
		from tb_cf_item_desc
		where item_id = #{id}
	</select>

    <select id="queryList" resultType="com.diaoyun.zion.chinafrica.entity.TbCfItemDescEntity">
        select
        `item_id`,
        `item_desc`,
        `del_flag`,
        `create_time`,
        `update_time`
        from tb_cf_item_desc
        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 item_id desc
            </otherwise>
        </choose>
        <if test="offset != null and limit != null">
            limit #{offset}, #{limit}
        </if>
    </select>

    <select id="queryTotal" resultType="int">
        select count(*) from tb_cf_item_desc
        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.TbCfItemDescEntity">
		insert into tb_cf_item_desc(
			`item_id`,
			`item_desc`,
			`del_flag`,
			`create_time`,
			`update_time`)
		values(
			#{itemId},
			#{itemDesc},
			#{delFlag},
			#{createTime},
			#{updateTime})
	</insert>

    <update id="update" parameterType="com.diaoyun.zion.chinafrica.entity.TbCfItemDescEntity">
        update tb_cf_item_desc
        <set>
            <if test="itemDesc != null">`item_desc` = #{itemDesc},</if>
            <if test="delFlag != null">`del_flag` = #{delFlag},</if>
            <if test="createTime != null">`create_time` = #{createTime},</if>
            <if test="updateTime != null">`update_time` = #{updateTime}</if>
        </set>
        where item_id = #{itemId}
    </update>

    <update id="changStatus" parameterType="com.diaoyun.zion.chinafrica.entity.TbCfItemDescEntity">
        update tb_cf_item_desc set del_flag=0 where item_id=#{itemId}
    </update>
    <update id="changStatusBatch" parameterType="com.diaoyun.zion.chinafrica.entity.TbCfItemDescEntity">
        update tb_cf_item_desc set del_flag=0 where item_id in
        <foreach item="itemId" collection="array" open="(" separator="," close=")">
            #{itemId}
        </foreach>
    </update>
    <delete id="delete">
		delete from tb_cf_item_desc where item_id = #{value}
	</delete>

    <delete id="deleteBatch">
        delete from tb_cf_item_desc where item_id in
        <foreach item="itemId" collection="array" open="(" separator="," close=")">
            #{itemId}
        </foreach>
    </delete>


</mapper>