克隆完成版
parent
1376f9375e
commit
ee7a83547e
|
@ -1,5 +1,6 @@
|
||||||
generator client {
|
generator client {
|
||||||
provider = "prisma-client-js"
|
provider = "prisma-client-js"
|
||||||
|
// previewFeatures = ["strictUndefinedChecks"]
|
||||||
}
|
}
|
||||||
|
|
||||||
datasource db {
|
datasource db {
|
||||||
|
@ -33,7 +34,7 @@ model SystemCharter {
|
||||||
voiceName String?
|
voiceName String?
|
||||||
|
|
||||||
// 剩余可克隆次数
|
// 剩余可克隆次数
|
||||||
remainingCloneCount Int @default(10)
|
remainingCloneCount Int? @default(10)
|
||||||
|
|
||||||
// 原始音频
|
// 原始音频
|
||||||
originAudioUrl String?
|
originAudioUrl String?
|
||||||
|
|
|
@ -26,10 +26,7 @@ export class RedisTaskProcessor {
|
||||||
|
|
||||||
const volcenAudioSpeakService = new VolcenAudioSpeakService();
|
const volcenAudioSpeakService = new VolcenAudioSpeakService();
|
||||||
// voiceId = await volcenAudioSpeakService.getVoiceId();
|
// voiceId = await volcenAudioSpeakService.getVoiceId();
|
||||||
// const voiceId = 'S_FC60x0Gb1';
|
// voiceId = 'S_VK2Yw0Gb1';
|
||||||
// 剩余1次
|
|
||||||
// const voiceId = 'S_VK2Yw0Gb1';
|
|
||||||
voiceId = 'S_5QKWw0Gb1';
|
|
||||||
// 请求ossurl获取base64
|
// 请求ossurl获取base64
|
||||||
const base64 = await volcenAudioSpeakService.getAudioBase64(ossUrl);
|
const base64 = await volcenAudioSpeakService.getAudioBase64(ossUrl);
|
||||||
// 克隆音频
|
// 克隆音频
|
||||||
|
|
|
@ -7,6 +7,8 @@ import { RedisTaskService } from 'src/common/RedisTask/RedisTask.service';
|
||||||
import { VolcenAudioSpeakService } from 'src/services/VolcenAudioSpeakService';
|
import { VolcenAudioSpeakService } from 'src/services/VolcenAudioSpeakService';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { CloneSpeakDto } from './dto/CloneSpeakDto.dto';
|
import { CloneSpeakDto } from './dto/CloneSpeakDto.dto';
|
||||||
|
import { isNotEmpty } from 'class-validator';
|
||||||
|
import { Prisma } from '@prisma/client';
|
||||||
|
|
||||||
// 添加任务查询DTO
|
// 添加任务查询DTO
|
||||||
export class TaskQueryDto {
|
export class TaskQueryDto {
|
||||||
|
@ -26,12 +28,30 @@ export class SystemCharterController {
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@Get('/getList')
|
@Get('/getList')
|
||||||
async getList(@Query() query: SystemCharterlDto) {
|
async getList(@Query() query: SystemCharterlDto & { originAudioUrl?: string }) {
|
||||||
const { current, pageSize, ...other } = query;
|
const { current, pageSize, ...other } = query;
|
||||||
const where = {};
|
const where = {};
|
||||||
if (query.roleName) {
|
if (other.roleName) {
|
||||||
where['roleName'] = other.roleName;
|
where['roleName'] = {
|
||||||
|
contains: other.roleName,
|
||||||
|
mode: 'insensitive',
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
if (query.originAudioUrl) {
|
||||||
|
// 根据原始音频状态筛选
|
||||||
|
if (query.originAudioUrl == 'true') {
|
||||||
|
// 已克隆的
|
||||||
|
where['originAudioUrl'] = {
|
||||||
|
not: null,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
// 为空的数据
|
||||||
|
// where['OR'] = [{ originAudioUrl: null }, { originAudioUrl: '' }, { originAudioUrl: undefined }];
|
||||||
|
where['originAudioUrl'] = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(where, query.originAudioUrl, typeof query.originAudioUrl);
|
||||||
|
|
||||||
const [record, total] = await this.dbService.systemCharter.findManyAndCount({
|
const [record, total] = await this.dbService.systemCharter.findManyAndCount({
|
||||||
where,
|
where,
|
||||||
|
@ -152,9 +172,12 @@ export class SystemCharterController {
|
||||||
}
|
}
|
||||||
|
|
||||||
const volcenAudioSpeakService = new VolcenAudioSpeakService();
|
const volcenAudioSpeakService = new VolcenAudioSpeakService();
|
||||||
const result = await volcenAudioSpeakService.speakActivate(speakerId);
|
const isActivate = await volcenAudioSpeakService.speakActivate(speakerId);
|
||||||
|
if (isActivate) {
|
||||||
return ApiResponse.successToMessage('音频激活成功', result);
|
return ApiResponse.success('音频激活成功');
|
||||||
|
} else {
|
||||||
|
return ApiResponse.failToMessage('音频激活失败');
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('激活音频失败:', error);
|
console.error('激活音频失败:', error);
|
||||||
return ApiResponse.failToMessage('激活音频失败:' + error.message);
|
return ApiResponse.failToMessage('激活音频失败:' + error.message);
|
||||||
|
@ -300,6 +323,9 @@ export class SystemCharterController {
|
||||||
where: { id: roleId },
|
where: { id: roleId },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 判断是否有克隆次数
|
||||||
|
|
||||||
|
|
||||||
if (!charter) {
|
if (!charter) {
|
||||||
throw new HttpException('角色不存在', HttpStatus.BAD_REQUEST);
|
throw new HttpException('角色不存在', HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { IsOptional, IsString } from 'class-validator';
|
import { IsBoolean, IsOptional, IsString } from 'class-validator';
|
||||||
import { PaginationDto } from 'src/common/pagination/PaginationDto.dto';
|
import { PaginationDto } from 'src/common/pagination/PaginationDto.dto';
|
||||||
|
|
||||||
export class SystemCharterlDto extends PaginationDto {
|
export class SystemCharterlDto extends PaginationDto {
|
||||||
|
|
Loading…
Reference in New Issue