Forráskód Böngészése

管理端初始化

Zhangbw 2 hónapja
szülő
commit
0565c29237

+ 5 - 0
ruoyi-admin/src/main/resources/application.yml

@@ -268,3 +268,8 @@ xfyun:
     appid: 0b53c170
     api-key: 3915b5e04c7e118fea615889a1c94794
     api-secret: ZTZjZmU3YzczMjdmNmQwMTc0ZDU3OTEw
+
+spring:
+  web:
+    resources:
+      static-locations: file:uploads/

+ 1 - 1
ruoyi-modules/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm

@@ -99,7 +99,7 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service {
 #end
 #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
 #if($column.isPk==1)
-        lqw.orderByAsc(${ClassName}::get$AttrName);
+        lqw.orderByDesc(${ClassName}::get$AttrName);
 #end
 #end
         return lqw;

+ 24 - 0
ruoyi-modules/yp-talk/pom.xml

@@ -50,6 +50,30 @@
             <artifactId>lombok</artifactId>
             <scope>provided</scope>
         </dependency>
+        <dependency>
+            <groupId>org.dromara</groupId>
+            <artifactId>ruoyi-common-idempotent</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.dromara</groupId>
+            <artifactId>ruoyi-common-log</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.dromara</groupId>
+            <artifactId>ruoyi-common-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.dromara</groupId>
+            <artifactId>ruoyi-common-mybatis</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.dromara</groupId>
+            <artifactId>ruoyi-common-excel</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.dromara</groupId>
+            <artifactId>ruoyi-common-tenant</artifactId>
+        </dependency>
     </dependencies>
 
 </project>

+ 0 - 90
ruoyi-modules/yp-talk/src/main/java/org/dromara/talk/controller/ChatController.java

@@ -1,90 +0,0 @@
-package org.dromara.talk.controller;
-
-import cn.dev33.satoken.annotation.SaIgnore;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.dromara.talk.service.ITtsService;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import java.util.concurrent.CompletableFuture;
-
-@Slf4j
-@RequiredArgsConstructor
-@RestController
-@RequestMapping("/talk")
-@CrossOrigin(origins = "*", maxAge = 3600)
-public class ChatController {
-
-    private final ITtsService ttsService;
-
-    @SaIgnore
-    @PostMapping("/message")
-    public Map<String, Object> handleMessage(@RequestBody Map<String, Object> request) {
-        String userMessage = (String) request.get("message");
-        Long agentId = request.get("agentId") != null ?
-            Long.valueOf(request.get("agentId").toString()) : null;
-
-        log.info("收到用户消息: {}, 客服ID: {}", userMessage, agentId);
-
-        // 生成客服回复(后期接入AI)
-        String reply = generateReply(userMessage);
-
-        // 异步合成语音
-        CompletableFuture<String> audioFuture = new CompletableFuture<>();
-
-        ttsService.synthesize(reply, new ITtsService.AudioCallback() {
-            private final java.io.ByteArrayOutputStream audioBytes = new java.io.ByteArrayOutputStream();
-
-            @Override
-            public void onAudio(String base64Audio, int status) {
-                log.info("收到音频数据: status={}, 数据长度={}", status, base64Audio != null ? base64Audio.length() : 0);
-                try {
-                    // 先解码base64为字节,然后写入流
-                    byte[] decoded = java.util.Base64.getDecoder().decode(base64Audio);
-                    audioBytes.write(decoded);
-                    log.info("已写入字节数: {}", decoded.length);
-                } catch (Exception e) {
-                    log.error("解码音频数据失败", e);
-                }
-                if (status == 2) {
-                    // 将完整的字节数组重新编码为base64
-                    String finalBase64 = java.util.Base64.getEncoder().encodeToString(audioBytes.toByteArray());
-                    log.info("音频合成完成,原始字节数={}, base64长度={}", audioBytes.size(), finalBase64.length());
-                    audioFuture.complete(finalBase64);
-                }
-            }
-
-            @Override
-            public void onError(int code, String message) {
-                log.error("TTS合成失败: {}", message);
-                audioFuture.complete(null);
-            }
-        });
-
-        // 等待音频合成完成(最多10秒)
-        String audioBase64 = null;
-        try {
-            audioBase64 = audioFuture.get(10, java.util.concurrent.TimeUnit.SECONDS);
-        } catch (Exception e) {
-            log.error("等待音频合成超时", e);
-        }
-
-        // 返回响应
-        Map<String, Object> response = new HashMap<>();
-        response.put("reply", reply);
-        response.put("audio", audioBase64);
-        response.put("timestamp", System.currentTimeMillis());
-
-        log.info("准备返回响应: reply长度={}, audio长度={}", reply != null ? reply.length() : 0, audioBase64 != null ? audioBase64.length() : 0);
-
-        return response;
-    }
-
-    private String generateReply(String userMessage) {
-        // 默认回复(后期接入AI)
-        return "收到您的消息:" + userMessage;
-    }
-}

+ 97 - 0
ruoyi-modules/yp-talk/src/main/java/org/dromara/talk/domain/TalkAgent.java

@@ -0,0 +1,97 @@
+package org.dromara.talk.domain;
+
+import org.dromara.common.tenant.core.TenantEntity;
+import com.baomidou.mybatisplus.annotation.*;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serial;
+
+/**
+ * 客服配置对象 talk_agent
+ *
+ * @author Lion Li
+ * @date 2026-01-27
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@TableName("talk_agent")
+public class TalkAgent extends TenantEntity {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 客服ID
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 客服名称
+     */
+    private String name;
+
+    /**
+     * 性别(0=男 1=女)
+     */
+    private String gender;
+
+    /**
+     * 头像URL
+     */
+    private String avatarUrl;
+
+    /**
+     * 客服描述
+     */
+    private String description;
+
+    /**
+     * 欢迎语
+     */
+    private String greetingMessage;
+
+    /**
+     * 状态(0=正常 1=停用)
+     */
+    private String status;
+
+    /**
+     * TTS发音人(字典)
+     */
+    private String ttsVcn;
+
+    /**
+     * TTS语速 0-100
+     */
+    private Long ttsSpeed;
+
+    /**
+     * TTS音调 0-100
+     */
+    private Long ttsPitch;
+
+    /**
+     * TTS音量 0-100
+     */
+    private Long ttsVolume;
+
+    /**
+     * TTS背景音开关 0=无背景音 1=有背景音
+     */
+    private Long ttsBgs;
+
+    /**
+     * AI回复语言(字典)
+     */
+    private String language;
+
+    /**
+     * 删除标志(0=存在 1=删除)
+     */
+    @TableLogic
+    private String delFlag;
+
+
+}

