Blame view

ExerciseTreeMappingMapper.xml 2.07 KB
涂亚平 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
<?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.meishu.mapper.ExerciseTreeMappingMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.meishu.model.ExerciseTreeMappingDO">
        <id column="id" property="id" />
        <result column="exercise_id" property="exerciseId" />
        <result column="tree_id" property="treeId" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        create_date,
        update_date,
        delete_date,
        id, exercise_id, tree_id
    </sql>

    <select id="getTreeExerciseCount" resultType="integer">
        SELECT
        count(1)
        FROM
        exercise_related t
        LEFT JOIN exercise_dict t2 ON t.exercise_id = t2.id
        WHERE
        t.delete_date IS NULL
        AND t2.delete_date IS NULL
        <if test="treeId !=null and treeId !=''">
            AND t.tree_id = #{treeId}
        </if>
        <if test="userId !=null and userId !=''">
            AND t2.user_id = #{userId}
        </if>
        <if test="shareStatus !=null and shareStatus !=''">
            AND t2.share_status = #{shareStatus}
        </if>
        <if test="subject!=null and subject !=''">
            AND t2.subject = #{subject}
        </if>
        <if test="checkStatus==2">
            AND t2.check_status = 2
        </if>
        <if test="checkStatus==1">
            AND (t2.check_status = 1 or t2.check_status = 3 )
        </if>
    </select>

    <select id="getRelatedExercise"  resultType="com.meishu.model.ExerciseDictDO">
    SELECT
        t2.id,
        t2.advice_length,
        t2.tree_id,
        t2.exercise_type,
        t2.difficulty,
        t2.title,
        t2.items,
        t2.right_answer,
        t2.detail
    FROM
        (SELECT t.exercise_id FROM exercise_related t WHERE t.tree_id = #{treeId} and t.status = 1)t
        LEFT JOIN exercise_dict t2
        ON t.exercise_id = t2.id
        where t2.check_status = 1
    </select>

</mapper>