Skip to content

Commit

Permalink
feat(be): add release_date create manga api
Browse files Browse the repository at this point in the history
  • Loading branch information
harisato committed Jul 28, 2023
1 parent ba652d6 commit ae91a77
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/manga/dto/create-manga-request.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export class CreateMangaRequestDto {
@ApiProperty({ type: [MangaLanguage] })
manga_languages: string;

@ApiProperty()
release_date: string;

@ApiProperty({ type: 'string', format: 'binary' })
banner: Express.Multer.File;

Expand Down
20 changes: 10 additions & 10 deletions src/manga/manga.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class MangaService {

async create(data: CreateMangaRequestDto, files: Array<Express.Multer.File>) {
const { token } = ContextProvider.getAuthUser();
const { status } = data;
const { status, release_date } = data;
const manga_tags = plainToInstance(
MangaTag,
JSON.parse(data.manga_tags) as any[],
Expand All @@ -44,19 +44,19 @@ export class MangaService {
manga_tags,
manga_creators,
manga_languages,
release_date,
};
const result = await this.graphqlSvc.query(
this.configSvc.get<string>('graphql.endpoint'),
token,
`
mutation CreateNewManga($status: String = "", $banner: String = "", $poster: String = "", $manga_languages: [manga_languages_insert_input!] = {language_id: 10, is_main_language: false, description: "", title: ""}, $manga_creators: [manga_creator_insert_input!] = {creator_id: 10}, $manga_tags: [manga_tag_insert_input!] = {tag_id: 10}) {
insert_manga_one(object: {status: $status, manga_creators: {data: $manga_creators}, banner: $banner, poster: $poster, manga_languages: {data: $manga_languages}, manga_tags: {data: $manga_tags}}) {
id
created_at
status
}
}
`,
`mutation CreateNewManga($status: String = "", $banner: String = "", $poster: String = "", $manga_languages: [manga_languages_insert_input!] = {language_id: 10, is_main_language: false, description: "", title: ""}, $manga_creators: [manga_creator_insert_input!] = {creator_id: 10}, $manga_tags: [manga_tag_insert_input!] = {tag_id: 10}, $release_date: timestamptz = "") {
insert_manga_one(object: {status: $status, manga_creators: {data: $manga_creators}, banner: $banner, poster: $poster, manga_languages: {data: $manga_languages}, manga_tags: {data: $manga_tags}, release_date: $release_date}) {
id
created_at
status
release_date
}
}`,
'CreateNewManga',
variables,
);
Expand Down

0 comments on commit ae91a77

Please sign in to comment.