|
@@ -1,7 +1,7 @@
|
|
|
import { Body, Controller, Del, Get, Inject, Param, Post, Query } from '@midwayjs/decorator';
|
|
|
import { BaseController } from 'free-midway-component';
|
|
|
import { CourseService } from '../../service/core/course.service';
|
|
|
-import { CDTO_course, CVO_course, FVO_course, QDTO_course, QVO_course, UDTO_course, UVAO_course } from '../../interface/core/course.interface';
|
|
|
+import { CDTO_course, CVO_course, FVO_course,QDTO_course, QVO_course, UDTO_course, UVAO_course } from '../../interface/core/course.interface';
|
|
|
import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
|
|
|
import { Validate } from '@midwayjs/validate';
|
|
|
@ApiTags(['课程'])
|
|
@@ -10,18 +10,15 @@ export class CourseController extends BaseController {
|
|
|
@Inject()
|
|
|
service: CourseService;
|
|
|
|
|
|
- @Post('/')
|
|
|
- @Validate()
|
|
|
- @ApiResponse({ type: CVO_course })
|
|
|
+
|
|
|
+@Post('/') @Validate() @ApiResponse({ type: CVO_course })
|
|
|
async create(@Body() data: CDTO_course) {
|
|
|
const dbData = await this.service.create(data);
|
|
|
const result = new CVO_course(dbData);
|
|
|
return result;
|
|
|
}
|
|
|
- @Get('/')
|
|
|
- @ApiQuery({ name: 'query' })
|
|
|
- @ApiResponse({ type: QVO_course })
|
|
|
- async query(@Query() filter: QDTO_course, @Query('skip') skip: number, @Query('limit') limit: number) {
|
|
|
+@Get('/')@ApiQuery({name:'query'})@ApiResponse({ type: QVO_course })
|
|
|
+ async query(@Query() filter:QDTO_course, @Query('skip') skip: number,@Query('limit') limit: number){
|
|
|
const list = await this.service.query(filter, { skip, limit });
|
|
|
const data = [];
|
|
|
for (const i of list) {
|
|
@@ -32,24 +29,23 @@ export class CourseController extends BaseController {
|
|
|
return { data, total };
|
|
|
}
|
|
|
|
|
|
- @Get('/:id')
|
|
|
- @ApiResponse({ type: FVO_course })
|
|
|
+
|
|
|
+@Get('/:id')@ApiResponse({ type: FVO_course })
|
|
|
async fetch(@Param('id') id: string) {
|
|
|
const data = await this.service.fetch(id);
|
|
|
const result = new FVO_course(data);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- @Post('/:id')
|
|
|
- @Validate()
|
|
|
- @ApiResponse({ type: UVAO_course })
|
|
|
+
|
|
|
+@Post('/:id')@Validate()@ApiResponse({ type: UVAO_course })
|
|
|
async update(@Param('id') id: string, @Body() body: UDTO_course) {
|
|
|
const result = await this.service.updateOne(id, body);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- @Del('/:id')
|
|
|
- @Validate()
|
|
|
+
|
|
|
+@Del('/:id')@Validate()
|
|
|
async delete(@Param('id') id: string) {
|
|
|
await this.service.delete(id);
|
|
|
return 'ok';
|
|
@@ -58,11 +54,14 @@ export class CourseController extends BaseController {
|
|
|
throw new Error('Method not implemented.');
|
|
|
}
|
|
|
|
|
|
+
|
|
|
async updateMany(...args: any[]) {
|
|
|
throw new Error('Method not implemented.');
|
|
|
}
|
|
|
|
|
|
+
|
|
|
async deleteMany(...args: any[]) {
|
|
|
throw new Error('Method not implemented.');
|
|
|
}
|
|
|
}
|
|
|
+
|