AnsweringQuestionMapper.xml 1.96 KB
<?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.subsidy.mapper.AnsweringQuestionMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.subsidy.model.AnsweringQuestionDO">
        <id column="id" property="id"/>
        <result column="create_date" property="createDate"/>
        <result column="update_date" property="updateDate"/>
        <result column="delete_date" property="deleteDate"/>
        <result column="course_id" property="courseId"/>
        <result column="ask_id" property="askId"/>
        <result column="answer_id" property="answerId"/>
        <result column="title" property="title"/>
        <result column="answer" property="answer"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        create_date,
        update_date,
        delete_date,
        id, course_id, ask_id, answer_id, title, answer
    </sql>

    <select id="getCourseQuestion" resultType="com.subsidy.vo.answer.GetCourseQuestionVO">
        SELECT
            t.id,
            t.class_id,
            t.ask_id,
            t.answer_id,
            t.title,
            t.answer,
            t.create_date,
            t.update_date,
            t2.user_name as memberName,
            t3.user_name as administerName,
            t4.company_name
        FROM
            answering_question t
        LEFT JOIN member t2 ON t.ask_id = t2.id
        left join administer t3 on t.answer_id = t3.id
        left join company_member_mapping t5 on t5.member_id = t2.id and t5.member_status = 1
        left join company_dict t4 on t5.company_id = t4.id
        WHERE
            t.delete_date IS NULL
        AND t2.delete_date IS NULL
        AND t.class_id = #{classId}
        <if test="memberId != null ">
            and t.ask_id = #{memberId}
        </if>
        order by t.create_date desc
    </select>

</mapper>