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