parent
de19873c67
commit
5e2956da8d
@ -0,0 +1,21 @@
|
|||||||
|
package com.learning.newdemo.entity;
|
||||||
|
|
||||||
|
import com.learning.newdemo.enums.Position;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ArgumentHistory {
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
private Integer userId; // 关联用户ID
|
||||||
|
|
||||||
|
private String topic; // 辩题
|
||||||
|
|
||||||
|
private String argumentContent; // 立论内容
|
||||||
|
|
||||||
|
private Position position; // 用户持方(枚举类型)
|
||||||
|
|
||||||
|
private Date createTime; // 创建时间
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
package com.learning.newdemo.mapper;
|
||||||
|
|
||||||
|
import com.learning.newdemo.entity.DebateHistory;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface DebateHistoryMapper {
|
||||||
|
/**
|
||||||
|
* 插入辩论记录
|
||||||
|
* @param debateHistory 辩论记录
|
||||||
|
* @return 影响行数
|
||||||
|
*/
|
||||||
|
int insert(DebateHistory debateHistory);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户ID查询辩论记录
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 辩论记录列表
|
||||||
|
*/
|
||||||
|
List<DebateHistory> selectByUserId(@Param("userId") Integer userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户ID查询最新的i条辩论记录
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @param limit 记录条数
|
||||||
|
* @return 最新的i条辩论记录
|
||||||
|
*/
|
||||||
|
List<DebateHistory> selectLatestByUserId(@Param("userId") Integer userId, @Param("limit") Integer limit);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据立论记录ID查询辩论记录
|
||||||
|
* @param argumentId 立论记录ID
|
||||||
|
* @return 辩论记录列表
|
||||||
|
*/
|
||||||
|
List<DebateHistory> selectByArgumentId(@Param("argumentId") Integer argumentId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据主键查询辩论记录
|
||||||
|
* @param id 主键ID
|
||||||
|
* @return 辩论记录
|
||||||
|
*/
|
||||||
|
DebateHistory selectByPrimaryKey(@Param("id") Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新复盘分析内容
|
||||||
|
* @param id 辩论记录ID
|
||||||
|
* @param reviewResult 复盘分析内容
|
||||||
|
* @return 影响行数
|
||||||
|
*/
|
||||||
|
int updateReviewResult(@Param("id") Integer id, @Param("reviewResult") String reviewResult);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询辩论记录及其关联的立论内容
|
||||||
|
* @param id 辩论记录ID
|
||||||
|
* @return 包含立论内容的辩论记录
|
||||||
|
*/
|
||||||
|
DebateHistory selectWithArgument(@Param("id") Integer id);
|
||||||
|
}
|
@ -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