<?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="org.dromara.main.mapper.MainExamEvaluationMapper">

    <resultMap type="org.dromara.main.domain.MainExamEvaluation" id="MainExamEvaluationResult">
        <result property="id" column="id"/>
        <result property="evaluationName" column="evaluation_name"/>
        <result property="grade" column="grade"/>
        <result property="position" column="position"/>
        <result property="positionType" column="position_type"/>
        <result property="tags" column="tags"/>
        <result property="mainImage" column="main_image"/>
        <result property="imageAlbum" column="image_album"/>
        <result property="detail" column="detail"/>
        <result property="price" column="price"/>
        <result property="onTime" column="on_time"/>
        <result property="downTime" column="down_time"/>
        <result property="status" column="status"/>
        <result property="tenantId" column="tenant_id"/>
        <result property="createDept" column="create_dept"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
        <result property="delFlag" column="del_flag"/>
    </resultMap>

    <resultMap type="org.dromara.main.domain.vo.MainExamEvaluationVo" id="MainExamEvaluationVoResult" extends="MainExamEvaluationResult">
        <result property="mainImageUrl" column="main_image_url"/>
        <collection property="abilityConfigs"
                    ofType="org.dromara.main.domain.MainAbilityConfig"
                    select="org.dromara.main.mapper.MainAbilityConfigMapper.selectByEvaluationId"
                    column="id"/>
    </resultMap>

    <sql id="selectMainExamEvaluationVo">
        SELECT
            e.id, e.evaluation_name, e.grade, e.position, e.position_type,
            e.tags, e.main_image, e.image_album, e.detail, e.price,
            e.on_time, e.down_time, e.status,
            e.tenant_id, e.create_dept, e.create_by, e.create_time,
            e.update_by, e.update_time, e.remark, e.del_flag,
            oss.url AS main_image_url
        FROM main_exam_evaluation e
                 LEFT JOIN sys_oss oss ON e.main_image = oss.oss_id
    </sql>

    <select id="selectVoByIdWithImages" resultMap="MainExamEvaluationVoResult">
        <include refid="selectMainExamEvaluationVo"/>
        WHERE e.id = #{id} AND e.del_flag = '0'
    </select>

    <select id="selectVoPageWithImages" resultMap="MainExamEvaluationVoResult">
        <include refid="selectMainExamEvaluationVo"/>
        ${ew.customSqlSegment}
    </select>

</mapper>
