parent
dbdd037ed7
commit
4d9b5a2e69
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,89 @@
|
|||||||
|
<?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.learning.newdemo.mapper.ArgumentHistoryMapper">
|
||||||
|
|
||||||
|
<resultMap id="BaseResultMap" type="com.learning.newdemo.entity.ArgumentHistory">
|
||||||
|
<id column="id" property="id" jdbcType="INTEGER"/>
|
||||||
|
<result column="user_id" property="userId" jdbcType="INTEGER"/>
|
||||||
|
<result column="topic" property="topic" jdbcType="VARCHAR"/>
|
||||||
|
<result column="argument_content" property="argumentContent" jdbcType="LONGVARCHAR"/>
|
||||||
|
<result column="position" property="position"
|
||||||
|
typeHandler="org.apache.ibatis.type.EnumTypeHandler"
|
||||||
|
jdbcType="VARCHAR"/>
|
||||||
|
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
id, user_id, topic, argument_content, position, create_time
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<!-- 插入立论记录 -->
|
||||||
|
<insert id="insert" parameterType="com.learning.newdemo.entity.ArgumentHistory"
|
||||||
|
useGeneratedKeys="true" keyProperty="id">
|
||||||
|
INSERT INTO argument_history (
|
||||||
|
user_id, topic, argument_content, position
|
||||||
|
)
|
||||||
|
VALUES (
|
||||||
|
#{userId,jdbcType=INTEGER},
|
||||||
|
#{topic,jdbcType=VARCHAR},
|
||||||
|
#{argumentContent,jdbcType=LONGVARCHAR},
|
||||||
|
#{position,jdbcType=VARCHAR, typeHandler=org.apache.ibatis.type.EnumTypeHandler}
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!-- 根据用户ID查询 -->
|
||||||
|
<select id="selectByUserId" resultMap="BaseResultMap">
|
||||||
|
SELECT <include refid="Base_Column_List"/>
|
||||||
|
FROM argument_history
|
||||||
|
WHERE user_id = #{userId,jdbcType=INTEGER}
|
||||||
|
ORDER BY create_time DESC
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 根据用户ID和持方查询 -->
|
||||||
|
<select id="selectByUserAndPosition" resultMap="BaseResultMap">
|
||||||
|
SELECT <include refid="Base_Column_List"/>
|
||||||
|
FROM argument_history
|
||||||
|
WHERE user_id = #{userId,jdbcType=INTEGER}
|
||||||
|
AND position = #{position,jdbcType=VARCHAR, typeHandler=org.apache.ibatis.type.EnumTypeHandler}
|
||||||
|
ORDER BY create_time DESC
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 根据主键查询 -->
|
||||||
|
<select id="selectByPrimaryKey" resultMap="BaseResultMap">
|
||||||
|
SELECT <include refid="Base_Column_List"/>
|
||||||
|
FROM argument_history
|
||||||
|
WHERE id = #{id,jdbcType=INTEGER}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 获取用户最新立论记录 -->
|
||||||
|
<select id="selectLatestByUserId" resultMap="BaseResultMap">
|
||||||
|
SELECT <include refid="Base_Column_List"/>
|
||||||
|
FROM argument_history
|
||||||
|
WHERE user_id = #{userId,jdbcType=INTEGER}
|
||||||
|
ORDER BY create_time DESC
|
||||||
|
LIMIT 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 根据用户ID查询最新的i条记录 -->
|
||||||
|
<select id="selectLatestByUserIdWithLimit" resultMap="BaseResultMap">
|
||||||
|
SELECT <include refid="Base_Column_List"/>
|
||||||
|
FROM argument_history
|
||||||
|
WHERE user_id = #{userId,jdbcType=INTEGER}
|
||||||
|
ORDER BY create_time DESC
|
||||||
|
LIMIT #{limit,jdbcType=INTEGER}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 根据用户ID和持方查询最新的i条记录 -->
|
||||||
|
<select id="selectLatestByUserAndPositionWithLimit" resultMap="BaseResultMap">
|
||||||
|
SELECT <include refid="Base_Column_List"/>
|
||||||
|
FROM argument_history
|
||||||
|
WHERE user_id = #{userId,jdbcType=INTEGER}
|
||||||
|
<if test="position != null">
|
||||||
|
AND position = #{position,jdbcType=VARCHAR,
|
||||||
|
typeHandler=org.apache.ibatis.type.EnumTypeHandler}
|
||||||
|
</if>
|
||||||
|
ORDER BY create_time DESC
|
||||||
|
LIMIT #{limit,jdbcType=INTEGER}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
@ -0,0 +1,106 @@
|
|||||||
|
<?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.learning.newdemo.mapper.DebateHistoryMapper">
|
||||||
|
|
||||||
|
<resultMap id="BaseResultMap" type="com.learning.newdemo.entity.DebateHistory">
|
||||||
|
<id column="id" property="id" jdbcType="INTEGER"/>
|
||||||
|
<result column="user_id" property="userId" jdbcType="INTEGER"/>
|
||||||
|
<result column="argument_id" property="argumentId" jdbcType="INTEGER"/>
|
||||||
|
<result column="topic" property="topic" jdbcType="VARCHAR"/>
|
||||||
|
<result column="position" property="position"
|
||||||
|
typeHandler="org.apache.ibatis.type.EnumTypeHandler"
|
||||||
|
jdbcType="VARCHAR"/>
|
||||||
|
<result column="total_rounds" property="totalRounds" jdbcType="SMALLINT"/>
|
||||||
|
<result column="debate_content" property="debateContent" jdbcType="LONGVARCHAR"/>
|
||||||
|
<result column="review_result" property="reviewResult" jdbcType="LONGVARCHAR"/>
|
||||||
|
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<!-- 包含关联立论记录的结果映射 -->
|
||||||
|
<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"/>
|
||||||
|
<result column="arg_topic" property="topic"/>
|
||||||
|
<result column="arg_content" property="argumentContent"/>
|
||||||
|
<result column="arg_position" property="position"
|
||||||
|
typeHandler="org.apache.ibatis.type.EnumTypeHandler"/>
|
||||||
|
<result column="arg_create_time" property="createTime"/>
|
||||||
|
</association>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
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,
|
||||||
|
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
|
||||||
|
)
|
||||||
|
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}
|
||||||
|
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>
|
Loading…
Reference in new issue