+ 93 - 0
ruoyi-modules/yp-talk/src/main/java/org/dromara/talk/domain/TalkSession.java

@@ -0,0 +1,93 @@
+package org.dromara.talk.domain;
+
+import org.dromara.common.tenant.core.TenantEntity;
+import com.baomidou.mybatisplus.annotation.*;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import java.util.Date;
+
+import java.io.Serial;
+
+/**
+ * 对话会话对象 talk_session
+ *
+ * @author Lion Li
+ * @date 2026-01-27
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@TableName("talk_session")
+public class TalkSession extends TenantEntity {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 会话ID
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 会话唯一标识
+     */
+    private String sessionId;
+
+    /**
+     * 客服ID
+     */
+    private Long agentId;
+
+    /**
+     * 客户电话
+     */
+    private String customerPhone;
+
+    /**
+     * 对话详细数据
+     */
+    private String conversationJson;
+
+    /**
+     * 消息总数
+     */
+    private Long messageCount;
+
+    /**
+     * 用户消息数
+     */
+    private Long userMessageCount;
+
+    /**
+     * 客服消息数
+     */
+    private Long agentMessageCount;
+
+    /**
+     * 对话时长(秒)
+     */
+    private Long duration;
+
+    /**
+     * 会话状态(0=进行中 1=已结束)
+     */
+    private String status;
+
+    /**
+     * 会话开始时间
+     */
+    private Date startTime;
+
+    /**
+     * 会话结束时间
+     */
+    private Date endTime;
+
+    /**
+     * 删除标志
+     */
+    @TableLogic
+    private String delFlag;
+
+
+}

+ 92 - 0
ruoyi-modules/yp-talk/src/main/java/org/dromara/talk/domain/bo/TalkAgentBo.java

