Просмотр исходного кода

1.提交看课记录count统计

jzp 1 месяц назад
Родитель
Сommit
ceecb0c973
1 измененных файлов с 101 добавлено и 0 удалено
  1. 101 0
      fs-service/src/main/resources/mapper/course/FsCourseWatchLogMapper.xml

+ 101 - 0
fs-service/src/main/resources/mapper/course/FsCourseWatchLogMapper.xml

@@ -53,6 +53,107 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectFsCourseWatchLogVo"/>
         where log_id = #{logId}
     </select>
+    <select id="selectFsCourseWatchLogListVO_COUNT" resultType="java.lang.Long">
+        SELECT COUNT(*) AS total
+        FROM fs_course_watch_log l
+        <!-- 动态LEFT JOIN:仅当筛选用到对应表字段时才关联 -->
+        <if test="maps.nickName != null and maps.nickName != ''">
+            LEFT JOIN fs_user u ON u.user_id = l.user_id
+        </if>
+        <if test="maps.companyUserName != null and maps.companyUserName != ''">
+            LEFT JOIN company_user cu ON cu.user_id = l.company_user_id
+        </if>
+        <if test="maps.externalUserName != null and maps.externalUserName != ''
+            or maps.qecSTime != null or maps.qecETime != null">
+            LEFT JOIN qw_external_contact qec ON l.qw_external_contact_id = qec.id
+        </if>
+        <where>
+            <!-- 原筛选条件:仅保留基于主表的条件,关联表条件需判断表是否关联 -->
+            <if test ='maps.isVip != null and maps.isVip == 0'>
+                and (l.user_id = #{maps.isVip} or l.user_id is null)
+            </if>
+            <if test ='maps.isVip != null and maps.isVip == 1'>
+                and l.user_id != 0 and l.user_id is not null
+            </if>
+            <if test ='maps.sendType !=null'>
+                and l.send_type = #{maps.sendType}
+            </if>
+            <if test ='maps.userId !=null'>
+                and l.user_id = #{maps.userId}
+            </if>
+            <if test ='maps.qwExternalContactId !=null'>
+                and l.qw_external_contact_id = #{maps.qwExternalContactId}
+            </if>
+            <if test ='maps.qwUserId !=null'>
+                and l.qw_user_id = #{maps.qwUserId}
+            </if>
+            <if test ='maps.courseId !=null'>
+                and l.course_id = #{maps.courseId}
+            </if>
+            <if test ='maps.videoId !=null'>
+                and l.video_id = #{maps.videoId}
+            </if>
+            <if test ='maps.logType !=null'>
+                and l.log_type = #{maps.logType}
+            </if>
+            <if test ='maps.companyId !=null'>
+                and l.company_id = #{maps.companyId}
+            </if>
+            <if test ='maps.companyUserId !=null'>
+                and l.company_user_id = #{maps.companyUserId}
+            </if>
+            <!-- 关联company_user后才执行该条件 -->
+            <if test="maps.companyUserName !=null and maps.companyUserName!=''">
+                and cu.nick_name like concat('%', #{maps.companyUserName}, '%')
+            </if>
+            <!-- 关联fs_user后才执行该条件 -->
+            <if test="maps.nickName !=null and maps.nickName!=''">
+                and u.nick_name like concat('%', #{maps.nickName}, '%')
+            </if>
+            <!-- 关联qw_external_contact后才执行该类条件 -->
+            <if test="maps.externalUserName !=null and maps.externalUserName!=''">
+                and qec.name like concat('%', #{maps.externalUserName}, '%')
+            </if>
+            <if test='maps.qecSTime != null '>
+                and DATE(qec.create_time) &gt;= DATE(#{maps.qecSTime})
+            </if>
+            <if test='maps.qecETime != null '>
+                and DATE(qec.create_time) &lt;= DATE(#{maps.qecETime})
+            </if>
+            <!-- 主表时间条件 -->
+            <if test='maps.sTime != null '>
+                and DATE(l.create_time) &gt;= DATE(#{maps.sTime})
+            </if>
+            <if test='maps.eTime != null '>
+                and DATE(l.create_time) &lt;= DATE(#{maps.eTime})
+            </if>
+            <if test='maps.scheduleStartTime != null '>
+                and DATE(l.camp_period_time) &gt;= DATE(#{maps.scheduleStartTime})
+            </if>
+            <if test='maps.scheduleEndTime != null '>
+                and DATE(l.camp_period_time) &lt;= DATE(#{maps.scheduleEndTime})
+            </if>
+            <if test='maps.upSTime != null '>
+                and DATE(l.update_time) &gt;= DATE(#{maps.upSTime})
+            </if>
+            <if test='maps.upETime != null '>
+                and DATE(l.update_time) &lt;= DATE(#{maps.upETime})
+            </if>
+            <!-- SOP相关条件 -->
+            <if test="maps.sopIds != null and maps.sopIds.size() > 0">
+                and l.sop_id in
+                <foreach item="sopId" index="index" collection="maps.sopIds" open="(" separator="," close=")">
+                    #{sopId}
+                </foreach>
+            </if>
+            <if test ='maps.project !=null'>
+                and l.project = #{maps.project}
+            </if>
+            <if test="maps.sopId != null  and maps.sopId != '' ">
+                and l.sop_id = #{maps.sopId}
+            </if>
+        </where>
+    </select>
 
     <select id="selectFsCourseWatchLogListVO" resultType="com.fs.course.vo.FsCourseWatchLogListVO">
         select l.log_id,l.user_id,uc.course_name,v.title as video_name,qec.avatar as external_user_avatar,