refactor user accounts structure
This commit is contained in:
@@ -9,8 +9,8 @@ export class AdminUsersService {
|
||||
|
||||
async findAll() {
|
||||
const [users, count] = await this.prisma.$transaction([
|
||||
this.prisma.user.findMany(),
|
||||
this.prisma.user.count(),
|
||||
this.prisma.admin.findMany(),
|
||||
this.prisma.admin.count(),
|
||||
])
|
||||
return ResponseMapper.paginate(
|
||||
users.map(user => ({ ...user, fullname: `${user.first_name} ${user.last_name}` })),
|
||||
@@ -19,7 +19,7 @@ export class AdminUsersService {
|
||||
}
|
||||
|
||||
async findOne(id: string) {
|
||||
const user = await this.prisma.user.findUnique({
|
||||
const user = await this.prisma.admin.findUnique({
|
||||
where: { id },
|
||||
})
|
||||
|
||||
@@ -33,14 +33,14 @@ export class AdminUsersService {
|
||||
}
|
||||
|
||||
async create(data: CreateUserDto) {
|
||||
return this.prisma.user.create({ data })
|
||||
return this.prisma.admin.create({ data })
|
||||
}
|
||||
|
||||
async update(id: string, data: UpdateUserDto) {
|
||||
return this.prisma.user.update({ where: { id }, data })
|
||||
return this.prisma.admin.update({ where: { id }, data })
|
||||
}
|
||||
|
||||
async delete(id: string) {
|
||||
return this.prisma.user.delete({ where: { id } })
|
||||
return this.prisma.admin.delete({ where: { id } })
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user