<?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.sg.managementcenter.activiti.mapper.UploadImagesMapper">
    
	<sql id="constructionColumns">
		a.id AS "id",
		a.uId AS "uid",
		a.imgName AS "imgName",
		a.path AS "path",
		a.proc_ins_id AS "procInsId",
		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.del_flag AS "delFlag",

	</sql>

	<select id="get" resultType="com.jeeplus.modules.sg.managementcenter.activiti.entity.UploadImages" >
		SELECT *
		FROM xm_upolad_images a
		WHERE a.id = #{id}
	</select>
	
	<select id="findList" resultType="UploadImages" >
		SELECT a.*,b.project_name as projectName
		FROM xm_upolad_images a,xm_construction_clarificaiton b
		<where>
			a.proc_ins_id=b.proc_ins_id
			<if test="dataScope != null and dataScope != ''">
				${dataScope}
			</if>
			<if test="uId != null and uId != ''">
				AND a.uId = #{uId}
			</if>
			<if test="procInsId!=null and procInsId!=''">
				and a.proc_ins_id = #{procInsId}
			</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="findMaterialImg" resultType="com.jeeplus.modules.sg.managementcenter.activiti.entity.UploadImages">
		select imgName,path,proc_ins_id,uId from xm_upolad_images where proc_ins_id = #{procInsId}
	</select>
	
	<select id="findAllList" resultType="UploadImages" >
		SELECT *
		FROM xm_upolad_images a
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
			${dataScope}
		</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 xm_upolad_images(
			id,
			create_by,
			create_date,
			update_by,
			update_date,
			remarks,
			del_flag,
			imgName,
			path,
			proc_ins_id,
			uId
		) VALUES (
			#{id},
			#{createBy.id},
			#{createDate},
			#{updateBy.id},
			#{updateDate},
			#{remarks},
			#{delFlag},
			#{imgName},
			#{path},
			#{procInsId},
			#{uId}
		)
	</insert>
	
	<update id="update">
		UPDATE xm_upolad_images SET
			path = #{path},
			update_by = #{updateBy.id},
			update_date = #{updateDate},
			remarks = #{remarks}
		WHERE id = #{id}
	</update>

	<!--物理删除-->
	<update id="delete">
		DELETE FROM xm_upolad_images
		WHERE id = #{id}
	</update>
	
	<!--逻辑删除-->
	<update id="deleteByLogic">
		UPDATE xm_upolad_images SET
			del_flag = #{DEL_FLAG_DELETE}
		WHERE id = #{id}
	</update>
	

	
</mapper>