<?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.artfess.examine.dao.ExamYearAssessmentSubDao">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.artfess.examine.model.ExamYearAssessmentSub">
        <id column="id_" property="id" />
        <result column="year_" property="year" />
        <result column="position_id_" property="positionId" />
        <result column="subject_ids_" property="subjectIds" />
        <result column="sn_" property="sn" />
        <result column="memo_" property="memo" />
        <result column="is_dele_" property="isDele" />
        <result column="create_by_" property="createBy" />
        <result column="create_org_id_" property="createOrgId" />
        <result column="create_time_" property="createTime" />
        <result column="update_by_" property="updateBy" />
        <result column="update_time_" property="updateTime" />
        <result column="version_" property="version" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id_, year_, position_id_, subject_ids_, sn_, memo_, is_dele_, create_by_, create_org_id_, create_time_, update_by_, update_time_, version_
    </sql>
    <select id="getUserInfoList" resultType="com.artfess.examine.vo.UserInfoVo">
        SELECT
            o.user_id_,
            u.fullname_ AS userName,
            o.pos_id_,
            u.account_
        FROM
            uc_org_user o
            LEFT JOIN uc_user u ON u.id_ = o.user_id_
        WHERE
            o.pos_id_ = #{positionId}
    </select>
    <select id="findByPage" resultType="com.artfess.examine.model.ExamSubjectInfo">

        SELECT
        DISTINCT s.*,y.id_ as id,y.year_,s.id_ as subjectId
        FROM
            exam_subject_info s
        LEFT JOIN exam_year_assessment_sub y ON y.subject_ids_ = s.id_
        LEFT JOIN exam_subject_pos po on po.subject_id_ = s.id_
        <if test="ew.customSqlSegment!=null">
            ${ew.customSqlSegment}
        </if>
    </select>

</mapper>
