<?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.ObeCultureProgramMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.qmth.distributed.print.business.entity.ObeCultureProgram">
        <id column="id" property="id" />
        <result column="professional_id" property="professionalId" />
        <result column="name" property="name" />
        <result column="target_count" property="targetCount" />
        <result column="requirement_count" property="requirementCount" />
        <result column="course_count" property="courseCount" />
        <result column="description" property="description" />
        <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="pageData"
            resultType="com.qmth.distributed.print.business.bean.result.obe.cultureProgram.CultureProgramResult">
        SELECT
            ocp.*,
            bp.name professionalName,
            su.login_name createLoginName,
            su.real_name createRealName
        FROM
            obe_culture_program ocp
                LEFT JOIN
            basic_professional bp ON ocp.professional_id = bp.id
                LEFT JOIN
            sys_user su ON ocp.create_id = su.id
        <where>
            <if test="schoolId != null">
                and bp.school_id = #{schoolId}
            </if>
            <if test="professionalId != null">
                and ocp.professional_id = #{professionalId}
            </if>
            <if test="name != null and name != ''">
                and ocp.name like concat('%',#{name},'%')
            </if>
            <if test="dpr != null">
                <if test="dpr.requestUserId != null">
                    AND ocp.create_id = #{dpr.requestUserId}
                </if>
                <if test="dpr.orgIdSet != null and dpr.orgIdSet != '' and dpr.orgIdSet.size > 0">
                    AND su.org_id IN
                    <foreach collection="dpr.orgIdSet" item="item" index="index" open="(" separator="," close=")">
                        #{item}
                    </foreach>
                </if>
            </if>
        </where>
    </select>
    <select id="getByCultureProgramId"
            resultType="com.qmth.distributed.print.business.bean.result.obe.cultureProgram.CultureProgramResult"
            parameterType="java.lang.Long">
        SELECT
            ocp.*,
            bp.name professionalName,
            su.login_name createLoginName,
            su.real_name createRealName
        FROM
            obe_culture_program ocp
                LEFT JOIN
            basic_professional bp ON ocp.professional_id = bp.id
                LEFT JOIN
            sys_user su ON ocp.create_id = su.id
        where ocp.id = #{id}
    </select>

</mapper>
