Compare commits
16 Commits
Author | SHA1 | Date |
---|---|---|
|
edde0bf3ed | 2 months ago |
|
0379bf5114 | 2 months ago |
|
c4db02796b | 2 months ago |
|
df8586446e | 2 months ago |
|
d3e4ae3688 | 2 months ago |
|
76c895033e | 2 months ago |
|
a89d6bb9ec | 2 months ago |
|
3a814e1214 | 2 months ago |
|
7f65bab280 | 2 months ago |
|
cc63675e71 | 2 months ago |
|
14f6b2d661 | 2 months ago |
|
6fae2e87af | 2 months ago |
|
da3f1638c6 | 2 months ago |
|
4c614647e9 | 2 months ago |
|
da100df835 | 2 months ago |
|
16dccb1f00 | 2 months ago |
@ -0,0 +1,23 @@
|
||||
package com.learning.newdemo.Dto;
|
||||
|
||||
import com.learning.newdemo.entity.WxArgument;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class ArgumentDetailDTO {
|
||||
private Integer id;
|
||||
private String userMessage;
|
||||
private String content;
|
||||
private Integer sequence;
|
||||
private Date createTime;
|
||||
|
||||
public ArgumentDetailDTO(WxArgument wxArgument) {
|
||||
this.id = wxArgument.getId();
|
||||
this.userMessage = wxArgument.getUserMessage();
|
||||
this.content = wxArgument.getContent();
|
||||
this.sequence = wxArgument.getSequence();
|
||||
this.createTime = wxArgument.getCreateTime();
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.learning.newdemo.Dto;
|
||||
|
||||
import com.learning.newdemo.entity.WxConversation;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class ConversationDTO {
|
||||
private Long id;
|
||||
private String type; // "debate"/"argument"/"review"
|
||||
private String title;
|
||||
private String preview; // AI回复的前10个字符
|
||||
private Date updateTime;
|
||||
|
||||
public ConversationDTO(WxConversation wxConversation) {
|
||||
this.id = wxConversation.getId();
|
||||
this.type = wxConversation.getType();
|
||||
this.title = wxConversation.getTitle();
|
||||
this.preview = wxConversation.getPreview();
|
||||
this.updateTime = wxConversation.getUpdateTime();
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.learning.newdemo.Dto;
|
||||
|
||||
import com.learning.newdemo.entity.WxDebate;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class DebateDetailDTO {
|
||||
private Long id;
|
||||
private String userMessage;
|
||||
private String content;
|
||||
private Integer sequence;
|
||||
private Date createTime;
|
||||
|
||||
public DebateDetailDTO(WxDebate wxDebate) {
|
||||
this.id = wxDebate.getId();
|
||||
this.userMessage = wxDebate.getUserMessage();
|
||||
this.content = wxDebate.getContent();
|
||||
this.sequence = wxDebate.getSequence();
|
||||
this.createTime = wxDebate.getCreateTime();
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.learning.newdemo.Dto;
|
||||
|
||||
import com.learning.newdemo.entity.WxReview;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class ReviewDetailDTO {
|
||||
private Long id;
|
||||
private String userMessage; // 用户消息
|
||||
private String content; // AI回复内容
|
||||
private Integer sequence; // 消息序号
|
||||
private Date createTime;
|
||||
|
||||
public ReviewDetailDTO(WxReview wxReview) {
|
||||
this.id = wxReview.getId();
|
||||
this.userMessage = wxReview.getUserMessage();
|
||||
this.content = wxReview.getContent();
|
||||
this.sequence = wxReview.getSequence();
|
||||
this.createTime = wxReview.getCreateTime();
|
||||
}
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
package com.learning.newdemo.controller;
|
||||
|
||||
|
||||
import com.learning.newdemo.Dto.ArgumentDetailDTO;
|
||||
import com.learning.newdemo.Dto.ConversationDTO;
|
||||
import com.learning.newdemo.Dto.DebateDetailDTO;
|
||||
import com.learning.newdemo.Dto.ReviewDetailDTO;
|
||||
import com.learning.newdemo.common.Result;
|
||||
import com.learning.newdemo.entity.WxArgument;
|
||||
import com.learning.newdemo.entity.WxConversation;
|
||||
import com.learning.newdemo.entity.WxDebate;
|
||||
import com.learning.newdemo.entity.WxReview;
|
||||
import com.learning.newdemo.mapper.WxArgumentMapper;
|
||||
import com.learning.newdemo.mapper.WxConversationMapper;
|
||||
import com.learning.newdemo.mapper.WxDebateMapper;
|
||||
import com.learning.newdemo.mapper.WxReviewMapper;
|
||||
import com.learning.newdemo.util.JwtUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("api/conversation")
|
||||
public class WxConversationController {
|
||||
private final WxConversationMapper wxConversationMapper;
|
||||
private final WxDebateMapper wxDebateMapper;
|
||||
private final WxArgumentMapper wxArgumentMapper;
|
||||
private final WxReviewMapper wxReviewMapper;
|
||||
private final JwtUtil jwtUtil;
|
||||
|
||||
public WxConversationController(WxConversationMapper wxConversationMapper, WxDebateMapper wxDebateMapper, WxArgumentMapper wxArgumentMapper, WxReviewMapper wxReviewMapper, JwtUtil jwtUtil) {
|
||||
this.wxConversationMapper = wxConversationMapper;
|
||||
this.wxDebateMapper = wxDebateMapper;
|
||||
this.wxArgumentMapper = wxArgumentMapper;
|
||||
this.wxReviewMapper = wxReviewMapper;
|
||||
this.jwtUtil = jwtUtil;
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
public Result<List<ConversationDTO>> getConversationList(@RequestHeader("Authorization") String token){
|
||||
log.info("test111:",token);
|
||||
try{
|
||||
int userId = jwtUtil.getUserIdFromToken(token);
|
||||
|
||||
List<WxConversation> conversations = wxConversationMapper.selectByUserId(userId);
|
||||
|
||||
List<ConversationDTO> result = conversations.stream()
|
||||
.map(conv -> new ConversationDTO(
|
||||
conv))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return Result.success(result);
|
||||
} catch (Exception e){
|
||||
log.error("获取对话失败");
|
||||
return Result.error("获取对话失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping( "/debate/{conversation}")
|
||||
public Result<List<DebateDetailDTO>> getDebate(@PathVariable("conversation") Long conversationId) {
|
||||
try{
|
||||
|
||||
List<WxDebate> wxDebates = wxDebateMapper.selectByConversationId(conversationId);
|
||||
|
||||
List<DebateDetailDTO> debateDetailDTOS = wxDebates.stream().map(DebateDetailDTO::new).collect(Collectors.toList());
|
||||
|
||||
return Result.success(debateDetailDTOS);
|
||||
} catch (Exception e) {
|
||||
log.error("获取辩论失败", e);
|
||||
return Result.error("获取辩论失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/argument/{conversationId}")
|
||||
public Result<List<ArgumentDetailDTO>> getArgument(@PathVariable Long conversationId) {
|
||||
try {
|
||||
List <WxArgument> wxArguments = wxArgumentMapper.selectByConversationId(conversationId);
|
||||
|
||||
List <ArgumentDetailDTO> argumentDetailDTOS = wxArguments.stream().map(ArgumentDetailDTO::new).collect(Collectors.toList());
|
||||
|
||||
return Result.success(argumentDetailDTOS);
|
||||
} catch ( Exception e) {
|
||||
log.error("获取立论失败", e);
|
||||
return Result.error("获取立论失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/review/{conversationId}")
|
||||
public Result<List<ReviewDetailDTO>> getReview(@PathVariable Long conversationId) {
|
||||
try {
|
||||
List<WxReview> wxReviews = wxReviewMapper.selectByConversationId(conversationId);
|
||||
|
||||
List<ReviewDetailDTO> reviewDetailDTOS = wxReviews.stream().map(ReviewDetailDTO::new).collect(Collectors.toList());
|
||||
|
||||
return Result.success(reviewDetailDTOS);
|
||||
} catch ( Exception e){
|
||||
log.error("获取评论失败", e);
|
||||
return Result.error("获取评论失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.learning.newdemo.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class WxConversation {
|
||||
private Long id;
|
||||
private int userId;
|
||||
private String type;
|
||||
private String title;
|
||||
private String preview;
|
||||
private Date createTime;
|
||||
private Date updateTime;
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.learning.newdemo.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class WxDebate {
|
||||
private Long id;
|
||||
private Long conversationId;
|
||||
private String content;
|
||||
private String userMessage;
|
||||
private Integer sequence;
|
||||
private Date createTime;
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.learning.newdemo.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class WxReview {
|
||||
private Long id;
|
||||
private Long conversationId; // 关联的对话活动ID
|
||||
private String content; // AI回复内容
|
||||
private String userMessage; // 用户消息
|
||||
private Integer sequence; // 消息序号
|
||||
private Date createTime;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.learning.newdemo.mapper;
|
||||
|
||||
import com.learning.newdemo.entity.WxArgument;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface WxArgumentMapper {
|
||||
List<WxArgument> selectByConversationId(long conversationId);
|
||||
int insert(WxArgument wxArgument);
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.learning.newdemo.mapper;
|
||||
|
||||
import com.learning.newdemo.entity.WxConversation;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface WxConversationMapper {
|
||||
List<WxConversation> selectByUserId(Integer userId);
|
||||
int insert(WxConversation wxConversation);
|
||||
int updatePreview(Long conversationId, String preview);
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.learning.newdemo.mapper;
|
||||
|
||||
import com.learning.newdemo.entity.WxDebate;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface WxDebateMapper {
|
||||
List<WxDebate> selectByConversationId(Long conversationId);
|
||||
int insert(WxDebate wxDebate);
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.learning.newdemo.mapper;
|
||||
|
||||
import com.learning.newdemo.entity.WxReview;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface WxReviewMapper {
|
||||
List<WxReview> selectByConversationId(Long conversationId);
|
||||
int insert(WxReview wxReview);
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.learning.newdemo.service;
|
||||
|
||||
public interface WxDebateService {
|
||||
String GetDebate(String history, String userMessage);
|
||||
String GetDebate(Long conversationId, String userMessage);
|
||||
long UpdateDebate(Long conversationId, String content, String userMessage, String token);
|
||||
}
|
||||
|
@ -1,22 +0,0 @@
|
||||
-- 创建数据库
|
||||
CREATE DATABASE IF NOT EXISTS wx_miniapp DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
|
||||
-- 使用数据库
|
||||
USE wx_miniapp;
|
||||
|
||||
-- 创建微信用户表
|
||||
CREATE TABLE IF NOT EXISTS `wx_user` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`openid` varchar(100) NOT NULL COMMENT '微信openid',
|
||||
`nickname` varchar(50) DEFAULT NULL COMMENT '昵称',
|
||||
`avatar_url` varchar(500) DEFAULT NULL COMMENT '头像URL',
|
||||
`gender` tinyint(4) DEFAULT NULL COMMENT '性别 0-未知 1-男 2-女',
|
||||
`country` varchar(50) DEFAULT NULL COMMENT '国家',
|
||||
`province` varchar(50) DEFAULT NULL COMMENT '省份',
|
||||
`city` varchar(50) DEFAULT NULL COMMENT '城市',
|
||||
`language` varchar(50) DEFAULT NULL COMMENT '语言',
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_openid` (`openid`) COMMENT 'openid唯一索引'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='微信用户表';
|
@ -0,0 +1,45 @@
|
||||
<?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.WxArgumentMapper">
|
||||
<!-- 基础结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="com.learning.newdemo.entity.WxArgument">
|
||||
<id column="id" property="id" jdbcType="BIGINT"/>
|
||||
<result column="conversation_id" property="conversationId" jdbcType="BIGINT"/>
|
||||
<result column="topic" property="topic" jdbcType="VARCHAR"/>
|
||||
<result column="stance" property="stance" jdbcType="VARCHAR"/>
|
||||
<result column="content" property="content" jdbcType="LONGVARCHAR"/>
|
||||
<result column="user_message" property="userMessage" jdbcType="LONGVARCHAR"/>
|
||||
<result column="sequence" property="sequence" jdbcType="INTEGER"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 可复用的列名列表 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, conversation_id, topic, stance, content, user_message, sequence, create_time
|
||||
</sql>
|
||||
|
||||
<!-- 按 conversationId 查询并按 sequence 排序 -->
|
||||
<select id="selectByConversationId" resultMap="BaseResultMap" parameterType="java.lang.Long">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM wx_argument_record
|
||||
WHERE conversation_id = #{conversationId,jdbcType=BIGINT}
|
||||
ORDER BY sequence
|
||||
</select>
|
||||
|
||||
<!-- 插入新记录 -->
|
||||
<insert id="insert" parameterType="com.learning.newdemo.entity.WxArgument" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO wx_argument_record (
|
||||
conversation_id, topic, stance, content, user_message, sequence, create_time
|
||||
)
|
||||
VALUES (
|
||||
#{conversationId,jdbcType=BIGINT},
|
||||
#{topic,jdbcType=VARCHAR},
|
||||
#{stance,jdbcType=VARCHAR},
|
||||
#{content,jdbcType=LONGVARCHAR},
|
||||
#{userMessage,jdbcType=LONGVARCHAR},
|
||||
#{sequence,jdbcType=INTEGER},
|
||||
#{createTime,jdbcType=TIMESTAMP}
|
||||
)
|
||||
</insert>
|
||||
</mapper>
|
@ -0,0 +1,49 @@
|
||||
<?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.WxConversationMapper">
|
||||
|
||||
<!-- 基础结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="com.learning.newdemo.entity.WxConversation">
|
||||
<id column="id" property="id" jdbcType="BIGINT"/>
|
||||
<result column="user_id" property="userId" jdbcType="BIGINT"/>
|
||||
<result column="type" property="type" jdbcType="VARCHAR"/>
|
||||
<result column="title" property="title" jdbcType="VARCHAR"/>
|
||||
<result column="preview" property="preview" jdbcType="VARCHAR"/>
|
||||
<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, type, title, preview, create_time, update_time
|
||||
</sql>
|
||||
|
||||
<!-- 按用户ID和类型查询对话活动 (用于接口4.1) -->
|
||||
<select id="selectByUserId" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM wx_conversation
|
||||
WHERE user_id = #{userId}
|
||||
ORDER BY update_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 插入新对话活动 (用于接口3.1/3.2/3.3) -->
|
||||
<insert id="insert" parameterType="com.learning.newdemo.entity.WxConversation"
|
||||
useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO wx_conversation (
|
||||
user_id, type, title, preview, create_time, update_time
|
||||
)
|
||||
VALUES (
|
||||
#{userId}, #{type}, #{title}, #{preview}, #{createTime}, #{updateTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 更新对话预览信息 (用于更新最后一次AI回复的预览) -->
|
||||
<update id="updatePreview">
|
||||
UPDATE wx_conversation
|
||||
SET
|
||||
preview = #{preview},
|
||||
update_time = NOW()
|
||||
WHERE id = #{conversationId}
|
||||
</update>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,38 @@
|
||||
<?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.WxDebateMapper">
|
||||
<resultMap id="BaseResultMap" type="com.learning.newdemo.entity.WxDebate">
|
||||
<id column="id" property="id" jdbcType="BIGINT"/>
|
||||
<result column="conversation_id" property="conversationId" jdbcType="BIGINT"/>
|
||||
<result column="content" property="content" jdbcType="LONGVARCHAR"/>
|
||||
<result column="user_message" property="userMessage" jdbcType="LONGVARCHAR"/>
|
||||
<result column="sequence" property="sequence" jdbcType="INTEGER"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id, conversation_id, content, user_message, sequence, create_time
|
||||
</sql>
|
||||
|
||||
<select id="selectByConversationId" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from wx_debate_record
|
||||
where conversation_id = #{conversationId}
|
||||
ORDER BY sequence
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="com.learning.newdemo.entity.WxDebate"
|
||||
useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO wx_debate_record (
|
||||
conversation_id, content, user_message, sequence, create_time
|
||||
)
|
||||
VALUES (
|
||||
#{conversationId,jdbcType=BIGINT},
|
||||
#{content,jdbcType=LONGNVARCHAR},
|
||||
#{userMessage,jdbcType=LONGNVARCHAR},
|
||||
#{sequence,jdbcType=INTEGER},
|
||||
#{createTime, jdbcType=TIMESTAMP}
|
||||
)
|
||||
</insert>
|
||||
</mapper>
|
@ -0,0 +1,38 @@
|
||||
<?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.WxReviewMapper">
|
||||
<resultMap id="BaseResultMap" type="com.learning.newdemo.entity.WxReview">
|
||||
<id column="id" property="id" jdbcType="BIGINT"/>
|
||||
<result column="conversation_id" property="conversationId" jdbcType="BIGINT"/>
|
||||
<result column="content" property="content" jdbcType="LONGVARCHAR"/>
|
||||
<result column="user_message" property="userMessage" jdbcType="LONGVARCHAR"/>
|
||||
<result column="sequence" property="sequence" jdbcType="INTEGER"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id, conversation_id, content, user_message, sequence, create_time
|
||||
</sql>
|
||||
|
||||
<select id="selectByConversationId" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from wx_review_record
|
||||
where conversation_id = #{conversationId}
|
||||
ORDER BY sequence
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="com.learning.newdemo.entity.WxDebate"
|
||||
useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO wx_review_record (
|
||||
conversation_id, content, user_message, sequence, create_time
|
||||
)
|
||||
VALUES (
|
||||
#{conversationId,jdbcType=BIGINT},
|
||||
#{content,jdbcType=LONGNVARCHAR},
|
||||
#{userMessage,jdbcType=LONGNVARCHAR},
|
||||
#{sequence,jdbcType=INTEGER},
|
||||
#{createTime, jdbcType=TIMESTAMP}
|
||||
)
|
||||
</insert>
|
||||
</mapper>
|
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.
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.
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.
@ -1,22 +0,0 @@
|
||||
-- 创建数据库
|
||||
CREATE DATABASE IF NOT EXISTS wx_miniapp DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
|
||||
-- 使用数据库
|
||||
USE wx_miniapp;
|
||||
|
||||
-- 创建微信用户表
|
||||
CREATE TABLE IF NOT EXISTS `wx_user` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`openid` varchar(100) NOT NULL COMMENT '微信openid',
|
||||
`nickname` varchar(50) DEFAULT NULL COMMENT '昵称',
|
||||
`avatar_url` varchar(500) DEFAULT NULL COMMENT '头像URL',
|
||||
`gender` tinyint(4) DEFAULT NULL COMMENT '性别 0-未知 1-男 2-女',
|
||||
`country` varchar(50) DEFAULT NULL COMMENT '国家',
|
||||
`province` varchar(50) DEFAULT NULL COMMENT '省份',
|
||||
`city` varchar(50) DEFAULT NULL COMMENT '城市',
|
||||
`language` varchar(50) DEFAULT NULL COMMENT '语言',
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_openid` (`openid`) COMMENT 'openid唯一索引'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='微信用户表';
|
@ -0,0 +1,45 @@
|
||||
<?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.WxArgumentMapper">
|
||||
<!-- 基础结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="com.learning.newdemo.entity.WxArgument">
|
||||
<id column="id" property="id" jdbcType="BIGINT"/>
|
||||
<result column="conversation_id" property="conversationId" jdbcType="BIGINT"/>
|
||||
<result column="topic" property="topic" jdbcType="VARCHAR"/>
|
||||
<result column="stance" property="stance" jdbcType="VARCHAR"/>
|
||||
<result column="content" property="content" jdbcType="LONGVARCHAR"/>
|
||||
<result column="user_message" property="userMessage" jdbcType="LONGVARCHAR"/>
|
||||
<result column="sequence" property="sequence" jdbcType="INTEGER"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 可复用的列名列表 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, conversation_id, topic, stance, content, user_message, sequence, create_time
|
||||
</sql>
|
||||
|
||||
<!-- 按 conversationId 查询并按 sequence 排序 -->
|
||||
<select id="selectByConversationId" resultMap="BaseResultMap" parameterType="java.lang.Long">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM wx_argument_record
|
||||
WHERE conversation_id = #{conversationId,jdbcType=BIGINT}
|
||||
ORDER BY sequence
|
||||
</select>
|
||||
|
||||
<!-- 插入新记录 -->
|
||||
<insert id="insert" parameterType="com.learning.newdemo.entity.WxArgument" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO wx_argument_record (
|
||||
conversation_id, topic, stance, content, user_message, sequence, create_time
|
||||
)
|
||||
VALUES (
|
||||
#{conversationId,jdbcType=BIGINT},
|
||||
#{topic,jdbcType=VARCHAR},
|
||||
#{stance,jdbcType=VARCHAR},
|
||||
#{content,jdbcType=LONGVARCHAR},
|
||||
#{userMessage,jdbcType=LONGVARCHAR},
|
||||
#{sequence,jdbcType=INTEGER},
|
||||
#{createTime,jdbcType=TIMESTAMP}
|
||||
)
|
||||
</insert>
|
||||
</mapper>
|
@ -0,0 +1,49 @@
|
||||
<?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.WxConversationMapper">
|
||||
|
||||
<!-- 基础结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="com.learning.newdemo.entity.WxConversation">
|
||||
<id column="id" property="id" jdbcType="BIGINT"/>
|
||||
<result column="user_id" property="userId" jdbcType="BIGINT"/>
|
||||
<result column="type" property="type" jdbcType="VARCHAR"/>
|
||||
<result column="title" property="title" jdbcType="VARCHAR"/>
|
||||
<result column="preview" property="preview" jdbcType="VARCHAR"/>
|
||||
<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, type, title, preview, create_time, update_time
|
||||
</sql>
|
||||
|
||||
<!-- 按用户ID和类型查询对话活动 (用于接口4.1) -->
|
||||
<select id="selectByUserId" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM wx_conversation
|
||||
WHERE user_id = #{userId}
|
||||
ORDER BY update_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 插入新对话活动 (用于接口3.1/3.2/3.3) -->
|
||||
<insert id="insert" parameterType="com.learning.newdemo.entity.WxConversation"
|
||||
useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO wx_conversation (
|
||||
user_id, type, title, preview, create_time, update_time
|
||||
)
|
||||
VALUES (
|
||||
#{userId}, #{type}, #{title}, #{preview}, #{createTime}, #{updateTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 更新对话预览信息 (用于更新最后一次AI回复的预览) -->
|
||||
<update id="updatePreview">
|
||||
UPDATE wx_conversation
|
||||
SET
|
||||
preview = #{preview},
|
||||
update_time = NOW()
|
||||
WHERE id = #{conversationId}
|
||||
</update>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,38 @@
|
||||
<?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.WxDebateMapper">
|
||||
<resultMap id="BaseResultMap" type="com.learning.newdemo.entity.WxDebate">
|
||||
<id column="id" property="id" jdbcType="BIGINT"/>
|
||||
<result column="conversation_id" property="conversationId" jdbcType="BIGINT"/>
|
||||
<result column="content" property="content" jdbcType="LONGVARCHAR"/>
|
||||
<result column="user_message" property="userMessage" jdbcType="LONGVARCHAR"/>
|
||||
<result column="sequence" property="sequence" jdbcType="INTEGER"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id, conversation_id, content, user_message, sequence, create_time
|
||||
</sql>
|
||||
|
||||
<select id="selectByConversationId" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from wx_debate_record
|
||||
where conversation_id = #{conversationId}
|
||||
ORDER BY sequence
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="com.learning.newdemo.entity.WxDebate"
|
||||
useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO wx_debate_record (
|
||||
conversation_id, content, user_message, sequence, create_time
|
||||
)
|
||||
VALUES (
|
||||
#{conversationId,jdbcType=BIGINT},
|
||||
#{content,jdbcType=LONGNVARCHAR},
|
||||
#{userMessage,jdbcType=LONGNVARCHAR},
|
||||
#{sequence,jdbcType=INTEGER},
|
||||
#{createTime, jdbcType=TIMESTAMP}
|
||||
)
|
||||
</insert>
|
||||
</mapper>
|
@ -0,0 +1,38 @@
|
||||
<?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.WxReviewMapper">
|
||||
<resultMap id="BaseResultMap" type="com.learning.newdemo.entity.WxReview">
|
||||
<id column="id" property="id" jdbcType="BIGINT"/>
|
||||
<result column="conversation_id" property="conversationId" jdbcType="BIGINT"/>
|
||||
<result column="content" property="content" jdbcType="LONGVARCHAR"/>
|
||||
<result column="user_message" property="userMessage" jdbcType="LONGVARCHAR"/>
|
||||
<result column="sequence" property="sequence" jdbcType="INTEGER"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id, conversation_id, content, user_message, sequence, create_time
|
||||
</sql>
|
||||
|
||||
<select id="selectByConversationId" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from wx_review_record
|
||||
where conversation_id = #{conversationId}
|
||||
ORDER BY sequence
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="com.learning.newdemo.entity.WxDebate"
|
||||
useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO wx_review_record (
|
||||
conversation_id, content, user_message, sequence, create_time
|
||||
)
|
||||
VALUES (
|
||||
#{conversationId,jdbcType=BIGINT},
|
||||
#{content,jdbcType=LONGNVARCHAR},
|
||||
#{userMessage,jdbcType=LONGNVARCHAR},
|
||||
#{sequence,jdbcType=INTEGER},
|
||||
#{createTime, jdbcType=TIMESTAMP}
|
||||
)
|
||||
</insert>
|
||||
</mapper>
|
@ -1,58 +1,58 @@
|
||||
<?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.WxUserMapper">
|
||||
<resultMap id="BaseResultMap" type="com.learning.newdemo.entity.WxUser">
|
||||
<id column="id" property="id" jdbcType="INTEGER"/>
|
||||
<result column="openid" property="openid" jdbcType="VARCHAR"/>
|
||||
<result column="nickname" property="nickname" jdbcType="VARCHAR"/>
|
||||
<result column="avatar_url" property="avatarUrl" jdbcType="VARCHAR"/>
|
||||
<result column="gender" property="gender" jdbcType="INTEGER"/>
|
||||
<result column="country" property="country" jdbcType="VARCHAR"/>
|
||||
<result column="province" property="province" jdbcType="VARCHAR"/>
|
||||
<result column="city" property="city" jdbcType="VARCHAR"/>
|
||||
<result column="language" property="language" jdbcType="VARCHAR"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id, openid, nickname, avatar_url, gender, country, province, city, language, create_time, update_time
|
||||
</sql>
|
||||
|
||||
<select id="selectByOpenid" resultMap="BaseResultMap" parameterType="java.lang.String">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from wx_user
|
||||
where openid = #{openid,jdbcType=VARCHAR}
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="com.learning.newdemo.entity.WxUser" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into wx_user (
|
||||
openid, nickname, avatar_url, gender, country, province, city, language, create_time
|
||||
)
|
||||
values (
|
||||
#{openid,jdbcType=VARCHAR},
|
||||
#{nickname,jdbcType=VARCHAR},
|
||||
#{avatarUrl,jdbcType=VARCHAR},
|
||||
#{gender,jdbcType=INTEGER},
|
||||
#{country,jdbcType=VARCHAR},
|
||||
#{province,jdbcType=VARCHAR},
|
||||
#{city,jdbcType=VARCHAR},
|
||||
#{language,jdbcType=VARCHAR},
|
||||
now()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateByPrimaryKey" parameterType="com.learning.newdemo.entity.WxUser">
|
||||
update wx_user
|
||||
set nickname = #{nickname,jdbcType=VARCHAR},
|
||||
avatar_url = #{avatarUrl,jdbcType=VARCHAR},
|
||||
gender = #{gender,jdbcType=INTEGER},
|
||||
country = #{country,jdbcType=VARCHAR},
|
||||
province = #{province,jdbcType=VARCHAR},
|
||||
city = #{city,jdbcType=VARCHAR},
|
||||
language = #{language,jdbcType=VARCHAR},
|
||||
update_time = now()
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
<?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.WxUserMapper">
|
||||
<resultMap id="BaseResultMap" type="com.learning.newdemo.entity.WxUser">
|
||||
<id column="id" property="id" jdbcType="INTEGER"/>
|
||||
<result column="openid" property="openid" jdbcType="VARCHAR"/>
|
||||
<result column="nickname" property="nickname" jdbcType="VARCHAR"/>
|
||||
<result column="avatar_url" property="avatarUrl" jdbcType="VARCHAR"/>
|
||||
<result column="gender" property="gender" jdbcType="INTEGER"/>
|
||||
<result column="country" property="country" jdbcType="VARCHAR"/>
|
||||
<result column="province" property="province" jdbcType="VARCHAR"/>
|
||||
<result column="city" property="city" jdbcType="VARCHAR"/>
|
||||
<result column="language" property="language" jdbcType="VARCHAR"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id, openid, nickname, avatar_url, gender, country, province, city, language, create_time, update_time
|
||||
</sql>
|
||||
|
||||
<select id="selectByOpenid" resultMap="BaseResultMap" parameterType="java.lang.String">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from wx_user
|
||||
where openid = #{openid,jdbcType=VARCHAR}
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="com.learning.newdemo.entity.WxUser" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into wx_user (
|
||||
openid, nickname, avatar_url, gender, country, province, city, language, create_time
|
||||
)
|
||||
values (
|
||||
#{openid,jdbcType=VARCHAR},
|
||||
#{nickname,jdbcType=VARCHAR},
|
||||
#{avatarUrl,jdbcType=VARCHAR},
|
||||
#{gender,jdbcType=INTEGER},
|
||||
#{country,jdbcType=VARCHAR},
|
||||
#{province,jdbcType=VARCHAR},
|
||||
#{city,jdbcType=VARCHAR},
|
||||
#{language,jdbcType=VARCHAR},
|
||||
now()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateByPrimaryKey" parameterType="com.learning.newdemo.entity.WxUser">
|
||||
update wx_user
|
||||
set nickname = #{nickname,jdbcType=VARCHAR},
|
||||
avatar_url = #{avatarUrl,jdbcType=VARCHAR},
|
||||
gender = #{gender,jdbcType=INTEGER},
|
||||
country = #{country,jdbcType=VARCHAR},
|
||||
province = #{province,jdbcType=VARCHAR},
|
||||
city = #{city,jdbcType=VARCHAR},
|
||||
language = #{language,jdbcType=VARCHAR},
|
||||
update_time = now()
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
</mapper>
|
File diff suppressed because it is too large
Load Diff
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 6.8 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 3.8 KiB |
@ -1,13 +1,27 @@
|
||||
// stores/argumentStore.ts
|
||||
import { defineStore } from 'pinia'
|
||||
import { defineStore } from "pinia";
|
||||
|
||||
export const useArgumentStore = defineStore('argument', {
|
||||
export const useArgumentStore = defineStore("argument", {
|
||||
state: () => ({
|
||||
selectedArgument: null
|
||||
conversationId: -1,
|
||||
selectedArgument: "",
|
||||
conversation: [
|
||||
{
|
||||
role: "ai",
|
||||
content:
|
||||
"哈喽~ 我是辩论助手,很高兴为你服务!请告诉我你想立论的立场和题目。",
|
||||
},
|
||||
],
|
||||
}),
|
||||
actions: {
|
||||
setArgument(arg) {
|
||||
this.selectedArgument = arg
|
||||
}
|
||||
}
|
||||
})
|
||||
this.selectedArgument = arg;
|
||||
},
|
||||
setConversationId(id) {
|
||||
this.conversationId = id;
|
||||
},
|
||||
setConversation(conversation) {
|
||||
this.conversation = conversation;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
@ -0,0 +1,23 @@
|
||||
// stores/argumentStore.ts
|
||||
import { defineStore } from "pinia";
|
||||
|
||||
export const useReviewStore = defineStore("review", {
|
||||
state: () => ({
|
||||
conversationId: -1,
|
||||
conversation: [
|
||||
{
|
||||
role: "ai",
|
||||
content:
|
||||
"哈喽~ 我是辩论助手,很高兴为你服务!请告诉我你想立论的立场和题目。",
|
||||
},
|
||||
],
|
||||
}),
|
||||
actions: {
|
||||
setConversationId(id) {
|
||||
this.conversationId = id;
|
||||
},
|
||||
setConversation(conversation) {
|
||||
this.conversation = conversation;
|
||||
},
|
||||
},
|
||||
});
|
@ -0,0 +1,15 @@
|
||||
// stores/DebateStore.ts
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export const useTokenStore = defineStore('token', {
|
||||
state: () => ({
|
||||
token: {
|
||||
content: '',
|
||||
},
|
||||
}),
|
||||
actions: {
|
||||
setToken(content) {
|
||||
this.token.content = content;
|
||||
}
|
||||
}
|
||||
});
|
@ -1,19 +0,0 @@
|
||||
create database if not exists wx_miniapp default charset utf8mb4;
|
||||
|
||||
use wx_miniapp;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `wx_user` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`openid` varchar(100) NOT NULL COMMENT '微信openid',
|
||||
`nickname` varchar(50) DEFAULT NULL COMMENT '昵称',
|
||||
`avatar_url` varchar(500) DEFAULT NULL COMMENT '头像URL',
|
||||
`gender` tinyint(4) DEFAULT NULL COMMENT '性别 0-未知 1-男 2-女',
|
||||
`country` varchar(50) DEFAULT NULL COMMENT '国家',
|
||||
`province` varchar(50) DEFAULT NULL COMMENT '省份',
|
||||
`city` varchar(50) DEFAULT NULL COMMENT '城市',
|
||||
`language` varchar(50) DEFAULT NULL COMMENT '语言',
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_openid` (`openid`) COMMENT 'openid唯一索引'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='微信用户表';
|
Loading…
Reference in new issue