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 | 3 months ago |
|
7f65bab280 | 3 months ago |
|
cc63675e71 | 3 months ago |
|
14f6b2d661 | 3 months ago |
|
6fae2e87af | 3 months ago |
|
da3f1638c6 | 3 months ago |
|
4c614647e9 | 3 months ago |
|
da100df835 | 3 months ago |
|
16dccb1f00 | 3 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();
|
||||||
|
}
|
||||||
|
}
|
@ -1,37 +0,0 @@
|
|||||||
package com.learning.newdemo.controller;
|
|
||||||
|
|
||||||
import com.learning.newdemo.common.Result;
|
|
||||||
import com.learning.newdemo.entity.DebateHistory;
|
|
||||||
import com.learning.newdemo.service.DebateHistoryService;
|
|
||||||
import com.learning.newdemo.util.JwtUtil;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/api/debate-history")
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class DebateHistoryController {
|
|
||||||
|
|
||||||
private final DebateHistoryService historyService;
|
|
||||||
private final JwtUtil jwtUtil;
|
|
||||||
|
|
||||||
@PostMapping
|
|
||||||
public Result<?> saveHistory(@RequestBody DebateHistory history,
|
|
||||||
@RequestHeader("Authorization") String token) {
|
|
||||||
Integer userId = jwtUtil.getUserIdFromToken(token);
|
|
||||||
if (userId == null) {
|
|
||||||
return Result.error(401, "无效的认证令牌");
|
|
||||||
}
|
|
||||||
history.setUserId(userId);
|
|
||||||
historyService.saveDebateHistory(history);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping
|
|
||||||
public Result<List<DebateHistory>> getHistories(@RequestHeader("Authorization") String token) {
|
|
||||||
Integer userId = jwtUtil.getUserIdFromToken(token);
|
|
||||||
return Result.success(historyService.getHistoriesByUser(userId));
|
|
||||||
}
|
|
||||||
}
|
|
@ -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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,21 +0,0 @@
|
|||||||
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,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,9 +0,0 @@
|
|||||||
package com.learning.newdemo.service;
|
|
||||||
|
|
||||||
import com.learning.newdemo.entity.DebateHistory;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface DebateHistoryService {
|
|
||||||
void saveDebateHistory(DebateHistory history);
|
|
||||||
List<DebateHistory> getHistoriesByUser(Integer userId);
|
|
||||||
}
|
|
@ -1,9 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
package com.learning.newdemo.service;
|
package com.learning.newdemo.service;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public interface WxDebateService {
|
public interface WxDebateService {
|
||||||
Map<String, Object> GetDebate(String history, String userMessage, int currentRound, int maxRounds);
|
String GetDebate(Long conversationId, String userMessage);
|
||||||
}
|
long UpdateDebate(Long conversationId, String content, String userMessage, String token);
|
||||||
|
}
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
// DebateHistoryServiceImpl.java
|
|
||||||
package com.learning.newdemo.service.impl;
|
|
||||||
|
|
||||||
import com.learning.newdemo.entity.DebateHistory;
|
|
||||||
import com.learning.newdemo.mapper.DebateHistoryMapper;
|
|
||||||
import com.learning.newdemo.service.DebateHistoryService;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
@Transactional
|
|
||||||
public class DebateHistoryServiceImpl implements DebateHistoryService {
|
|
||||||
|
|
||||||
private final DebateHistoryMapper historyMapper;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void saveDebateHistory(DebateHistory history) {
|
|
||||||
historyMapper.insert(history);
|
|
||||||
// 清理超出10条的旧记录
|
|
||||||
historyMapper.cleanOverflowHistories(history.getUserId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<DebateHistory> getHistoriesByUser(Integer userId) {
|
|
||||||
return historyMapper.selectLatestByUserId(userId, 10);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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='微信用户表';
|
|
@ -1,89 +0,0 @@
|
|||||||
<?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,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.
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='微信用户表';
|
|
@ -1,89 +0,0 @@
|
|||||||
<?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,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" ?>
|
<?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.WxUserMapper">
|
<mapper namespace="com.learning.newdemo.mapper.WxUserMapper">
|
||||||
<resultMap id="BaseResultMap" type="com.learning.newdemo.entity.WxUser">
|
<resultMap id="BaseResultMap" type="com.learning.newdemo.entity.WxUser">
|
||||||
<id column="id" property="id" jdbcType="INTEGER"/>
|
<id column="id" property="id" jdbcType="INTEGER"/>
|
||||||
<result column="openid" property="openid" jdbcType="VARCHAR"/>
|
<result column="openid" property="openid" jdbcType="VARCHAR"/>
|
||||||
<result column="nickname" property="nickname" jdbcType="VARCHAR"/>
|
<result column="nickname" property="nickname" jdbcType="VARCHAR"/>
|
||||||
<result column="avatar_url" property="avatarUrl" jdbcType="VARCHAR"/>
|
<result column="avatar_url" property="avatarUrl" jdbcType="VARCHAR"/>
|
||||||
<result column="gender" property="gender" jdbcType="INTEGER"/>
|
<result column="gender" property="gender" jdbcType="INTEGER"/>
|
||||||
<result column="country" property="country" jdbcType="VARCHAR"/>
|
<result column="country" property="country" jdbcType="VARCHAR"/>
|
||||||
<result column="province" property="province" jdbcType="VARCHAR"/>
|
<result column="province" property="province" jdbcType="VARCHAR"/>
|
||||||
<result column="city" property="city" jdbcType="VARCHAR"/>
|
<result column="city" property="city" jdbcType="VARCHAR"/>
|
||||||
<result column="language" property="language" jdbcType="VARCHAR"/>
|
<result column="language" property="language" jdbcType="VARCHAR"/>
|
||||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id, openid, nickname, avatar_url, gender, country, province, city, language, create_time, update_time
|
id, openid, nickname, avatar_url, gender, country, province, city, language, create_time, update_time
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectByOpenid" resultMap="BaseResultMap" parameterType="java.lang.String">
|
<select id="selectByOpenid" resultMap="BaseResultMap" parameterType="java.lang.String">
|
||||||
select
|
select
|
||||||
<include refid="Base_Column_List"/>
|
<include refid="Base_Column_List"/>
|
||||||
from wx_user
|
from wx_user
|
||||||
where openid = #{openid,jdbcType=VARCHAR}
|
where openid = #{openid,jdbcType=VARCHAR}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insert" parameterType="com.learning.newdemo.entity.WxUser" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insert" parameterType="com.learning.newdemo.entity.WxUser" useGeneratedKeys="true" keyProperty="id">
|
||||||
insert into wx_user (
|
insert into wx_user (
|
||||||
openid, nickname, avatar_url, gender, country, province, city, language, create_time
|
openid, nickname, avatar_url, gender, country, province, city, language, create_time
|
||||||
)
|
)
|
||||||
values (
|
values (
|
||||||
#{openid,jdbcType=VARCHAR},
|
#{openid,jdbcType=VARCHAR},
|
||||||
#{nickname,jdbcType=VARCHAR},
|
#{nickname,jdbcType=VARCHAR},
|
||||||
#{avatarUrl,jdbcType=VARCHAR},
|
#{avatarUrl,jdbcType=VARCHAR},
|
||||||
#{gender,jdbcType=INTEGER},
|
#{gender,jdbcType=INTEGER},
|
||||||
#{country,jdbcType=VARCHAR},
|
#{country,jdbcType=VARCHAR},
|
||||||
#{province,jdbcType=VARCHAR},
|
#{province,jdbcType=VARCHAR},
|
||||||
#{city,jdbcType=VARCHAR},
|
#{city,jdbcType=VARCHAR},
|
||||||
#{language,jdbcType=VARCHAR},
|
#{language,jdbcType=VARCHAR},
|
||||||
now()
|
now()
|
||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<update id="updateByPrimaryKey" parameterType="com.learning.newdemo.entity.WxUser">
|
<update id="updateByPrimaryKey" parameterType="com.learning.newdemo.entity.WxUser">
|
||||||
update wx_user
|
update wx_user
|
||||||
set nickname = #{nickname,jdbcType=VARCHAR},
|
set nickname = #{nickname,jdbcType=VARCHAR},
|
||||||
avatar_url = #{avatarUrl,jdbcType=VARCHAR},
|
avatar_url = #{avatarUrl,jdbcType=VARCHAR},
|
||||||
gender = #{gender,jdbcType=INTEGER},
|
gender = #{gender,jdbcType=INTEGER},
|
||||||
country = #{country,jdbcType=VARCHAR},
|
country = #{country,jdbcType=VARCHAR},
|
||||||
province = #{province,jdbcType=VARCHAR},
|
province = #{province,jdbcType=VARCHAR},
|
||||||
city = #{city,jdbcType=VARCHAR},
|
city = #{city,jdbcType=VARCHAR},
|
||||||
language = #{language,jdbcType=VARCHAR},
|
language = #{language,jdbcType=VARCHAR},
|
||||||
update_time = now()
|
update_time = now()
|
||||||
where id = #{id,jdbcType=INTEGER}
|
where id = #{id,jdbcType=INTEGER}
|
||||||
</update>
|
</update>
|
||||||
</mapper>
|
</mapper>
|
File diff suppressed because it is too large
Load Diff
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 |
@ -1,13 +1,27 @@
|
|||||||
// stores/argumentStore.ts
|
// stores/argumentStore.ts
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from "pinia";
|
||||||
|
|
||||||
export const useArgumentStore = defineStore('argument', {
|
export const useArgumentStore = defineStore("argument", {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
selectedArgument: null
|
conversationId: -1,
|
||||||
|
selectedArgument: "",
|
||||||
|
conversation: [
|
||||||
|
{
|
||||||
|
role: "ai",
|
||||||
|
content:
|
||||||
|
"哈喽~ 我是辩论助手,很高兴为你服务!请告诉我你想立论的立场和题目。",
|
||||||
|
},
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
setArgument(arg) {
|
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,34 +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='微信用户表';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `debate_history` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`user_id` int(11) NOT NULL COMMENT '关联用户ID',
|
|
||||||
`topic` varchar(255) NOT NULL COMMENT '辩题',
|
|
||||||
`stance` enum('正方','反方') NOT NULL COMMENT '持方',
|
|
||||||
`content` text COMMENT '辩论内容JSON',
|
|
||||||
`review` text COMMENT 'AI复盘内容',
|
|
||||||
`rounds` smallint(6) DEFAULT 0 COMMENT '辩论轮数',
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `idx_user_time` (`user_id`, `create_time`),
|
|
||||||
CONSTRAINT `fk_user_history` FOREIGN KEY (`user_id`) REFERENCES `wx_user` (`id`) ON DELETE CASCADE
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='辩论历史记录表';
|
|
@ -1,31 +0,0 @@
|
|||||||
#-------------------------------------------------------------------------------#
|
|
||||||
# Qodana analysis is configured by qodana.yaml file #
|
|
||||||
# https://www.jetbrains.com/help/qodana/qodana-yaml.html #
|
|
||||||
#-------------------------------------------------------------------------------#
|
|
||||||
version: "1.0"
|
|
||||||
|
|
||||||
#Specify inspection profile for code analysis
|
|
||||||
profile:
|
|
||||||
name: qodana.starter
|
|
||||||
|
|
||||||
#Enable inspections
|
|
||||||
#include:
|
|
||||||
# - name: <SomeEnabledInspectionId>
|
|
||||||
|
|
||||||
#Disable inspections
|
|
||||||
#exclude:
|
|
||||||
# - name: <SomeDisabledInspectionId>
|
|
||||||
# paths:
|
|
||||||
# - <path/where/not/run/inspection>
|
|
||||||
|
|
||||||
projectJDK: 17 #(Applied in CI/CD pipeline)
|
|
||||||
|
|
||||||
#Execute shell command before Qodana execution (Applied in CI/CD pipeline)
|
|
||||||
#bootstrap: sh ./prepare-qodana.sh
|
|
||||||
|
|
||||||
#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline)
|
|
||||||
#plugins:
|
|
||||||
# - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com)
|
|
||||||
|
|
||||||
#Specify Qodana linter for analysis (Applied in CI/CD pipeline)
|
|
||||||
linter: jetbrains/qodana-jvm-community:latest
|
|
Loading…
Reference in new issue