Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catalogue service #3

Merged
merged 8 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/backend-bff/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import { AppController } from './test/app.controller';
import { AppService } from './test/app.service';
import { RemoteGroupController } from "./remoteGroup/remote.group.controller";
import { RemoteTableController } from "./remoteTable/remote.table.controller";
import { RemoteCatalogueController } from './remoteCatalogue/remote.catalogue.controller';

@Module({
imports: [],
controllers: [AppController, RemoteGroupController, RemoteTableController],
controllers: [AppController, RemoteGroupController, RemoteTableController,RemoteCatalogueController],
providers: [AppService],
})
export class AppModule {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Controller, Get, Query } from '@nestjs/common';
import { ApiProperty, ApiTags } from '@nestjs/swagger';
import { container } from '@spos/services/common';
import { CatalogueService, TYPES, CategorizedCatalog } from "@spos/services/common";
import { MenuItem, MenuItemCategoryEnum } from '@spos/clients-menu';

export class MenuItemDto implements MenuItem {
@ApiProperty()
_id : string;

@ApiProperty()
fullName : string;

@ApiProperty()
shortName : string;

@ApiProperty()
price : number;

@ApiProperty({ enum: MenuItemCategoryEnum })
category : MenuItemCategoryEnum;

@ApiProperty()
image : string;
}

export class CategorizedCatalogDto {
@ApiProperty({ type: 'object', additionalProperties: { type: 'array', items: { $ref: '#/components/schemas/MenuItemDto' } } })
categories: Record<string, MenuItemDto[]>;
}