@@ -0,0 +1,92 @@
+package org.dromara.talk.domain.bo;
+
+import org.dromara.talk.domain.TalkAgent;
+import org.dromara.common.mybatis.core.domain.BaseEntity;
+import org.dromara.common.core.validate.AddGroup;
+import org.dromara.common.core.validate.EditGroup;
+import io.github.linpeilie.annotations.AutoMapper;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import jakarta.validation.constraints.*;
+
+/**
+ * 客服配置业务对象 talk_agent
+ *
+ * @author Lion Li
+ * @date 2026-01-27
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@AutoMapper(target = TalkAgent.class, reverseConvertGenerate = false)
+public class TalkAgentBo extends BaseEntity {
+
+    /**
+     * 客服ID
+     */
+    @NotNull(message = "客服ID不能为空", groups = { EditGroup.class })
+    private Long id;
+
+    /**
+     * 客服名称
+     */
+    @NotBlank(message = "客服名称不能为空", groups = { AddGroup.class, EditGroup.class })
+    private String name;
+
+    /**
+     * 性别(0=男 1=女)
+     */
+    @NotBlank(message = "性别(0=男 1=女)不能为空", groups = { AddGroup.class, EditGroup.class })
+    private String gender;
+
+    /**
+     * 头像URL
+     */
+    private String avatarUrl;
+
+    /**
+     * 客服描述
+     */
+    private String description;
+
+    /**
+     * 欢迎语
+     */
+    private String greetingMessage;
+
+    /**
+     * 状态(0=正常 1=停用)
+     */
+    private String status;
+
+    /**
+     * TTS发音人(字典)
+     */
+    private String ttsVcn;
+
+    /**
+     * TTS语速 0-100
+     */
+    private Long ttsSpeed;
+
+    /**
+     * TTS音调 0-100
+     */
+    private Long ttsPitch;
+
+    /**
+     * TTS音量 0-100
+     */
+    private Long ttsVolume;
+
+    /**
+     * TTS背景音开关 0=无背景音 1=有背景音
+     */
+    private Long ttsBgs;
+
+    /**
+     * AI回复语言(字典)
+     */
+    private String language;
+
+
+}

+ 88 - 0
ruoyi-modules/yp-talk/src/main/java/org/dromara/talk/domain/bo/TalkSessionBo.java

@@ -0,0 +1,88 @@
+package org.dromara.talk.domain.bo;
+
+import org.dromara.talk.domain.TalkSession;
+import org.dromara.common.mybatis.core.domain.BaseEntity;
+import org.dromara.common.core.validate.AddGroup;
+import org.dromara.common.core.validate.EditGroup;
+import io.github.linpeilie.annotations.AutoMapper;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import jakarta.validation.constraints.*;
+import java.util.Date;
+
+/**
+ * 对话会话业务对象 talk_session
+ *
+ * @author Lion Li
+ * @date 2026-01-27
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@AutoMapper(target = TalkSession.class, reverseConvertGenerate = false)
+public class TalkSessionBo extends BaseEntity {
+
+    /**
+     * 会话ID
+     */
+    @NotNull(message = "会话ID不能为空", groups = { EditGroup.class })
+    private Long id;
+
+    /**
+     * 会话唯一标识
+     */
+    @NotBlank(message = "会话唯一标识不能为空", groups = { AddGroup.class, EditGroup.class })
+    private String sessionId;
+
+    /**
+     * 客服ID
+     */
+    @NotNull(message = "客服ID不能为空", groups = { AddGroup.class, EditGroup.class })
+    private Long agentId;
+
+    /**
+     * 客户电话
+     */
+    private String customerPhone;
+
+    /**
+     * 对话详细数据
+     */
+    private String conversationJson;
+
+    /**
+     * 消息总数
+     */
+    private Long messageCount;
+
+    /**
+     * 用户消息数
+     */
+    private Long userMessageCount;
+
+    /**
+     * 客服消息数
+     */
+    private Long agentMessageCount;
+
+    /**
+     * 对话时长(秒)
+     */
+    private Long duration;
+
+    /**
+     * 会话状态(0=进行中 1=已结束)
+     */
+    private String status;
+
+    /**
+     * 会话开始时间
+     */
+    private Date startTime;
+
+    /**
+     * 会话结束时间
+     */
+    private Date endTime;
+
+
+}

+ 112 - 0
ruoyi-modules/yp-talk/src/main/java/org/dromara/talk/domain/vo/TalkAgentVo.java

