<?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.project.dao.ProjectEvaluationRecordDao">
    
	<sql id="projectEvaluationRecordColumns">
		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.del_flag AS "delFlag",
		a.client_id AS "clientId",
		a.bidsuccess_money AS "bidsuccessMoney",
		a.duration AS "duration",
		a.project_manager AS "projectManager",
		a.openbid_time AS "openbidMime",
		a.openbid_place AS "openbidPlace",
		a.assessbid_time AS "assessbidTime",
		a.assessbid_place AS "assessbidPlace",
		a.project_id AS "projectId"
	</sql>
	
	<sql id="projectEvaluationRecordJoins">
	</sql>
	
    
	<select id="get" resultType="ProjectEvaluationRecord" >
		SELECT 
			<include refid="projectEvaluationRecordColumns"/>
		FROM project_evaluation_record a
		<include refid="projectEvaluationRecordJoins"/>
		WHERE a.id = #{id}
	</select>
	
	<select id="findList" resultType="ProjectEvaluationRecord" >
		SELECT 
			<include refid="projectEvaluationRecordColumns"/>
		FROM project_evaluation_record a
		<include refid="projectEvaluationRecordJoins"/>
		<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>
	
	<select id="findAllList" resultType="ProjectEvaluationRecord" >
		SELECT 
			<include refid="projectEvaluationRecordColumns"/>
		FROM project_evaluation_record a
		<include refid="projectEvaluationRecordJoins"/>
		<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 project_evaluation_record(
			id,
			create_by,
			create_date,
			update_by,
			update_date,
			remarks,
			del_flag,
			client_id,
			bidsuccess_money,
			duration,
			project_manager,
			openbid_time,
			openbid_place,
			assessbid_time,
			assessbid_place,
			project_id
		) VALUES (
			#{id},
			#{createBy.id},
			#{createDate},
			#{updateBy.id},
			#{updateDate},
			#{remarks},
			#{delFlag},
			#{clientId},
			#{bidsuccessMoney},
			#{duration},
			#{projectManager},
			#{openbidMime},
			#{openbidPlace},
			#{assessbidTime},
			#{assessbidPlace},
			#{projectId}
		)
	</insert>
	
	<update id="update">
		UPDATE project_evaluation_record SET 	
			update_by = #{updateBy.id},
			update_date = #{updateDate},
			remarks = #{remarks},
			client_id = #{clientId},
			bidsuccess_money = #{bidsuccessMoney},
			duration = #{duration},
			project_manager = #{projectManager},
			openbid_time = #{openbidMime},
			openbid_place = #{openbidPlace},
			assessbid_time = #{assessbidTime},
			assessbid_place = #{assessbidPlace},
			project_id = #{projectId}
		WHERE id = #{id}
	</update>
	
	
	<!--物理删除-->
	<update id="delete">
		DELETE FROM project_evaluation_record
		WHERE id = #{id}
	</update>
	
	<!--逻辑删除-->
	<update id="deleteByLogic">
		UPDATE project_evaluation_record SET 
			del_flag = #{DEL_FLAG_DELETE}
		WHERE id = #{id}
	</update>
	
	
	<!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
	<select id="findUniqueByProperty" resultType="ProjectEvaluationRecord" statementType="STATEMENT">
		select * FROM project_evaluation_record  where ${propertyName} = '${value}'
	</select>
	
</mapper>