<?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.testor.module.fives.dao.TFivesStandardDao">
    <!-- 开启二级缓存 -->
    <!-- <cache type="org.mybatis.caches.ehcache.LoggingEhcache"/> -->
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.testor.module.fives.model.domain.TFivesStandard">
        <id column="id" property="id"/>
        <id column="ref_id" property="refId"/>
        <id column="parent_id" property="parentId"/>
        <id column="tenant_id" property="tenantId"/>
        <id column="process_id" property="processId"/>
        <id column="process_status" property="processStatus"/>
        <id column="org_id" property="orgId"/>
        <id column="standard_type" property="standardType"/>
        <id column="standard_name" property="standardName"/>
        <id column="sub_option" property="subOption"/>
        <id column="child" property="child"/>
        <id column="total_score" property="totalScore"/>
    </resultMap>

    <!--    AND tf.parent_id = #{id}-->

    <select id="exportFiveStandard" parameterType="com.testor.module.fives.model.excel.TFivesStandardReport"
            resultType="com.testor.module.fives.model.excel.TFivesStandardReport">
        SELECT tf.name,
        ts.content,
        ts.score,
        ts.detail_rules,
        tfs.sub_option,
        tfs.child,
        tfs.standard_type
        FROM t_fives_sub_option AS ts
        LEFT JOIN t_fives_sub_option AS tf ON tf.id = ts.sub_id
        LEFT JOIN t_fives_standard AS tfs ON ts.parent_id = tfs.id
        WHERE ts.status = 0
        AND tf.status = 0
        <if test="param.standardName!=null and param.standardName!=''">
            AND tfs.standard_name LIKE CONCAT('%',#{param.standardName},'%')
        </if>
        <if test="param.standardType!=null and param.standardType!=''">
            AND tfs.standard_type=#{param.standardType}
        </if>
        <if test="param.subOption!=null and param.subOption!=''">
            AND tfs.sub_option=#{param.subOption}
        </if>
        <if test="param.child!=null and param.child!=''">
            AND tfs.child=#{param.child}
        </if>
    </select>
</mapper>