Blame view

ClassDictMapper.xml 5.3 KB
涂亚平 committed
1 2 3 4 5 6
<?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.ClassDictMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.subsidy.model.ClassDictDO">
涂亚平 committed
7 8 9 10 11 12 13 14
        <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="class_name" property="className"/>
        <result column="course_id" property="courseId"/>
        <result column="start_date" property="startDate"/>
        <result column="end_date" property="endDate"/>
涂亚平 committed
15 16 17 18 19 20 21 22 23 24 25 26
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        create_date,
        update_date,
        delete_date,
        id, class_name, course_id, start_date, end_date
    </sql>

    <select id="getAllClasses" resultType="com.subsidy.vo.classdict.GetAllClassesVO">
        SELECT
涂亚平 committed
27 28 29 30 31 32
        t.id,
        t2.id as courseId,
        t.class_name,
        t2.course_name,
        t.start_date,
        t.end_date,
33
        t4.cnt,
涂亚平 committed
34 35
        t5.class_type,
        t.open_status
涂亚平 committed
36 37
        FROM
        class_dict t
涂亚平 committed
38
        left join class_type_dict t5 on t.class_type_id = t5.id
涂亚平 committed
39 40 41 42 43 44
        LEFT JOIN course_dict t2 ON t.course_id = t2.id
        LEFT JOIN ( SELECT t3.class_id, sum( 1 ) AS cnt FROM class_member_mapping t3 WHERE t3.delete_date IS NULL GROUP
        BY t3.class_id ) t4 ON t.id = t4.class_id
        WHERE
        t.delete_date IS NULL
        AND t2.delete_date IS NULL
涂亚平 committed
45
        and t5.delete_date is null
涂亚平 committed
46 47 48 49
        and t.company_id = #{companyId}
        <if test="className != null and className !=''">
            and t.class_name like concat('%',#{className} ,'%')
        </if>
涂亚平 committed
50
        <if test="startDate != null and endDate != null and startDate != '' and endDate != ''">
涂亚平 committed
51
            and t.end_date >= DATE_FORMAT( #{startDate}, '%Y-%m-%d' )
涂亚平 committed
52
            and t.start_date  &lt; DATE_FORMAT( #{endDate}, '%Y-%m-%d' )
涂亚平 committed
53 54 55 56
        </if>
        <if test="openStatus != null and openStatus != ''">
            and t.open_status = #{openStatus}
        </if>
涂亚平 committed
57
        order by t.create_date desc
涂亚平 committed
58 59 60 61 62
    </select>

    <select id="getClassVods" parameterType="long" resultType="com.subsidy.model.VodDictDO">
        SELECT
            t3.*
涂亚平 committed
63 64
        FROM
            class_dict t
涂亚平 committed
65 66
            LEFT JOIN course_content t2 ON t.course_id = t2.course_id
            LEFT JOIN vod_dict t3 ON t2.id = t3.content_id
涂亚平 committed
67 68 69
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
涂亚平 committed
70 71 72 73 74 75 76 77
            AND t3.delete_date IS NULL
            and t3.id is not null
            and t.id = #{classId}
    </select>

    <select id="getSpareMembers" parameterType="com.subsidy.dto.classDict.GetSpareMembersDTO"
            resultType="com.subsidy.model.MemberDO">
       SELECT
78 79 80 81 82 83 84 85 86 87 88
           distinct 	t2.id,
                        t2.company_id,
                        t2.user_name,
                        t2.account_name,
                        t2.telephone,
                        t2.PASSWORD,
                        t2.gender,
                        t2.image,
                        t2.id_card,
                        t2.STATUS,
                        t2.first_login
涂亚平 committed
89 90
        FROM
            member t2
涂亚平 committed
91 92 93
	    LEFT JOIN member_department_mapping t ON t.member_id = t2.id
	    left join department_dict t3 on t.department_id = t3.id
	    left join company_dict t4 on t3.company_id = t4.id
涂亚平 committed
94 95 96
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
涂亚平 committed
97
            AND t3.company_id = #{companyId}
涂亚平 committed
98 99
            AND t2.id NOT IN (
            SELECT
100
                t3.member_id
涂亚平 committed
101 102 103 104 105
            FROM
                class_member_mapping t3
            WHERE
            t3.delete_date IS NULL
            AND t3.class_id = #{classId})
涂亚平 committed
106 107
    </select>

108 109
    <select id="classMembers" parameterType="long" resultType="com.subsidy.model.MemberDO">
        SELECT
110 111 112 113 114 115 116 117 118 119 120
            	t2.id,
                t2.company_id,
                t2.user_name,
                t2.account_name,
                t2.telephone,
                t2.PASSWORD,
                t2.gender,
                t2.image,
                t2.id_card,
                t2.STATUS,
                t2.first_login
121 122 123 124 125 126 127 128 129
        FROM
            class_member_mapping t
            LEFT JOIN member t2 ON t.member_id = t2.id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t.class_id = #{classId}
    </select>

涂亚平 committed
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
    <select id="getClassBaseInfo" parameterType="long" resultType="com.subsidy.vo.classdict.GetClassBaseInfoVO">
        SELECT
            t3.class_type,
            t2.course_name,
            t.start_date,
            t.end_date,
            ifnull( t4.cnt, 0 ) AS cnt
        FROM
            class_dict t
            LEFT JOIN course_dict t2 ON t.course_id = t2.id
            LEFT JOIN class_type_dict t3 ON t.class_type_id = t3.id
            LEFT JOIN ( SELECT t.class_id, count( 1 ) AS cnt FROM class_member_mapping t WHERE t.delete_date IS NULL AND t.class_id = #{classId} ) t4 ON t.id = t4.class_id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t3.delete_date IS NULL
            AND t.id = #{classId}
    </select>
涂亚平 committed
148
</mapper>