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