<?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.TFivesToolCaseDao">
    <!-- 开启二级缓存 -->
    <!-- <cache type="org.mybatis.caches.ehcache.LoggingEhcache"/> -->
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.testor.module.fives.model.domain.TFivesToolCase">
        <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="case_type" property="caseType"/>
        <id column="case_name" property="caseName"/>
        <id column="recommend_reason" property="recommendReason"/>
        <id column="problem_des" property="problemDes"/>
        <id column="improve_des" property="improveDes"/>
        <id column="image_1" property="image1"/>
        <id column="image_2" property="image2"/>
    </resultMap>

    <select id="caseReport" resultType="com.testor.module.fives.model.excel.TFivesToolCaseReport">
        SELECT
            tftc.case_name AS theme_name,
            tsu.user_name AS create_by,
            tftu.create_date,
            tftu.grain_org_id,
            tftu.area_org_id,
            tftu.serial_number,
            tftc.case_type,
            tftc.recommend_reason,
            tftc.problem_des,
            tftc.improve_des,
            CASE
                tftu.score_type
                WHEN '7' THEN
                    '未评'
                WHEN '6' THEN
                    '评价中' ELSE tftu.score
                END AS score
        FROM
            t_fives_tool_use AS tftu
                LEFT JOIN t_fives_tool_case AS tftc ON tftu.id = tftc.parent_id
                LEFT JOIN t_sys_user AS tsu ON tftu.create_by = tsu.user_id
        WHERE
            tftu.use_type = 1
          AND tftu.STATUS = '0'
    </select>
</mapper>