doc: artist and album controller
This commit is contained in:
@@ -13,13 +13,14 @@ import {
|
|||||||
Query,
|
Query,
|
||||||
Req,
|
Req,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { Plage } from 'src/models/plage';
|
import { ApiOkResponsePlaginated, Plage } from 'src/models/plage';
|
||||||
import { CreateAlbumDto } from './dto/create-album.dto';
|
import { CreateAlbumDto } from './dto/create-album.dto';
|
||||||
import { AlbumService } from './album.service';
|
import { AlbumService } from './album.service';
|
||||||
import { Request } from 'express';
|
import { Request } from 'express';
|
||||||
import { Prisma, Album } from '@prisma/client';
|
import { Prisma, Album } from '@prisma/client';
|
||||||
import { ApiTags } from '@nestjs/swagger';
|
import { ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||||
import { FilterQuery } from 'src/utils/filter.pipe';
|
import { FilterQuery } from 'src/utils/filter.pipe';
|
||||||
|
import { Album as _Album } from 'src/_gen/prisma-class/album';
|
||||||
|
|
||||||
@Controller('album')
|
@Controller('album')
|
||||||
@ApiTags('album')
|
@ApiTags('album')
|
||||||
@@ -29,6 +30,7 @@ export class AlbumController {
|
|||||||
constructor(private readonly albumService: AlbumService) {}
|
constructor(private readonly albumService: AlbumService) {}
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
|
@ApiOperation({ description: "Register a new album, should not be used by frontend"})
|
||||||
async create(@Body() createAlbumDto: CreateAlbumDto) {
|
async create(@Body() createAlbumDto: CreateAlbumDto) {
|
||||||
try {
|
try {
|
||||||
return await this.albumService.createAlbum({
|
return await this.albumService.createAlbum({
|
||||||
@@ -45,6 +47,7 @@ export class AlbumController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
|
@ApiOperation({ description: "Delete an album by id"})
|
||||||
async remove(@Param('id', ParseIntPipe) id: number) {
|
async remove(@Param('id', ParseIntPipe) id: number) {
|
||||||
try {
|
try {
|
||||||
return await this.albumService.deleteAlbum({ id });
|
return await this.albumService.deleteAlbum({ id });
|
||||||
@@ -54,6 +57,8 @@ export class AlbumController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
|
@ApiOkResponsePlaginated(_Album)
|
||||||
|
@ApiOperation({ description: "Get all albums paginated"})
|
||||||
async findAll(
|
async findAll(
|
||||||
@Req() req: Request,
|
@Req() req: Request,
|
||||||
@FilterQuery(AlbumController.filterableFields)
|
@FilterQuery(AlbumController.filterableFields)
|
||||||
@@ -70,6 +75,8 @@ export class AlbumController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
|
@ApiOperation({ description: "Get an album by id"})
|
||||||
|
@ApiOkResponse({ type: _Album})
|
||||||
async findOne(@Param('id', ParseIntPipe) id: number) {
|
async findOne(@Param('id', ParseIntPipe) id: number) {
|
||||||
const res = await this.albumService.album({ id });
|
const res = await this.albumService.album({ id });
|
||||||
|
|
||||||
|
|||||||
@@ -15,14 +15,15 @@ import {
|
|||||||
Req,
|
Req,
|
||||||
StreamableFile,
|
StreamableFile,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { Plage } from 'src/models/plage';
|
import { ApiOkResponsePlaginated, Plage } from 'src/models/plage';
|
||||||
import { CreateArtistDto } from './dto/create-artist.dto';
|
import { CreateArtistDto } from './dto/create-artist.dto';
|
||||||
import { Request } from 'express';
|
import { Request } from 'express';
|
||||||
import { ArtistService } from './artist.service';
|
import { ArtistService } from './artist.service';
|
||||||
import { Prisma, Artist } from '@prisma/client';
|
import { Prisma, Artist } from '@prisma/client';
|
||||||
import { ApiTags } from '@nestjs/swagger';
|
import { ApiNotFoundResponse, ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||||
import { createReadStream, existsSync } from 'fs';
|
import { createReadStream, existsSync } from 'fs';
|
||||||
import { FilterQuery } from 'src/utils/filter.pipe';
|
import { FilterQuery } from 'src/utils/filter.pipe';
|
||||||
|
import { Artist as _Artist} from 'src/_gen/prisma-class/artist';
|
||||||
|
|
||||||
@Controller('artist')
|
@Controller('artist')
|
||||||
@ApiTags('artist')
|
@ApiTags('artist')
|
||||||
@@ -32,6 +33,7 @@ export class ArtistController {
|
|||||||
constructor(private readonly service: ArtistService) {}
|
constructor(private readonly service: ArtistService) {}
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
|
@ApiOperation({ description: "Register a new artist, should not be used by frontend"})
|
||||||
async create(@Body() dto: CreateArtistDto) {
|
async create(@Body() dto: CreateArtistDto) {
|
||||||
try {
|
try {
|
||||||
return await this.service.create(dto);
|
return await this.service.create(dto);
|
||||||
@@ -41,6 +43,7 @@ export class ArtistController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
|
@ApiOperation({ description: "Delete an artist by id"})
|
||||||
async remove(@Param('id', ParseIntPipe) id: number) {
|
async remove(@Param('id', ParseIntPipe) id: number) {
|
||||||
try {
|
try {
|
||||||
return await this.service.delete({ id });
|
return await this.service.delete({ id });
|
||||||
@@ -50,6 +53,8 @@ export class ArtistController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Get(':id/illustration')
|
@Get(':id/illustration')
|
||||||
|
@ApiOperation({ description: "Get an artist's illustration"})
|
||||||
|
@ApiNotFoundResponse({ description: "Artist or illustration not found"})
|
||||||
async getIllustration(@Param('id', ParseIntPipe) id: number) {
|
async getIllustration(@Param('id', ParseIntPipe) id: number) {
|
||||||
const artist = await this.service.get({ id });
|
const artist = await this.service.get({ id });
|
||||||
if (!artist) throw new NotFoundException('Artist not found');
|
if (!artist) throw new NotFoundException('Artist not found');
|
||||||
@@ -66,6 +71,8 @@ export class ArtistController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
|
@ApiOperation({ description: "Get all artists paginated"})
|
||||||
|
@ApiOkResponsePlaginated(_Artist)
|
||||||
async findAll(
|
async findAll(
|
||||||
@Req() req: Request,
|
@Req() req: Request,
|
||||||
@FilterQuery(ArtistController.filterableFields)
|
@FilterQuery(ArtistController.filterableFields)
|
||||||
@@ -82,6 +89,8 @@ export class ArtistController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
|
@ApiOperation({ description: "Get an artist by id"})
|
||||||
|
@ApiOkResponse({ type: _Artist})
|
||||||
async findOne(@Param('id', ParseIntPipe) id: number) {
|
async findOne(@Param('id', ParseIntPipe) id: number) {
|
||||||
const res = await this.service.get({ id });
|
const res = await this.service.get({ id });
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user