<?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.bootdo.data.dao.DataUploadDao">

	<select id="get" resultType="com.bootdo.data.domain.DataUploadDO">
		select `ID`,`REPORTER_UNIT`,`UNIT_PROVINCE`,`UNIT_CITY`,`UNIT_OTHER`,`DATA_INDUSTRY`,`DATA_SOURCE`,`DATA_NAME`,`DATA_LEVEL`,`DATA_TYPE`,`DATA_SUB`,`DATA_ADJ_SUB`,`DATA_SCOPE`,`DATA_RESULT`,`DATA_LOCATION`,`DATA_RANGE`,`DATA_RULER`,`SHARE_RANGE`,`CROSS_RANGE`,`DATA_SAFETY`,`DATA_DESC`,`DATA_STATUS`,`UPLOAD_USER`,`UPLOAD_USERID`,`UPLOAD_TIME`,`UPDATE_TIME` from tf_data_upload where ID = #{value}
	</select>

	<select id="list" resultType="com.bootdo.data.domain.DataUploadDO">
		select `ID`,`REPORTER_UNIT`,`UNIT_PROVINCE`,`UNIT_CITY`,`UNIT_OTHER`,`DATA_INDUSTRY`,`DATA_SOURCE`,`DATA_NAME`,`DATA_LEVEL`,`DATA_TYPE`,`DATA_SUB`,`DATA_ADJ_SUB`,`DATA_SCOPE`,`DATA_RESULT`,`DATA_LOCATION`,`DATA_RANGE`,`DATA_RULER`,`SHARE_RANGE`,`CROSS_RANGE`,`DATA_SAFETY`,`DATA_DESC`,`DATA_STATUS`,`UPLOAD_USER`,`UPLOAD_USERID`,`UPLOAD_TIME`,`UPDATE_TIME` from tf_data_upload
        <where>  
		  		  <if test="id != null and id != ''"> and ID = #{id} </if>
		  		  <if test="reporterUnit != null and reporterUnit != ''"> and REPORTER_UNIT = #{reporterUnit} </if>
		  		  <if test="unitProvince != null and unitProvince != ''"> and UNIT_PROVINCE = #{unitProvince} </if>
		  		  <if test="unitCity != null and unitCity != ''"> and UNIT_CITY = #{unitCity} </if>
		  		  <if test="unitOther != null and unitOther != ''"> and UNIT_OTHER = #{unitOther} </if>
		  		  <if test="dataIndustry != null and dataIndustry != ''"> and DATA_INDUSTRY = #{dataIndustry} </if>
		  		  <if test="dataSource != null and dataSource != ''"> and DATA_SOURCE = #{dataSource} </if>
		  		  <if test="dataName != null and dataName != ''"> and DATA_NAME = #{dataName} </if>
		  		  <if test="dataLevel != null and dataLevel != ''"> and DATA_LEVEL = #{dataLevel} </if>
		  		  <if test="dataType != null and dataType != ''"> and DATA_TYPE = #{dataType} </if>
		  		  <if test="dataSub != null and dataSub != ''"> and DATA_SUB = #{dataSub} </if>
		  		  <if test="dataAdjSub != null and dataAdjSub != ''"> and DATA_ADJ_SUB = #{dataAdjSub} </if>
		  		  <if test="dataScope != null and dataScope != ''"> and DATA_SCOPE = #{dataScope} </if>
		  		  <if test="dataResult != null and dataResult != ''"> and DATA_RESULT = #{dataResult} </if>
		  		  <if test="dataLocation != null and dataLocation != ''"> and DATA_LOCATION = #{dataLocation} </if>
		  		  <if test="dataRange != null and dataRange != ''"> and DATA_RANGE = #{dataRange} </if>
		  		  <if test="dataRuler != null and dataRuler != ''"> and DATA_RULER = #{dataRuler} </if>
		  		  <if test="shareRange != null and shareRange != ''"> and SHARE_RANGE = #{shareRange} </if>
		  		  <if test="crossRange != null and crossRange != ''"> and CROSS_RANGE = #{crossRange} </if>
		  		  <if test="dataSafety != null and dataSafety != ''"> and DATA_SAFETY = #{dataSafety} </if>
		  		  <if test="dataDesc != null and dataDesc != ''"> and DATA_DESC = #{dataDesc} </if>
		  		  <if test="dataStatus != null and dataStatus != ''"> and DATA_STATUS = #{dataStatus} </if>
		  		  <if test="uploadUser != null and uploadUser != ''"> and UPLOAD_USER = #{uploadUser} </if>
		  		  <if test="uploadUserid != null and uploadUserid != ''"> and UPLOAD_USERID = #{uploadUserid} </if>
		  		  <if test="uploadTime != null and uploadTime != ''"> and UPLOAD_TIME = #{uploadTime} </if>
		  		  <if test="updateTime != null and updateTime != ''"> and UPDATE_TIME = #{updateTime} </if>
		  		</where>
        <choose>
            <when test="sort != null and sort.trim() != ''">
                order by ${sort} ${order}
            </when>
			<otherwise>
                order by ID desc
			</otherwise>
        </choose>
		<if test="offset != null and limit != null">
			limit #{offset}, #{limit}
		</if>
	</select>
	
 	<select id="count" resultType="int">
		select count(*) from tf_data_upload
		 <where>  
		  		  <if test="id != null and id != ''"> and ID = #{id} </if>
		  		  <if test="reporterUnit != null and reporterUnit != ''"> and REPORTER_UNIT = #{reporterUnit} </if>
		  		  <if test="unitProvince != null and unitProvince != ''"> and UNIT_PROVINCE = #{unitProvince} </if>
		  		  <if test="unitCity != null and unitCity != ''"> and UNIT_CITY = #{unitCity} </if>
		  		  <if test="unitOther != null and unitOther != ''"> and UNIT_OTHER = #{unitOther} </if>
		  		  <if test="dataIndustry != null and dataIndustry != ''"> and DATA_INDUSTRY = #{dataIndustry} </if>
		  		  <if test="dataSource != null and dataSource != ''"> and DATA_SOURCE = #{dataSource} </if>
		  		  <if test="dataName != null and dataName != ''"> and DATA_NAME = #{dataName} </if>
		  		  <if test="dataLevel != null and dataLevel != ''"> and DATA_LEVEL = #{dataLevel} </if>
		  		  <if test="dataType != null and dataType != ''"> and DATA_TYPE = #{dataType} </if>
		  		  <if test="dataSub != null and dataSub != ''"> and DATA_SUB = #{dataSub} </if>
		  		  <if test="dataAdjSub != null and dataAdjSub != ''"> and DATA_ADJ_SUB = #{dataAdjSub} </if>
		  		  <if test="dataScope != null and dataScope != ''"> and DATA_SCOPE = #{dataScope} </if>
		  		  <if test="dataResult != null and dataResult != ''"> and DATA_RESULT = #{dataResult} </if>
		  		  <if test="dataLocation != null and dataLocation != ''"> and DATA_LOCATION = #{dataLocation} </if>
		  		  <if test="dataRange != null and dataRange != ''"> and DATA_RANGE = #{dataRange} </if>
		  		  <if test="dataRuler != null and dataRuler != ''"> and DATA_RULER = #{dataRuler} </if>
		  		  <if test="shareRange != null and shareRange != ''"> and SHARE_RANGE = #{shareRange} </if>
		  		  <if test="crossRange != null and crossRange != ''"> and CROSS_RANGE = #{crossRange} </if>
		  		  <if test="dataSafety != null and dataSafety != ''"> and DATA_SAFETY = #{dataSafety} </if>
		  		  <if test="dataDesc != null and dataDesc != ''"> and DATA_DESC = #{dataDesc} </if>
		  		  <if test="dataStatus != null and dataStatus != ''"> and DATA_STATUS = #{dataStatus} </if>
		  		  <if test="uploadUser != null and uploadUser != ''"> and UPLOAD_USER = #{uploadUser} </if>
		  		  <if test="uploadUserid != null and uploadUserid != ''"> and UPLOAD_USERID = #{uploadUserid} </if>
		  		  <if test="uploadTime != null and uploadTime != ''"> and UPLOAD_TIME = #{uploadTime} </if>
		  		  <if test="updateTime != null and updateTime != ''"> and UPDATE_TIME = #{updateTime} </if>
		  		</where>
	</select>
	 
	<insert id="save" parameterType="com.bootdo.data.domain.DataUploadDO" useGeneratedKeys="true" keyProperty="id">
		insert into tf_data_upload
		(
			`REPORTER_UNIT`, 
			`UNIT_PROVINCE`, 
			`UNIT_CITY`, 
			`UNIT_OTHER`, 
			`DATA_INDUSTRY`, 
			`DATA_SOURCE`, 
			`DATA_NAME`, 
			`DATA_LEVEL`, 
			`DATA_TYPE`, 
			`DATA_SUB`, 
			`DATA_ADJ_SUB`, 
			`DATA_SCOPE`, 
			`DATA_RESULT`, 
			`DATA_LOCATION`, 
			`DATA_RANGE`, 
			`DATA_RULER`, 
			`SHARE_RANGE`, 
			`CROSS_RANGE`, 
			`DATA_SAFETY`, 
			`DATA_DESC`, 
			`DATA_STATUS`, 
			`UPLOAD_USER`, 
			`UPLOAD_USERID`, 
			`UPLOAD_TIME`, 
			`UPDATE_TIME`
		)
		values
		(
			#{reporterUnit}, 
			#{unitProvince}, 
			#{unitCity}, 
			#{unitOther}, 
			#{dataIndustry}, 
			#{dataSource}, 
			#{dataName}, 
			#{dataLevel}, 
			#{dataType}, 
			#{dataSub}, 
			#{dataAdjSub}, 
			#{dataScope}, 
			#{dataResult}, 
			#{dataLocation}, 
			#{dataRange}, 
			#{dataRuler}, 
			#{shareRange}, 
			#{crossRange}, 
			#{dataSafety}, 
			#{dataDesc}, 
			#{dataStatus}, 
			#{uploadUser}, 
			#{uploadUserid}, 
			#{uploadTime}, 
			#{updateTime}
		)
	</insert>
	 
	<update id="update" parameterType="com.bootdo.data.domain.DataUploadDO">
		update tf_data_upload 
		<set>
			<if test="reporterUnit != null">`REPORTER_UNIT` = #{reporterUnit}, </if>
			<if test="unitProvince != null">`UNIT_PROVINCE` = #{unitProvince}, </if>
			<if test="unitCity != null">`UNIT_CITY` = #{unitCity}, </if>
			<if test="unitOther != null">`UNIT_OTHER` = #{unitOther}, </if>
			<if test="dataIndustry != null">`DATA_INDUSTRY` = #{dataIndustry}, </if>
			<if test="dataSource != null">`DATA_SOURCE` = #{dataSource}, </if>
			<if test="dataName != null">`DATA_NAME` = #{dataName}, </if>
			<if test="dataLevel != null">`DATA_LEVEL` = #{dataLevel}, </if>
			<if test="dataType != null">`DATA_TYPE` = #{dataType}, </if>
			<if test="dataSub != null">`DATA_SUB` = #{dataSub}, </if>
			<if test="dataAdjSub != null">`DATA_ADJ_SUB` = #{dataAdjSub}, </if>
			<if test="dataScope != null">`DATA_SCOPE` = #{dataScope}, </if>
			<if test="dataResult != null">`DATA_RESULT` = #{dataResult}, </if>
			<if test="dataLocation != null">`DATA_LOCATION` = #{dataLocation}, </if>
			<if test="dataRange != null">`DATA_RANGE` = #{dataRange}, </if>
			<if test="dataRuler != null">`DATA_RULER` = #{dataRuler}, </if>
			<if test="shareRange != null">`SHARE_RANGE` = #{shareRange}, </if>
			<if test="crossRange != null">`CROSS_RANGE` = #{crossRange}, </if>
			<if test="dataSafety != null">`DATA_SAFETY` = #{dataSafety}, </if>
			<if test="dataDesc != null">`DATA_DESC` = #{dataDesc}, </if>
			<if test="dataStatus != null">`DATA_STATUS` = #{dataStatus}, </if>
			<if test="uploadUser != null">`UPLOAD_USER` = #{uploadUser}, </if>
			<if test="uploadUserid != null">`UPLOAD_USERID` = #{uploadUserid}, </if>
			<if test="uploadTime != null">`UPLOAD_TIME` = #{uploadTime}, </if>
			<if test="updateTime != null">`UPDATE_TIME` = #{updateTime}</if>
		</set>
		where ID = #{id}
	</update>
	
	<delete id="remove">
		delete from tf_data_upload where ID = #{value}
	</delete>
	
	<delete id="batchRemove">
		delete from tf_data_upload where ID in 
		<foreach item="id" collection="array" open="(" separator="," close=")">
			#{id}
		</foreach>
	</delete>

</mapper>