Files
schoolNews/schoolNewsServ/study/src/main/resources/mapper/LearningStatisticsMapper.xml
2025-10-15 13:11:19 +08:00

46 lines
1.8 KiB
XML

<?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="org.xyzh.study.mapper.LearningStatisticsMapper">
<!-- 基础结果映射 -->
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.study.TbLearningStatistics">
<id column="id" property="id" jdbcType="VARCHAR"/>
<result column="user_id" property="userID" jdbcType="VARCHAR"/>
<result column="stat_date" property="statDate" jdbcType="DATE"/>
<result column="total_duration" property="totalDuration" jdbcType="INTEGER"/>
<result column="resource_count" property="resourceCount" jdbcType="INTEGER"/>
<result column="course_count" property="courseCount" jdbcType="INTEGER"/>
<result column="complete_count" property="completeCount" jdbcType="INTEGER"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
</resultMap>
<!-- 基础字段 -->
<sql id="Base_Column_List">
id, user_id, stat_date, total_duration, resource_count, course_count,
complete_count, create_time, update_time
</sql>
<!-- 通用条件 -->
<sql id="Where_Clause">
<where>
<if test="userID != null and userID != ''">
AND user_id = #{userID}
</if>
<if test="statDate != null">
AND stat_date = #{statDate}
</if>
</where>
</sql>
<!-- selectLearningStatistics -->
<select id="selectLearningStatistics" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM tb_learning_statistics
<include refid="Where_Clause"/>
ORDER BY stat_date DESC
</select>
</mapper>