import { Injectable } from '@nestjs/common'; import { CreateMerchantDto } from './dto/create-merchant.dto'; import { UpdateMerchantDto } from './dto/update-merchant.dto'; import { MerchantDataService } from './merchant-data.service'; import { Merchant } from './entities/merchant.entity'; @Injectable() export class MerchantsService { public constructor(private merchantDataService: MerchantDataService) { } public async findAll(): Promise { return await this.merchantDataService.getAllMerchants(); } public async findById(id: string): Promise { const merchant = await this.merchantDataService.getMerchantById(id); if (!merchant) { throw new Error('Merchant not found.'); } return merchant; } public async create(newMerchant: CreateMerchantDto): Promise { return await this.merchantDataService.createMerchant(newMerchant.name); } public async update(updateMerchant: UpdateMerchantDto): Promise { return await this.merchantDataService.updateMerchant(updateMerchant); } public async remove(id: string): Promise { await this.merchantDataService.deleteMerchant(id); } }