<?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.jeeplus.modules.workpartetag.dao.WorkPartEtagDao">
    
	<sql id="workPartEtagColumns">
		a.id AS "id",
		a.create_by AS "createBy.id",
		a.create_date AS "createDate",
		a.update_by AS "updateBy.id",
		a.update_date AS "updateDate",
		a.remarks AS "remarks",
		a.status AS "status",
		a.del_flag AS "delFlag",
		a.bucket_name AS "bucketName",
		a.part_key AS "key",
		a.upload_id AS "uploadId",
		a.part_number AS "partNumber",
		a.e_tag AS "eTag",
		a.part_size AS "size",
		a.part_CRC AS "partCRC"
	</sql>
	
	<sql id="workPartEtagJoins">
	</sql>
	
    
	<select id="get" resultType="WorkPartEtag" >
		SELECT 
			<include refid="workPartEtagColumns"/>
		FROM work_part_etag a
		<include refid="workPartEtagJoins"/>
		WHERE a.id = #{id}
	</select>

	<select id="getByuploadId" resultType="WorkPartEtag" >
		SELECT
			<include refid="workPartEtagColumns"/>
		FROM work_part_etag a
		<include refid="workPartEtagJoins"/>
		WHERE a.upload_id = #{uploadId} and a.part_number = #{partNumber}
	</select>

	<select id="findList" resultType="WorkPartEtag" >
		SELECT 
			<include refid="workPartEtagColumns"/>
		FROM work_part_etag a
		<include refid="workPartEtagJoins"/>
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
			<if test="uploadId != null and uploadId != ''">
				AND a.upload_id = #{uploadId}
			</if>
			<if test="partNumber != null and partNumber != ''">
				AND a.part_number = #{partNumber}
			</if>
			<if test="status != null and status != ''">
				AND a.status = #{status}
			</if>
		</where>
		<choose>
			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
				ORDER BY ${page.orderBy}
			</when>
			<otherwise>
				ORDER BY a.update_date DESC
			</otherwise>
		</choose>
	</select>
	
	<select id="findAllList" resultType="WorkPartEtag" >
		SELECT 
			<include refid="workPartEtagColumns"/>
		FROM work_part_etag a
		<include refid="workPartEtagJoins"/>
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
		</where>		
		<choose>
			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
				ORDER BY ${page.orderBy}
			</when>
			<otherwise>
				ORDER BY a.update_date DESC
			</otherwise>
		</choose>
	</select>
	
	<insert id="insert">
		INSERT INTO work_part_etag(
			id,
			create_by,
			create_date,
			update_by,
			update_date,
			remarks,
			status,
			del_flag,
			bucket_name,
			part_key,
			upload_id,
			part_number,
			e_tag,
			part_size,
			part_CRC
		) VALUES (
			#{id},
			#{createBy.id},
			#{createDate},
			#{updateBy.id},
			#{updateDate},
			#{remarks},
			#{status},
			#{delFlag},
			#{bucketName},
			#{key},
			#{uploadId},
			#{partNumber},
			#{eTag},
			#{size},
			#{partCRC}
		)
	</insert>
	
	<update id="update">
		UPDATE work_part_etag SET 	
			update_by = #{updateBy.id},
			update_date = #{updateDate},
			remarks = #{remarks},
			status = #{status},
			bucket_name = #{bucketName},
			part_key = #{key},
			upload_id = #{uploadId},
			part_number = #{partNumber},
			e_tag = #{eTag},
			part_CRC = #{partCRC},
			part_size = #{size}
		WHERE id = #{id}
	</update>
	
	
	<!--物理删除-->
	<update id="delete">
		DELETE FROM work_part_etag
		WHERE id = #{id}
	</update>
	
	<!--逻辑删除-->
	<update id="deleteByLogic">
		UPDATE work_part_etag SET 
			del_flag = #{DEL_FLAG_DELETE}
		WHERE id = #{id}
	</update>
	
	
	<!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
	<select id="findUniqueByProperty" resultType="WorkPartEtag" statementType="STATEMENT">
		select * FROM work_part_etag  where ${propertyName} = '${value}'
	</select>
	
</mapper>