<?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.hotent.portal.persistence.dao.PortalMeetingApplyDao">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.hotent.portal.model.PortalMeetingApply">
        <id column="ID_" property="id" />
        <result column="SUBJECT_" property="subject" />
        <result column="MEETING_NAME_" property="meetingName" />
        <result column="MEETING_ID_" property="meetingId" />
        <result column="MEETING_OWNER_" property="meetingOwner" />
        <result column="OWNER_OWNER_ID_" property="ownerOwnerId" />
        <result column="MEETING_DEP_" property="meetingDep" />
        <result column="MEETING_DEP_ID_" property="meetingDepId" />
        <result column="PARTICIPANTS_" property="participants" />
        <result column="PARTICIPANTS_ID_" property="participantsId" />
        <result column="DEPARTMENT_" property="department" />
        <result column="DEPARTMENT_ID_" property="departmentId" />
        <result column="OUTSIDERS_" property="outsiders" />
        <result column="ATTENDANCE_" property="attendance" />
        <result column="MEETING_NOTES_" property="meetingNotes" />
        <result column="FILES_" property="files" />
        <result column="APPLY_DESC_" property="applyDesc" />
        <result column="START_TIME_" property="startTime" />
        <result column="END_TIME_" property="endTime" />
        <result column="PRO_INST_ID_" property="proInstId" />
        <result column="STATUS_" property="status" />
        <result column="SERVICE_" property="service" />
        <result column="CREATE_BY_" property="createBy" />
        <result column="UPDATE_BY_" property="updateBy" />
        <result column="CREATE_TIME_" property="createTime" />
        <result column="UPDATE_TIME_" property="updateTime" />
        <result column="CREATE_ORG_ID_" property="createOrgId" />
        <result column="TENANT_ID_" property="tenantId" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        ID_, SUBJECT_, MEETING_NAME_, MEETING_ID_, MEETING_OWNER_, OWNER_OWNER_ID_, MEETING_DEP_, MEETING_DEP_ID_, PARTICIPANTS_, PARTICIPANTS_ID_, DEPARTMENT_, DEPARTMENT_ID_, OUTSIDERS_, ATTENDANCE_, MEETING_NOTES_, FILES_, APPLY_DESC_, START_TIME_, END_TIME_, PRO_INST_ID_, STATUS_, SERVICE_, CREATE_BY_, UPDATE_BY_, CREATE_TIME_, UPDATE_TIME_, CREATE_ORG_ID_, TENANT_ID_
    </sql>
    
     <select id="getByInstId"   parameterType="java.lang.String" resultMap="BaseResultMap">
		SELECT <include refid="Base_Column_List" /> FROM portal_meeting_apply 
		WHERE 
		PRO_INST_ID_=#{instId} 
	</select>
	
	<select id="getApplyCount" resultType="java.util.Map">
		select STATUS_ as status,COUNT(1) as amount
		from 
		portal_meeting_apply 
		where STATUS_ is not null 
		<if test="ownerId!=null">
			and OWNER_OWNER_ID_ = #{ownerId}
		</if>
		<if test="roomId!=null">
			and MEETING_ID_ = #{roomId}
		</if>
		GROUP BY STATUS_
	</select>

</mapper>
