<?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.qmth.distributed.print.business.mapper.ObeRequirementTargetMatrixMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.qmth.distributed.print.business.entity.ObeRequirementTargetMatrix">
        <id column="id" property="id" />
        <result column="obe_requirement_id" property="obeRequirementId" />
        <result column="obe_target_id" property="obeTargetId" />
        <result column="enable" property="enable" />
        <result column="create_id" property="createId" />
        <result column="create_time" property="createTime" />
        <result column="update_id" property="updateId" />
        <result column="update_time" property="updateTime" />
    </resultMap>
    <select id="listMatrix" resultType="com.qmth.distributed.print.business.entity.ObeRequirementTargetMatrix"
            parameterType="java.lang.Long">
        SELECT
            ortm.*,
            ocpr.name requirementName,
            ocpt.name targetName
        FROM
            obe_requirement_target_matrix ortm
                LEFT JOIN
            obe_culture_program_requirement ocpr ON ortm.obe_requirement_id = ocpr.id
                LEFT JOIN
            obe_culture_program_target ocpt ON ortm.obe_target_id = ocpt.id
        WHERE
            ortm.culture_program_id = #{cultureProgramId}
        ORDER BY ocpr.sort_num , ocpt.create_time
    </select>

</mapper>