@@ -0,0 +1,112 @@
+package org.dromara.talk.domain.vo;
+
+import org.dromara.talk.domain.TalkAgent;
+import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
+import cn.idev.excel.annotation.ExcelProperty;
+import org.dromara.common.excel.annotation.ExcelDictFormat;
+import org.dromara.common.excel.convert.ExcelDictConvert;
+import io.github.linpeilie.annotations.AutoMapper;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+
+/**
+ * 客服配置视图对象 talk_agent
+ *
+ * @author Lion Li
+ * @date 2026-01-27
+ */
+@Data
+@ExcelIgnoreUnannotated
+@AutoMapper(target = TalkAgent.class)
+public class TalkAgentVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 客服ID
+     */
+    @ExcelProperty(value = "客服ID")
+    private Long id;
+
+    /**
+     * 客服名称
+     */
+    @ExcelProperty(value = "客服名称")
+    private String name;
+
+    /**
+     * 性别(0=男 1=女)
+     */
+    @ExcelProperty(value = "性别", converter = ExcelDictConvert.class)
+    @ExcelDictFormat(readConverterExp = "0==男,1==女")
+    private String gender;
+
+    /**
+     * 头像URL
+     */
+    @ExcelProperty(value = "头像URL")
+    private String avatarUrl;
+
+    /**
+     * 客服描述
+     */
+    @ExcelProperty(value = "客服描述")
+    private String description;
+
+    /**
+     * 欢迎语
+     */
+    @ExcelProperty(value = "欢迎语")
+    private String greetingMessage;
+
+    /**
+     * 状态(0=正常 1=停用)
+     */
+    @ExcelProperty(value = "状态", converter = ExcelDictConvert.class)
+    @ExcelDictFormat(readConverterExp = "0==正常,1==停用")
+    private String status;
+
+    /**
+     * TTS发音人(字典)
+     */
+    @ExcelProperty(value = "TTS发音人", converter = ExcelDictConvert.class)
+    @ExcelDictFormat(readConverterExp = "字=典")
+    private String ttsVcn;
+
+    /**
+     * TTS语速 0-100
+     */
+    @ExcelProperty(value = "TTS语速 0-100")
+    private Long ttsSpeed;
+
+    /**
+     * TTS音调 0-100
+     */
+    @ExcelProperty(value = "TTS音调 0-100")
+    private Long ttsPitch;
+
+    /**
+     * TTS音量 0-100
+     */
+    @ExcelProperty(value = "TTS音量 0-100")
+    private Long ttsVolume;
+
+    /**
+     * TTS背景音开关 0=无背景音 1=有背景音
+     */
+    @ExcelProperty(value = "TTS背景音开关 0=无背景音 1=有背景音")
+    private Long ttsBgs;
+
+    /**
+     * AI回复语言(字典)
+     */
+    @ExcelProperty(value = "AI回复语言", converter = ExcelDictConvert.class)
+    @ExcelDictFormat(readConverterExp = "字=典")
+    private String language;
+
+
+}

+ 106 - 0
ruoyi-modules/yp-talk/src/main/java/org/dromara/talk/domain/vo/TalkSessionVo.java

@@ -0,0 +1,106 @@
+package org.dromara.talk.domain.vo;
+
+import java.util.Date;
+
+import org.dromara.talk.domain.TalkSession;
+import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
+import cn.idev.excel.annotation.ExcelProperty;
+import org.dromara.common.excel.annotation.ExcelDictFormat;
+import org.dromara.common.excel.convert.ExcelDictConvert;
+import io.github.linpeilie.annotations.AutoMapper;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+
+/**
+ * 对话会话视图对象 talk_session
+ *
+ * @author Lion Li
+ * @date 2026-01-27
+ */
+@Data
+@ExcelIgnoreUnannotated
+@AutoMapper(target = TalkSession.class)
+public class TalkSessionVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 会话ID
+     */
+    @ExcelProperty(value = "会话ID")
+    private Long id;
+
+    /**
+     * 会话唯一标识
+     */
+    @ExcelProperty(value = "会话唯一标识")
+    private String sessionId;
+
+    /**
+     * 客服ID
+     */
+    @ExcelProperty(value = "客服ID")
+    private Long agentId;
+
+    /**
+     * 客户电话
+     */
+    @ExcelProperty(value = "客户电话")
+    private String customerPhone;
+
+    /**
+     * 对话详细数据
+     */
+    @ExcelProperty(value = "对话详细数据")
+    private String conversationJson;
+
+    /**
+     * 消息总数
+     */
+    @ExcelProperty(value = "消息总数")
+    private Long messageCount;
+
+    /**
+     * 用户消息数
+     */
+    @ExcelProperty(value = "用户消息数")
+    private Long userMessageCount;
+
+    /**
+     * 客服消息数
+     */
+    @ExcelProperty(value = "客服消息数")
+    private Long agentMessageCount;
+
+    /**
+     * 对话时长(秒)
+     */
+    @ExcelProperty(value = "对话时长", converter = ExcelDictConvert.class)
+    @ExcelDictFormat(readConverterExp = "秒=")
+    private Long duration;
+
+    /**
+     * 会话状态(0=进行中 1=已结束)
+     */
+    @ExcelProperty(value = "会话状态", converter = ExcelDictConvert.class)
+    @ExcelDictFormat(readConverterExp = "0==进行中,1==已结束")
+    private String status;
+
+    /**
+     * 会话开始时间
+     */
+    @ExcelProperty(value = "会话开始时间")
+    private Date startTime;
+
+    /**
+     * 会话结束时间
+     */
+    @ExcelProperty(value = "会话结束时间")
+    private Date endTime;
+
+
+}

