<?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.workfullmanage.dao.WorkFullSurveyDao">
    
	<sql id="workFullClientColumns">
		a.id AS "id",
		a.unit_name AS "unitName",
		a.unit_link_man AS "unitLinkMan",
		a.link_phone AS "linkPhone",
		a.create_by AS "createBy.id",
		a.create_date AS "createDate",
		a.update_by AS "updateBy.id",
		a.update_date AS "updateDate",
		a.del_flag AS "delFlag",
		a.remarks AS "remarks"
	</sql>
	
	<sql id="workFullClientJoins">
	</sql>

	<!-- 监理信息 -->
	<select id="get" resultType="WorkFullSurvey" >
		SELECT
		<include refid="workFullClientColumns"/>
		FROM work_full_survey a
		<include refid="workFullClientJoins"/>
		WHERE a.id = #{id}
	</select>

	<!-- 监理 -->
	<select id="findList" resultType="WorkFullSurvey" >
		SELECT
		<include refid="workFullClientColumns"/>
		FROM work_full_survey a
		<include refid="workFullClientJoins"/>
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
			<if test="unitName != null and unitName != ''">
				AND a.unit_name like concat('%',#{unitName},'%')
			</if>
			<if test="unitLinkMan != null and unitLinkMan != ''">
				AND a.unit_link_man = #{unitLinkMan}
			</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="WorkFullSurvey" >
		SELECT
		<include refid="workFullClientColumns"/>
		FROM work_full_survey a
		<include refid="workFullClientJoins"/>
		<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_full_survey(
		id,
		unit_name,
		unit_link_man,
		link_phone,
		create_by,
		create_date,
		update_by,
		update_date,
		del_flag,
		remarks
		) VALUES (
		#{id},
		#{unitName},
		#{unitLinkMan},
		#{linkPhone},
		#{createBy.id},
		#{createDate},
		#{updateBy.id},
		#{updateDate},
		#{delFlag},
		#{remarks}
		)
	</insert>

	<!--监理-->
	<update id="update">
		UPDATE work_full_survey SET
		unit_name = #{unitName},
		unit_link_man = #{unitLinkMan},
		link_phone = #{linkPhone},
		update_by = #{updateBy.id},
		update_date = #{updateDate},
		remarks = #{remarks}
		WHERE id = #{id}
	</update>

	<!--物理删除 监理-->
	<update id="delete">
		DELETE FROM work_full_survey
		WHERE id = #{id}
	</update>

	<!--逻辑删除 监理-->
	<update id="deleteByLogic">
		UPDATE work_full_survey SET
		del_flag = #{DEL_FLAG_DELETE}
		WHERE id = #{id}
	</update>

	<!-- 根据实体名称和字段名称和字段值获取唯一记录 监理-->
	<select id="findUniqueByProperty" resultType="WorkFullSurvey" statementType="STATEMENT">
		select * FROM work_full_survey  where ${propertyName} = '${value}'
	</select>
</mapper>