<?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.yida.data.school.transaction.mapper.EduApplyMapper">
    <resultMap id="applyMap" type="com.yida.data.common.core.entity.apply.EduApply">
        <result column="id" property="id"/>
        <result column="apply_name" property="applyName"/>
        <result column="apply_code" property="applyCode"/>


        <collection select="selectFunction" property="functionList" javaType="java.util.List"
                    ofType="com.yida.data.common.core.entity.apply.EduApplyFunction" column="id">
            <result column="function_id" property="id"/>
            <result column="apply_id" property="applyId"/>
            <result column="function_name" property="functionName"/>
        </collection>
    </resultMap>

    <select id="listEduProductApply" parameterType="java.lang.String" resultMap="applyMap">
        SELECT
        a.id,
        a.apply_name,
        a.apply_code
        FROM `edu_apply` a
        WHERE 1=1
        AND a.del_flag = 0
        <if test="name != null and name != ''">
            AND a.apply_name LIKE CONCAT('%',#{name},'%')
        </if>
        ORDER BY a.create_date desc
    </select>

    <select id="selectFunction" resultType="com.yida.data.common.core.entity.apply.EduApplyFunction">
        select * from edu_apply_function
        where apply_id = #{id}
        and del_flag = 0
    </select>
</mapper>
