Commit 3842efdd authored by nanahira's avatar nanahira

readme

parent d57d031a
# App name
# ygopro-deckform-filler
App description.
上传 YGOPro YDK 卡组文件,生成可打印的卡组登记表 PDF。
## Installation
......
......@@ -14,7 +14,7 @@ import {
import { FileInterceptor } from '@nestjs/platform-express';
import { FileUploadDto } from './dto/file-upload.dto';
import YGOProDeck from 'ygopro-deck-encode';
import { DataQuery } from 'nesties';
import { ApiError, BlankReturnMessageDto, DataQuery } from 'nesties';
import { FillOptionsDto } from './dto/fill-options.dto';
@Controller()
......@@ -34,11 +34,19 @@ export class AppController {
format: 'binary',
},
})
@ApiError(400, '不是有效的 YDK 文件')
@ApiError(404, '有卡片数据未找到')
@ApiError(500, '服务器内部错误')
async fillDeckForm(
@UploadedFile() file: Express.Multer.File,
@DataQuery() dto: FillOptionsDto,
) {
const ydk = YGOProDeck.fromYdkString(file.buffer.toString('utf-8'));
const ydk = new YGOProDeck();
try {
ydk.fromYdkString(file.buffer.toString('utf-8'));
} catch (e) {
throw new BlankReturnMessageDto(400, 'Invalid YDK file').toException();
}
return this.appService.fillDeckForm(ydk, dto);
}
}
......@@ -4,6 +4,7 @@ export class FileUploadDto {
@ApiProperty({
type: 'string',
format: 'binary',
description: '上传的 YGOPro YDK 卡组文件',
})
file: string;
}
import { IsDate, IsNotEmpty, IsOptional, IsString } from 'class-validator';
import { IsDateString, IsOptional, IsString } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';
import moment from 'moment';
export class FillOptionsDto {
@IsString()
@IsOptional()
@ApiProperty({
description: '参赛者姓名',
})
name?: string;
@IsDate()
@IsDateString()
@IsOptional()
date?: Date;
@ApiProperty({
type: String,
format: 'date',
example: moment().format('YYYY-MM-DD'),
description: '参赛日期,格式为 YYYY-MM-DD 或者其他符合 ISO 8601 的日期格式',
})
date?: string;
@IsString()
@IsOptional()
@ApiProperty({
description: '比赛名称',
})
event?: string;
@IsString()
@IsOptional()
@ApiProperty({
description: '座位号 / 姓氏首字母',
})
lastInitial?: string;
}
......@@ -13,8 +13,8 @@ async function bootstrap() {
const config = app.get(ConfigService);
if (!config.get('NO_OPENAPI')) {
const documentConfig = new DocumentBuilder()
.setTitle('app')
.setDescription('The app')
.setTitle('ygopro-deckform-filler')
.setDescription('上传 YGOPro YDK 卡组文件,生成可打印的卡组登记表 PDF。')
.setVersion('1.0')
.build();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment