|
|
@@ -0,0 +1,102 @@
|
|
|
+<?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.fs.course.mapper.FsPublicCourseTrafficLogMapper">
|
|
|
+
|
|
|
+ <resultMap type="com.fs.course.domain.FsPublicCourseTrafficLog" id="FsPublicCourseTrafficLogResult">
|
|
|
+ <result property="logId" column="log_id"/>
|
|
|
+ <result property="uuId" column="uu_id"/>
|
|
|
+ <result property="userId" column="user_id"/>
|
|
|
+ <result property="courseId" column="course_id"/>
|
|
|
+ <result property="videoId" column="video_id"/>
|
|
|
+ <result property="internetTraffic" column="internet_traffic"/>
|
|
|
+ <result property="status" column="status"/>
|
|
|
+ <result property="createTime" column="create_time"/>
|
|
|
+ <result property="project_id" column="projectId"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <sql id="selectFsPublicCourseTrafficLogVo">
|
|
|
+ select log_id,
|
|
|
+ uu_id,
|
|
|
+ user_id,
|
|
|
+ course_id,
|
|
|
+ video_id,
|
|
|
+ company_id,
|
|
|
+ internet_traffic,
|
|
|
+ status,
|
|
|
+ create_time,
|
|
|
+ project_id
|
|
|
+ from fs_public_course_traffic_log
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <select id="selectFsPublicCourseTrafficLogByLogId" parameterType="Long" resultMap="FsPublicCourseTrafficLogResult">
|
|
|
+ <include refid="selectFsPublicCourseTrafficLogVo"/>
|
|
|
+ where log_id = #{logId}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <insert id="insertFsPublicCourseTrafficLog" parameterType="com.fs.course.domain.FsPublicCourseTrafficLog"
|
|
|
+ useGeneratedKeys="true" keyProperty="logId">
|
|
|
+ insert into fs_public_course_traffic_log
|
|
|
+ <trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="uuId != null">uu_id,</if>
|
|
|
+ <if test="userId != null">user_id,</if>
|
|
|
+ <if test="courseId != null">course_id,</if>
|
|
|
+ <if test="videoId != null">video_id,</if>
|
|
|
+ <if test="internetTraffic != null">internet_traffic,</if>
|
|
|
+ <if test="status != null">status,</if>
|
|
|
+ create_time,
|
|
|
+ <if test="projectId != null">project_id,</if>
|
|
|
+ </trim>
|
|
|
+ <trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="uuId != null">#{uuId},</if>
|
|
|
+ <if test="userId != null">#{userId},</if>
|
|
|
+ <if test="courseId != null">#{courseId},</if>
|
|
|
+ <if test="videoId != null">#{videoId},</if>
|
|
|
+ <if test="internetTraffic != null">#{internetTraffic},</if>
|
|
|
+ <if test="status != null">#{status},</if>
|
|
|
+ sysdate(),
|
|
|
+ <if test="projectId != null">#{projectId},</if>
|
|
|
+ </trim>
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <update id="updateFsPublicCourseTrafficLog" parameterType="com.fs.course.domain.FsPublicCourseTrafficLog">
|
|
|
+ update fs_public_course_traffic_log
|
|
|
+ <trim prefix="SET" suffixOverrides=",">
|
|
|
+ <if test="uuId != null">uu_id = #{uuId},</if>
|
|
|
+ <if test="userId != null">user_id = #{userId},</if>
|
|
|
+ <if test="courseId != null">course_id = #{courseId},</if>
|
|
|
+ <if test="videoId != null">video_id = #{videoId},</if>
|
|
|
+ <if test="internetTraffic != null">internet_traffic = #{internetTraffic},</if>
|
|
|
+ <if test="status != null">status = #{status},</if>
|
|
|
+ </trim>
|
|
|
+ where log_id = #{logId}
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <insert id="insertOrUpdateTrafficLog" parameterType="com.fs.course.domain.FsPublicCourseTrafficLog">
|
|
|
+ insert into fs_public_course_traffic_log (uu_id, user_id, course_id, video_id,
|
|
|
+ internet_traffic, status, create_time, project_id)
|
|
|
+ values (#{uuId}, #{userId}, #{courseId}, #{videoId}, #{internetTraffic}, #{status}, sysdate(),
|
|
|
+ #{projectId}) ON DUPLICATE KEY
|
|
|
+ UPDATE
|
|
|
+ internet_traffic = internet_traffic + #{internetTraffic}
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <select id="selectTrafficNew" resultType="com.fs.course.vo.FsCourseTrafficLogListVO">
|
|
|
+ select
|
|
|
+ log.course_id,
|
|
|
+ SUM(log.internet_traffic) AS total_internet_traffic,
|
|
|
+ DATE_FORMAT(log.create_time, '%Y-%m-%d') AS `month`
|
|
|
+ FROM fs_public_course_traffic_log log
|
|
|
+ <where>
|
|
|
+ <if test="startDate != null and endDate != null">
|
|
|
+ and DATE_FORMAT(log.create_time, '%Y-%m-%d') between #{startDate} AND #{endDate}
|
|
|
+ </if>
|
|
|
+ <if test="courseId != null">
|
|
|
+ and log.course_id = ${courseId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ group by log.course_id,`month`
|
|
|
+ </select>
|
|
|
+
|
|
|
+</mapper>
|