nestjs_auth...
This commit is contained in:
parent
80318c7009
commit
2ed6e8ed21
@ -25,7 +25,7 @@ export class UserController {
|
|||||||
@Roles(ROLE.ADMIN)
|
@Roles(ROLE.ADMIN)
|
||||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||||
@Get()
|
@Get()
|
||||||
fetchAll(@Query() query) {
|
async fetchAll(@Query() query) {
|
||||||
console.log(query)
|
console.log(query)
|
||||||
|
|
||||||
//Field별 filter AND Sql용
|
//Field별 filter AND Sql용
|
||||||
@ -114,8 +114,8 @@ export class UserController {
|
|||||||
console.log(fetchSQL)
|
console.log(fetchSQL)
|
||||||
|
|
||||||
//전체 갯수 및 fetched Data
|
//전체 갯수 및 fetched Data
|
||||||
const total = this.userService.count(fetchSQL)
|
const total = await this.userService.count(fetchSQL)
|
||||||
const rows = this.userService.fetchAll(fetchSQL)
|
const rows = await this.userService.fetchAll(fetchSQL)
|
||||||
const result = {
|
const result = {
|
||||||
total: total,
|
total: total,
|
||||||
perPage: perPage,
|
perPage: perPage,
|
||||||
@ -132,23 +132,23 @@ export class UserController {
|
|||||||
@Roles(ROLE.ADMIN)
|
@Roles(ROLE.ADMIN)
|
||||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
fetchOne(@Param('id') id: string): Promise<User | undefined> {
|
async fetchOne(@Param('id') id: string) {
|
||||||
return this.userService.fetchOne({ id: Number(id) })
|
return await this.userService.fetchOne({ id: Number(id) })
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(ROLE.ADMIN)
|
@Roles(ROLE.ADMIN)
|
||||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||||
@Post('add')
|
@Post('add')
|
||||||
add(@Body() data: UserDTO): Promise<User> {
|
async add(@Body() data: UserDTO) {
|
||||||
return this.userService.add(data)
|
return await this.userService.add(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(ROLE.ADMIN)
|
@Roles(ROLE.ADMIN)
|
||||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||||
@Put(':id')
|
@Put(':id')
|
||||||
update(@Param('id') id: string, @Body() data: UserDTO): Promise<User> {
|
async update(@Param('id') id: string, @Body() data: UserDTO) {
|
||||||
data.updatedAt = new Date()
|
data.updatedAt = new Date()
|
||||||
return this.userService.update({
|
return await this.userService.update({
|
||||||
where: { id: Number(id) },
|
where: { id: Number(id) },
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
@ -157,7 +157,7 @@ export class UserController {
|
|||||||
@Roles(ROLE.ADMIN)
|
@Roles(ROLE.ADMIN)
|
||||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
delete(@Param('id') id: string): Promise<User | undefined> {
|
async delete(@Param('id') id: string): Promise<User | undefined> {
|
||||||
return this.userService.remove({ id: Number(id) })
|
return await this.userService.remove({ id: Number(id) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user