<?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.ruoyi.branch.mapper.TBranchMeetingMapper">
    
    <resultMap type="TBranchMeeting" id="TBranchMeetingMgrResult">
        <result property="meetingId"    column="meeting_id"    />
        <result property="meetingType"    column="meeting_type"    />
        <result property="meetingTime"    column="meeting_time"    />
        <result property="meetingVenue"    column="meeting_venue"    />
        <result property="host"    column="host"    />
        <result property="recorder"    column="recorder"    />
        <result property="participants"    column="participants"    />
        <result property="absentees"    column="absentees"    />
        <result property="attendees"    column="attendees"    />
        <result property="mainTopics"    column="main_topics"    />
        <result property="resolutionsFormed"    column="resolutions_formed"    />
        <result property="remarks"    column="remarks"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="deptId"       column="dept_id"      />
    </resultMap>

    <sql id="selectTBranchMeetingMgrVo">
        select
            u.meeting_id,
            u.meeting_type,
            u.meeting_time,
            u.meeting_venue,
            u.host,
            u.recorder,
            u.participants,
            u.absentees,
            u.attendees,
            u.main_topics,
            u.resolutions_formed,
            u.remarks,
            u.del_flag,
            u.create_by,
            u.create_time,
            u.update_by,
            u.update_time,
            u.dept_id
        from T_BRANCH_MEETING u
        left join sys_dept d on u.dept_id = d.dept_id
    </sql>

    <select id="selectTBranchMeetingMgrList" parameterType="TBranchMeeting" resultMap="TBranchMeetingMgrResult">
        <include refid="selectTBranchMeetingMgrVo"/>
        <where>  
            <if test="meetingId != null "> and u.meeting_id = #{meetingId}</if>
            <if test="meetingType != null  and meetingType != ''"> and u.meeting_type = #{meetingType}</if>
            <if test="meetingTime != null "> and u.meeting_time = #{meetingTime}</if>
            <if test="meetingVenue != null  and meetingVenue != ''"> and u.meeting_venue like concat(concat('%', #{meetingVenue}), '%')</if>
            <if test="host != null  and host != ''"> and u.host = #{host}</if>
            <if test="recorder != null  and recorder != ''"> and u.recorder = #{recorder}</if>
            <if test="participants != null  and participants != ''"> and u.participants = #{participants}</if>
            <if test="absentees != null  and absentees != ''"> and u.absentees = #{absentees}</if>
            <if test="attendees != null  and attendees != ''"> and u.attendees = #{attendees}</if>
            <if test="mainTopics != null  and mainTopics != ''"> and u.main_topics like concat(concat('%', #{mainTopics}), '%')</if>
            <if test="resolutionsFormed != null  and resolutionsFormed != ''"> and u.resolutions_formed like concat(concat('%', #{resolutionsFormed}), '%')</if>
            <if test="remarks != null  and remarks != ''"> and u.remarks like concat(concat('%', #{remarks}), '%')</if>
            <if test="deptId != null "> and u.dept_id = #{deptId}</if>
            and u.del_flag = 0
        </where>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
        order by u.meeting_time desc
    </select>
    
    <select id="selectTBranchMeetingMgrByMeetingId" parameterType="Long" resultMap="TBranchMeetingMgrResult">
        <include refid="selectTBranchMeetingMgrVo"/>
        where u.meeting_id = #{meetingId}
        and u.del_flag = 0
    </select>
        
    <insert id="insertTBranchMeetingMgr" parameterType="TBranchMeeting">
        <selectKey keyProperty="meetingId" resultType="long" order="BEFORE">
            SELECT seq_t_branch_meeting.NEXTVAL as meetingId FROM DUAL
        </selectKey>
        insert into t_branch_meeting
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="meetingId != null">meeting_id,</if>
            <if test="meetingType != null">meeting_type,</if>
            <if test="meetingTime != null">meeting_time,</if>
            <if test="meetingVenue != null">meeting_venue,</if>
            <if test="host != null">host,</if>
            <if test="recorder != null">recorder,</if>
            <if test="participants != null">participants,</if>
            <if test="absentees != null">absentees,</if>
            <if test="attendees != null">attendees,</if>
            <if test="mainTopics != null">main_topics,</if>
            <if test="resolutionsFormed != null">resolutions_formed,</if>
            <if test="remarks != null">remarks,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="deptId != null and deptId != 0">dept_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="meetingId != null">#{meetingId},</if>
            <if test="meetingType != null">#{meetingType},</if>
            <if test="meetingTime != null">#{meetingTime},</if>
            <if test="meetingVenue != null">#{meetingVenue},</if>
            <if test="host != null">#{host},</if>
            <if test="recorder != null">#{recorder},</if>
            <if test="participants != null">#{participants},</if>
            <if test="absentees != null">#{absentees},</if>
            <if test="attendees != null">#{attendees},</if>
            <if test="mainTopics != null">#{mainTopics},</if>
            <if test="resolutionsFormed != null">#{resolutionsFormed},</if>
            <if test="remarks != null">#{remarks},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="deptId != null and deptId != ''">#{deptId},</if>
         </trim>
    </insert>

    <update id="updateTBranchMeetingMgr" parameterType="TBranchMeeting">
        update T_BRANCH_MEETING
        <trim prefix="SET" suffixOverrides=",">
            <if test="meetingType != null">meeting_type = #{meetingType},</if>
            <if test="meetingTime != null">meeting_time = #{meetingTime},</if>
            <if test="meetingVenue != null">meeting_venue = #{meetingVenue},</if>
            <if test="host != null">host = #{host},</if>
            <if test="recorder != null">recorder = #{recorder},</if>
            <if test="participants != null">participants = #{participants},</if>
            <if test="absentees != null">absentees = #{absentees},</if>
            <if test="attendees != null">attendees = #{attendees},</if>
            <if test="mainTopics != null">main_topics = #{mainTopics},</if>
            <if test="resolutionsFormed != null">resolutions_formed = #{resolutionsFormed},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
        </trim>
        where meeting_id = #{meetingId}
    </update>

    <delete id="deleteTBranchMeetingMgrByMeetingId" parameterType="Long">
        update T_BRANCH_MEETING set del_flag = 2 where meeting_id = #{meetingId}
    </delete>

    <delete id="deleteTBranchMeetingMgrByMeetingIds" parameterType="String">
        update T_BRANCH_MEETING set del_flag = 2 where meeting_id in
        <foreach item="meetingId" collection="array" open="(" separator="," close=")">
            #{meetingId}
        </foreach>
    </delete>
</mapper>