@Controller('remoteCatalogue')
@ApiTags('remoteCatalogue')
export class RemoteCatalogueController {
@Get('filteredCatalog')
async getFilteredCatalog(@Query('offerName') offerName: string): Promise<CategorizedCatalogDto> {
console.log('offerName:', offerName);
const catalog = await container.get<CatalogueService>(TYPES.CatalogueService).getFilteredCatalog(offerName);
console.log('catalog:', catalog);
return { categories: catalog };
}


@Get('items')
async getFullItemFromItemIdsArray(@Query('ids') ids: string[]): Promise<MenuItemDto[]> {
return container.get<CatalogueService>(TYPES.CatalogueService).getFullItemFromItemIdsArray(ids);
}
}
2 changes: 1 addition & 1 deletion libs/clients/bff/openapi.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"openapi":"3.0.0","paths":{"/api/test":{"get":{"operationId":"AppController_getData","parameters":[],"responses":{"200":{"description":""}}}},"/api/remoteGroup":{"get":{"operationId":"RemoteGroupController_getGroups","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/AnnotatedGroup"}}}}}},"tags":["remoteGroup"]},"post":{"operationId":"RemoteGroupController_addGroup","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnnotatedGroupCreateDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnnotatedGroup"}}}}},"tags":["remoteGroup"]}},"/api/remoteGroup/{id}":{"get":{"operationId":"RemoteGroupController_getGroup","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnnotatedGroup"}}}}},"tags":["remoteGroup"]}},"/api/remoteTable":{"get":{"operationId":"RemoteTableController_getFreeTables","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/AnnotatedTableWithOrderDto"}}}}}},"tags":["remoteTable"]},"post":{"operationId":"RemoteTableController_closeAllTables","parameters":[],"responses":{"201":{"description":""}},"tags":["remoteTable"]}}},"info":{"title":"BFF API","description":"Backend For Frontend API","version":"1.0","contact":{}},"tags":[],"servers":[],"components":{"schemas":{"TableDto":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"number"},"customerCount":{"type":"number"}},"required":["id","number","customerCount"]},"AnnotatedGroup":{"type":"object","properties":{"id":{"type":"string"},"tables":{"type":"array","items":{"$ref":"#/components/schemas/TableDto"}},"offer":{"type":"string"}},"required":["id","tables","offer"]},"AnnotatedCreateTableDto":{"type":"object","properties":{"number":{"type":"number"},"customerCount":{"type":"number"}},"required":["number","customerCount"]},"AnnotatedGroupCreateDto":{"type":"object","properties":{"offer":{"type":"string"},"tables":{"type":"array","items":{"$ref":"#/components/schemas/AnnotatedCreateTableDto"}}},"required":["offer","tables"]},"AnnotatedTableWithOrderDto":{"type":"object","properties":{"_id":{"type":"string"},"number":{"type":"number"},"tableOrderId":{"type":"string"},"taken":{"type":"boolean"}},"required":["_id","number","tableOrderId","taken"]}}}}
{"openapi":"3.0.0","paths":{"/api/test":{"get":{"operationId":"AppController_getData","parameters":[],"responses":{"200":{"description":""}}}},"/api/remoteGroup":{"get":{"operationId":"RemoteGroupController_getGroups","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/AnnotatedGroup"}}}}}},"tags":["remoteGroup"]},"post":{"operationId":"RemoteGroupController_addGroup","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnnotatedGroupCreateDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnnotatedGroup"}}}}},"tags":["remoteGroup"]}},"/api/remoteGroup/{id}":{"get":{"operationId":"RemoteGroupController_getGroup","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnnotatedGroup"}}}}},"tags":["remoteGroup"]}},"/api/remoteTable":{"get":{"operationId":"RemoteTableController_getFreeTables","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/AnnotatedTableWithOrderDto"}}}}}},"tags":["remoteTable"]},"post":{"operationId":"RemoteTableController_closeAllTables","parameters":[],"responses":{"201":{"description":""}},"tags":["remoteTable"]}},"/api/remoteCatalogue/filteredCatalog":{"get":{"operationId":"RemoteCatalogueController_getFilteredCatalog","parameters":[{"name":"offerName","required":true,"in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CategorizedCatalogDto"}}}}},"tags":["remoteCatalogue"]}},"/api/remoteCatalogue/items":{"get":{"operationId":"RemoteCatalogueController_getFullItemFromItemIdsArray","parameters":[{"name":"ids","required":true,"in":"query","schema":{"type":"array","items":{"type":"string"}}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/MenuItemDto"}}}}}},"tags":["remoteCatalogue"]}}},"info":{"title":"BFF API","description":"Backend For Frontend API","version":"1.0","contact":{}},"tags":[],"servers":[],"components":{"schemas":{"TableDto":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"number"},"customerCount":{"type":"number"}},"required":["id","number","customerCount"]},"AnnotatedGroup":{"type":"object","properties":{"id":{"type":"string"},"tables":{"type":"array","items":{"$ref":"#/components/schemas/TableDto"}},"offer":{"type":"string"}},"required":["id","tables","offer"]},"AnnotatedCreateTableDto":{"type":"object","properties":{"number":{"type":"number"},"customerCount":{"type":"number"}},"required":["number","customerCount"]},"AnnotatedGroupCreateDto":{"type":"object","properties":{"offer":{"type":"string"},"tables":{"type":"array","items":{"$ref":"#/components/schemas/AnnotatedCreateTableDto"}}},"required":["offer","tables"]},"AnnotatedTableWithOrderDto":{"type":"object","properties":{"_id":{"type":"string"},"number":{"type":"number"},"tableOrderId":{"type":"string"},"taken":{"type":"boolean"}},"required":["_id","number","tableOrderId","taken"]},"CategorizedCatalogDto":{"type":"object","properties":{"categories":{"type":"object","additionalProperties":{"type":"array","items":{"$ref":"#/components/schemas/MenuItemDto"}}}},"required":["categories"]},"MenuItemDto":{"type":"object","properties":{"_id":{"type":"string"},"fullName":{"type":"string"},"shortName":{"type":"string"},"price":{"type":"number"},"category":{"type":"string","enum":["STARTER","MAIN","DESSERT","BEVERAGE"]},"image":{"type":"string"}},"required":["_id","fullName","shortName","price","category","image"]}}}}
3 changes: 3 additions & 0 deletions libs/clients/bff/src/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.openapi-generator-ignore
api.ts
api/default-api.ts
api/remote-catalogue-api.ts
api/remote-group-api.ts
api/remote-table-api.ts
base.ts
Expand All @@ -12,5 +13,7 @@ models/annotated-create-table-dto.ts
models/annotated-group-create-dto.ts
models/annotated-group.ts
models/annotated-table-with-order-dto.ts
models/categorized-catalog-dto.ts
models/index.ts
models/menu-item-dto.ts
models/table-dto.ts
1 change: 1 addition & 0 deletions libs/clients/bff/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@


export * from './api/default-api';
export * from './api/remote-catalogue-api';
export * from './api/remote-group-api';
export * from './api/remote-table-api';

228 changes: 228 additions & 0 deletions libs/clients/bff/src/api/remote-catalogue-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
/* tslint:disable */
/* eslint-disable */
/**
* BFF API
* Backend For Frontend API
*
* The version of the OpenAPI document: 1.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/


import type { Configuration } from '../configuration';
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
import globalAxios from 'axios';
// Some imports not used depending on template conditions
// @ts-ignore
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, type RequestArgs, BaseAPI, RequiredError, operationServerMap } from '../base';
// @ts-ignore
import type { CategorizedCatalogDto } from '../models';
// @ts-ignore
import type { MenuItemDto } from '../models';
/**
* RemoteCatalogueApi - axios parameter creator
* @export
*/
export const RemoteCatalogueApiAxiosParamCreator = function (configuration?: Configuration) {
return {
/**
*
* @param {string} offerName
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
remoteCatalogueControllerGetFilteredCatalog: async (offerName: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'offerName' is not null or undefined
assertParamExists('remoteCatalogueControllerGetFilteredCatalog', 'offerName', offerName)
const localVarPath = `/api/remoteCatalogue/filteredCatalog`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}

const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;

if (offerName !== undefined) {
localVarQueryParameter['offerName'] = offerName;
}



setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @param {Array<string>} ids
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
remoteCatalogueControllerGetFullItemFromItemIdsArray: async (ids: Array<string>, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'ids' is not null or undefined
assertParamExists('remoteCatalogueControllerGetFullItemFromItemIdsArray', 'ids', ids)
const localVarPath = `/api/remoteCatalogue/items`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}

const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;

if (ids) {
localVarQueryParameter['ids'] = ids;
}



setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
}
};

/**
* RemoteCatalogueApi - functional programming interface
* @export
*/
export const RemoteCatalogueApiFp = function(configuration?: Configuration) {
const localVarAxiosParamCreator = RemoteCatalogueApiAxiosParamCreator(configuration)
return {
/**
*
* @param {string} offerName
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async remoteCatalogueControllerGetFilteredCatalog(offerName: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CategorizedCatalogDto>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.remoteCatalogueControllerGetFilteredCatalog(offerName, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['RemoteCatalogueApi.remoteCatalogueControllerGetFilteredCatalog']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
*
* @param {Array<string>} ids
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async remoteCatalogueControllerGetFullItemFromItemIdsArray(ids: Array<string>, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<MenuItemDto>>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.remoteCatalogueControllerGetFullItemFromItemIdsArray(ids, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['RemoteCatalogueApi.remoteCatalogueControllerGetFullItemFromItemIdsArray']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
}
};

/**
* RemoteCatalogueApi - factory interface
* @export
*/
export const RemoteCatalogueApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
const localVarFp = RemoteCatalogueApiFp(configuration)
return {
/**
*
* @param {RemoteCatalogueApiRemoteCatalogueControllerGetFilteredCatalogRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
remoteCatalogueControllerGetFilteredCatalog(requestParameters: RemoteCatalogueApiRemoteCatalogueControllerGetFilteredCatalogRequest, options?: RawAxiosRequestConfig): AxiosPromise<CategorizedCatalogDto> {
return localVarFp.remoteCatalogueControllerGetFilteredCatalog(requestParameters.offerName, options).then((request) => request(axios, basePath));
},
/**
*
* @param {RemoteCatalogueApiRemoteCatalogueControllerGetFullItemFromItemIdsArrayRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
remoteCatalogueControllerGetFullItemFromItemIdsArray(requestParameters: RemoteCatalogueApiRemoteCatalogueControllerGetFullItemFromItemIdsArrayRequest, options?: RawAxiosRequestConfig): AxiosPromise<Array<MenuItemDto>> {
return localVarFp.remoteCatalogueControllerGetFullItemFromItemIdsArray(requestParameters.ids, options).then((request) => request(axios, basePath));
},
};
};

/**
* Request parameters for remoteCatalogueControllerGetFilteredCatalog operation in RemoteCatalogueApi.
* @export
* @interface RemoteCatalogueApiRemoteCatalogueControllerGetFilteredCatalogRequest
*/
export interface RemoteCatalogueApiRemoteCatalogueControllerGetFilteredCatalogRequest {
/**
*
* @type {string}
* @memberof RemoteCatalogueApiRemoteCatalogueControllerGetFilteredCatalog
*/
readonly offerName: string
}

/**
* Request parameters for remoteCatalogueControllerGetFullItemFromItemIdsArray operation in RemoteCatalogueApi.
* @export
* @interface RemoteCatalogueApiRemoteCatalogueControllerGetFullItemFromItemIdsArrayRequest
*/
export interface RemoteCatalogueApiRemoteCatalogueControllerGetFullItemFromItemIdsArrayRequest {
/**
*
* @type {Array<string>}
* @memberof RemoteCatalogueApiRemoteCatalogueControllerGetFullItemFromItemIdsArray
*/
readonly ids: Array<string>
}

/**
* RemoteCatalogueApi - object-oriented interface
* @export
* @class RemoteCatalogueApi
* @extends {BaseAPI}
*/
export class RemoteCatalogueApi extends BaseAPI {
/**
*
* @param {RemoteCatalogueApiRemoteCatalogueControllerGetFilteredCatalogRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof RemoteCatalogueApi
*/
public remoteCatalogueControllerGetFilteredCatalog(requestParameters: RemoteCatalogueApiRemoteCatalogueControllerGetFilteredCatalogRequest, options?: RawAxiosRequestConfig) {
return RemoteCatalogueApiFp(this.configuration).remoteCatalogueControllerGetFilteredCatalog(requestParameters.offerName, options).then((request) => request(this.axios, this.basePath));
}

/**
*
* @param {RemoteCatalogueApiRemoteCatalogueControllerGetFullItemFromItemIdsArrayRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof RemoteCatalogueApi
*/
public remoteCatalogueControllerGetFullItemFromItemIdsArray(requestParameters: RemoteCatalogueApiRemoteCatalogueControllerGetFullItemFromItemIdsArrayRequest, options?: RawAxiosRequestConfig) {
return RemoteCatalogueApiFp(this.configuration).remoteCatalogueControllerGetFullItemFromItemIdsArray(requestParameters.ids, options).then((request) => request(this.axios, this.basePath));
}
}

Loading
Loading