62 lines
1.9 KiB
Go
62 lines
1.9 KiB
Go
package controller
|
|
|
|
import (
|
|
"ai-agent/digital-human/model/dto"
|
|
"ai-agent/digital-human/service"
|
|
"context"
|
|
|
|
"gitea.redpowerfuture.com/red-future/common/beans"
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
)
|
|
|
|
type customVoice struct{}
|
|
|
|
// CustomVoice 自定义音色控制器
|
|
var CustomVoice = new(customVoice)
|
|
|
|
// CreateCustomVoice 创建自定义音色
|
|
func (c *customVoice) CreateCustomVoice(ctx context.Context, req *dto.CreateCustomVoiceReq) (res *dto.CreateCustomVoiceRes, err error) {
|
|
// 从上下文获取用户信息
|
|
if ctx.Value("userId") == nil {
|
|
ctx = context.WithValue(ctx, "userId", gconv.String(1))
|
|
}
|
|
if ctx.Value("userName") == nil {
|
|
ctx = context.WithValue(ctx, "userName", "admin")
|
|
}
|
|
if ctx.Value("tenantId") == nil {
|
|
ctx = context.WithValue(ctx, "tenantId", uint64(1))
|
|
}
|
|
return service.CustomVoice.CreateCustomVoice(ctx, req)
|
|
}
|
|
|
|
// ListCustomVoices 获取自定义音色列表
|
|
func (c *customVoice) ListCustomVoices(ctx context.Context, req *dto.ListCustomVoiceReq) (res *dto.ListCustomVoiceRes, err error) {
|
|
// 从上下文获取用户信息
|
|
if ctx.Value("userId") == nil {
|
|
ctx = context.WithValue(ctx, "userId", gconv.String(1))
|
|
}
|
|
if ctx.Value("userName") == nil {
|
|
ctx = context.WithValue(ctx, "userName", "admin")
|
|
}
|
|
if ctx.Value("tenantId") == nil {
|
|
ctx = context.WithValue(ctx, "tenantId", uint64(1))
|
|
}
|
|
return service.CustomVoice.ListCustomVoices(ctx, req)
|
|
}
|
|
|
|
// DeleteCustomVoice 删除自定义音色
|
|
func (c *customVoice) DeleteCustomVoice(ctx context.Context, req *dto.DeleteCustomVoiceReq) (res *beans.ResponseEmpty, err error) {
|
|
// 从上下文获取用户信息
|
|
if ctx.Value("userId") == nil {
|
|
ctx = context.WithValue(ctx, "userId", gconv.String(1))
|
|
}
|
|
if ctx.Value("userName") == nil {
|
|
ctx = context.WithValue(ctx, "userName", "admin")
|
|
}
|
|
if ctx.Value("tenantId") == nil {
|
|
ctx = context.WithValue(ctx, "tenantId", uint64(1))
|
|
}
|
|
err = service.CustomVoice.DeleteCustomVoice(ctx, req)
|
|
return
|
|
}
|