parent
1d57f4a8d9
commit
0e3ec4ebf9
|
@ -12,6 +12,7 @@ import {
|
|||
EntityFromParam,
|
||||
EntityFromBody,
|
||||
} from "typeorm-routing-controllers-extensions";
|
||||
import { ResponseSchema } from "routing-controllers-openapi";
|
||||
import { Track } from "../models/Track";
|
||||
|
||||
@JsonController("/track")
|
||||
|
@ -23,13 +24,15 @@ export class TrackController {
|
|||
}
|
||||
|
||||
@Get()
|
||||
async getAll() {
|
||||
return await this.trackRepository.find();
|
||||
@ResponseSchema(Track, { isArray: true })
|
||||
getAll() {
|
||||
return this.trackRepository.find();
|
||||
}
|
||||
|
||||
@Get(":id")
|
||||
async getOne(@EntityFromParam("id") track: Track) {
|
||||
return track;
|
||||
@Get("/:id")
|
||||
@ResponseSchema(Track)
|
||||
getOne(@Param("id") id: number) {
|
||||
return this.trackRepository.findOne({ id: id });
|
||||
}
|
||||
|
||||
@Post()
|
||||
|
@ -37,19 +40,13 @@ export class TrackController {
|
|||
return this.trackRepository.save(track);
|
||||
}
|
||||
|
||||
@Put(":id")
|
||||
put(@Param("id") id: number, @Body() user: any) {
|
||||
return "Updating a user...";
|
||||
@Put("/:id")
|
||||
put(@Param("id") id: number, @EntityFromBody() track: Track) {
|
||||
return this.trackRepository.update({id: id}, track);
|
||||
return this.trackRepository.update({ id: id }, track);
|
||||
}
|
||||
|
||||
@Delete(":id")
|
||||
remove(@EntityFromParam("id") track: Track) {
|
||||
return this.trackRepository.delete(track);
|
||||
@Delete("/:id")
|
||||
remove(@Param('id') id: number) {
|
||||
return this.trackRepository.delete({id: id});
|
||||
remove(@Param("id") id: number) {
|
||||
return this.trackRepository.delete({ id: id });
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue