<?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.worklog.dao.WorkMeetingDao">
    
	<sql id="infoColums">
		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.content AS "content",
		a.project_id AS "projectId",
		a.meet_type as "meetType",
		a.start_date AS "startDate",
		a.area AS "area.name",
		a.address AS "address",
		a.weather,
		a.low_tem AS "lowTem",
		a.high_tem AS "highTem",
		a.theme,
		wind
	</sql>



	<sql id="workMeetingJoins">

	</sql>

	
    <!--<resultMap type="WorkInfoList" id="WorkMeeting" autoMapping="true">-->
    	<!--<result column="content" property="content"   typeHandler="com.jeeplus.common.mapper.ConvertBlobTypeHandler"/>-->
    <!--</resultMap>-->
    
	<select id="get" resultType="WorkMeeting" >
		SELECT 
			<include refid="infoColums"/>
		FROM work_meeting a
		<include refid="workMeetingJoins"/>
		WHERE a.id = #{id}
	</select>
	
	<select id="findList" resultType="WorkMeeting" >
		SELECT 
			<include refid="infoColums"/>
		FROM work_meeting a
		<include refid="workMeetingJoins"/>
		<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="WorkMeeting" >
		SELECT 
			<include refid="infoColums"/>
		FROM work_meeting a
		<include refid="workMeetingJoins"/>
		<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_meeting(
			id,
			create_by,
			create_date,
			update_by,
			update_date,
			remarks,
			del_flag,
			content,
			project_id,
			meet_type ,
		    start_date,
		    area ,
		    address,
		    weather,
		    low_tem,
		    high_tem,
		    theme,
		    wind
		) VALUES (
			#{id},
			#{createBy.id},
			#{createDate},
			#{updateBy.id},
			#{updateDate},
			#{remarks},
			#{delFlag},
			#{content},
			#{projectId},
			#{meetType},
			#{startDate},
			#{area.name},
			#{address},
			#{weather},
			#{lowTem},
			#{highTem},
			#{theme},
			#{wind}
		)
	</insert>
	
	<update id="update">
		UPDATE work_meeting SET 	
			update_by = #{updateBy.id},
			update_date = #{updateDate},
			remarks = #{remarks},
			content = #{content},
			project_id = #{projectId},
			meet_type = #{meetType},
			start_date = #{startDate},
			area = #{area.id},
			address= #{address},
			weather = #{weather},
			low_tem = #{lowTem},
			high_tem = #{highTem},
			theme = #{theme},
		WHERE id = #{id}
	</update>
	
	
	<!--物理删除-->
	<update id="delete">
		DELETE FROM work_meeting
		WHERE id = #{id}
	</update>
	
	<!--逻辑删除-->
	<update id="deleteByMeetingic">
		UPDATE work_meeting SET 
			del_flag = #{DEL_FLAG_DELETE}
		WHERE id = #{id}
	</update>
	
	
	<!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
	<select id="findUniqueByProperty" resultType="WorkInfoList" statementType="STATEMENT">
		select * FROM work_meeting  where ${propertyName} = '${value}'
	</select>

	<!-- 删除关联所有文件 -->
	<delete id="deleteByProId">
		DELETE FROM work_meeting
		WHERE project_id = #{projectId}
	</delete>

	<!-- 获取实体 -->
	<select id="findListByProId" resultType="WorkMeeting" >
		SELECT
		<include refid="infoColums"/>
		FROM work_meeting a
		<include refid="workMeetingJoins"/>
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
			and a.project_id = #{projectId}
		</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>
</mapper>