<?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.bbd.bpm.dao.MemberMapper">


    <select id="getMemberList" resultType="com.bbd.bpm.vo.BpmEmployeeVo">
        SELECT
            a.id,
            a.created_time createdTime,
            a.update_time updateTime,
            a.`name`,
            a.position,
            IFNULL(b.`name`,'无') department,
            c.`code`
        FROM
            bpm_employee a
        LEFT JOIN bpm_company b ON b.id = a.department
        LEFT JOIN bpm_company c ON c.id = a.code_id
        WHERE
            a.`status` = 0 and department=#{id}
        <if test="name!=null">
            and a.name LIKE CONCAT('%',#{name},'%')
        </if>
    </select>

    <select id="getAllMemberList" resultType="com.bbd.bpm.vo.BpmEmployeeVo">
        SELECT
        a.id,
        a.created_time createdTime,
        a.update_time updateTime,
        a.`name`,
        a.position,
        IFNULL(b.`name`,'无') department,
        c.`code`
        FROM
        bpm_employee a
        LEFT JOIN bpm_company b ON b.id = a.department
        LEFT JOIN bpm_company c ON c.id = a.code_id
        WHERE
        a.`status` = 0 and code_id=#{id}
        <if test="name!=null">
            and a.name LIKE CONCAT('%',#{name},'%')
        </if>
    </select>


    <update id="deletedMember">
        update bpm_employee set status=2 where code_id=#{id}
    </update>

    <update id="deletedMembers">
        update bpm_employee set status=2 where department=#{id}
    </update>

    <select id="getAreaAll" resultType="map">
        SELECT
            id,
            `name`
        FROM
            bpm_company
        WHERE
            parent_id=#{id}
    </select>

    <select id="selectMenuList" resultType="com.bbd.bpm.vo.MenuVO">
        SELECT
            u.id,
            u.menu_name AS menuName,
            u.menu_url AS menuUrl,
            u.parent_id AS parentId
        FROM
            bpm_menu u
        ORDER BY
            u.sequence ASC
    </select>

</mapper>