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

    <resultMap type="com.diaoyun.zion.chinafrica.entity.TbCfVersionEntity" id="tbCfVersionMap">
        <result property="versionId" column="version_id"/>
        <result property="versionCode" column="version_code"/>
        <result property="versionLike" column="version_like"/>
        <result property="versionDetail" column="version_detail"/>
    </resultMap>
	<select id="getVersionCode" resultType="com.diaoyun.zion.chinafrica.entity.TbCfVersionEntity">
		select
			`version_id`,
			`version_code`,
			`version_like`,
			`version_detail`
		from tb_cf_version
		where version_code = #{code}

	</select>
	<select id="queryObject" resultType="com.diaoyun.zion.chinafrica.entity.TbCfVersionEntity">
		select
			`version_id`,
			`version_code`,
			`version_like`,
			`version_detail`
		from tb_cf_version
		where version_id = #{id}
	</select>

	<select id="queryList" resultType="com.diaoyun.zion.chinafrica.entity.TbCfVersionEntity">
		select
    		`version_id`,
    		`version_code`,
    		`version_like`,
    		`version_detail`
		from tb_cf_version
		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 version_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_version
		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.TbCfVersionEntity">
		insert into tb_cf_version(
			`version_id`,
			`version_code`,
			`version_like`,
			`version_detail`)
		values(
			#{versionId},
			#{versionCode},
			#{versionLike},
			#{versionDetail})
	</insert>
	 
	<update id="update" parameterType="com.diaoyun.zion.chinafrica.entity.TbCfVersionEntity">
		update tb_cf_version 
		<set>
			<if test="versionCode != null">`version_code` = #{versionCode}, </if>
			<if test="versionLike != null">`version_like` = #{versionLike}, </if>
			<if test="versionDetail != null">`version_detail` = #{versionDetail}</if>
		</set>
		where version_id = #{versionId}
	</update>
	
	<delete id="delete">
		delete from tb_cf_version where version_id = #{value}
	</delete>
	
	<delete id="deleteBatch">
		delete from tb_cf_version where version_id in 
		<foreach item="versionId" collection="array" open="(" separator="," close=")">
			#{versionId}
		</foreach>
	</delete>

</mapper>