Blame view

ClassDictMapper.xml 10.7 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
        t5.class_type,
涂亚平 committed
35 36
        t5.id as class_type_id,
        t.class_code
涂亚平 committed
37 38
        FROM
        class_dict t
涂亚平 committed
39
        left join class_type_dict t5 on t.class_type_id = t5.id
涂亚平 committed
40 41 42 43 44 45
        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
46
        and t5.delete_date is null
涂亚平 committed
47 48 49 50
        and t.company_id = #{companyId}
        <if test="className != null and className !=''">
            and t.class_name like concat('%',#{className} ,'%')
        </if>
涂亚平 committed
51
        <if test="startDate != null and endDate != null and startDate != '' and endDate != ''">
涂亚平 committed
52
            and t.end_date >= DATE_FORMAT( #{startDate}, '%Y-%m-%d' )
涂亚平 committed
53
            and t.start_date  &lt; DATE_FORMAT( #{endDate}, '%Y-%m-%d' )
涂亚平 committed
54
        </if>
涂亚平 committed
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
        <if test="openStatus != '' and openStatus == 0">
            and t.end_date >= DATE_FORMAT(now(), '%Y-%m-%d' )
            and t.start_date  &lt; DATE_FORMAT(now(), '%Y-%m-%d' )
        </if>
        <if test="openStatus != '' and openStatus == 1">
            and t.start_date  > DATE_FORMAT(now(), '%Y-%m-%d' )
        </if>
        <if test="openStatus != '' and openStatus == 2">
            and t.end_date &lt; DATE_FORMAT(now(), '%Y-%m-%d' )
        </if>
        <if test="classType == 2">
            and t5.class_type = '社会化、学徒制'
        </if>
        <if test="classType == 0">
            and t5.class_type != '社会化、学徒制'
        </if>
涂亚平 committed
71
        order by t.create_date desc
涂亚平 committed
72 73 74 75 76
    </select>

    <select id="getClassVods" parameterType="long" resultType="com.subsidy.model.VodDictDO">
        SELECT
            t3.*
涂亚平 committed
77 78
        FROM
            class_dict t
涂亚平 committed
79
            LEFT JOIN course_content t2 ON t.course_id = t2.course_id
邓敏 committed
80 81
            LEFT JOIN content_vod_mapping t4 ON t4.content_id = t2.id
            LEFT JOIN vod_dict t3 ON t3.id = t4.vod_id
涂亚平 committed
82 83 84
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
涂亚平 committed
85
            AND t3.delete_date IS NULL
邓敏 committed
86 87 88
            AND t4.delete_date IS NULL
            AND t3.id IS NOT NULL
            AND t.id = #{classId}
涂亚平 committed
89 90 91 92 93
    </select>

    <select id="getSpareMembers" parameterType="com.subsidy.dto.classDict.GetSpareMembersDTO"
            resultType="com.subsidy.model.MemberDO">
       SELECT
94
           distinct 	t2.id,
95
                        t5.company_id,
96 97 98 99 100 101 102 103 104
                        t2.user_name,
                        t2.account_name,
                        t2.telephone,
                        t2.PASSWORD,
                        t2.gender,
                        t2.image,
                        t2.id_card,
                        t2.STATUS,
                        t2.first_login
涂亚平 committed
105 106
        FROM
            member t2
涂亚平 committed
107 108
	    LEFT JOIN member_department_mapping t ON t.member_id = t2.id
	    left join department_dict t3 on t.department_id = t3.id
109 110
        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
涂亚平 committed
111 112 113
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
涂亚平 committed
114
            AND t3.company_id = #{companyId}
涂亚平 committed
115 116
            AND t2.id NOT IN (
            SELECT
117
                t3.member_id
涂亚平 committed
118 119 120 121 122
            FROM
                class_member_mapping t3
            WHERE
            t3.delete_date IS NULL
            AND t3.class_id = #{classId})
涂亚平 committed
123 124 125
             <if test="userName != null and userName !=''">
                and t2.user_name like concat('%',#{userName} ,'%')
            </if>
涂亚平 committed
126 127
    </select>

128 129
    <select id="classMembers" parameterType="long" resultType="com.subsidy.model.MemberDO">
        SELECT
130
            	t2.id,
131
                t5.company_id,
132 133 134 135 136 137 138 139 140
                t2.user_name,
                t2.account_name,
                t2.telephone,
                t2.PASSWORD,
                t2.gender,
                t2.image,
                t2.id_card,
                t2.STATUS,
                t2.first_login
141 142 143
        FROM
            class_member_mapping t
            LEFT JOIN member t2 ON t.member_id = t2.id
144 145
            left join company_member_mapping t5 on t5.member_id = t2.id and t5.member_status = 1
            left join company_dict t6 on t5.company_id = t6.id
146 147 148 149 150 151
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t.class_id = #{classId}
    </select>

涂亚平 committed
152 153 154
    <select id="getClassBaseInfo" parameterType="long" resultType="com.subsidy.vo.classdict.GetClassBaseInfoVO">
        SELECT
            t3.class_type,
涂亚平 committed
155
            t.class_name,
涂亚平 committed
156 157 158
            t2.course_name,
            t.start_date,
            t.end_date,
涂亚平 committed
159 160
            ifnull( t4.cnt, 0 ) AS count,
            t2.id as courseId,
涂亚平 committed
161 162 163
            t3.id as classTypeId,
            t.is_order,
            t.is_fast_play,
涂亚平 committed
164
            t.test_rule,
涂亚平 committed
165
            t2.cover_page,
166 167
            t.class_code,
            t.class_type as rensheClassType
涂亚平 committed
168 169 170 171 172 173 174 175 176 177 178
        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
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196

    <select id="getClassAndCompanyInfoVO" resultType="com.subsidy.vo.classdict.ClassAndCompanyInfoVO">
        SELECT
            cd.company_name AS company,
            cd.short_name AS NAME,
            d.course_name,
            c.start_date,
            c.end_date
        FROM
            class_dict c
            LEFT JOIN company_dict cd ON cd.id = c.company_id
            LEFT JOIN course_dict d ON d.id = c.course_id
        WHERE
            c.id = #{classId}
            AND c.delete_date IS NULL
            AND cd.delete_date IS NULL
            AND d.delete_date IS NULL
    </select>
邓敏 committed
197 198 199 200 201 202 203 204 205 206 207 208

    <select id="getClassCount" resultType="java.lang.Integer">
        SELECT
            count(t1.id)
        FROM
            class_dict t1
            LEFT JOIN course_dict t2 ON t2.id = t1.course_id
        WHERE
            t2.course_type = "补贴培训"
          AND t1.delete_date IS NULL
          AND t2.delete_date IS NULL
    </select>
邓敏 committed
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224

    <select id="getClassSettings" resultType="com.subsidy.vo.classdict.ClassSettingsVO">
        SELECT
            t1.*,
            t3.ip_address_record,
            t3.device_no_record
        FROM
            class_dict t1
            LEFT JOIN class_member_mapping t2 ON t2.class_id = t1.id
            LEFT JOIN company_dict t3 ON t3.id = t1.company_id
        WHERE
            t2.member_id = #{userId}
          AND t1.delete_date IS NULL
          AND t2.delete_date IS NULL
          AND t3.delete_date IS NULL
    </select>
涂亚平 committed
225 226 227

    <select id="getCompanySettings" parameterType="long" resultType="com.subsidy.vo.classdict.SystemSettings">
        SELECT
涂亚平 committed
228
            t2.id,
涂亚平 committed
229 230 231 232 233 234 235 236 237 238 239 240
            t2.time_limit,
            t2.ip_address_record,
            t2.device_no_record
        FROM
            class_dict t
            LEFT JOIN company_dict t2 ON t.company_id = t2.id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t.id = #{classId}
    </select>

涂亚平 committed
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
    <select id="getAllCertClasses" resultType="com.subsidy.vo.classdict.GetAllClassesVO">
        SELECT
        t.id,
        t2.id as courseId,
        t.class_name,
        t2.course_name,
        t.start_date,
        t.end_date,
        t4.cnt,
        t5.class_type,
        t5.id as class_type_id
        FROM
        class_dict t
        left join class_type_dict t5 on t.class_type_id = t5.id
        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
        and t5.delete_date is null
        and t5.id = 0
        <if test="className != null and className !=''">
            and t.class_name like concat('%',#{className} ,'%')
        </if>
        <if test="startDate != null and endDate != null and startDate != '' and endDate != ''">
            and t.end_date >= DATE_FORMAT( #{startDate}, '%Y-%m-%d' )
            and t.start_date  &lt; DATE_FORMAT( #{endDate}, '%Y-%m-%d' )
        </if>
        order by t.create_date desc
    </select>

涂亚平 committed
273 274 275 276 277 278
    <select id="dailyClassInfo" resultType="long">
        SELECT DISTINCT
            t1.class_id
        FROM
            vod_play_history t1
        WHERE
279
            DATE_FORMAT( DATE_ADD( t1.create_date,interval 1 day), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' )
涂亚平 committed
280 281 282
            AND t1.delete_date IS NULL
    </select>

涂亚平 committed
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
    <select id="classVods" parameterType="long" resultType="com.subsidy.vo.vod.VodInfoVO">
        SELECT
            t4.id,
            t4.vod_name
        FROM
            class_dict t
            LEFT JOIN course_content t2 ON t.course_id = t2.course_id
            LEFT JOIN content_vod_mapping t3 ON t2.id = t3.content_id
            LEFT JOIN vod_dict t4 ON t3.vod_id = t4.id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t3.delete_date IS NULL
            AND t4.delete_date IS NULL
            AND t.id = #{classId}
            order by t2.id,t4.id
    </select>

涂亚平 committed
301
</mapper>