|
|
|
@ -1,5 +1,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">
|
|
|
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
|
|
<mapper namespace="com.learning.newdemo.mapper.DebateHistoryMapper">
|
|
|
|
|
|
|
|
|
|
<resultMap id="BaseResultMap" type="com.learning.newdemo.entity.DebateHistory">
|
|
|
|
@ -16,8 +17,8 @@
|
|
|
|
|
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
<!-- 包含关联立论记录的结果映射 -->
|
|
|
|
|
<resultMap id="WithArgumentResultMap" type="com.learning.newdemo.entity.DebateHistory" extends="BaseResultMap">
|
|
|
|
|
<resultMap id="WithArgumentResultMap" type="com.learning.newdemo.entity.DebateHistory"
|
|
|
|
|
extends="BaseResultMap">
|
|
|
|
|
<association property="argumentHistory" javaType="com.learning.newdemo.entity.ArgumentHistory">
|
|
|
|
|
<id column="arg_id" property="id"/>
|
|
|
|
|
<result column="arg_user_id" property="userId"/>
|
|
|
|
@ -30,77 +31,41 @@
|
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
<sql id="Base_Column_List">
|
|
|
|
|
id, user_id, argument_id, topic, position, total_rounds, debate_content, review_result, create_time
|
|
|
|
|
id, user_id, argument_id, topic, position, total_rounds,
|
|
|
|
|
debate_content, review_result, create_time
|
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
|
|
<sql id="WithArgument_Column_List">
|
|
|
|
|
dh.id, dh.user_id, dh.argument_id, dh.topic, dh.position, dh.total_rounds,
|
|
|
|
|
dh.debate_content, dh.review_result, dh.create_time,
|
|
|
|
|
dh.id, dh.user_id, dh.argument_id, dh.topic, dh.position,
|
|
|
|
|
dh.total_rounds, dh.debate_content, dh.review_result, dh.create_time,
|
|
|
|
|
ah.id as arg_id, ah.user_id as arg_user_id, ah.topic as arg_topic,
|
|
|
|
|
ah.argument_content as arg_content, ah.position as arg_position,
|
|
|
|
|
ah.create_time as arg_create_time
|
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
|
|
<!-- 插入辩论记录 -->
|
|
|
|
|
<insert id="insert" parameterType="com.learning.newdemo.entity.DebateHistory"
|
|
|
|
|
useGeneratedKeys="true" keyProperty="id">
|
|
|
|
|
INSERT INTO debate_history (
|
|
|
|
|
user_id, argument_id, topic, position, total_rounds, debate_content
|
|
|
|
|
user_id, argument_id, topic, position,
|
|
|
|
|
total_rounds, debate_content, create_time
|
|
|
|
|
) VALUES (
|
|
|
|
|
#{userId}, #{argumentId}, #{topic},
|
|
|
|
|
#{position,typeHandler=org.apache.ibatis.type.EnumTypeHandler},
|
|
|
|
|
#{totalRounds}, #{debateContent}, NOW()
|
|
|
|
|
)
|
|
|
|
|
VALUES (
|
|
|
|
|
#{userId,jdbcType=INTEGER},
|
|
|
|
|
#{argumentId,jdbcType=INTEGER},
|
|
|
|
|
#{topic,jdbcType=VARCHAR},
|
|
|
|
|
#{position,jdbcType=VARCHAR, typeHandler=org.apache.ibatis.type.EnumTypeHandler},
|
|
|
|
|
#{totalRounds,jdbcType=SMALLINT},
|
|
|
|
|
#{debateContent,jdbcType=LONGVARCHAR}
|
|
|
|
|
)
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<!-- 根据用户ID查询 -->
|
|
|
|
|
<select id="selectByUserId" resultMap="BaseResultMap">
|
|
|
|
|
SELECT <include refid="Base_Column_List"/>
|
|
|
|
|
FROM debate_history
|
|
|
|
|
WHERE user_id = #{userId,jdbcType=INTEGER}
|
|
|
|
|
<!-- 清理历史记录(保留最近10条) -->
|
|
|
|
|
<delete id="cleanOverflowHistories">
|
|
|
|
|
DELETE FROM debate_history
|
|
|
|
|
WHERE user_id = #{userId}
|
|
|
|
|
AND id NOT IN (
|
|
|
|
|
SELECT id FROM (
|
|
|
|
|
SELECT id FROM debate_history
|
|
|
|
|
WHERE user_id = #{userId}
|
|
|
|
|
ORDER BY create_time DESC
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 根据用户ID查询最新的i条记录 -->
|
|
|
|
|
<select id="selectLatestByUserId" resultMap="BaseResultMap">
|
|
|
|
|
SELECT <include refid="Base_Column_List"/>
|
|
|
|
|
FROM debate_history
|
|
|
|
|
WHERE user_id = #{userId,jdbcType=INTEGER}
|
|
|
|
|
ORDER BY create_time DESC
|
|
|
|
|
LIMIT #{limit,jdbcType=INTEGER}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 根据立论记录ID查询 -->
|
|
|
|
|
<select id="selectByArgumentId" resultMap="BaseResultMap">
|
|
|
|
|
SELECT <include refid="Base_Column_List"/>
|
|
|
|
|
FROM debate_history
|
|
|
|
|
WHERE argument_id = #{argumentId,jdbcType=INTEGER}
|
|
|
|
|
ORDER BY create_time DESC
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 根据主键查询 -->
|
|
|
|
|
<select id="selectByPrimaryKey" resultMap="BaseResultMap">
|
|
|
|
|
SELECT <include refid="Base_Column_List"/>
|
|
|
|
|
FROM debate_history
|
|
|
|
|
WHERE id = #{id,jdbcType=INTEGER}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 更新复盘分析内容 -->
|
|
|
|
|
<update id="updateReviewResult">
|
|
|
|
|
UPDATE debate_history
|
|
|
|
|
SET review_result = #{reviewResult,jdbcType=LONGVARCHAR}
|
|
|
|
|
WHERE id = #{id,jdbcType=INTEGER}
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<!-- 查询辩论记录及其关联的立论内容 -->
|
|
|
|
|
<select id="selectWithArgument" resultMap="WithArgumentResultMap">
|
|
|
|
|
SELECT <include refid="WithArgument_Column_List"/>
|
|
|
|
|
FROM debate_history dh
|
|
|
|
|
JOIN argument_history ah ON dh.argument_id = ah.id
|
|
|
|
|
WHERE dh.id = #{id,jdbcType=INTEGER}
|
|
|
|
|
</select>
|
|
|
|
|
</mapper>
|
|
|
|
|
LIMIT 10
|
|
|
|
|
) t
|
|
|
|
|
)
|
|
|
|
|
</delete>
|
|
|
|
|
</mapper>
|
|
|
|
|