88 lines
3.9 KiB
Go
88 lines
3.9 KiB
Go
|
|
// Package controller - 客服账号控制器
|
|||
|
|
// 功能:客服账号的增删改查
|
|||
|
|
package controller
|
|||
|
|
|
|||
|
|
import (
|
|||
|
|
"context"
|
|||
|
|
"customer-server/model/dto"
|
|||
|
|
"customer-server/service"
|
|||
|
|
|
|||
|
|
"gitea.com/red-future/common/beans"
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
var CustomerServiceAccount = new(customerServiceAccount)
|
|||
|
|
|
|||
|
|
type customerServiceAccount struct{}
|
|||
|
|
|
|||
|
|
// Add 添加客服账号
|
|||
|
|
// 参数: req - 添加客服账号请求,包含账号名、平台、开场白等信息
|
|||
|
|
// 返回: res - 添加成功后的账号ID等信息
|
|||
|
|
// 功能: 创建客服账号并自动创建对应的RAGFlow配置(Dataset、Chat)
|
|||
|
|
func (c *customerServiceAccount) Add(ctx context.Context, req *dto.AddCustomerServiceAccountReq) (res *dto.AddCustomerServiceAccountRes, err error) {
|
|||
|
|
res, err = service.CustomerServiceAccount.Add(ctx, req)
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Update 更新客服账号
|
|||
|
|
// 参数: req - 更新客服账号请求,包含账号ID和待更新字段
|
|||
|
|
// 返回: res - 空响应(成功则err为nil)
|
|||
|
|
// 功能: 更新客服账号基本信息(不包含开场白和RAGFlow配置)
|
|||
|
|
func (c *customerServiceAccount) Update(ctx context.Context, req *dto.UpdateCustomerServiceAccountReq) (res *beans.ResponseEmpty, err error) {
|
|||
|
|
err = service.CustomerServiceAccount.Update(ctx, req)
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ToggleStatus 切换客服账号状态(启用/禁用)
|
|||
|
|
// 参数: req - 状态切换请求,包含账号ID
|
|||
|
|
// 返回: res - 空响应(成功则err为nil)
|
|||
|
|
// 功能: 在启用和禁用状态之间切换,禁用后不再接收用户消息
|
|||
|
|
func (c *customerServiceAccount) ToggleStatus(ctx context.Context, req *dto.ToggleCustomerServiceAccountStatusReq) (res *beans.ResponseEmpty, err error) {
|
|||
|
|
err = service.CustomerServiceAccount.ToggleStatus(ctx, req)
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// List 获取客服账号列表
|
|||
|
|
// 参数: req - 列表查询请求,支持分页、平台筛选、状态筛选
|
|||
|
|
// 返回: res - 客服账号列表及分页信息
|
|||
|
|
// 功能: 分页查询客服账号,支持按平台、状态筛选
|
|||
|
|
func (c *customerServiceAccount) List(ctx context.Context, req *dto.ListCustomerServiceAccountReq) (res *dto.ListCustomerServiceAccountRes, err error) {
|
|||
|
|
res, err = service.CustomerServiceAccount.List(ctx, req)
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Delete 删除客服账号
|
|||
|
|
// 参数: req - 删除客服账号请求,包含账号ID
|
|||
|
|
// 返回: res - 删除结果信息
|
|||
|
|
// 功能: 逻辑删除客服账号,同时删除关联的RAGFlow配置
|
|||
|
|
func (c *customerServiceAccount) Delete(ctx context.Context, req *dto.DeleteCustomerServiceAccountReq) (res *dto.DeleteCustomerServiceAccountRes, err error) {
|
|||
|
|
res, err = service.CustomerServiceAccount.Delete(ctx, req)
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// GetAccessibleSpeechcrafts 获取客服账号可访问的话术列表
|
|||
|
|
// 参数: req - 查询请求,包含账号名
|
|||
|
|
// 返回: res - 该账号可访问的话术列表
|
|||
|
|
// 功能: 查询绑定到该客服账号的所有话术
|
|||
|
|
func (c *customerServiceAccount) GetAccessibleSpeechcrafts(ctx context.Context, req *dto.GetAccessibleSpeechcraftsReq) (res *dto.GetAccessibleSpeechcraftsRes, err error) {
|
|||
|
|
res, err = service.CustomerServiceAccount.GetAccessibleSpeechcrafts(ctx, req)
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// RecreateRAGFlowConfig 重新创建RAGFlow配置
|
|||
|
|
// 参数: req - 重建请求,包含账号名
|
|||
|
|
// 返回: res - 空响应(成功则err为nil)
|
|||
|
|
// 功能: 删除旧配置并重新创建Dataset和Chat,用于修复配置异常
|
|||
|
|
func (c *customerServiceAccount) RecreateRAGFlowConfig(ctx context.Context, req *dto.RecreateRAGFlowConfigReq) (res *beans.ResponseEmpty, err error) {
|
|||
|
|
err = service.CustomerServiceAccount.RecreateRAGFlowConfig(ctx, req)
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// UpdateGreeting 更新开场白
|
|||
|
|
// 参数: req - 更新开场白请求,包含账号名和新开场白内容
|
|||
|
|
// 返回: res - 空响应(成功则err为nil)
|
|||
|
|
// 功能: 更新客服账号的开场白,用户连接WebSocket时推送
|
|||
|
|
func (c *customerServiceAccount) UpdateGreeting(ctx context.Context, req *dto.UpdateGreetingReq) (res *beans.ResponseEmpty, err error) {
|
|||
|
|
err = service.CustomerServiceAccount.UpdateGreeting(ctx, req)
|
|||
|
|
return
|
|||
|
|
}
|