feat: 新增账号编码和HTTP连接功能
This commit is contained in:
@@ -6,32 +6,33 @@ import (
|
||||
"context"
|
||||
"customer-server/dao"
|
||||
"customer-server/model/dto"
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
var (
|
||||
ScriptedSpeech = new(scriptedSpeech)
|
||||
ScriptedSpeechService = new(scriptedSpeechService)
|
||||
)
|
||||
|
||||
type scriptedSpeech struct{}
|
||||
type scriptedSpeechService struct{}
|
||||
|
||||
// Add 添加预制话术
|
||||
// 参数: ctx - 上下文,req - 添加预制话术请求
|
||||
// 返回: res - 添加成功后的预制话术ID,err - 错误信息
|
||||
// 功能: 创建新的预制话术记录
|
||||
func (s *scriptedSpeech) Add(ctx context.Context, req *dto.AddScriptedSpeechReq) (res *dto.AddScriptedSpeechRes, err error) {
|
||||
// 检查账号是否存在
|
||||
account, err := dao.Account.GetById(ctx, &dto.GetAccountReq{Id: req.AccountId})
|
||||
func (s *scriptedSpeechService) Add(ctx context.Context, req *dto.AddScriptedSpeechReq) (res *dto.AddScriptedSpeechRes, err error) {
|
||||
count, err := dao.ScriptedSpeech.Count(ctx, &dto.ListScriptedSpeechReq{
|
||||
DatasetId: req.DatasetId,
|
||||
SceneType: req.SceneType,
|
||||
})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if account == nil {
|
||||
err = gerror.New("客服账号不存在")
|
||||
if count > 0 {
|
||||
err = fmt.Errorf("话术场景已存在")
|
||||
return
|
||||
}
|
||||
|
||||
// 插入数据库
|
||||
id, err := dao.ScriptedSpeech.Insert(ctx, req)
|
||||
if err != nil {
|
||||
@@ -45,7 +46,7 @@ func (s *scriptedSpeech) Add(ctx context.Context, req *dto.AddScriptedSpeechReq)
|
||||
// 参数: ctx - 上下文,req - 更新预制话术请求
|
||||
// 返回: err - 错误信息
|
||||
// 功能: 更新预制话术信息
|
||||
func (s *scriptedSpeech) Update(ctx context.Context, req *dto.UpdateScriptedSpeechReq) (err error) {
|
||||
func (s *scriptedSpeechService) Update(ctx context.Context, req *dto.UpdateScriptedSpeechReq) (err error) {
|
||||
_, err = dao.ScriptedSpeech.Update(ctx, req)
|
||||
return
|
||||
}
|
||||
@@ -54,7 +55,7 @@ func (s *scriptedSpeech) Update(ctx context.Context, req *dto.UpdateScriptedSpee
|
||||
// 参数: ctx - 上下文,req - 删除预制话术请求
|
||||
// 返回: err - 错误信息
|
||||
// 功能: 逻辑删除预制话术记录
|
||||
func (s *scriptedSpeech) Delete(ctx context.Context, req *dto.DeleteScriptedSpeechReq) (err error) {
|
||||
func (s *scriptedSpeechService) Delete(ctx context.Context, req *dto.DeleteScriptedSpeechReq) (err error) {
|
||||
_, err = dao.ScriptedSpeech.Delete(ctx, req)
|
||||
return
|
||||
}
|
||||
@@ -63,7 +64,7 @@ func (s *scriptedSpeech) Delete(ctx context.Context, req *dto.DeleteScriptedSpee
|
||||
// 参数: ctx - 上下文,req - 获取预制话术请求
|
||||
// 返回: res - 预制话术信息,err - 错误信息
|
||||
// 功能: 根据ID获取单个预制话术详情
|
||||
func (s *scriptedSpeech) Get(ctx context.Context, req *dto.GetScriptedSpeechReq) (res *dto.ScriptedSpeechVO, err error) {
|
||||
func (s *scriptedSpeechService) Get(ctx context.Context, req *dto.GetScriptedSpeechReq) (res *dto.ScriptedSpeechVO, err error) {
|
||||
r, err := dao.ScriptedSpeech.GetById(ctx, req)
|
||||
if err != nil {
|
||||
return
|
||||
@@ -76,7 +77,7 @@ func (s *scriptedSpeech) Get(ctx context.Context, req *dto.GetScriptedSpeechReq)
|
||||
// 参数: ctx - 上下文,req - 列表查询请求
|
||||
// 返回: res - 预制话术列表及分页信息,err - 错误信息
|
||||
// 功能: 分页查询预制话术记录
|
||||
func (s *scriptedSpeech) List(ctx context.Context, req *dto.ListScriptedSpeechReq) (res *dto.ListScriptedSpeechRes, err error) {
|
||||
func (s *scriptedSpeechService) List(ctx context.Context, req *dto.ListScriptedSpeechReq) (res *dto.ListScriptedSpeechRes, err error) {
|
||||
list, total, err := dao.ScriptedSpeech.List(ctx, req)
|
||||
if err != nil {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user