added merchants resource
This commit is contained in:
parent
d7ad5828af
commit
b5ced781c9
17 changed files with 214 additions and 80 deletions
|
|
@ -1,26 +1,35 @@
|
|||
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 {
|
||||
create(createMerchantDto: CreateMerchantDto) {
|
||||
return 'This action adds a new merchant';
|
||||
public constructor(private merchantDataService: MerchantDataService) { }
|
||||
|
||||
public async findAll(): Promise<Merchant[]> {
|
||||
return await this.merchantDataService.getAllMerchants();
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return `This action returns all merchants`;
|
||||
public async findById(id: string): Promise<Merchant> {
|
||||
const merchant = await this.merchantDataService.getMerchantById(id);
|
||||
if (!merchant) {
|
||||
throw new Error('Merchant not found.');
|
||||
}
|
||||
|
||||
return merchant;
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
return `This action returns a #${id} merchant`;
|
||||
public async create(newMerchant: CreateMerchantDto): Promise<Merchant> {
|
||||
return await this.merchantDataService.createMerchant(newMerchant.name);
|
||||
}
|
||||
|
||||
update(id: number, updateMerchantDto: UpdateMerchantDto) {
|
||||
return `This action updates a #${id} merchant`;
|
||||
public async update(updateMerchant: UpdateMerchantDto): Promise<Merchant> {
|
||||
return await this.merchantDataService.updateMerchant(updateMerchant);
|
||||
}
|
||||
|
||||
remove(id: number) {
|
||||
return `This action removes a #${id} merchant`;
|
||||
public async remove(id: string): Promise<void> {
|
||||
await this.merchantDataService.deleteMerchant(id);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue