updating
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Body, Controller, Delete, Get, Param, Post, Put } from '@nestjs/common'
|
||||
import { Body, Controller, Delete, Get, Param, Patch, Post } from '@nestjs/common'
|
||||
import { CreateUserDto, UpdateUserDto } from './dto/user.dto'
|
||||
import { AdminUsersService } from './users.service'
|
||||
|
||||
@@ -21,7 +21,7 @@ export class AdminUsersController {
|
||||
return this.usersService.create(data as CreateUserDto)
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
@Patch(':id')
|
||||
async update(@Param('id') id: string, @Body() data: any) {
|
||||
return this.usersService.update(id, data as UpdateUserDto)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { PrismaService } from '@/prisma/prisma.service'
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { Injectable, NotFoundException } from '@nestjs/common'
|
||||
import { ResponseMapper } from 'common/response/response-mapper'
|
||||
import { CreateUserDto, UpdateUserDto } from './dto/user.dto'
|
||||
|
||||
@@ -22,6 +22,10 @@ export class AdminUsersService {
|
||||
const user = await this.prisma.user.findUnique({
|
||||
where: { id },
|
||||
})
|
||||
|
||||
if (!user) {
|
||||
throw new NotFoundException('کاربری یافت نشد')
|
||||
}
|
||||
return ResponseMapper.single({
|
||||
...user,
|
||||
fullname: `${user?.first_name} ${user?.last_name}`,
|
||||
@@ -33,7 +37,7 @@ export class AdminUsersService {
|
||||
}
|
||||
|
||||
async update(id: string, data: UpdateUserDto) {
|
||||
return this.prisma.user.update({ where: { id }, data: data as UpdateUserDto })
|
||||
return this.prisma.user.update({ where: { id }, data })
|
||||
}
|
||||
|
||||
async delete(id: string) {
|
||||
|
||||
Reference in New Issue
Block a user