transform core api codes into this project, update modules as admin/pos context modules
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { PrismaService } from '@/prisma/prisma.service'
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { ResponseMapper } from 'common/response/response-mapper'
|
||||
|
||||
@Injectable()
|
||||
export class DeviceBrandsService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
async findAll() {
|
||||
const brands = await this.prisma.deviceBrand.findMany()
|
||||
return ResponseMapper.list(brands)
|
||||
}
|
||||
|
||||
async findOne(id: string) {
|
||||
const brand = await this.prisma.deviceBrand.findUnique({
|
||||
where: { id },
|
||||
})
|
||||
return ResponseMapper.single(brand)
|
||||
}
|
||||
|
||||
async create(data: any) {
|
||||
const device = await this.prisma.deviceBrand.create({ data })
|
||||
return ResponseMapper.create(device)
|
||||
}
|
||||
|
||||
async update(id: string, data: any) {
|
||||
const device = await this.prisma.deviceBrand.update({ where: { id }, data })
|
||||
return ResponseMapper.update(device)
|
||||
}
|
||||
|
||||
async delete(id: string) {
|
||||
await this.prisma.deviceBrand.delete({ where: { id } })
|
||||
return ResponseMapper.delete()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user