<?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.unis.enterpriseManagement.info.modular.emPersonPlan.mapper.EmPersonPlanMapper">
    <select id="selectMyMapsPage" resultType="java.util.Map">
        <if test="type == 1" >
        SELECT
        a.id AS "personInfoId",
        c.id AS "planId",
        a.name AS "name",
        a.age,
        a.contact,
        c.plan_direction,
        c.description,
        IFNULL(c.status,0) AS "status"
        FROM
        biz_em_person_info a
        inner JOIN biz_em_person_plan c ON a.id = c.person_info_id
        </if>
        <if test="type == 2" >
       SELECT
        a.id AS "personInfoId",
        c.id AS "planId",
        d.id AS "requestId",
        a.name AS "name",
        a.age,
        a.contact,
        c.plan_direction,
        c.description,
        IFNULL(c.status,0) AS "status",
        IFNULL(d.audit_status,0) AS "auditStatus"
        FROM
        biz_em_person_info a
        inner JOIN biz_em_person_plan c ON a.id = c.person_info_id
        LEFT JOIN biz_audit_request d on c.id = d.request_id AND d.type = 2 and d.step = 1 -- 人才规划审核
        </if>
        <if test="ew.sqlSegment != null and ew.sqlSegment != ''">
            where  ${ew.sqlSegment}
        </if>
        ORDER BY a.create_time DESC
    </select>
</mapper>