## 概要 [Task1836: API実装(I/F実装)](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/1836) - タスクのソート条件更新APIのI/Fを実装 - タスク一覧APIのI/Fを修正 - TODO/XXXですぐ対処可能、または単純に消し忘れているものを対処 ## レビューポイント - API I/Fの修正は妥当な内容であるか - 特にfilterはカンマ区切りでいいか、指定したものを除外という形式でいいか等 - TODO/XXXの対処は妥当な対処であるか ## 動作確認状況 - ローカルでswagger表示されることを確認
361 lines
9.1 KiB
TypeScript
361 lines
9.1 KiB
TypeScript
import {
|
||
Controller,
|
||
Get,
|
||
Headers,
|
||
HttpStatus,
|
||
Param,
|
||
Post,
|
||
Query,
|
||
} from '@nestjs/common';
|
||
import {
|
||
ApiResponse,
|
||
ApiOperation,
|
||
ApiTags,
|
||
ApiBearerAuth,
|
||
} from '@nestjs/swagger';
|
||
import { ErrorResponse } from '../../common/error/types/types';
|
||
import { TasksService } from './tasks.service';
|
||
import {
|
||
AudioNextRequest,
|
||
AudioNextResponse,
|
||
ChangeStatusRequest,
|
||
ChangeStatusResponse,
|
||
TasksRequest,
|
||
TasksResponse,
|
||
} from './types/types';
|
||
|
||
@ApiTags('tasks')
|
||
@Controller('tasks')
|
||
export class TasksController {
|
||
constructor(private readonly taskService: TasksService) {}
|
||
|
||
@ApiResponse({
|
||
status: HttpStatus.OK,
|
||
type: TasksResponse,
|
||
description: '成功時のレスポンス',
|
||
})
|
||
@ApiResponse({
|
||
status: HttpStatus.BAD_REQUEST,
|
||
description: '不正なパラメータ',
|
||
type: ErrorResponse,
|
||
})
|
||
@ApiResponse({
|
||
status: HttpStatus.UNAUTHORIZED,
|
||
description: '認証エラー',
|
||
type: ErrorResponse,
|
||
})
|
||
@ApiResponse({
|
||
status: HttpStatus.INTERNAL_SERVER_ERROR,
|
||
description: '想定外のサーバーエラー',
|
||
type: ErrorResponse,
|
||
})
|
||
@ApiOperation({
|
||
operationId: 'getTasks',
|
||
description: '音声ファイル・文字起こしタスク情報をページ指定して取得します',
|
||
})
|
||
@ApiBearerAuth()
|
||
@Get()
|
||
async getTasks(
|
||
@Headers() headers,
|
||
@Query() body: TasksRequest,
|
||
): Promise<TasksResponse> {
|
||
console.log(headers);
|
||
console.log(body);
|
||
return {
|
||
limit: 200,
|
||
offset: 0,
|
||
total: 0,
|
||
tasks: [],
|
||
};
|
||
}
|
||
|
||
@Get('next')
|
||
@ApiResponse({
|
||
status: HttpStatus.OK,
|
||
type: AudioNextResponse,
|
||
description: '成功時のレスポンス',
|
||
})
|
||
@ApiResponse({
|
||
status: HttpStatus.BAD_REQUEST,
|
||
description: '不正なパラメータ',
|
||
type: ErrorResponse,
|
||
})
|
||
@ApiResponse({
|
||
status: HttpStatus.UNAUTHORIZED,
|
||
description: '認証エラー',
|
||
type: ErrorResponse,
|
||
})
|
||
@ApiResponse({
|
||
status: HttpStatus.INTERNAL_SERVER_ERROR,
|
||
description: '想定外のサーバーエラー',
|
||
type: ErrorResponse,
|
||
})
|
||
@ApiOperation({
|
||
operationId: 'getNextAudioFile',
|
||
description:
|
||
'指定した文字起こしタスクの次のタスクに紐づく音声ファイルIDを取得します',
|
||
})
|
||
@ApiBearerAuth()
|
||
async getNextAudioFile(
|
||
@Headers() headers,
|
||
@Query() body: AudioNextRequest,
|
||
): Promise<AudioNextResponse> {
|
||
const { endedFileId } = body;
|
||
console.log(endedFileId);
|
||
|
||
return { nextFileId: 1234 };
|
||
}
|
||
|
||
@Post(':audioFileId/checkout')
|
||
@ApiResponse({
|
||
status: HttpStatus.OK,
|
||
type: ChangeStatusResponse,
|
||
description: '成功時のレスポンス',
|
||
})
|
||
@ApiResponse({
|
||
status: HttpStatus.BAD_REQUEST,
|
||
description: '不正なパラメータ',
|
||
type: ErrorResponse,
|
||
})
|
||
@ApiResponse({
|
||
status: HttpStatus.NOT_FOUND,
|
||
description: '指定したIDの音声ファイルが存在しない場合',
|
||
type: ErrorResponse,
|
||
})
|
||
@ApiResponse({
|
||
status: HttpStatus.UNAUTHORIZED,
|
||
description: '認証エラー',
|
||
type: ErrorResponse,
|
||
})
|
||
@ApiResponse({
|
||
status: HttpStatus.INTERNAL_SERVER_ERROR,
|
||
description: '想定外のサーバーエラー',
|
||
type: ErrorResponse,
|
||
})
|
||
@ApiOperation({
|
||
operationId: 'checkout',
|
||
description:
|
||
'指定した文字起こしタスクをチェックアウトします(ステータスをInprogressにします)',
|
||
})
|
||
@ApiBearerAuth()
|
||
async checkout(
|
||
@Headers() headers,
|
||
@Param() params: ChangeStatusRequest,
|
||
): Promise<ChangeStatusResponse> {
|
||
const { audioFileId } = params;
|
||
console.log(audioFileId);
|
||
|
||
return {};
|
||
}
|
||
|
||
@Post(':audioFileId/checkin')
|
||
@ApiResponse({
|
||
status: HttpStatus.OK,
|
||
type: ChangeStatusResponse,
|
||
description: '成功時のレスポンス',
|
||
})
|
||
@ApiResponse({
|
||
status: HttpStatus.BAD_REQUEST,
|
||
description: '不正なパラメータ',
|
||
type: ErrorResponse,
|
||
})
|
||
@ApiResponse({
|
||
status: HttpStatus.NOT_FOUND,
|
||
description: '指定したIDの音声ファイルが存在しない場合',
|
||
type: ErrorResponse,
|
||
})
|
||
@ApiResponse({
|
||
status: HttpStatus.UNAUTHORIZED,
|
||
description: '認証エラー',
|
||
type: ErrorResponse,
|
||
})
|
||
@ApiResponse({
|
||
status: HttpStatus.INTERNAL_SERVER_ERROR,
|
||
description: '想定外のサーバーエラー',
|
||
type: ErrorResponse,
|
||
})
|
||
@ApiOperation({
|
||
operationId: 'checkin',
|
||
description:
|
||
'指定した文字起こしタスクをチェックインします(ステータスをFinishedにします)',
|
||
})
|
||
@ApiBearerAuth()
|
||
async checkin(
|
||
@Headers() headers,
|
||
@Param() params: ChangeStatusRequest,
|
||
): Promise<ChangeStatusResponse> {
|
||
const { audioFileId } = params;
|
||
console.log(audioFileId);
|
||
|
||
return {};
|
||
}
|
||
|
||
@Post(':audioFileId/cancel')
|
||
@ApiResponse({
|
||
status: HttpStatus.OK,
|
||
type: ChangeStatusResponse,
|
||
description: '成功時のレスポンス',
|
||
})
|
||
@ApiResponse({
|
||
status: HttpStatus.BAD_REQUEST,
|
||
description: '不正なパラメータ',
|
||
type: ErrorResponse,
|
||
})
|
||
@ApiResponse({
|
||
status: HttpStatus.NOT_FOUND,
|
||
description: '指定したIDの音声ファイルが存在しない場合',
|
||
type: ErrorResponse,
|
||
})
|
||
@ApiResponse({
|
||
status: HttpStatus.UNAUTHORIZED,
|
||
description: '認証エラー',
|
||
type: ErrorResponse,
|
||
})
|
||
@ApiResponse({
|
||
status: HttpStatus.INTERNAL_SERVER_ERROR,
|
||
description: '想定外のサーバーエラー',
|
||
type: ErrorResponse,
|
||
})
|
||
@ApiOperation({
|
||
operationId: 'cancel',
|
||
description:
|
||
'指定した文字起こしタスクをキャンセルします(ステータスをUploadedにします)',
|
||
})
|
||
@ApiBearerAuth()
|
||
async cancel(
|
||
@Headers() headers,
|
||
@Param() params: ChangeStatusRequest,
|
||
): Promise<ChangeStatusResponse> {
|
||
const { audioFileId } = params;
|
||
console.log(audioFileId);
|
||
|
||
return {};
|
||
}
|
||
|
||
@Post(':audioFileId/suspend')
|
||
@ApiResponse({
|
||
status: HttpStatus.OK,
|
||
type: ChangeStatusResponse,
|
||
description: '成功時のレスポンス',
|
||
})
|
||
@ApiResponse({
|
||
status: HttpStatus.BAD_REQUEST,
|
||
description: '不正なパラメータ',
|
||
type: ErrorResponse,
|
||
})
|
||
@ApiResponse({
|
||
status: HttpStatus.NOT_FOUND,
|
||
description: '指定したIDの音声ファイルが存在しない場合',
|
||
type: ErrorResponse,
|
||
})
|
||
@ApiResponse({
|
||
status: HttpStatus.UNAUTHORIZED,
|
||
description: '認証エラー',
|
||
type: ErrorResponse,
|
||
})
|
||
@ApiResponse({
|
||
status: HttpStatus.INTERNAL_SERVER_ERROR,
|
||
description: '想定外のサーバーエラー',
|
||
type: ErrorResponse,
|
||
})
|
||
@ApiOperation({
|
||
operationId: 'suspend',
|
||
description:
|
||
'指定した文字起こしタスクを一時中断します(ステータスをPendingにします)',
|
||
})
|
||
@ApiBearerAuth()
|
||
async suspend(
|
||
@Headers() headers,
|
||
@Param() params: ChangeStatusRequest,
|
||
): Promise<ChangeStatusResponse> {
|
||
const { audioFileId } = params;
|
||
console.log(audioFileId);
|
||
|
||
return {};
|
||
}
|
||
|
||
@Post(':audioFileId/send-back')
|
||
@ApiResponse({
|
||
status: HttpStatus.OK,
|
||
type: ChangeStatusResponse,
|
||
description: '成功時のレスポンス',
|
||
})
|
||
@ApiResponse({
|
||
status: HttpStatus.BAD_REQUEST,
|
||
description: '不正なパラメータ',
|
||
type: ErrorResponse,
|
||
})
|
||
@ApiResponse({
|
||
status: HttpStatus.NOT_FOUND,
|
||
description: '指定したIDの音声ファイルが存在しない場合',
|
||
type: ErrorResponse,
|
||
})
|
||
@ApiResponse({
|
||
status: HttpStatus.UNAUTHORIZED,
|
||
description: '認証エラー',
|
||
type: ErrorResponse,
|
||
})
|
||
@ApiResponse({
|
||
status: HttpStatus.INTERNAL_SERVER_ERROR,
|
||
description: '想定外のサーバーエラー',
|
||
type: ErrorResponse,
|
||
})
|
||
@ApiOperation({
|
||
operationId: 'sendBack',
|
||
description:
|
||
'指定した文字起こしタスクを差し戻します(ステータスをPendingにします)',
|
||
})
|
||
@ApiBearerAuth()
|
||
async sendBack(
|
||
@Headers() headers,
|
||
@Param() params: ChangeStatusRequest,
|
||
): Promise<ChangeStatusResponse> {
|
||
const { audioFileId } = params;
|
||
console.log(audioFileId);
|
||
|
||
return {};
|
||
}
|
||
|
||
@Post(':audioFileId/backup')
|
||
@ApiResponse({
|
||
status: HttpStatus.OK,
|
||
type: ChangeStatusResponse,
|
||
description: '成功時のレスポンス',
|
||
})
|
||
@ApiResponse({
|
||
status: HttpStatus.BAD_REQUEST,
|
||
description: '不正なパラメータ',
|
||
type: ErrorResponse,
|
||
})
|
||
@ApiResponse({
|
||
status: HttpStatus.NOT_FOUND,
|
||
description: '指定したIDの音声ファイルが存在しない場合',
|
||
type: ErrorResponse,
|
||
})
|
||
@ApiResponse({
|
||
status: HttpStatus.UNAUTHORIZED,
|
||
description: '認証エラー',
|
||
type: ErrorResponse,
|
||
})
|
||
@ApiResponse({
|
||
status: HttpStatus.INTERNAL_SERVER_ERROR,
|
||
description: '想定外のサーバーエラー',
|
||
type: ErrorResponse,
|
||
})
|
||
@ApiOperation({
|
||
operationId: 'backup',
|
||
description:
|
||
'指定した文字起こしタスクをバックアップします(ステータスをBackupにします)',
|
||
})
|
||
@ApiBearerAuth()
|
||
async backup(
|
||
@Headers() headers,
|
||
@Param() params: ChangeStatusRequest,
|
||
): Promise<ChangeStatusResponse> {
|
||
const { audioFileId } = params;
|
||
console.log(audioFileId);
|
||
|
||
return {};
|
||
}
|
||
}
|