+ 15 - 0
ruoyi-modules/yp-talk/src/main/java/org/dromara/talk/mapper/TalkAgentMapper.java

@@ -0,0 +1,15 @@
+package org.dromara.talk.mapper;
+
+import org.dromara.talk.domain.TalkAgent;
+import org.dromara.talk.domain.vo.TalkAgentVo;
+import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
+
+/**
+ * 客服配置Mapper接口
+ *
+ * @author Lion Li
+ * @date 2026-01-27
+ */
+public interface TalkAgentMapper extends BaseMapperPlus<TalkAgent, TalkAgentVo> {
+
+}

+ 15 - 0
ruoyi-modules/yp-talk/src/main/java/org/dromara/talk/mapper/TalkSessionMapper.java

@@ -0,0 +1,15 @@
+package org.dromara.talk.mapper;
+
+import org.dromara.talk.domain.TalkSession;
+import org.dromara.talk.domain.vo.TalkSessionVo;
+import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
+
+/**
+ * 对话会话Mapper接口
+ *
+ * @author Lion Li
+ * @date 2026-01-27
+ */
+public interface TalkSessionMapper extends BaseMapperPlus<TalkSession, TalkSessionVo> {
+
+}

+ 79 - 0
ruoyi-modules/yp-talk/src/main/java/org/dromara/talk/service/ITalkAgentService.java

@@ -0,0 +1,79 @@
+package org.dromara.talk.service;
+
+import org.dromara.talk.domain.vo.TalkAgentVo;
+import org.dromara.talk.domain.bo.TalkAgentBo;
+import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.common.mybatis.core.page.PageQuery;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * 客服配置Service接口
+ *
+ * @author Lion Li
+ * @date 2026-01-27
+ */
+public interface ITalkAgentService {
+
+    /**
+     * 查询客服配置
+     *
+     * @param id 主键
+     * @return 客服配置
+     */
+    TalkAgentVo queryById(Long id);
+
+    /**
+     * 分页查询客服配置列表
+     *
+     * @param bo        查询条件
+     * @param pageQuery 分页参数
+     * @return 客服配置分页列表
+     */
+    TableDataInfo<TalkAgentVo> queryPageList(TalkAgentBo bo, PageQuery pageQuery);
+
+    /**
+     * 查询符合条件的客服配置列表
+     *
+     * @param bo 查询条件
+     * @return 客服配置列表
+     */
+    List<TalkAgentVo> queryList(TalkAgentBo bo);
+
+    /**
+     * 新增客服配置
+     *
+     * @param bo 客服配置
+     * @return 是否新增成功
+     */
+    Boolean insertByBo(TalkAgentBo bo);
+
+    /**
+     * 修改客服配置
+     *
+     * @param bo 客服配置
+     * @return 是否修改成功
+     */
+    Boolean updateByBo(TalkAgentBo bo);
+
+    /**
+     * 校验并批量删除客服配置信息
+     *
+     * @param ids     待删除的主键集合
+     * @param isValid 是否进行有效性校验
+     * @return 是否删除成功
+     */
+    Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
+
+    /**
+     * 上传客服头像
+     *
+     * @param file 上传的文件
+     * @return 文件访问路径
+     * @throws IOException IO异常
+     */
+    String uploadAvatar(MultipartFile file) throws IOException;
+}

+ 68 - 0
ruoyi-modules/yp-talk/src/main/java/org/dromara/talk/service/ITalkSessionService.java

