This commit is contained in:
2026-03-11 20:42:34 +03:30
parent 8c5f1d4d49
commit 007db7f9bd
30 changed files with 393 additions and 219 deletions
+2 -2
View File
@@ -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)
}
+6 -2
View File
@@ -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) {