<?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.workcontractinfo.dao.WorkContractReviewDao">
    
	<sql id="workcontractreviewColumns">
		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.contract_id AS "contractId",
		a.time_requirements AS "timeRequirements",
		a.special_requirements AS "specialRequirements",
		a.is_legitimate AS "isLegitimate",
		a.credibility AS "credibility",
		a.preliminary_risk_assessment AS "preliminaryRiskAssessmen",
		a.service_object_industry AS "serviceObjectIndustry",
		a.is_proper_acquisition AS "isProperAcquisition",
		a.is_user_qualified AS "isUserQualified",
		a.is_external_expert_power AS "isExternalExpertPower",
		a.is_equipment_meet_requirements AS "isEquipmentMeetRequirements",
		a.is_time_meet_requirements AS "isTimeMeetRequirements",
		a.is_contract_signature AS "isContractSignature"
	</sql>
	
	<sql id="workcontractreviewJoins">
	</sql>
	
    
	<select id="get" resultType="Workcontractreview" >
		SELECT 
			<include refid="workcontractreviewColumns"/>
		FROM work_contract_review a
		<include refid="workcontractreviewJoins"/>
		WHERE a.id = #{id}
	</select>
	
	<select id="getByContractId" resultType="Workcontractreview" >
		SELECT
			<include refid="workcontractreviewColumns"/>
		FROM work_contract_review a
		<include refid="workcontractreviewJoins"/>
		WHERE a.contract_id = #{contractId}
	</select>

	<select id="findList" resultType="Workcontractreview" >
		SELECT 
			<include refid="workcontractreviewColumns"/>
		FROM work_contract_review a
		<include refid="workcontractreviewJoins"/>
		<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="Workcontractreview" >
		SELECT 
			<include refid="workcontractreviewColumns"/>
		FROM work_contract_review a
		<include refid="workcontractreviewJoins"/>
		<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_contract_review(
			id,
			create_by,
			create_date,
			update_by,
			update_date,
			remarks,
			del_flag,
			contract_id,
			time_requirements,
			special_requirements,
			is_legitimate,
			credibility,
			preliminary_risk_assessment,
			service_object_industry,
			is_proper_acquisition,
			is_user_qualified,
			is_external_expert_power,
			is_equipment_meet_requirements,
			is_time_meet_requirements,
			is_contract_signature
		) VALUES (
			#{id},
			#{createBy.id},
			#{createDate},
			#{updateBy.id},
			#{updateDate},
			#{remarks},
			#{delFlag},
			#{contractId},
			#{timeRequirements},
			#{specialRequirements},
			#{isLegitimate},
			#{credibility},
			#{preliminaryRiskAssessmen},
			#{serviceObjectIndustry},
			#{isProperAcquisition},
			#{isUserQualified},
			#{isExternalExpertPower},
			#{isEquipmentMeetRequirements},
			#{isTimeMeetRequirements},
			#{isContractSignature}
		)
	</insert>
	
	<update id="update">
		UPDATE work_contract_review SET 	
			update_by = #{updateBy.id},
			update_date = #{updateDate},
			remarks = #{remarks},
			contract_id = #{contractId},
			time_requirements = #{timeRequirements},
			special_requirements = #{specialRequirements},
			is_legitimate = #{isLegitimate},
			credibility = #{credibility},
			preliminary_risk_assessment = #{preliminaryRiskAssessmen},
			service_object_industry = #{serviceObjectIndustry},
			is_proper_acquisition = #{isProperAcquisition},
			is_user_qualified = #{isUserQualified},
			is_external_expert_power = #{isExternalExpertPower},
			is_equipment_meet_requirements = #{isEquipmentMeetRequirements},
			is_time_meet_requirements = #{isTimeMeetRequirements},
			is_contract_signature = #{isContractSignature}
		WHERE id = #{id}
	</update>
	
	
	<!--物理删除-->
	<update id="delete">
		DELETE FROM work_contract_review
		WHERE id = #{id}
	</update>
	
	<!--逻辑删除-->
	<update id="deleteByLogic">
		UPDATE work_contract_review SET 
			del_flag = #{DEL_FLAG_DELETE}
		WHERE id = #{id}
	</update>
	
	
	<!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
	<select id="findUniqueByProperty" resultType="Workcontractreview" statementType="STATEMENT">
		select * FROM work_contract_review  where ${propertyName} = '${value}'
	</select>
	
</mapper>