@@ -0,0 +1,68 @@
+package org.dromara.talk.service;
+
+import org.dromara.talk.domain.vo.TalkSessionVo;
+import org.dromara.talk.domain.bo.TalkSessionBo;
+import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.common.mybatis.core.page.PageQuery;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * 对话会话Service接口
+ *
+ * @author Lion Li
+ * @date 2026-01-27
+ */
+public interface ITalkSessionService {
+
+    /**
+     * 查询对话会话
+     *
+     * @param id 主键
+     * @return 对话会话
+     */
+    TalkSessionVo queryById(Long id);
+
+    /**
+     * 分页查询对话会话列表
+     *
+     * @param bo        查询条件
+     * @param pageQuery 分页参数
+     * @return 对话会话分页列表
+     */
+    TableDataInfo<TalkSessionVo> queryPageList(TalkSessionBo bo, PageQuery pageQuery);
+
+    /**
+     * 查询符合条件的对话会话列表
+     *
+     * @param bo 查询条件
+     * @return 对话会话列表
+     */
+    List<TalkSessionVo> queryList(TalkSessionBo bo);
+
+    /**
+     * 新增对话会话
+     *
+     * @param bo 对话会话
+     * @return 是否新增成功
+     */
+    Boolean insertByBo(TalkSessionBo bo);
+
+    /**
+     * 修改对话会话
+     *
+     * @param bo 对话会话
+     * @return 是否修改成功
+     */
+    Boolean updateByBo(TalkSessionBo bo);
+
+    /**
+     * 校验并批量删除对话会话信息
+     *
+     * @param ids     待删除的主键集合
+     * @param isValid 是否进行有效性校验
+     * @return 是否删除成功
+     */
+    Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
+}

+ 179 - 0
ruoyi-modules/yp-talk/src/main/java/org/dromara/talk/service/impl/TalkAgentServiceImpl.java

