<?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"/>
		<result property="versionSort" column="version_sort"/>
    </resultMap>

	<select id="queryObject" resultType="com.diaoyun.zion.chinafrica.entity.TbCfVersionEntity">
		select
			`version_id`,
			`version_code`,
			`version_like`,
			`version_detail`,
			`version_sort`
		from tb_cf_version
		where version_id = #{id}
	</select>
	<select id="getVersionCode" resultType="com.diaoyun.zion.chinafrica.entity.TbCfVersionEntity">
		select
			`version_id`,
			`version_code`,
			`version_like`,
			`version_detail`,
			`version_sort`
		from tb_cf_version
		where 1=1
		<if test="versionCode != null and versionCode.trim() != ''" >
		and version_code = #{versionCode}
		</if>
	</select>
	<select id="queryList" resultType="com.diaoyun.zion.chinafrica.entity.TbCfVersionEntity">
		select
    		`version_id`,
    		`version_code`,
    		`version_like`,
    		`version_detail`,
			`version_sort`
		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`,
			`version_sort`)
		values(
			#{versionId},
			#{versionCode},
			#{versionLike},
			#{versionDetail},
			#{versionSort})
	</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="versionSort != null">`version_sort` = #{versionSort}, </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>