transform core api codes into this project, update modules as admin/pos context modules

This commit is contained in:
2026-03-07 11:25:11 +03:30
parent b949500482
commit 8c5f1d4d49
167 changed files with 26975 additions and 1837 deletions
+42
View File
@@ -0,0 +1,42 @@
import { PrismaService } from '@/prisma/prisma.service'
import { Injectable } from '@nestjs/common'
import { ResponseMapper } from 'common/response/response-mapper'
import { CreateUserDto, UpdateUserDto } from './dto/user.dto'
@Injectable()
export class AdminUsersService {
constructor(private readonly prisma: PrismaService) {}
async findAll() {
const [users, count] = await this.prisma.$transaction([
this.prisma.user.findMany(),
this.prisma.user.count(),
])
return ResponseMapper.paginate(
users.map(user => ({ ...user, fullname: `${user.first_name} ${user.last_name}` })),
{ count },
)
}
async findOne(id: string) {
const user = await this.prisma.user.findUnique({
where: { id },
})
return ResponseMapper.single({
...user,
fullname: `${user?.first_name} ${user?.last_name}`,
})
}
async create(data: CreateUserDto) {
return this.prisma.user.create({ data })
}
async update(id: string, data: UpdateUserDto) {
return this.prisma.user.update({ where: { id }, data: data as UpdateUserDto })
}
async delete(id: string) {
return this.prisma.user.delete({ where: { id } })
}
}