feat: 优化swagger的生成设置
parent
c89a732209
commit
1a32173fc7
Binary file not shown.
|
|
@ -14,7 +14,7 @@ export class PaginationDto {
|
||||||
@IsNumber()
|
@IsNumber()
|
||||||
@Min(1)
|
@Min(1)
|
||||||
@Transform(({ value }) => Number(value))
|
@Transform(({ value }) => Number(value))
|
||||||
page: number;
|
page?: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 每页条数
|
* 每页条数
|
||||||
|
|
@ -24,5 +24,5 @@ export class PaginationDto {
|
||||||
@IsNumber()
|
@IsNumber()
|
||||||
@Min(1)
|
@Min(1)
|
||||||
@Transform(({ value }) => Number(value))
|
@Transform(({ value }) => Number(value))
|
||||||
size: number;
|
size?: number;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,6 @@ export function addResponseWrapper(doc: OpenAPIObject) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'object',
|
type: 'object',
|
||||||
description: '返回数据',
|
|
||||||
properties: {
|
properties: {
|
||||||
data: schema,
|
data: schema,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -9,5 +9,5 @@ export class FindUserDto extends IntersectionType(PaginationDto) {
|
||||||
*/
|
*/
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsString()
|
@IsString()
|
||||||
nickname: string;
|
nickname?: string;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ export class User extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* 用户角色
|
* 用户角色
|
||||||
*/
|
*/
|
||||||
|
@ApiHideProperty()
|
||||||
@ManyToMany(() => Role, (role) => role.user)
|
@ManyToMany(() => Role, (role) => role.user)
|
||||||
@JoinTable()
|
@JoinTable()
|
||||||
roles: Role[];
|
roles: Role[];
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ export class UserController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
@ApiOperation({ summary: '创建用户', operationId: 'addUser' })
|
@ApiOperation({ description: '创建用户', operationId: 'addUser' })
|
||||||
create(@Body() createUserDto: CreateUserDto) {
|
create(@Body() createUserDto: CreateUserDto) {
|
||||||
return this.userService.create(createUserDto);
|
return this.userService.create(createUserDto);
|
||||||
}
|
}
|
||||||
|
|
@ -24,26 +24,26 @@ export class UserController extends BaseController {
|
||||||
@Get()
|
@Get()
|
||||||
@Respond(Respond.PAGINATION)
|
@Respond(Respond.PAGINATION)
|
||||||
@ApiOkResponse({ isArray: true, type: User })
|
@ApiOkResponse({ isArray: true, type: User })
|
||||||
@ApiOperation({ summary: '批量查询用户', operationId: 'getUsers' })
|
@ApiOperation({ description: '批量查询用户', operationId: 'getUsers' })
|
||||||
async findMany(@Query() query: FindUserDto) {
|
async findMany(@Query() query: FindUserDto) {
|
||||||
return this.userService.findMany(query);
|
return this.userService.findMany(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
@Version('2')
|
@Version('2')
|
||||||
@ApiOperation({ summary: '查询用户', operationId: 'getUserv2' })
|
@ApiOperation({ description: '查询用户', operationId: 'getUserv2' })
|
||||||
findOne(@Param('id') id: number) {
|
findOne(@Param('id') id: number) {
|
||||||
return this.userService.findOne(+id);
|
return this.userService.findOne(+id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Patch(':id')
|
@Patch(':id')
|
||||||
@ApiOperation({ summary: '更新用户', operationId: 'updateUser' })
|
@ApiOperation({ description: '更新用户', operationId: 'updateUser' })
|
||||||
update(@Param('id') id: number, @Body() updateUserDto: UpdateUserDto) {
|
update(@Param('id') id: number, @Body() updateUserDto: UpdateUserDto) {
|
||||||
return this.userService.update(+id, updateUserDto);
|
return this.userService.update(+id, updateUserDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
@ApiOperation({ summary: '删除用户', operationId: 'deleteUser' })
|
@ApiOperation({ description: '删除用户', operationId: 'deleteUser' })
|
||||||
remove(@Param('id') id: number) {
|
remove(@Param('id') id: number) {
|
||||||
return this.userService.remove(+id);
|
return this.userService.remove(+id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue