add server to monorepo.

This commit is contained in:
a.bouhuolia
2023-02-03 11:57:50 +02:00
parent 28e309981b
commit 80b97b5fdc
1303 changed files with 137049 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
import { Inject } from 'typedi';
import { IItem } from '@/interfaces';
import HasTenancyService from '@/services/Tenancy/TenancyService';
import { TransformerInjectable } from '@/lib/Transformer/TransformerInjectable';
import ItemTransformer from './ItemTransformer';
@Inject()
export class GetItem {
@Inject()
private tenancy: HasTenancyService;
@Inject()
private transformer: TransformerInjectable;
/**
* Retrieve the item details of the given id with associated details.
* @param {number} tenantId
* @param {number} itemId
*/
public async getItem(tenantId: number, itemId: number): Promise<IItem> {
const { Item } = this.tenancy.models(tenantId);
const item = await Item.query()
.findById(itemId)
.withGraphFetched('sellAccount')
.withGraphFetched('inventoryAccount')
.withGraphFetched('category')
.withGraphFetched('costAccount')
.withGraphFetched('itemWarehouses.warehouse')
.throwIfNotFound();
return this.transformer.transform(tenantId, item, new ItemTransformer());
}
}