Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Shucai Chen
/
lufa-ai
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a7cc17d2
authored
Jun 02, 2026
by
pengshun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 添加今日对话总结功能
parent
f3d8ea05
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
1182 additions
and
4 deletions
+1182
-4
.DS_Store
+0
-0
ruoyi-vue-pro-master-jdk17/.DS_Store
+0
-0
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ErrorCodeConstants.java
+1
-0
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/chat/AiChatAnalysisController.java
+14
-1
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/chat/vo/analysis/AiChatSummaryCreateReqVO.java
+36
-0
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/chat/vo/analysis/AiChatSummaryReqVO.java
+26
-0
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/chat/vo/analysis/AiChatSummaryRespVO.java
+18
-0
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/AiKnowledgeDocumentController.java
+9
-0
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/vo/document/AiKnowledgeDocumentRespVO.java
+5
-0
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/vo/document/AiKnowledgeDocumentUpdateProcessedStatusReqVO.java
+23
-0
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/vo/document/AiKnowledgeDocumentUpdateReqVO.java
+2
-0
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/dataobject/chat/AiChatSummaryDO.java
+51
-0
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/dataobject/knowledge/AiKnowledgeDocumentDO.java
+2
-0
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/mysql/chat/AiChatAnalysisMapper.java
+2
-0
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/mysql/chat/AiChatSummaryMapper.java
+24
-0
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/mysql/knowledge/AiKnowledgeDocumentMapper.java
+9
-0
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/chat/AiChatAnalysisService.java
+5
-0
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/chat/AiChatAnalysisServiceImpl.java
+27
-0
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/knowledge/AiKnowledgeDocumentService.java
+2
-0
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/knowledge/AiKnowledgeDocumentServiceImpl.java
+26
-0
ruoyi-vue-pro-master-jdk17/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
+2
-0
ruoyi-vue-pro-master-jdk17/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/logger/LoginResultEnum.java
+2
-0
ruoyi-vue-pro-master-jdk17/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java
+41
-0
ruoyi-vue-pro-master-jdk17/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java
+37
-0
ruoyi-vue-pro-master-jdk17/yudao-server/.DS_Store
+0
-0
yudao-ui-admin-vue3/.DS_Store
+0
-0
yudao-ui-admin-vue3/src/api/ai/chat/analysis/index.ts
+4
-0
yudao-ui-admin-vue3/src/views/ai/chat/manager/ChatConversationList.vue
+1
-0
yudao-ui-admin-vue3/src/views/ai/chat/manager/ChatMessageList.vue
+1
-0
yudao-ui-admin-vue3/src/views/ai/chat_analysis/message/index copy.vue
+741
-0
yudao-ui-admin-vue3/src/views/ai/chat_analysis/message/index.vue
+71
-3
No files found.
.DS_Store
View file @
a7cc17d2
No preview for this file type
ruoyi-vue-pro-master-jdk17/.DS_Store
View file @
a7cc17d2
No preview for this file type
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ErrorCodeConstants.java
View file @
a7cc17d2
...
@@ -59,6 +59,7 @@ public interface ErrorCodeConstants {
...
@@ -59,6 +59,7 @@ public interface ErrorCodeConstants {
ErrorCode
KNOWLEDGE_NO_AUTH
=
new
ErrorCode
(
1_040_009_405
,
"无权限操作!"
);
ErrorCode
KNOWLEDGE_NO_AUTH
=
new
ErrorCode
(
1_040_009_405
,
"无权限操作!"
);
ErrorCode
KNOWLEDGE_NO_SPACE
=
new
ErrorCode
(
1_040_009_406
,
"知识库容量超额!"
);
ErrorCode
KNOWLEDGE_NO_SPACE
=
new
ErrorCode
(
1_040_009_406
,
"知识库容量超额!"
);
ErrorCode
KNOWLEDGE_REPEAT_FILE
=
new
ErrorCode
(
1_040_009_407
,
"不可重复上传文件!"
);
ErrorCode
KNOWLEDGE_DOCUMENT_NOT_EXISTS
=
new
ErrorCode
(
1_040_009_101
,
"文档不存在!"
);
ErrorCode
KNOWLEDGE_DOCUMENT_NOT_EXISTS
=
new
ErrorCode
(
1_040_009_101
,
"文档不存在!"
);
ErrorCode
KNOWLEDGE_DOCUMENT_FILE_EMPTY
=
new
ErrorCode
(
1_040_009_102
,
"文档内容为空!"
);
ErrorCode
KNOWLEDGE_DOCUMENT_FILE_EMPTY
=
new
ErrorCode
(
1_040_009_102
,
"文档内容为空!"
);
...
...
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/chat/AiChatAnalysisController.java
View file @
a7cc17d2
...
@@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.ai.controller.admin.chat.vo.analysis.*;
...
@@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.ai.controller.admin.chat.vo.analysis.*;
import
cn.iocoder.yudao.module.ai.controller.admin.chat.vo.conversation.AiChatConversationRespVO
;
import
cn.iocoder.yudao.module.ai.controller.admin.chat.vo.conversation.AiChatConversationRespVO
;
import
cn.iocoder.yudao.module.ai.dal.dataobject.chat.AiChatAnalysisDO
;
import
cn.iocoder.yudao.module.ai.dal.dataobject.chat.AiChatAnalysisDO
;
import
cn.iocoder.yudao.module.ai.dal.dataobject.chat.AiChatConversationDO
;
import
cn.iocoder.yudao.module.ai.dal.dataobject.chat.AiChatConversationDO
;
import
cn.iocoder.yudao.module.ai.dal.dataobject.chat.AiChatSummaryDO
;
import
cn.iocoder.yudao.module.ai.service.chat.AiChatAnalysisService
;
import
cn.iocoder.yudao.module.ai.service.chat.AiChatAnalysisService
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.Parameter
;
import
io.swagger.v3.oas.annotations.Parameter
;
...
@@ -21,7 +22,6 @@ import java.util.List;
...
@@ -21,7 +22,6 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
pojo
.
CommonResult
.
success
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
pojo
.
CommonResult
.
success
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
util
.
collection
.
CollectionUtils
.
convertList
;
@Tag
(
name
=
"管理后台 - 聊天分析记录"
)
@Tag
(
name
=
"管理后台 - 聊天分析记录"
)
@RestController
@RestController
...
@@ -111,4 +111,17 @@ public class AiChatAnalysisController {
...
@@ -111,4 +111,17 @@ public class AiChatAnalysisController {
return
success
(
BeanUtils
.
toBean
(
pageResult
,
AiChatKeywordCountVO
.
class
));
return
success
(
BeanUtils
.
toBean
(
pageResult
,
AiChatKeywordCountVO
.
class
));
}
}
@Operation
(
summary
=
"获得分析总结数据"
)
@GetMapping
(
"/get-summary"
)
public
CommonResult
<
AiChatSummaryRespVO
>
getChatSummary
(
AiChatSummaryReqVO
pageReqVO
)
{
AiChatSummaryDO
result
=
chatAnalysisService
.
getChatSummaryPage
(
pageReqVO
);
return
success
(
BeanUtils
.
toBean
(
result
,
AiChatSummaryRespVO
.
class
));
}
@Operation
(
summary
=
"获得分析总结数据"
)
@PostMapping
(
"/create-summary"
)
public
CommonResult
<
Long
>
createChatSummary
(
@RequestBody
@Valid
AiChatSummaryCreateReqVO
createReqVO
)
{
return
success
(
chatAnalysisService
.
createChatSummary
(
createReqVO
));
}
}
}
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/chat/vo/analysis/AiChatSummaryCreateReqVO.java
0 → 100644
View file @
a7cc17d2
package
cn
.
iocoder
.
yudao
.
module
.
ai
.
controller
.
admin
.
chat
.
vo
.
analysis
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
jakarta.validation.constraints.DecimalMax
;
import
jakarta.validation.constraints.DecimalMin
;
import
jakarta.validation.constraints.NotBlank
;
import
lombok.Data
;
import
org.hibernate.validator.constraints.Length
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
java.math.BigDecimal
;
import
java.time.LocalDateTime
;
import
java.util.List
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
util
.
date
.
DateUtils
.
FORMAT_YEAR_MONTH_DAY
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
util
.
date
.
DateUtils
.
FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND
;
@Schema
(
description
=
"管理后台 - 对话分析记录创建/修改 Request VO"
)
@Data
public
class
AiChatSummaryCreateReqVO
{
@Schema
(
description
=
"分析记录编号"
,
example
=
"1024"
)
private
Long
id
;
@Schema
(
description
=
"对话编号"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"wmCYMpJwAAnATZZNG3vu6Qq32Wph0YrQ"
)
@NotBlank
(
message
=
"对话编号不能为空"
)
private
String
chatId
;
@Schema
(
description
=
"总结内容"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"公租房业务:登录密码是多少?"
)
private
String
summary
;
@Schema
(
description
=
"总结时间"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"1780243200000"
)
@DateTimeFormat
(
pattern
=
FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND
)
private
LocalDateTime
summaryTime
;
}
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/chat/vo/analysis/AiChatSummaryReqVO.java
0 → 100644
View file @
a7cc17d2
package
cn
.
iocoder
.
yudao
.
module
.
ai
.
controller
.
admin
.
chat
.
vo
.
analysis
;
import
cn.iocoder.yudao.framework.common.pojo.PageParam
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
jakarta.validation.constraints.NotBlank
;
import
lombok.Data
;
import
org.hibernate.validator.constraints.Length
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
java.time.LocalDateTime
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
util
.
date
.
DateUtils
.
FORMAT_YEAR_MONTH_DAY
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
util
.
date
.
DateUtils
.
FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND
;
@Schema
(
description
=
"管理后台 - AI 总结对话分析的分页 Request VO"
)
@Data
public
class
AiChatSummaryReqVO
{
@Schema
(
description
=
"对话编号"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"wmCYMpJwAAnATZZNG3vu6Qq32Wph0YrQ"
)
@NotBlank
(
message
=
"对话编号不能为空"
)
private
String
chatId
;
@Schema
(
description
=
"今日时间"
)
@DateTimeFormat
(
pattern
=
FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND
)
private
LocalDateTime
summaryTime
;
}
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/chat/vo/analysis/AiChatSummaryRespVO.java
0 → 100644
View file @
a7cc17d2
package
cn
.
iocoder
.
yudao
.
module
.
ai
.
controller
.
admin
.
chat
.
vo
.
analysis
;
import
com.fhs.core.trans.vo.VO
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
@Schema
(
description
=
"管理后台 - 对话分析记录 Response VO"
)
@Data
public
class
AiChatSummaryRespVO
implements
VO
{
@Schema
(
description
=
"分析记录编号"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"1024"
)
private
Long
id
;
@Schema
(
description
=
"对话编号"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"wmCYMpJwAAnATZZNG3vu6Qq32Wph0YrQ"
)
private
String
chatId
;
@Schema
(
description
=
"总结内容"
,
example
=
"待解决的问题:1. 。。。"
)
private
String
summary
;
}
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/AiKnowledgeDocumentController.java
View file @
a7cc17d2
...
@@ -199,6 +199,15 @@ public class AiKnowledgeDocumentController {
...
@@ -199,6 +199,15 @@ public class AiKnowledgeDocumentController {
return
success
(
true
);
return
success
(
true
);
}
}
@PutMapping
(
"/update-processed-status"
)
@Operation
(
summary
=
"更新文档解析状态"
)
@PreAuthorize
(
"@ss.hasPermission('ai:knowledge:update')"
)
public
CommonResult
<
Boolean
>
updateKnowledgeDocumentProcessedStatus
(
@Valid
@RequestBody
AiKnowledgeDocumentUpdateProcessedStatusReqVO
reqVO
)
{
documentService
.
updateKnowledgeDocumentProcessedStatus
(
reqVO
);
return
success
(
true
);
}
// @DeleteMapping("/delete")
// @DeleteMapping("/delete")
// @Operation(summary = "删除文档")
// @Operation(summary = "删除文档")
// @PreAuthorize("@ss.hasPermission('ai:knowledge:delete')")
// @PreAuthorize("@ss.hasPermission('ai:knowledge:delete')")
...
...
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/vo/document/AiKnowledgeDocumentRespVO.java
View file @
a7cc17d2
package
cn
.
iocoder
.
yudao
.
module
.
ai
.
controller
.
admin
.
knowledge
.
vo
.
document
;
package
cn
.
iocoder
.
yudao
.
module
.
ai
.
controller
.
admin
.
knowledge
.
vo
.
document
;
import
cn.iocoder.yudao.framework.common.enums.CommonStatusEnum
;
import
cn.iocoder.yudao.framework.common.validation.InEnum
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
import
lombok.Data
;
...
@@ -56,4 +58,7 @@ public class AiKnowledgeDocumentRespVO {
...
@@ -56,4 +58,7 @@ public class AiKnowledgeDocumentRespVO {
@Schema
(
description
=
"创建人"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"24790"
)
@Schema
(
description
=
"创建人"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"24790"
)
private
String
creator
;
private
String
creator
;
@Schema
(
description
=
"解析状态"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"0"
)
private
Integer
processed
;
}
}
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/vo/document/AiKnowledgeDocumentUpdateProcessedStatusReqVO.java
0 → 100644
View file @
a7cc17d2
package
cn
.
iocoder
.
yudao
.
module
.
ai
.
controller
.
admin
.
knowledge
.
vo
.
document
;
import
cn.iocoder.yudao.framework.common.enums.CommonStatusEnum
;
import
cn.iocoder.yudao.framework.common.validation.InEnum
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
jakarta.validation.constraints.NotNull
;
import
lombok.Data
;
@Schema
(
description
=
"管理后台 - AI 知识库文档更新解析状态 Request VO"
)
@Data
public
class
AiKnowledgeDocumentUpdateProcessedStatusReqVO
{
@Schema
(
description
=
"编号"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"15583"
)
@NotNull
(
message
=
"编号不能为空"
)
private
Long
id
;
@Schema
(
description
=
"解析状态"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"0"
)
@NotNull
(
message
=
"解析状态不能为空"
)
@InEnum
(
CommonStatusEnum
.
class
)
private
Integer
processed
;
}
\ No newline at end of file
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/vo/document/AiKnowledgeDocumentUpdateReqVO.java
View file @
a7cc17d2
package
cn
.
iocoder
.
yudao
.
module
.
ai
.
controller
.
admin
.
knowledge
.
vo
.
document
;
package
cn
.
iocoder
.
yudao
.
module
.
ai
.
controller
.
admin
.
knowledge
.
vo
.
document
;
import
cn.iocoder.yudao.framework.common.enums.CommonStatusEnum
;
import
cn.iocoder.yudao.framework.common.validation.InEnum
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
jakarta.validation.constraints.NotNull
;
import
jakarta.validation.constraints.NotNull
;
import
lombok.Data
;
import
lombok.Data
;
...
...
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/dataobject/chat/AiChatSummaryDO.java
0 → 100644
View file @
a7cc17d2
package
cn
.
iocoder
.
yudao
.
module
.
ai
.
dal
.
dataobject
.
chat
;
import
cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO
;
import
com.baomidou.mybatisplus.annotation.KeySequence
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler
;
import
lombok.*
;
import
java.math.BigDecimal
;
import
java.time.LocalDateTime
;
import
java.util.List
;
/**
* AI Chat 对话 DO
*
* 用户每次发起 Chat 聊天时,会创建一个 {@link AiChatSummaryDO} 对象,将它的消息关联在一起
*
* @author fansili
* @since 2024/4/14 17:35
*/
@TableName
(
value
=
"ai_chat_summary"
,
autoResultMap
=
true
)
@KeySequence
(
"ai_chat_summary_seq"
)
// 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public
class
AiChatSummaryDO
extends
BaseDO
{
/**
* 分析记录编号,自增
*/
@TableId
private
Long
id
;
/**
* 对话编号
*/
private
String
chatId
;
/**
* 用户问题
*/
private
String
summary
;
private
LocalDateTime
summaryTime
;
}
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/dataobject/knowledge/AiKnowledgeDocumentDO.java
View file @
a7cc17d2
...
@@ -80,4 +80,6 @@ public class AiKnowledgeDocumentDO extends BaseDO {
...
@@ -80,4 +80,6 @@ public class AiKnowledgeDocumentDO extends BaseDO {
private
LocalDateTime
releaseTime
;
private
LocalDateTime
releaseTime
;
private
Integer
processed
;
}
}
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/mysql/chat/AiChatAnalysisMapper.java
View file @
a7cc17d2
...
@@ -5,6 +5,8 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
...
@@ -5,6 +5,8 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import
cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX
;
import
cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX
;
import
cn.iocoder.yudao.module.ai.controller.admin.chat.vo.analysis.AiChatAnalysisPageReqVO
;
import
cn.iocoder.yudao.module.ai.controller.admin.chat.vo.analysis.AiChatAnalysisPageReqVO
;
import
cn.iocoder.yudao.module.ai.controller.admin.chat.vo.analysis.AiChatKeywordsPageReqVO
;
import
cn.iocoder.yudao.module.ai.controller.admin.chat.vo.analysis.AiChatKeywordsPageReqVO
;
import
cn.iocoder.yudao.module.ai.controller.admin.chat.vo.analysis.AiChatSummaryReqVO
;
import
cn.iocoder.yudao.module.ai.controller.admin.chat.vo.analysis.AiChatSummaryRespVO
;
import
cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document.AiKnowledgeDocumentPageReqVO
;
import
cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document.AiKnowledgeDocumentPageReqVO
;
import
cn.iocoder.yudao.module.ai.dal.dataobject.chat.AiChatAnalysisDO
;
import
cn.iocoder.yudao.module.ai.dal.dataobject.chat.AiChatAnalysisDO
;
import
cn.iocoder.yudao.module.ai.dal.dataobject.chat.AiChatConversationDO
;
import
cn.iocoder.yudao.module.ai.dal.dataobject.chat.AiChatConversationDO
;
...
...
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/mysql/chat/AiChatSummaryMapper.java
0 → 100644
View file @
a7cc17d2
package
cn
.
iocoder
.
yudao
.
module
.
ai
.
dal
.
mysql
.
chat
;
import
cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX
;
import
cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX
;
import
cn.iocoder.yudao.module.ai.controller.admin.chat.vo.analysis.AiChatSummaryReqVO
;
import
cn.iocoder.yudao.module.ai.controller.admin.chat.vo.analysis.AiChatSummaryRespVO
;
import
cn.iocoder.yudao.module.ai.dal.dataobject.chat.AiChatSummaryDO
;
import
org.apache.ibatis.annotations.Mapper
;
/**
* AI 聊天对话 Mapper
*
* @author 芋道源码
*/
@Mapper
public
interface
AiChatSummaryMapper
extends
BaseMapperX
<
AiChatSummaryDO
>
{
default
AiChatSummaryDO
selectSummary
(
AiChatSummaryReqVO
reqVo
){
return
selectOne
(
new
LambdaQueryWrapperX
<
AiChatSummaryDO
>()
.
eqIfPresent
(
AiChatSummaryDO:
:
getChatId
,
reqVo
.
getChatId
())
.
eqIfPresent
(
AiChatSummaryDO:
:
getSummaryTime
,
reqVo
.
getSummaryTime
()));
}
}
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/mysql/knowledge/AiKnowledgeDocumentMapper.java
View file @
a7cc17d2
...
@@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
...
@@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import
cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX
;
import
cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX
;
import
cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX
;
import
cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX
;
import
cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document.AiKnowledgeDocumentPageReqVO
;
import
cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document.AiKnowledgeDocumentPageReqVO
;
import
cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.knowledge.AiKnowledgeDocumentCreateReqVO
;
import
cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeDocumentDO
;
import
cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeDocumentDO
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
...
@@ -112,4 +113,12 @@ public interface AiKnowledgeDocumentMapper extends BaseMapperX<AiKnowledgeDocume
...
@@ -112,4 +113,12 @@ public interface AiKnowledgeDocumentMapper extends BaseMapperX<AiKnowledgeDocume
.
setSql
(
String
.
format
(
"content_length = CASE WHEN content_length - %d > 0 THEN content_length - %d ELSE 0 END"
,
contentLength
,
contentLength
))
.
setSql
(
String
.
format
(
"content_length = CASE WHEN content_length - %d > 0 THEN content_length - %d ELSE 0 END"
,
contentLength
,
contentLength
))
.
in
(
AiKnowledgeDocumentDO:
:
getId
,
ids
));
.
in
(
AiKnowledgeDocumentDO:
:
getId
,
ids
));
}
}
default
AiKnowledgeDocumentDO
selectByName
(
AiKnowledgeDocumentCreateReqVO
createReqVO
){
return
selectOne
(
new
LambdaQueryWrapperX
<
AiKnowledgeDocumentDO
>()
.
eq
(
AiKnowledgeDocumentDO:
:
getKnowledgeId
,
createReqVO
.
getKnowledgeId
())
.
eq
(
AiKnowledgeDocumentDO:
:
getParentId
,
createReqVO
.
getParentId
())
.
like
(
AiKnowledgeDocumentDO:
:
getName
,
createReqVO
.
getName
())
);
}
}
}
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/chat/AiChatAnalysisService.java
View file @
a7cc17d2
...
@@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
...
@@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import
cn.iocoder.yudao.module.ai.controller.admin.chat.vo.analysis.*
;
import
cn.iocoder.yudao.module.ai.controller.admin.chat.vo.analysis.*
;
import
cn.iocoder.yudao.module.ai.dal.dataobject.chat.AiChatAnalysisDO
;
import
cn.iocoder.yudao.module.ai.dal.dataobject.chat.AiChatAnalysisDO
;
import
cn.iocoder.yudao.module.ai.dal.dataobject.chat.AiChatConversationDO
;
import
cn.iocoder.yudao.module.ai.dal.dataobject.chat.AiChatConversationDO
;
import
cn.iocoder.yudao.module.ai.dal.dataobject.chat.AiChatSummaryDO
;
import
java.util.List
;
import
java.util.List
;
...
@@ -25,4 +26,8 @@ public interface AiChatAnalysisService {
...
@@ -25,4 +26,8 @@ public interface AiChatAnalysisService {
AiChatAnalysisStatisticsRespVO
getStatistics
(
AiChatAnalysisStatisticsReqVO
pageReqVO
);
AiChatAnalysisStatisticsRespVO
getStatistics
(
AiChatAnalysisStatisticsReqVO
pageReqVO
);
List
<
AiChatKeywordCountVO
>
getChatKeywordsPage
(
AiChatKeywordsPageReqVO
pageReqVO
);
List
<
AiChatKeywordCountVO
>
getChatKeywordsPage
(
AiChatKeywordsPageReqVO
pageReqVO
);
AiChatSummaryDO
getChatSummaryPage
(
AiChatSummaryReqVO
pageReqVO
);
Long
createChatSummary
(
AiChatSummaryCreateReqVO
createReqVO
);
}
}
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/chat/AiChatAnalysisServiceImpl.java
View file @
a7cc17d2
...
@@ -3,7 +3,9 @@ package cn.iocoder.yudao.module.ai.service.chat;
...
@@ -3,7 +3,9 @@ package cn.iocoder.yudao.module.ai.service.chat;
import
cn.iocoder.yudao.framework.common.pojo.PageResult
;
import
cn.iocoder.yudao.framework.common.pojo.PageResult
;
import
cn.iocoder.yudao.module.ai.controller.admin.chat.vo.analysis.*
;
import
cn.iocoder.yudao.module.ai.controller.admin.chat.vo.analysis.*
;
import
cn.iocoder.yudao.module.ai.dal.dataobject.chat.AiChatAnalysisDO
;
import
cn.iocoder.yudao.module.ai.dal.dataobject.chat.AiChatAnalysisDO
;
import
cn.iocoder.yudao.module.ai.dal.dataobject.chat.AiChatSummaryDO
;
import
cn.iocoder.yudao.module.ai.dal.mysql.chat.AiChatAnalysisMapper
;
import
cn.iocoder.yudao.module.ai.dal.mysql.chat.AiChatAnalysisMapper
;
import
cn.iocoder.yudao.module.ai.dal.mysql.chat.AiChatSummaryMapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
jakarta.annotation.Resource
;
import
jakarta.annotation.Resource
;
...
@@ -37,6 +39,9 @@ public class AiChatAnalysisServiceImpl implements AiChatAnalysisService {
...
@@ -37,6 +39,9 @@ public class AiChatAnalysisServiceImpl implements AiChatAnalysisService {
@Resource
@Resource
private
AiChatAnalysisMapper
chatAnalysisMapper
;
private
AiChatAnalysisMapper
chatAnalysisMapper
;
@Resource
private
AiChatSummaryMapper
chatSummaryMapper
;
public
AiChatAnalysisDO
validateChatAnalysisExists
(
Long
id
)
{
public
AiChatAnalysisDO
validateChatAnalysisExists
(
Long
id
)
{
AiChatAnalysisDO
conversation
=
chatAnalysisMapper
.
selectById
(
id
);
AiChatAnalysisDO
conversation
=
chatAnalysisMapper
.
selectById
(
id
);
...
@@ -167,6 +172,28 @@ public class AiChatAnalysisServiceImpl implements AiChatAnalysisService {
...
@@ -167,6 +172,28 @@ public class AiChatAnalysisServiceImpl implements AiChatAnalysisService {
}
}
@Override
public
AiChatSummaryDO
getChatSummaryPage
(
AiChatSummaryReqVO
pageReqVO
)
{
return
chatSummaryMapper
.
selectSummary
(
pageReqVO
);
}
@Override
public
Long
createChatSummary
(
AiChatSummaryCreateReqVO
createReqVO
)
{
List
<
AiChatAnalysisDO
>
summary
=
chatAnalysisMapper
.
selectByChatId
(
createReqVO
.
getChatId
());
if
(
summary
.
isEmpty
())
{
throw
exception
(
CHAT_ANALYSIS_NOT_EXISTS
);
}
LocalDateTime
summaryTime
=
createReqVO
.
getSummaryTime
();
if
(
summaryTime
!=
null
)
{
summaryTime
=
summaryTime
.
withHour
(
0
).
withMinute
(
0
).
withSecond
(
0
).
withNano
(
0
);
}
// 2. 创建 AiChatConversationDO 聊天对话
AiChatSummaryDO
conversation
=
new
AiChatSummaryDO
().
setChatId
(
createReqVO
.
getChatId
())
.
setSummary
(
createReqVO
.
getSummary
()).
setSummaryTime
(
summaryTime
);
chatSummaryMapper
.
insert
(
conversation
);
return
conversation
.
getId
();
}
private
Double
calculatePercent
(
Long
current
,
Long
previous
)
{
private
Double
calculatePercent
(
Long
current
,
Long
previous
)
{
if
(
previous
==
null
||
previous
==
0
)
{
if
(
previous
==
null
||
previous
==
0
)
{
return
current
==
0
?
0.0
:
null
;
// 无法计算百分比时返回null,前端可展示“-”
return
current
==
0
?
0.0
:
null
;
// 无法计算百分比时返回null,前端可展示“-”
...
...
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/knowledge/AiKnowledgeDocumentService.java
View file @
a7cc17d2
...
@@ -133,4 +133,6 @@ public interface AiKnowledgeDocumentService {
...
@@ -133,4 +133,6 @@ public interface AiKnowledgeDocumentService {
void
updateKnowledgeDocumentDeletable
(
AiKnowledgeDocumentUpdateDeletableReqVO
reqVO
);
void
updateKnowledgeDocumentDeletable
(
AiKnowledgeDocumentUpdateDeletableReqVO
reqVO
);
PageResult
<
AiKnowledgeDocumentDO
>
getKnowledgeDocumentPageByUserId
(
AiKnowledgeDocumentPageReqVO
pageReqVO
,
Long
userId
);
PageResult
<
AiKnowledgeDocumentDO
>
getKnowledgeDocumentPageByUserId
(
AiKnowledgeDocumentPageReqVO
pageReqVO
,
Long
userId
);
void
updateKnowledgeDocumentProcessedStatus
(
AiKnowledgeDocumentUpdateProcessedStatusReqVO
reqVO
);
}
}
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/knowledge/AiKnowledgeDocumentServiceImpl.java
View file @
a7cc17d2
...
@@ -64,6 +64,12 @@ public class AiKnowledgeDocumentServiceImpl implements AiKnowledgeDocumentServic
...
@@ -64,6 +64,12 @@ public class AiKnowledgeDocumentServiceImpl implements AiKnowledgeDocumentServic
@Override
@Override
public
Long
createKnowledgeDocument
(
AiKnowledgeDocumentCreateReqVO
createReqVO
)
{
public
Long
createKnowledgeDocument
(
AiKnowledgeDocumentCreateReqVO
createReqVO
)
{
// 校验重复文件
// 设置状态为直接父级的状态
AiKnowledgeDocumentDO
sameKnowDoc
=
knowledgeDocumentMapper
.
selectByName
(
createReqVO
);
if
(
sameKnowDoc
!=
null
){
throw
exception
(
KNOWLEDGE_REPEAT_FILE
);
}
// 1. 校验参数
// 1. 校验参数
knowledgeService
.
validateKnowledgeExists
(
createReqVO
.
getKnowledgeId
());
knowledgeService
.
validateKnowledgeExists
(
createReqVO
.
getKnowledgeId
());
String
content
=
createReqVO
.
getContent
();
String
content
=
createReqVO
.
getContent
();
...
@@ -203,6 +209,16 @@ public class AiKnowledgeDocumentServiceImpl implements AiKnowledgeDocumentServic
...
@@ -203,6 +209,16 @@ public class AiKnowledgeDocumentServiceImpl implements AiKnowledgeDocumentServic
List
<
AiKnowledgeDocumentDO
>
documentDOs
=
new
ArrayList
<>(
createListReqVO
.
getList
().
size
());
List
<
AiKnowledgeDocumentDO
>
documentDOs
=
new
ArrayList
<>(
createListReqVO
.
getList
().
size
());
for
(
int
i
=
0
;
i
<
createListReqVO
.
getList
().
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
createListReqVO
.
getList
().
size
();
i
++)
{
AiKnowledgeDocumentCreateListReqVO
.
Document
documentVO
=
createListReqVO
.
getList
().
get
(
i
);
AiKnowledgeDocumentCreateListReqVO
.
Document
documentVO
=
createListReqVO
.
getList
().
get
(
i
);
// 校验重复文件
// 设置状态为直接父级的状态
AiKnowledgeDocumentCreateReqVO
createReqVO
=
new
AiKnowledgeDocumentCreateReqVO
();
createReqVO
.
setKnowledgeId
(
createListReqVO
.
getKnowledgeId
());
createReqVO
.
setParentId
(
parentId
);
createReqVO
.
setName
(
documentVO
.
getName
());
AiKnowledgeDocumentDO
sameKnowDoc
=
knowledgeDocumentMapper
.
selectByName
(
createReqVO
);
if
(
sameKnowDoc
!=
null
){
continue
;
}
documentDOs
.
add
(
BeanUtils
.
toBean
(
documentVO
,
AiKnowledgeDocumentDO
.
class
)
documentDOs
.
add
(
BeanUtils
.
toBean
(
documentVO
,
AiKnowledgeDocumentDO
.
class
)
.
setKnowledgeId
(
createListReqVO
.
getKnowledgeId
())
.
setKnowledgeId
(
createListReqVO
.
getKnowledgeId
())
.
setParentId
(
parentId
)
.
setParentId
(
parentId
)
...
@@ -546,6 +562,16 @@ public class AiKnowledgeDocumentServiceImpl implements AiKnowledgeDocumentServic
...
@@ -546,6 +562,16 @@ public class AiKnowledgeDocumentServiceImpl implements AiKnowledgeDocumentServic
}
}
@Override
@Override
public
void
updateKnowledgeDocumentProcessedStatus
(
AiKnowledgeDocumentUpdateProcessedStatusReqVO
reqVO
)
{
// 1. 校验存在
AiKnowledgeDocumentDO
document
=
validateKnowledgeDocumentExists
(
reqVO
.
getId
());
// 2. 更新状态
knowledgeDocumentMapper
.
updateById
(
new
AiKnowledgeDocumentDO
()
.
setId
(
reqVO
.
getId
()).
setProcessed
(
reqVO
.
getProcessed
()));
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
deleteKnowledgeDocumentByKnowledgeId
(
Long
knowledgeId
)
{
public
void
deleteKnowledgeDocumentByKnowledgeId
(
Long
knowledgeId
)
{
// // 1. 获取该知识库下的所有文档
// // 1. 获取该知识库下的所有文档
...
...
ruoyi-vue-pro-master-jdk17/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
View file @
a7cc17d2
...
@@ -17,6 +17,8 @@ public interface ErrorCodeConstants {
...
@@ -17,6 +17,8 @@ public interface ErrorCodeConstants {
ErrorCode
AUTH_MOBILE_NOT_EXISTS
=
new
ErrorCode
(
1_002_000_007
,
"手机号不存在"
);
ErrorCode
AUTH_MOBILE_NOT_EXISTS
=
new
ErrorCode
(
1_002_000_007
,
"手机号不存在"
);
ErrorCode
AUTH_REGISTER_CAPTCHA_CODE_ERROR
=
new
ErrorCode
(
1_002_000_008
,
"验证码不正确,原因:{}"
);
ErrorCode
AUTH_REGISTER_CAPTCHA_CODE_ERROR
=
new
ErrorCode
(
1_002_000_008
,
"验证码不正确,原因:{}"
);
ErrorCode
AUTH_LOGIN_WEAK_PASSWORD
=
new
ErrorCode
(
1_002_000_009
,
"弱密码被系统禁用,请修改密码!"
);
// ========== 菜单模块 1-002-001-000 ==========
// ========== 菜单模块 1-002-001-000 ==========
ErrorCode
MENU_NAME_DUPLICATE
=
new
ErrorCode
(
1_002_001_000
,
"已经存在该名字的菜单"
);
ErrorCode
MENU_NAME_DUPLICATE
=
new
ErrorCode
(
1_002_001_000
,
"已经存在该名字的菜单"
);
ErrorCode
MENU_PARENT_NOT_EXISTS
=
new
ErrorCode
(
1_002_001_001
,
"父菜单不存在"
);
ErrorCode
MENU_PARENT_NOT_EXISTS
=
new
ErrorCode
(
1_002_001_001
,
"父菜单不存在"
);
...
...
ruoyi-vue-pro-master-jdk17/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/logger/LoginResultEnum.java
View file @
a7cc17d2
...
@@ -16,6 +16,8 @@ public enum LoginResultEnum {
...
@@ -16,6 +16,8 @@ public enum LoginResultEnum {
CAPTCHA_NOT_FOUND
(
30
),
// 图片验证码不存在
CAPTCHA_NOT_FOUND
(
30
),
// 图片验证码不存在
CAPTCHA_CODE_ERROR
(
31
),
// 图片验证码不正确
CAPTCHA_CODE_ERROR
(
31
),
// 图片验证码不正确
WEAK_PASSWORD
(
40
),
// 弱密码被禁止登陆
;
;
/**
/**
...
...
ruoyi-vue-pro-master-jdk17/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java
View file @
a7cc17d2
...
@@ -30,10 +30,14 @@ import com.xingyuv.captcha.service.CaptchaService;
...
@@ -30,10 +30,14 @@ import com.xingyuv.captcha.service.CaptchaService;
import
jakarta.annotation.Resource
;
import
jakarta.annotation.Resource
;
import
jakarta.validation.Validator
;
import
jakarta.validation.Validator
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.Arrays
;
import
java.util.HashSet
;
import
java.util.Objects
;
import
java.util.Objects
;
import
java.util.Set
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
exception
.
util
.
ServiceExceptionUtil
.
exception
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
exception
.
util
.
ServiceExceptionUtil
.
exception
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
util
.
servlet
.
ServletUtils
.
getClientIP
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
util
.
servlet
.
ServletUtils
.
getClientIP
;
...
@@ -71,6 +75,35 @@ public class AdminAuthServiceImpl implements AdminAuthService {
...
@@ -71,6 +75,35 @@ public class AdminAuthServiceImpl implements AdminAuthService {
@Value
(
"${yudao.captcha.enable:true}"
)
@Value
(
"${yudao.captcha.enable:true}"
)
private
Boolean
captchaEnable
;
private
Boolean
captchaEnable
;
// 常见弱密码黑名单(静态常量,可放入类中)
private
static
final
Set
<
String
>
WEAK_PASSWORD_SET
=
new
HashSet
<>(
Arrays
.
asList
(
"123456"
,
"password"
,
"12345678"
,
"qwerty"
,
"abc123"
,
"admin"
,
"1234567890"
));
/**
* 弱密码校验函数
* @param rawPassword 明文密码
* @return true-弱密码,false-非弱密码
*/
private
boolean
isWeakPassword
(
String
rawPassword
)
{
if
(
StringUtils
.
isBlank
(
rawPassword
))
{
return
true
;
}
// 长度小于 8 位
if
(
rawPassword
.
length
()
<
8
)
{
return
true
;
}
// 纯数字或纯字母
if
(
rawPassword
.
matches
(
"\\d+"
)
||
rawPassword
.
matches
(
"[a-zA-Z]+"
))
{
return
true
;
}
// 命中常见弱密码列表
if
(
WEAK_PASSWORD_SET
.
contains
(
rawPassword
.
toLowerCase
()))
{
return
true
;
}
return
false
;
}
@Override
@Override
public
AdminUserDO
authenticate
(
String
username
,
String
password
)
{
public
AdminUserDO
authenticate
(
String
username
,
String
password
)
{
final
LoginLogTypeEnum
logTypeEnum
=
LoginLogTypeEnum
.
LOGIN_USERNAME
;
final
LoginLogTypeEnum
logTypeEnum
=
LoginLogTypeEnum
.
LOGIN_USERNAME
;
...
@@ -100,6 +133,14 @@ public class AdminAuthServiceImpl implements AdminAuthService {
...
@@ -100,6 +133,14 @@ public class AdminAuthServiceImpl implements AdminAuthService {
// 使用账号密码,进行登录
// 使用账号密码,进行登录
AdminUserDO
user
=
authenticate
(
reqVO
.
getUsername
(),
reqVO
.
getPassword
());
AdminUserDO
user
=
authenticate
(
reqVO
.
getUsername
(),
reqVO
.
getPassword
());
// 弱密码校验(仅针对用户名密码登录)
if
(
isWeakPassword
(
reqVO
.
getPassword
()))
{
// 记录登录失败日志
createLoginLog
(
user
.
getId
(),
reqVO
.
getUsername
(),
LoginLogTypeEnum
.
LOGIN_USERNAME
,
LoginResultEnum
.
WEAK_PASSWORD
);
throw
exception
(
AUTH_LOGIN_WEAK_PASSWORD
);
}
// 如果 socialType 非空,说明需要绑定社交用户
// 如果 socialType 非空,说明需要绑定社交用户
if
(
reqVO
.
getSocialType
()
!=
null
)
{
if
(
reqVO
.
getSocialType
()
!=
null
)
{
socialUserService
.
bindSocialUser
(
new
SocialUserBindReqDTO
(
user
.
getId
(),
getUserType
().
getValue
(),
socialUserService
.
bindSocialUser
(
new
SocialUserBindReqDTO
(
user
.
getId
(),
getUserType
().
getValue
(),
...
...
ruoyi-vue-pro-master-jdk17/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java
View file @
a7cc17d2
...
@@ -25,6 +25,8 @@ import cn.iocoder.yudao.module.system.dal.dataobject.dept.UserPostDO;
...
@@ -25,6 +25,8 @@ import cn.iocoder.yudao.module.system.dal.dataobject.dept.UserPostDO;
import
cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO
;
import
cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO
;
import
cn.iocoder.yudao.module.system.dal.mysql.dept.UserPostMapper
;
import
cn.iocoder.yudao.module.system.dal.mysql.dept.UserPostMapper
;
import
cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper
;
import
cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper
;
import
cn.iocoder.yudao.module.system.enums.logger.LoginLogTypeEnum
;
import
cn.iocoder.yudao.module.system.enums.logger.LoginResultEnum
;
import
cn.iocoder.yudao.module.system.service.dept.DeptService
;
import
cn.iocoder.yudao.module.system.service.dept.DeptService
;
import
cn.iocoder.yudao.module.system.service.dept.PostService
;
import
cn.iocoder.yudao.module.system.service.dept.PostService
;
import
cn.iocoder.yudao.module.system.service.permission.PermissionService
;
import
cn.iocoder.yudao.module.system.service.permission.PermissionService
;
...
@@ -36,6 +38,7 @@ import com.mzt.logapi.starter.annotation.LogRecord;
...
@@ -36,6 +38,7 @@ import com.mzt.logapi.starter.annotation.LogRecord;
import
jakarta.annotation.Resource
;
import
jakarta.annotation.Resource
;
import
jakarta.validation.ConstraintViolationException
;
import
jakarta.validation.ConstraintViolationException
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -85,6 +88,11 @@ public class AdminUserServiceImpl implements AdminUserService {
...
@@ -85,6 +88,11 @@ public class AdminUserServiceImpl implements AdminUserService {
@Resource
@Resource
private
ConfigApi
configApi
;
private
ConfigApi
configApi
;
// 常见弱密码黑名单(静态常量,可放入类中)
private
static
final
Set
<
String
>
WEAK_PASSWORD_SET
=
new
HashSet
<>(
Arrays
.
asList
(
"123456"
,
"password"
,
"12345678"
,
"qwerty"
,
"abc123"
,
"admin"
,
"1234567890"
));
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@LogRecord
(
type
=
SYSTEM_USER_TYPE
,
subType
=
SYSTEM_USER_CREATE_SUB_TYPE
,
bizNo
=
"{{#user.id}}"
,
@LogRecord
(
type
=
SYSTEM_USER_TYPE
,
subType
=
SYSTEM_USER_CREATE_SUB_TYPE
,
bizNo
=
"{{#user.id}}"
,
...
@@ -212,6 +220,30 @@ public class AdminUserServiceImpl implements AdminUserService {
...
@@ -212,6 +220,30 @@ public class AdminUserServiceImpl implements AdminUserService {
return
avatar
;
return
avatar
;
}
}
/**
* 弱密码校验函数
* @param rawPassword 明文密码
* @return true-弱密码,false-非弱密码
*/
private
boolean
isWeakPassword
(
String
rawPassword
)
{
if
(
StringUtils
.
isBlank
(
rawPassword
))
{
return
true
;
}
// 长度小于 8 位
if
(
rawPassword
.
length
()
<
8
)
{
return
true
;
}
// 纯数字或纯字母
if
(
rawPassword
.
matches
(
"\\d+"
)
||
rawPassword
.
matches
(
"[a-zA-Z]+"
))
{
return
true
;
}
// 命中常见弱密码列表
if
(
WEAK_PASSWORD_SET
.
contains
(
rawPassword
.
toLowerCase
()))
{
return
true
;
}
return
false
;
}
@Override
@Override
@LogRecord
(
type
=
SYSTEM_USER_TYPE
,
subType
=
SYSTEM_USER_UPDATE_PASSWORD_SUB_TYPE
,
bizNo
=
"{{#id}}"
,
@LogRecord
(
type
=
SYSTEM_USER_TYPE
,
subType
=
SYSTEM_USER_UPDATE_PASSWORD_SUB_TYPE
,
bizNo
=
"{{#id}}"
,
success
=
SYSTEM_USER_UPDATE_PASSWORD_SUCCESS
)
success
=
SYSTEM_USER_UPDATE_PASSWORD_SUCCESS
)
...
@@ -219,6 +251,11 @@ public class AdminUserServiceImpl implements AdminUserService {
...
@@ -219,6 +251,11 @@ public class AdminUserServiceImpl implements AdminUserService {
// 1. 校验用户存在
// 1. 校验用户存在
AdminUserDO
user
=
validateUserExists
(
id
);
AdminUserDO
user
=
validateUserExists
(
id
);
// 弱密码校验(仅针对用户名密码登录)
if
(
isWeakPassword
(
password
))
{
throw
exception
(
AUTH_LOGIN_WEAK_PASSWORD
);
}
// 2. 更新密码
// 2. 更新密码
AdminUserDO
updateObj
=
new
AdminUserDO
();
AdminUserDO
updateObj
=
new
AdminUserDO
();
updateObj
.
setId
(
id
);
updateObj
.
setId
(
id
);
...
...
ruoyi-vue-pro-master-jdk17/yudao-server/.DS_Store
View file @
a7cc17d2
No preview for this file type
yudao-ui-admin-vue3/.DS_Store
View file @
a7cc17d2
No preview for this file type
yudao-ui-admin-vue3/src/api/ai/chat/analysis/index.ts
View file @
a7cc17d2
...
@@ -57,4 +57,8 @@ export const ChatAnalysisApi = {
...
@@ -57,4 +57,8 @@ export const ChatAnalysisApi = {
getChatKeywords
:
async
(
params
:
any
)
=>
{
getChatKeywords
:
async
(
params
:
any
)
=>
{
return
await
request
.
get
({
url
:
`/ai/chat/analysis/get-keywords`
,
params
})
return
await
request
.
get
({
url
:
`/ai/chat/analysis/get-keywords`
,
params
})
},
},
getChatSummary
:
async
(
params
:
any
)
=>
{
return
await
request
.
get
({
url
:
`/ai/chat/analysis/get-summary`
,
params
})
},
}
}
yudao-ui-admin-vue3/src/views/ai/chat/manager/ChatConversationList.vue
View file @
a7cc17d2
...
@@ -12,6 +12,7 @@
...
@@ -12,6 +12,7 @@
<el-select
<el-select
v-model=
"queryParams.userId"
v-model=
"queryParams.userId"
clearable
clearable
filterable
placeholder=
"请输入用户编号"
placeholder=
"请输入用户编号"
class=
"!w-240px"
class=
"!w-240px"
>
>
...
...
yudao-ui-admin-vue3/src/views/ai/chat/manager/ChatMessageList.vue
View file @
a7cc17d2
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
<el-select
<el-select
v-model=
"queryParams.userId"
v-model=
"queryParams.userId"
clearable
clearable
filterable
placeholder=
"请输入用户编号"
placeholder=
"请输入用户编号"
class=
"!w-240px"
class=
"!w-240px"
>
>
...
...
yudao-ui-admin-vue3/src/views/ai/chat_analysis/message/index copy.vue
0 → 100644
View file @
a7cc17d2
<
template
>
<el-container
class=
"ai-layout"
>
<!-- 左侧:对话列表 -->
<ConversationList
:active-id=
"activeConversationId"
ref=
"conversationListRef"
@
on-conversation-create=
"handleConversationCreateSuccess"
@
on-conversation-click=
"handleConversationClick"
@
on-conversation-clear=
"handleConversationClear"
@
on-conversation-delete=
"handlerConversationDelete"
/>
<!-- 右侧:对话详情 -->
<el-container
class=
"detail-container"
>
<el-header
class=
"header"
>
<div
class=
"header-left"
>
<el-button
size=
"small"
@
click=
"handleExpandAllAnalysis"
>
一键展开
</el-button>
<el-button
size=
"small"
@
click=
"handleCollapseAllAnalysis"
>
一键收起
</el-button>
<el-button
size=
"small"
@
click=
"handleSummary"
>
今日总结
</el-button>
</div>
</el-header>
<!-- main:消息列表 -->
<el-main
class=
"main-container"
>
<div>
<div
class=
"message-container"
>
<!-- 情况一:消息加载中 -->
<MessageLoading
v-if=
"activeMessageListLoading"
/>
<!-- 情况二:无聊天对话时 -->
<MessageNewConversation
v-if=
"!activeConversation"
@
on-new-conversation=
"handleConversationCreate"
/>
<!-- 情况三:消息列表为空 -->
<MessageListEmpty
v-if=
"!activeMessageListLoading && messageList.length === 0 && activeConversation"
@
on-prompt=
"doSendMessage"
/>
<!-- 情况四:消息列表不为空 -->
<MessageList
v-if=
"!activeMessageListLoading && messageList.length > 0"
ref=
"messageRef"
:conversation=
"activeConversation"
:list=
"messageList"
@
on-delete-success=
"handleMessageDelete"
@
on-edit=
"handleMessageEdit"
@
on-refresh=
"handleMessageRefresh"
/>
</div>
</div>
</el-main>
</el-container>
<!-- 更新对话 Form -->
<ConversationUpdateForm
ref=
"conversationUpdateFormRef"
@
success=
"handleConversationUpdateSuccess"
/>
</el-container>
</
template
>
<
script
setup
lang=
"ts"
>
import
{
ChatMessageApi
,
ChatMessageVO
}
from
'@/api/ai/chat/message'
import
{
ChatAnalysisApi
,
ChatAnalysisVO
}
from
'@/api/ai/chat/analysis'
import
ConversationList
from
'./components/conversation/ConversationList.vue'
import
ConversationUpdateForm
from
'./components/conversation/ConversationUpdateForm.vue'
import
MessageList
from
'./components/message/MessageList.vue'
import
MessageListEmpty
from
'./components/message/MessageListEmpty.vue'
import
MessageLoading
from
'./components/message/MessageLoading.vue'
import
MessageNewConversation
from
'./components/message/MessageNewConversation.vue'
/** AI 聊天对话 列表 */
defineOptions
({
name
:
'AiChatMsg'
})
const
route
=
useRoute
()
// 路由
const
message
=
useMessage
()
// 消息弹窗
// 聊天对话
const
conversationListRef
=
ref
()
const
activeConversationId
=
ref
<
number
|
null
>
(
null
)
// 选中的对话编号
const
activeConversation
=
ref
<
ChatAnalysisVO
|
null
>
(
null
)
// 选中的 Conversation
const
conversationInProgress
=
ref
(
false
)
// 对话是否正在进行中。目前只有【发送】消息时,会更新为 true,避免切换对话、删除对话等操作
// 消息列表
const
messageRef
=
ref
()
const
activeMessageList
=
ref
<
ChatMessageVO
[]
>
([])
// 选中对话的消息列表
const
activeMessageListLoading
=
ref
<
boolean
>
(
false
)
// activeMessageList 是否正在加载中
const
activeMessageListLoadingTimer
=
ref
<
any
>
()
// activeMessageListLoading Timer 定时器。如果加载速度很快,就不进入加载中
// 消息滚动
const
textSpeed
=
ref
<
number
>
(
50
)
// Typing speed in milliseconds
const
textRoleRunning
=
ref
<
boolean
>
(
false
)
// Typing speed in milliseconds
// 发送消息输入框
const
isComposing
=
ref
(
false
)
// 判断用户是否在输入
const
conversationInAbortController
=
ref
<
any
>
()
// 对话进行中 abort 控制器(控制 stream 对话)
const
inputTimeout
=
ref
<
any
>
()
// 处理输入中回车的定时器
const
prompt
=
ref
<
string
>
()
// prompt
const
enableContext
=
ref
<
boolean
>
(
true
)
// 是否开启上下文
// 接收 Stream 消息
const
receiveMessageFullText
=
ref
(
''
)
const
receiveMessageDisplayedText
=
ref
(
''
)
// 获取子组件 ref
// const messageRef = ref
<
InstanceType
<
typeof
MessageList
>>
()
// 一键展开所有分析面板
const
handleExpandAllAnalysis
=
()
=>
{
if
(
messageRef
.
value
)
{
messageRef
.
value
.
toggleAllAnalysis
(
true
)
}
}
// 一键收起所有分析面板
const
handleCollapseAllAnalysis
=
()
=>
{
if
(
messageRef
.
value
)
{
messageRef
.
value
.
toggleAllAnalysis
(
false
)
}
}
// =========== 【聊天对话】相关 ===========
/** 获取对话信息 */
const
getConversation
=
async
(
id
:
number
|
null
)
=>
{
if
(
!
id
)
{
return
}
const
conversation
:
ChatAnalysisVO
=
await
ChatAnalysisApi
.
getChatConversationMyList
(
id
)
if
(
!
conversation
)
{
return
}
activeConversation
.
value
=
conversation
activeConversationId
.
value
=
conversation
.
id
}
/**
* 点击某个对话
*
* @param conversation 选中的对话
* @return 是否切换成功
*/
const
handleConversationClick
=
async
(
conversation
:
ChatAnalysisVO
)
=>
{
// 更新选中的对话 id
activeConversationId
.
value
=
conversation
.
id
activeConversation
.
value
=
conversation
// 刷新 message 列表
await
getMessageList
()
// 滚动底部
// scrollToBottom(true)
scrollToTop
(
true
)
// 清空输入框
prompt
.
value
=
''
return
true
}
/** 删除某个对话*/
const
handlerConversationDelete
=
async
(
delConversation
:
ChatAnalysisVO
)
=>
{
// 删除的对话如果是当前选中的,那么就重置
if
(
activeConversationId
.
value
===
delConversation
.
id
)
{
await
handleConversationClear
()
}
}
/** 清空选中的对话 */
const
handleConversationClear
=
async
()
=>
{
// 对话进行中,不允许切换
if
(
conversationInProgress
.
value
)
{
message
.
alert
(
'对话中,不允许切换!'
)
return
false
}
activeConversationId
.
value
=
null
activeConversation
.
value
=
null
activeMessageList
.
value
=
[]
}
/** 修改聊天对话 */
const
conversationUpdateFormRef
=
ref
()
const
openChatConversationUpdateForm
=
async
()
=>
{
conversationUpdateFormRef
.
value
.
open
(
activeConversationId
.
value
)
}
const
handleConversationUpdateSuccess
=
async
()
=>
{
// 对话更新成功,刷新最新信息
await
getConversation
(
activeConversation
.
value
.
chatId
)
}
/** 处理聊天对话的创建成功 */
const
handleConversationCreate
=
async
()
=>
{
// 创建对话
await
conversationListRef
.
value
.
createConversation
()
}
/** 处理聊天对话的创建成功 */
const
handleConversationCreateSuccess
=
async
()
=>
{
// 创建新的对话,清空输入框
prompt
.
value
=
''
}
// =========== 【消息列表】相关 ===========
/** 获取消息 message 列表 */
const
getMessageList
=
async
()
=>
{
try
{
if
(
activeConversationId
.
value
===
null
)
{
return
}
// Timer 定时器,如果加载速度很快,就不进入加载中
activeMessageListLoadingTimer
.
value
=
setTimeout
(()
=>
{
activeMessageListLoading
.
value
=
true
},
60
)
// 获取消息列表
activeMessageList
.
value
=
await
ChatAnalysisApi
.
getChatList
(
activeConversation
.
value
.
chatId
)
// 滚动到最下面
await
nextTick
()
// await scrollToBottom()
}
finally
{
// time 定时器,如果加载速度很快,就不进入加载中
if
(
activeMessageListLoadingTimer
.
value
)
{
clearTimeout
(
activeMessageListLoadingTimer
.
value
)
}
// 加载结束
activeMessageListLoading
.
value
=
false
}
}
/**
* 消息列表
*
* 和 {@link #getMessageList()} 的差异是,把 systemMessage 考虑进去
*/
const
messageList
=
computed
(()
=>
{
if
(
activeMessageList
.
value
.
length
>
0
)
{
return
activeMessageList
.
value
}
// 没有消息时,如果有 systemMessage 则展示它
if
(
activeConversation
.
value
?.
systemMessage
)
{
return
[
{
id
:
0
,
type
:
'system'
,
content
:
activeConversation
.
value
.
systemMessage
}
]
}
return
[]
})
/** 处理删除 message 消息 */
const
handleMessageDelete
=
()
=>
{
if
(
conversationInProgress
.
value
)
{
message
.
alert
(
'回答中,不能删除!'
)
return
}
// 刷新 message 列表
getMessageList
()
}
/** 处理 message 清空 */
const
handlerMessageClear
=
async
()
=>
{
if
(
!
activeConversationId
.
value
)
{
return
}
try
{
// 确认提示
await
message
.
delConfirm
(
'确认清空对话消息?'
)
// 清空对话
await
ChatMessageApi
.
deleteByConversationId
(
activeConversationId
.
value
)
// 刷新 message 列表
activeMessageList
.
value
=
[]
}
catch
{}
}
/** 回到 message 列表的顶部 */
const
handleGoTopMessage
=
()
=>
{
messageRef
.
value
.
handlerGoTop
()
}
// =========== 【发送消息】相关 ===========
/** 处理来自 keydown 的发送消息 */
const
handleSendByKeydown
=
async
(
event
)
=>
{
// 判断用户是否在输入
if
(
isComposing
.
value
)
{
return
}
// 进行中不允许发送
if
(
conversationInProgress
.
value
)
{
return
}
const
content
=
prompt
.
value
?.
trim
()
as
string
if
(
event
.
key
===
'Enter'
)
{
if
(
event
.
shiftKey
)
{
// 插入换行
prompt
.
value
+=
'\r\n'
event
.
preventDefault
()
// 防止默认的换行行为
}
else
{
// 发送消息
await
doSendMessage
(
content
)
event
.
preventDefault
()
// 防止默认的提交行为
}
}
}
/** 处理来自【发送】按钮的发送消息 */
const
handleSendByButton
=
()
=>
{
doSendMessage
(
prompt
.
value
?.
trim
()
as
string
)
}
/** 处理 prompt 输入变化 */
const
handlePromptInput
=
(
event
)
=>
{
// 非输入法 输入设置为 true
if
(
!
isComposing
.
value
)
{
// 回车 event data 是 null
if
(
event
.
data
==
null
)
{
return
}
isComposing
.
value
=
true
}
// 清理定时器
if
(
inputTimeout
.
value
)
{
clearTimeout
(
inputTimeout
.
value
)
}
// 重置定时器
inputTimeout
.
value
=
setTimeout
(()
=>
{
isComposing
.
value
=
false
},
400
)
}
// TODO @芋艿:是不是可以通过 @keydown.enter、@keydown.shift.enter 来实现,回车发送、shift+回车换行;主要看看,是不是可以简化 isComposing 相关的逻辑
const
onCompositionstart
=
()
=>
{
isComposing
.
value
=
true
}
const
onCompositionend
=
()
=>
{
// console.log('输入结束...')
setTimeout
(()
=>
{
isComposing
.
value
=
false
},
200
)
}
/** 真正执行【发送】消息操作 */
const
doSendMessage
=
async
(
content
:
string
)
=>
{
// 校验
if
(
content
.
length
<
1
)
{
message
.
error
(
'发送失败,原因:内容为空!'
)
return
}
if
(
activeConversationId
.
value
==
null
)
{
message
.
error
(
'还没创建对话,不能发送!'
)
return
}
// 清空输入框
prompt
.
value
=
''
// 执行发送
await
doSendMessageStream
({
conversationId
:
activeConversationId
.
value
,
content
:
content
}
as
ChatMessageVO
)
}
/** 真正执行【发送】消息操作 */
const
doSendMessageStream
=
async
(
userMessage
:
ChatMessageVO
)
=>
{
// 创建 AbortController 实例,以便中止请求
conversationInAbortController
.
value
=
new
AbortController
()
// 标记对话进行中
conversationInProgress
.
value
=
true
// 设置为空
receiveMessageFullText
.
value
=
''
try
{
// 1.1 先添加两个假数据,等 stream 返回再替换
activeMessageList
.
value
.
push
({
id
:
-
1
,
conversationId
:
activeConversationId
.
value
,
type
:
'user'
,
content
:
userMessage
.
content
,
createTime
:
new
Date
()
}
as
ChatMessageVO
)
activeMessageList
.
value
.
push
({
id
:
-
2
,
conversationId
:
activeConversationId
.
value
,
type
:
'assistant'
,
content
:
'思考中...'
,
createTime
:
new
Date
()
}
as
ChatMessageVO
)
// 1.2 滚动到最下面
await
nextTick
()
await
scrollToBottom
()
// 底部
// 1.3 开始滚动
textRoll
()
// 2. 发送 event stream
let
isFirstChunk
=
true
// 是否是第一个 chunk 消息段
await
ChatMessageApi
.
sendChatMessageStream
(
userMessage
.
conversationId
,
userMessage
.
content
,
conversationInAbortController
.
value
,
enableContext
.
value
,
async
(
res
)
=>
{
const
{
code
,
data
,
msg
}
=
JSON
.
parse
(
res
.
data
)
if
(
code
!==
0
)
{
message
.
alert
(
`对话异常!
${
msg
}
`
)
return
}
// 如果内容为空,就不处理。
if
(
data
.
receive
.
content
===
''
)
{
return
}
// 首次返回需要添加一个 message 到页面,后面的都是更新
if
(
isFirstChunk
)
{
isFirstChunk
=
false
// 弹出两个假数据
activeMessageList
.
value
.
pop
()
activeMessageList
.
value
.
pop
()
// 更新返回的数据
activeMessageList
.
value
.
push
(
data
.
send
)
activeMessageList
.
value
.
push
(
data
.
receive
)
}
// debugger
receiveMessageFullText
.
value
=
receiveMessageFullText
.
value
+
data
.
receive
.
content
// 滚动到最下面
await
scrollToBottom
()
},
(
error
)
=>
{
message
.
alert
(
`对话异常!
${
error
}
`
)
stopStream
()
},
()
=>
{
stopStream
()
}
)
}
catch
{}
}
/** 停止 stream 流式调用 */
const
stopStream
=
async
()
=>
{
// tip:如果 stream 进行中的 message,就需要调用 controller 结束
if
(
conversationInAbortController
.
value
)
{
conversationInAbortController
.
value
.
abort
()
}
// 设置为 false
conversationInProgress
.
value
=
false
}
/** 编辑 message:设置为 prompt,可以再次编辑 */
const
handleMessageEdit
=
(
message
:
ChatMessageVO
)
=>
{
prompt
.
value
=
message
.
content
}
/** 刷新 message:基于指定消息,再次发起对话 */
const
handleMessageRefresh
=
(
message
:
ChatMessageVO
)
=>
{
doSendMessage
(
message
.
content
)
}
// ============== 【消息滚动】相关 =============
/** 滚动到 message 底部 */
const
scrollToBottom
=
async
(
isIgnore
?:
boolean
)
=>
{
await
nextTick
()
if
(
messageRef
.
value
)
{
messageRef
.
value
.
scrollToBottom
(
isIgnore
)
}
}
const
scrollToTop
=
async
(
isIgnore
?:
boolean
)
=>
{
await
nextTick
()
if
(
messageRef
.
value
)
{
messageRef
.
value
.
handlerGoTop
()
}
}
/** 自提滚动效果 */
const
textRoll
=
async
()
=>
{
let
index
=
0
try
{
// 只能执行一次
if
(
textRoleRunning
.
value
)
{
return
}
// 设置状态
textRoleRunning
.
value
=
true
receiveMessageDisplayedText
.
value
=
''
const
task
=
async
()
=>
{
// 调整速度
const
diff
=
(
receiveMessageFullText
.
value
.
length
-
receiveMessageDisplayedText
.
value
.
length
)
/
10
if
(
diff
>
5
)
{
textSpeed
.
value
=
10
}
else
if
(
diff
>
2
)
{
textSpeed
.
value
=
30
}
else
if
(
diff
>
1.5
)
{
textSpeed
.
value
=
50
}
else
{
textSpeed
.
value
=
100
}
// 对话结束,就按 30 的速度
if
(
!
conversationInProgress
.
value
)
{
textSpeed
.
value
=
10
}
if
(
index
<
receiveMessageFullText
.
value
.
length
)
{
receiveMessageDisplayedText
.
value
+=
receiveMessageFullText
.
value
[
index
]
index
++
// 更新 message
const
lastMessage
=
activeMessageList
.
value
[
activeMessageList
.
value
.
length
-
1
]
lastMessage
.
content
=
receiveMessageDisplayedText
.
value
// 滚动到住下面
await
scrollToBottom
()
// 重新设置任务
timer
=
setTimeout
(
task
,
textSpeed
.
value
)
}
else
{
// 不是对话中可以结束
if
(
!
conversationInProgress
.
value
)
{
textRoleRunning
.
value
=
false
clearTimeout
(
timer
)
}
else
{
// 重新设置任务
timer
=
setTimeout
(
task
,
textSpeed
.
value
)
}
}
}
let
timer
=
setTimeout
(
task
,
textSpeed
.
value
)
}
catch
{}
}
/** 初始化 **/
onMounted
(
async
()
=>
{
// 如果有 conversationId 参数,则默认选中
if
(
route
.
query
.
conversationId
)
{
const
id
=
route
.
query
.
conversationId
as
unknown
as
number
activeConversationId
.
value
=
id
await
getConversation
(
id
)
}
// 获取列表数据
activeMessageListLoading
.
value
=
true
await
getMessageList
()
})
</
script
>
<
style
lang=
"scss"
scoped
>
.ai-layout
{
position
:
absolute
;
flex
:
1
;
top
:
0
;
left
:
0
;
height
:
100%
;
width
:
100%
;
}
.conversation-container
{
position
:
relative
;
display
:
flex
;
flex-direction
:
column
;
justify-content
:
space-between
;
padding
:
10px
10px
0
;
.btn-new-conversation
{
padding
:
18px
0
;
}
.search-input
{
margin-top
:
20px
;
}
.conversation-list
{
margin-top
:
20px
;
.conversation
{
display
:
flex
;
flex-direction
:
row
;
justify-content
:
space-between
;
flex
:
1
;
padding
:
0
5px
;
margin-top
:
10px
;
cursor
:
pointer
;
border-radius
:
5px
;
align-items
:
center
;
line-height
:
30px
;
&.active
{
background-color
:
#e6e6e6
;
.button
{
display
:
inline-block
;
}
}
.title-wrapper
{
display
:
flex
;
flex-direction
:
row
;
align-items
:
center
;
}
.title
{
padding
:
5px
10px
;
max-width
:
220px
;
font-size
:
14px
;
overflow
:
hidden
;
white-space
:
nowrap
;
text-overflow
:
ellipsis
;
}
.avatar
{
width
:
28px
;
height
:
28px
;
display
:
flex
;
flex-direction
:
row
;
justify-items
:
center
;
}
//
对话编辑、删除
.button-wrapper
{
right
:
2px
;
display
:
flex
;
flex-direction
:
row
;
justify-items
:
center
;
color
:
#606266
;
.el-icon
{
margin-right
:
5px
;
}
}
}
}
//
角色仓库、清空未设置对话
.tool-box
{
line-height
:
35px
;
display
:
flex
;
justify-content
:
space-between
;
align-items
:
center
;
color
:
var
(
--el-text-color
);
>
div
{
display
:
flex
;
align-items
:
center
;
color
:
#606266
;
padding
:
0
;
margin
:
0
;
cursor
:
pointer
;
>
span
{
margin-left
:
5px
;
}
}
}
}
//
头部
.detail-container
{
background
:
#ffffff
;
.header
{
display
:
flex
;
flex-direction
:
row
;
align-items
:
center
;
justify-content
:
space-between
;
background
:
#fbfbfb
;
box-shadow
:
0
0
0
0
#dcdfe6
;
.title
{
font-size
:
18px
;
font-weight
:
bold
;
}
.btns
{
display
:
flex
;
width
:
300px
;
flex-direction
:
row
;
justify-content
:
flex-end
;
//
justify-content
:
space-between
;
.btn
{
padding
:
10px
;
}
}
}
}
//
main
容器
.main-container
{
margin
:
0
;
padding
:
0
;
position
:
relative
;
height
:
100%
;
width
:
100%
;
.message-container
{
position
:
absolute
;
top
:
0
;
bottom
:
0
;
left
:
0
;
right
:
0
;
overflow-y
:
hidden
;
padding
:
0
;
margin
:
0
;
}
}
//
底部
.footer-container
{
display
:
flex
;
flex-direction
:
column
;
height
:
auto
;
margin
:
0
;
padding
:
0
;
.prompt-from
{
display
:
flex
;
flex-direction
:
column
;
height
:
auto
;
border
:
1px
solid
#e3e3e3
;
border-radius
:
10px
;
margin
:
10px
20px
20px
20px
;
padding
:
9px
10px
;
}
.prompt-input
{
height
:
80px
;
//
box-shadow
:
none
;
border
:
none
;
box-sizing
:
border-box
;
resize
:
none
;
padding
:
0
2px
;
overflow
:
auto
;
}
.prompt-input
:focus
{
outline
:
none
;
}
.prompt-btns
{
display
:
flex
;
justify-content
:
space-between
;
padding-bottom
:
0
;
padding-top
:
5px
;
}
}
</
style
>
yudao-ui-admin-vue3/src/views/ai/chat_analysis/message/index.vue
View file @
a7cc17d2
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
<div
class=
"header-left"
>
<div
class=
"header-left"
>
<el-button
size=
"small"
@
click=
"handleExpandAllAnalysis"
>
一键展开
</el-button>
<el-button
size=
"small"
@
click=
"handleExpandAllAnalysis"
>
一键展开
</el-button>
<el-button
size=
"small"
@
click=
"handleCollapseAllAnalysis"
>
一键收起
</el-button>
<el-button
size=
"small"
@
click=
"handleCollapseAllAnalysis"
>
一键收起
</el-button>
<el-button
size=
"small"
@
click=
"handleSummary"
>
今日总结
</el-button>
</div>
</div>
</el-header>
</el-header>
...
@@ -55,6 +56,16 @@
...
@@ -55,6 +56,16 @@
ref=
"conversationUpdateFormRef"
ref=
"conversationUpdateFormRef"
@
success=
"handleConversationUpdateSuccess"
@
success=
"handleConversationUpdateSuccess"
/>
/>
<!-- 新增:今日总结抽屉 -->
<el-drawer
v-model=
"summaryDrawerVisible"
:title=
"drawerTitle"
direction=
"rtl"
size=
"40%"
>
<div
class=
"summary-content"
v-html=
"formattedSummary"
></div>
</el-drawer>
</el-container>
</el-container>
</
template
>
</
template
>
...
@@ -99,8 +110,20 @@ const enableContext = ref<boolean>(true) // 是否开启上下文
...
@@ -99,8 +110,20 @@ const enableContext = ref<boolean>(true) // 是否开启上下文
const
receiveMessageFullText
=
ref
(
''
)
const
receiveMessageFullText
=
ref
(
''
)
const
receiveMessageDisplayedText
=
ref
(
''
)
const
receiveMessageDisplayedText
=
ref
(
''
)
// 获取子组件 ref
// ========== 新增:总结抽屉相关 ==========
// const messageRef = ref
<
InstanceType
<
typeof
MessageList
>>
()
const
summaryDrawerVisible
=
ref
(
false
)
// 抽屉显示状态
const
summaryContent
=
ref
(
''
)
// 总结原始内容
const
drawerTitle
=
ref
(
''
)
// 抽屉标题
// 若后端返回的summary包含HTML标签则直接渲染,否则可进行Markdown转换(按需)
const
formattedSummary
=
computed
(()
=>
{
// 如果内容是纯文本,可以转换为HTML(如换行转
<
br
>
)
if
(
summaryContent
.
value
)
{
return
summaryContent
.
value
.
replace
(
/
\n
/g
,
'
<
br
>
')
}
return ''
})
// =====================================
// 一键展开所有分析面板
// 一键展开所有分析面板
const handleExpandAllAnalysis = () => {
const handleExpandAllAnalysis = () => {
...
@@ -522,6 +545,40 @@ const textRoll = async () => {
...
@@ -522,6 +545,40 @@ const textRoll = async () => {
let
timer
=
setTimeout
(
task
,
textSpeed
.
value
)
let
timer
=
setTimeout
(
task
,
textSpeed
.
value
)
}
catch
{}
}
catch
{}
}
}
import
dayjs
from
'dayjs'
// =========== 新增:今日总结功能 ===========
const
handleSummary
=
async
()
=>
{
// 校验是否有选中的对话
if
(
!
activeConversationId
.
value
)
{
message
.
warning
(
'请先选择一个对话'
)
return
}
// 获取今日日期时间戳(当天0点,毫秒)
const
today
=
new
Date
()
today
.
setHours
(
0
,
0
,
0
,
0
)
const
dateTimestamp
=
dayjs
(
today
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
// 生成抽屉标题:例如 “5.17对话分析总结”
const
month
=
today
.
getMonth
()
+
1
const
day
=
today
.
getDate
()
drawerTitle
.
value
=
`
${
month
}
.
${
day
}
对话分析总结`
try
{
// 调用接口(参数格式根据实际API调整,此处假设接收 conversationId 和 date)
const
res
=
await
ChatAnalysisApi
.
getChatSummary
({
chatId
:
activeConversationId
.
value
,
summaryTime
:
dateTimestamp
})
// 假设返回数据中 summary 字段为总结内容
summaryContent
.
value
=
res
?.
summary
??
'暂无总结内容'
summaryDrawerVisible
.
value
=
true
}
catch
(
error
)
{
console
.
error
(
'获取对话总结失败'
,
error
)
message
.
error
(
'获取总结失败,请稍后重试'
)
}
}
// =====================================
/** 初始化 **/
/** 初始化 **/
onMounted
(
async
()
=>
{
onMounted
(
async
()
=>
{
...
@@ -737,4 +794,14 @@ onMounted(async () => {
...
@@ -737,4 +794,14 @@ onMounted(async () => {
padding-top
:
5px
;
padding-top
:
5px
;
}
}
}
}
</
style
>
//
新增:总结抽屉内容样式
.summary-content
{
padding
:
16px
;
font-size
:
14px
;
line-height
:
1.6
;
color
:
#333
;
white-space
:
pre-wrap
;
word-break
:
break-word
;
}
</
style
>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment