|
@@ -1,7 +1,7 @@
|
|
|
import { Body, Controller, Del, Get, Inject, Param, Post, Query } from '@midwayjs/decorator';
|
|
|
import { BaseController } from 'free-midway-component';
|
|
|
import { UserService } from '../../service/system/user.service';
|
|
|
-import { CDTO_user, CVO_user, FVO_user,QDTO_user, QVO_user, UDTO_user, UVAO_user } from '../../interface/system/user.interface';
|
|
|
+import { CDTO_user, CVO_user, FVO_user, QDTO_user, QVO_user, UDTO_user, UVAO_user } from '../../interface/system/user.interface';
|
|
|
import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
|
|
|
import { Validate } from '@midwayjs/validate';
|
|
|
@ApiTags(['用户表'])
|
|
@@ -10,15 +10,18 @@ export class UserController extends BaseController {
|
|
|
@Inject()
|
|
|
service: UserService;
|
|
|
|
|
|
-
|
|
|
-@Post('/') @Validate() @ApiResponse({ type: CVO_user })
|
|
|
+ @Post('/')
|
|
|
+ @Validate()
|
|
|
+ @ApiResponse({ type: CVO_user })
|
|
|
async create(@Body() data: CDTO_user) {
|
|
|
const dbData = await this.service.create(data);
|
|
|
const result = new CVO_user(dbData);
|
|
|
return result;
|
|
|
}
|
|
|
-@Get('/')@ApiQuery({name:'query'})@ApiResponse({ type: QVO_user })
|
|
|
- async query(@Query() filter:QDTO_user, @Query('skip') skip: number,@Query('limit') limit: number){
|
|
|
+ @Get('/')
|
|
|
+ @ApiQuery({ name: 'query' })
|
|
|
+ @ApiResponse({ type: QVO_user })
|
|
|
+ async query(@Query() filter: QDTO_user, @Query('skip') skip: number, @Query('limit') limit: number) {
|
|
|
const list = await this.service.query(filter, { skip, limit });
|
|
|
const data = [];
|
|
|
for (const i of list) {
|
|
@@ -29,23 +32,33 @@ export class UserController extends BaseController {
|
|
|
return { data, total };
|
|
|
}
|
|
|
|
|
|
+ @Get('/user')
|
|
|
+ @ApiQuery({ name: 'query' })
|
|
|
+ async user(@Query() filter: QDTO_user) {
|
|
|
+ const list = await this.service.user(filter);
|
|
|
+ const data = list.list;
|
|
|
+ const total = list.total;
|
|
|
+ return { data, total };
|
|
|
+ }
|
|
|
|
|
|
-@Get('/:id')@ApiResponse({ type: FVO_user })
|
|
|
+ @Get('/:id')
|
|
|
+ @ApiResponse({ type: FVO_user })
|
|
|
async fetch(@Param('id') id: string) {
|
|
|
const data = await this.service.fetch(id);
|
|
|
const result = new FVO_user(data);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-@Post('/:id')@Validate()@ApiResponse({ type: UVAO_user })
|
|
|
+ @Post('/:id')
|
|
|
+ @Validate()
|
|
|
+ @ApiResponse({ type: UVAO_user })
|
|
|
async update(@Param('id') id: string, @Body() body: UDTO_user) {
|
|
|
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';
|
|
@@ -54,14 +67,11 @@ export class UserController 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.');
|
|
|
}
|
|
|
}
|
|
|
-
|