import { Injectable } from "@nestjs/common"; import { Prisma } from "@prisma/client"; import { PrismaService } from "src/prisma/prisma.service"; import { Result } from "src/common/errors/result-error.factory"; @Injectable() export class BankCodesService { constructor(private readonly prisma: PrismaService) { } async create(dto: Prisma.BankCodesCreateInput): Promise> { try { await this.prisma.bankCodes.create({ data: { type: dto.type, categorie: dto.categorie, modifier: dto.modifier, bank_code: dto.bank_code, }, }); } catch (error) { return { success: false, error: 'INVALID_BANK_CODE' + error }; } return { success: true, data: true }; } findAll() { return this.prisma.bankCodes.findMany(); } async update(id: number, dto: Prisma.BankCodesUpdateInput): Promise> { try { await this.prisma.bankCodes.update({ where: { id }, data: { type: dto.type, categorie: dto.categorie, modifier: dto.modifier, bank_code: dto.bank_code, }, }); return { success: true, data: true }; } catch (error) { return { success: false, error: 'INVALID_BANK_CODE' + error }; } } }