mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
feat(nestjs): migrate to NestJS
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { CustomerTransfromer } from './CustomerTransformer';
|
||||
import { TransformerInjectable } from '@/modules/Transformer/TransformerInjectable.service';
|
||||
import { Customer } from '../models/Customer';
|
||||
import { TenantModelProxy } from '@/modules/System/models/TenantBaseModel';
|
||||
|
||||
@Injectable()
|
||||
export class GetCustomerService {
|
||||
constructor(
|
||||
private transformer: TransformerInjectable,
|
||||
|
||||
@Inject(Customer.name)
|
||||
private customerModel: TenantModelProxy<typeof Customer>,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Retrieve the given customer details.
|
||||
* @param {number} customerId
|
||||
*/
|
||||
public async getCustomer(customerId: number) {
|
||||
// Retrieve the customer model or throw not found error.
|
||||
const customer = await this.customerModel()
|
||||
.query()
|
||||
.findById(customerId)
|
||||
.throwIfNotFound();
|
||||
|
||||
// Retrieves the transformered customers.
|
||||
return this.transformer.transform(customer, new CustomerTransfromer());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user