@@ -0,0 +1,179 @@
+package org.dromara.talk.service.impl;
+
+import org.dromara.common.core.utils.MapstructUtils;
+import org.dromara.common.core.utils.StringUtils;
+import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.common.mybatis.core.page.PageQuery;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+import org.dromara.talk.domain.bo.TalkAgentBo;
+import org.dromara.talk.domain.vo.TalkAgentVo;
+import org.dromara.talk.domain.TalkAgent;
+import org.dromara.talk.mapper.TalkAgentMapper;
+import org.dromara.talk.service.ITalkAgentService;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.Collection;
+import java.util.UUID;
+
+/**
+ * 客服配置Service业务层处理
+ *
+ * @author Lion Li
+ * @date 2026-01-27
+ */
+@Slf4j
+@RequiredArgsConstructor
+@Service
+public class TalkAgentServiceImpl implements ITalkAgentService {
+
+    private final TalkAgentMapper baseMapper;
+
+    /**
+     * 查询客服配置
+     *
+     * @param id 主键
+     * @return 客服配置
+     */
+    @Override
+    public TalkAgentVo queryById(Long id){
+        return baseMapper.selectVoById(id);
+    }
+
+    /**
+     * 分页查询客服配置列表
+     *
+     * @param bo        查询条件
+     * @param pageQuery 分页参数
+     * @return 客服配置分页列表
+     */
+    @Override
+    public TableDataInfo<TalkAgentVo> queryPageList(TalkAgentBo bo, PageQuery pageQuery) {
+        LambdaQueryWrapper<TalkAgent> lqw = buildQueryWrapper(bo);
+        Page<TalkAgentVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
+        return TableDataInfo.build(result);
+    }
+
+    /**
+     * 查询符合条件的客服配置列表
+     *
+     * @param bo 查询条件
+     * @return 客服配置列表
+     */
+    @Override
+    public List<TalkAgentVo> queryList(TalkAgentBo bo) {
+        LambdaQueryWrapper<TalkAgent> lqw = buildQueryWrapper(bo);
+        return baseMapper.selectVoList(lqw);
+    }
+
+    private LambdaQueryWrapper<TalkAgent> buildQueryWrapper(TalkAgentBo bo) {
+        Map<String, Object> params = bo.getParams();
+        LambdaQueryWrapper<TalkAgent> lqw = Wrappers.lambdaQuery();
+        lqw.orderByAsc(TalkAgent::getId);
+        lqw.like(StringUtils.isNotBlank(bo.getName()), TalkAgent::getName, bo.getName());
+        lqw.eq(StringUtils.isNotBlank(bo.getGender()), TalkAgent::getGender, bo.getGender());
+        lqw.eq(StringUtils.isNotBlank(bo.getAvatarUrl()), TalkAgent::getAvatarUrl, bo.getAvatarUrl());
+        lqw.eq(StringUtils.isNotBlank(bo.getDescription()), TalkAgent::getDescription, bo.getDescription());
+        lqw.eq(StringUtils.isNotBlank(bo.getGreetingMessage()), TalkAgent::getGreetingMessage, bo.getGreetingMessage());
+        lqw.eq(StringUtils.isNotBlank(bo.getStatus()), TalkAgent::getStatus, bo.getStatus());
+        lqw.eq(StringUtils.isNotBlank(bo.getTtsVcn()), TalkAgent::getTtsVcn, bo.getTtsVcn());
+        lqw.eq(bo.getTtsSpeed() != null, TalkAgent::getTtsSpeed, bo.getTtsSpeed());
+        lqw.eq(bo.getTtsPitch() != null, TalkAgent::getTtsPitch, bo.getTtsPitch());
+        lqw.eq(bo.getTtsVolume() != null, TalkAgent::getTtsVolume, bo.getTtsVolume());
+        lqw.eq(bo.getTtsBgs() != null, TalkAgent::getTtsBgs, bo.getTtsBgs());
+        lqw.eq(StringUtils.isNotBlank(bo.getLanguage()), TalkAgent::getLanguage, bo.getLanguage());
+        return lqw;
+    }
+
+    /**
+     * 新增客服配置
+     *
+     * @param bo 客服配置
+     * @return 是否新增成功
+     */
+    @Override
+    public Boolean insertByBo(TalkAgentBo bo) {
+        TalkAgent add = MapstructUtils.convert(bo, TalkAgent.class);
+        validEntityBeforeSave(add);
+        boolean flag = baseMapper.insert(add) > 0;
+        if (flag) {
+            bo.setId(add.getId());
+        }
+        return flag;
+    }
+
+    /**
+     * 修改客服配置
+     *
+     * @param bo 客服配置
+     * @return 是否修改成功
+     */
+    @Override
+    public Boolean updateByBo(TalkAgentBo bo) {
+        TalkAgent update = MapstructUtils.convert(bo, TalkAgent.class);
+        validEntityBeforeSave(update);
+        return baseMapper.updateById(update) > 0;
+    }
+
+    /**
+     * 保存前的数据校验
+     */
+    private void validEntityBeforeSave(TalkAgent entity){
+        //TODO 做一些数据校验,如唯一约束
+    }
+
+    /**
+     * 校验并批量删除客服配置信息
+     *
+     * @param ids     待删除的主键集合
+     * @param isValid 是否进行有效性校验
+     * @return 是否删除成功
+     */
+    @Override
+    public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
+        if(isValid){
+            //TODO 做一些业务上的校验,判断是否需要校验
+        }
+        return baseMapper.deleteByIds(ids) > 0;
+    }
+
+    /**
+     * 上传客服头像
+     *
+     * @param file 上传的文件
+     * @return 文件访问路径
+     * @throws IOException IO异常
+     */
+    @Override
+    public String uploadAvatar(MultipartFile file) throws IOException {
+        if (file.isEmpty()) {
+            throw new IllegalArgumentException("上传文件不能为空");
+        }
+
+        String originalFilename = file.getOriginalFilename();
+        String extension = originalFilename != null && originalFilename.contains(".")
+            ? originalFilename.substring(originalFilename.lastIndexOf("."))
+            : "";
+
+        String fileName = System.currentTimeMillis() + "_" + UUID.randomUUID().toString() + extension;
+
+        String uploadDir = System.getProperty("user.dir") + File.separator + "uploads" + File.separator + "avatars" + File.separator;
+        File dir = new File(uploadDir);
+        if (!dir.exists()) {
+            dir.mkdirs();
+        }
+
+        File destFile = new File(uploadDir + fileName);
+        file.transferTo(destFile);
+
+        return "/uploads/avatars/" + fileName;
+    }
+}

+ 142 - 0
ruoyi-modules/yp-talk/src/main/java/org/dromara/talk/service/impl/TalkSessionServiceImpl.java

@@ -0,0 +1,142 @@
+package org.dromara.talk.service.impl;
+
+import org.dromara.common.core.utils.MapstructUtils;
+import org.dromara.common.core.utils.StringUtils;
+import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.common.mybatis.core.page.PageQuery;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.dromara.talk.domain.bo.TalkSessionBo;
+import org.dromara.talk.domain.vo.TalkSessionVo;
+import org.dromara.talk.domain.TalkSession;
+import org.dromara.talk.mapper.TalkSessionMapper;
+import org.dromara.talk.service.ITalkSessionService;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Collection;
+
+/**
+ * 对话会话Service业务层处理
+ *
+ * @author Lion Li
+ * @date 2026-01-27
+ */
+@Slf4j
+@RequiredArgsConstructor
+@Service
+public class TalkSessionServiceImpl implements ITalkSessionService {
+
+    private final TalkSessionMapper baseMapper;
+
+    /**
+     * 查询对话会话
+     *
+     * @param id 主键
+     * @return 对话会话
+     */
+    @Override
+    public TalkSessionVo queryById(Long id){
+        return baseMapper.selectVoById(id);
+    }
+
+    /**
+     * 分页查询对话会话列表
+     *
+     * @param bo        查询条件
+     * @param pageQuery 分页参数
+     * @return 对话会话分页列表
+     */
+    @Override
+    public TableDataInfo<TalkSessionVo> queryPageList(TalkSessionBo bo, PageQuery pageQuery) {
+        LambdaQueryWrapper<TalkSession> lqw = buildQueryWrapper(bo);
+        Page<TalkSessionVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
+        return TableDataInfo.build(result);
+    }
+
+    /**
+     * 查询符合条件的对话会话列表
+     *
+     * @param bo 查询条件
+     * @return 对话会话列表
+     */
+    @Override
+    public List<TalkSessionVo> queryList(TalkSessionBo bo) {
+        LambdaQueryWrapper<TalkSession> lqw = buildQueryWrapper(bo);
+        return baseMapper.selectVoList(lqw);
+    }
+
+    private LambdaQueryWrapper<TalkSession> buildQueryWrapper(TalkSessionBo bo) {
+        Map<String, Object> params = bo.getParams();
+        LambdaQueryWrapper<TalkSession> lqw = Wrappers.lambdaQuery();
+        lqw.orderByAsc(TalkSession::getId);
+        lqw.eq(StringUtils.isNotBlank(bo.getSessionId()), TalkSession::getSessionId, bo.getSessionId());
+        lqw.eq(bo.getAgentId() != null, TalkSession::getAgentId, bo.getAgentId());
+        lqw.eq(StringUtils.isNotBlank(bo.getCustomerPhone()), TalkSession::getCustomerPhone, bo.getCustomerPhone());
+        lqw.eq(StringUtils.isNotBlank(bo.getConversationJson()), TalkSession::getConversationJson, bo.getConversationJson());
+        lqw.eq(bo.getMessageCount() != null, TalkSession::getMessageCount, bo.getMessageCount());
+        lqw.eq(bo.getUserMessageCount() != null, TalkSession::getUserMessageCount, bo.getUserMessageCount());
+        lqw.eq(bo.getAgentMessageCount() != null, TalkSession::getAgentMessageCount, bo.getAgentMessageCount());
+        lqw.eq(bo.getDuration() != null, TalkSession::getDuration, bo.getDuration());
+        lqw.eq(StringUtils.isNotBlank(bo.getStatus()), TalkSession::getStatus, bo.getStatus());
+        lqw.eq(bo.getStartTime() != null, TalkSession::getStartTime, bo.getStartTime());
+        lqw.eq(bo.getEndTime() != null, TalkSession::getEndTime, bo.getEndTime());
+        return lqw;
+    }
+
+    /**
+     * 新增对话会话
+     *
+     * @param bo 对话会话
+     * @return 是否新增成功
+     */
+    @Override
+    public Boolean insertByBo(TalkSessionBo bo) {
+        TalkSession add = MapstructUtils.convert(bo, TalkSession.class);
+        validEntityBeforeSave(add);
+        boolean flag = baseMapper.insert(add) > 0;
+        if (flag) {
+            bo.setId(add.getId());
+        }
+        return flag;
+    }
+
+    /**
+     * 修改对话会话
+     *
+     * @param bo 对话会话
+     * @return 是否修改成功
+     */
+    @Override
+    public Boolean updateByBo(TalkSessionBo bo) {
+        TalkSession update = MapstructUtils.convert(bo, TalkSession.class);
+        validEntityBeforeSave(update);
+        return baseMapper.updateById(update) > 0;
+    }
+
+    /**
+     * 保存前的数据校验
+     */
+    private void validEntityBeforeSave(TalkSession entity){
+        //TODO 做一些数据校验,如唯一约束
+    }
+
+    /**
+     * 校验并批量删除对话会话信息
+     *
+     * @param ids     待删除的主键集合
+     * @param isValid 是否进行有效性校验
+     * @return 是否删除成功
+     */
+    @Override
+    public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
+        if(isValid){
+            //TODO 做一些业务上的校验,判断是否需要校验
+        }
+        return baseMapper.deleteByIds(ids) > 0;
+    }
+}