mirror of
https://github.com/Mueller-Patrick/Betterzon.git
synced 2024-12-23 04:05:12 +00:00
Compare commits
No commits in common. "058230e9a984a545c333ff29348011c66ae7824f" and "f71f53c8698da09c043c1113ff67cd164120671c" have entirely different histories.
058230e9a9
...
f71f53c869
|
@ -23,9 +23,6 @@ import {Categories} from './categories.interface';
|
||||||
* Service Methods
|
* Service Methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns all known categories
|
|
||||||
*/
|
|
||||||
export const findAll = async (): Promise<Categories> => {
|
export const findAll = async (): Promise<Categories> => {
|
||||||
let conn;
|
let conn;
|
||||||
let categRows = [];
|
let categRows = [];
|
||||||
|
@ -57,10 +54,6 @@ export const findAll = async (): Promise<Categories> => {
|
||||||
return categRows;
|
return categRows;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns the category with the specified id
|
|
||||||
* @param id The id of the category to fetch
|
|
||||||
*/
|
|
||||||
export const find = async (id: number): Promise<Category> => {
|
export const find = async (id: number): Promise<Category> => {
|
||||||
let conn;
|
let conn;
|
||||||
let categ: any;
|
let categ: any;
|
||||||
|
@ -84,10 +77,6 @@ export const find = async (id: number): Promise<Category> => {
|
||||||
return categ;
|
return categ;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns all categories that match the search term
|
|
||||||
* @param term the term to match
|
|
||||||
*/
|
|
||||||
export const findBySearchTerm = async (term: string): Promise<Categories> => {
|
export const findBySearchTerm = async (term: string): Promise<Categories> => {
|
||||||
let conn;
|
let conn;
|
||||||
let categRows = [];
|
let categRows = [];
|
||||||
|
@ -111,3 +100,36 @@ export const findBySearchTerm = async (term: string): Promise<Categories> => {
|
||||||
|
|
||||||
return categRows;
|
return categRows;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// export const create = async (newItem: Product): Promise<void> => {
|
||||||
|
// let conn;
|
||||||
|
// try {
|
||||||
|
// conn = await pool.getConnection();
|
||||||
|
// await conn.query("");
|
||||||
|
//
|
||||||
|
// } catch (err) {
|
||||||
|
// throw err;
|
||||||
|
// } finally {
|
||||||
|
// if (conn) conn.end();
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// export const update = async (updatedItem: Product): Promise<void> => {
|
||||||
|
// if (models.products[updatedItem.product_id]) {
|
||||||
|
// models.products[updatedItem.product_id] = updatedItem;
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// throw new Error("No record found to update");
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// export const remove = async (id: number): Promise<void> => {
|
||||||
|
// const record: Product = models.products[id];
|
||||||
|
//
|
||||||
|
// if (record) {
|
||||||
|
// delete models.products[id];
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// throw new Error("No record found to delete");
|
||||||
|
// };
|
||||||
|
|
|
@ -50,7 +50,7 @@ manufacturersRouter.get('/:id', async (req: Request, res: Response) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// GET items/:term
|
// GET items/:name
|
||||||
manufacturersRouter.get('/search/:term', async (req: Request, res: Response) => {
|
manufacturersRouter.get('/search/:term', async (req: Request, res: Response) => {
|
||||||
const term: string = req.params.term;
|
const term: string = req.params.term;
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,6 @@ import {Manufacturers} from './manufacturers.interface';
|
||||||
* Service Methods
|
* Service Methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns all known manufacturers
|
|
||||||
*/
|
|
||||||
export const findAll = async (): Promise<Manufacturers> => {
|
export const findAll = async (): Promise<Manufacturers> => {
|
||||||
let conn;
|
let conn;
|
||||||
let manRows = [];
|
let manRows = [];
|
||||||
|
@ -57,10 +54,6 @@ export const findAll = async (): Promise<Manufacturers> => {
|
||||||
return manRows;
|
return manRows;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns the manufacturer with the specified id
|
|
||||||
* @param id The id of the manufacturer to fetch
|
|
||||||
*/
|
|
||||||
export const find = async (id: number): Promise<Manufacturer> => {
|
export const find = async (id: number): Promise<Manufacturer> => {
|
||||||
let conn;
|
let conn;
|
||||||
let man: any;
|
let man: any;
|
||||||
|
@ -84,10 +77,6 @@ export const find = async (id: number): Promise<Manufacturer> => {
|
||||||
return man;
|
return man;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns all manufacturers that match the search term
|
|
||||||
* @param term the term to match
|
|
||||||
*/
|
|
||||||
export const findBySearchTerm = async (term: string): Promise<Manufacturers> => {
|
export const findBySearchTerm = async (term: string): Promise<Manufacturers> => {
|
||||||
let conn;
|
let conn;
|
||||||
let manRows = [];
|
let manRows = [];
|
||||||
|
@ -111,3 +100,36 @@ export const findBySearchTerm = async (term: string): Promise<Manufacturers> =>
|
||||||
|
|
||||||
return manRows;
|
return manRows;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// export const create = async (newItem: Product): Promise<void> => {
|
||||||
|
// let conn;
|
||||||
|
// try {
|
||||||
|
// conn = await pool.getConnection();
|
||||||
|
// await conn.query("");
|
||||||
|
//
|
||||||
|
// } catch (err) {
|
||||||
|
// throw err;
|
||||||
|
// } finally {
|
||||||
|
// if (conn) conn.end();
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// export const update = async (updatedItem: Product): Promise<void> => {
|
||||||
|
// if (models.products[updatedItem.product_id]) {
|
||||||
|
// models.products[updatedItem.product_id] = updatedItem;
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// throw new Error("No record found to update");
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// export const remove = async (id: number): Promise<void> => {
|
||||||
|
// const record: Product = models.products[id];
|
||||||
|
//
|
||||||
|
// if (record) {
|
||||||
|
// delete models.products[id];
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// throw new Error("No record found to delete");
|
||||||
|
// };
|
||||||
|
|
|
@ -23,9 +23,6 @@ import {Prices} from './prices.interface';
|
||||||
* Service Methods
|
* Service Methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns all known prices
|
|
||||||
*/
|
|
||||||
export const findAll = async (): Promise<Prices> => {
|
export const findAll = async (): Promise<Prices> => {
|
||||||
let conn;
|
let conn;
|
||||||
let priceRows = [];
|
let priceRows = [];
|
||||||
|
@ -63,10 +60,6 @@ export const findAll = async (): Promise<Prices> => {
|
||||||
return priceRows;
|
return priceRows;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns the price with the specified id
|
|
||||||
* @param id The id of the price to fetch
|
|
||||||
*/
|
|
||||||
export const find = async (id: number): Promise<Price> => {
|
export const find = async (id: number): Promise<Price> => {
|
||||||
let conn;
|
let conn;
|
||||||
let price: any;
|
let price: any;
|
||||||
|
@ -90,10 +83,6 @@ export const find = async (id: number): Promise<Price> => {
|
||||||
return price;
|
return price;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns all prices that belong to the specified product
|
|
||||||
* @param product the product to fetch the prices for
|
|
||||||
*/
|
|
||||||
export const findByProduct = async (product: number): Promise<Prices> => {
|
export const findByProduct = async (product: number): Promise<Prices> => {
|
||||||
let conn;
|
let conn;
|
||||||
let priceRows = [];
|
let priceRows = [];
|
||||||
|
@ -117,14 +106,6 @@ export const findByProduct = async (product: number): Promise<Prices> => {
|
||||||
return priceRows;
|
return priceRows;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns prices that belong to the specified product.
|
|
||||||
* If type is newest, only the newest prices for each vendor will be returned.
|
|
||||||
* If type is lowest, the lowest daily price for the product is returned.
|
|
||||||
* Otherwise, all prices for this product are returned.
|
|
||||||
* @param product The product to fetch the prices for
|
|
||||||
* @param type The type of prices, e.g. newest / lowest
|
|
||||||
*/
|
|
||||||
export const findByType = async (product: string, type: string): Promise<Prices> => {
|
export const findByType = async (product: string, type: string): Promise<Prices> => {
|
||||||
let conn;
|
let conn;
|
||||||
let priceRows = [];
|
let priceRows = [];
|
||||||
|
@ -171,15 +152,6 @@ export const findByType = async (product: string, type: string): Promise<Prices>
|
||||||
return priceRows;
|
return priceRows;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns prices that belong to the specified product and vendor.
|
|
||||||
* If type is newest, only the newest known price for the product at the vendor is returned.
|
|
||||||
* If type is lowest, only the lowest ever known price for the product at the vendor is returned.
|
|
||||||
* Otherwise, all prices for this product are returned.
|
|
||||||
* @param product The product to fetch the prices for
|
|
||||||
* @param vendor The vendor to fetch the prices for
|
|
||||||
* @param type The type of prices, e.g. newest / lowest
|
|
||||||
*/
|
|
||||||
export const findByVendor = async (product: string, vendor: string, type: string): Promise<Prices> => {
|
export const findByVendor = async (product: string, vendor: string, type: string): Promise<Prices> => {
|
||||||
let conn;
|
let conn;
|
||||||
let priceRows = [];
|
let priceRows = [];
|
||||||
|
@ -214,11 +186,6 @@ export const findByVendor = async (product: string, vendor: string, type: string
|
||||||
return priceRows;
|
return priceRows;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns the best current deals, i.e. the non-amazon prices that have the biggest difference to amazon prices.
|
|
||||||
* Only the latest known prices for every vendor are taken into consideration so we only get up-to-date-deals.
|
|
||||||
* @param amount The amount of deals to return
|
|
||||||
*/
|
|
||||||
export const getBestDeals = async (amount: number): Promise<Prices> => {
|
export const getBestDeals = async (amount: number): Promise<Prices> => {
|
||||||
let conn;
|
let conn;
|
||||||
let priceRows = [];
|
let priceRows = [];
|
||||||
|
@ -315,7 +282,7 @@ export const getBestDeals = async (amount: number): Promise<Prices> => {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches and returns the lowest, latest, non-amazon price for each given product
|
* Get the lowest, latest, non-amazon price for each given product
|
||||||
* @param ids the ids of the products
|
* @param ids the ids of the products
|
||||||
*/
|
*/
|
||||||
export const findListByProducts = async (productIds: [number]): Promise<Prices> => {
|
export const findListByProducts = async (productIds: [number]): Promise<Prices> => {
|
||||||
|
@ -377,3 +344,36 @@ export const findListByProducts = async (productIds: [number]): Promise<Prices>
|
||||||
|
|
||||||
return priceRows;
|
return priceRows;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// export const create = async (newItem: Product): Promise<void> => {
|
||||||
|
// let conn;
|
||||||
|
// try {
|
||||||
|
// conn = await pool.getConnection();
|
||||||
|
// await conn.query("");
|
||||||
|
//
|
||||||
|
// } catch (err) {
|
||||||
|
// throw err;
|
||||||
|
// } finally {
|
||||||
|
// if (conn) conn.end();
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// export const update = async (updatedItem: Product): Promise<void> => {
|
||||||
|
// if (models.products[updatedItem.product_id]) {
|
||||||
|
// models.products[updatedItem.product_id] = updatedItem;
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// throw new Error("No record found to update");
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// export const remove = async (id: number): Promise<void> => {
|
||||||
|
// const record: Product = models.products[id];
|
||||||
|
//
|
||||||
|
// if (record) {
|
||||||
|
// delete models.products[id];
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// throw new Error("No record found to delete");
|
||||||
|
// };
|
||||||
|
|
|
@ -23,9 +23,6 @@ import {Products} from './products.interface';
|
||||||
* Service Methods
|
* Service Methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns all known products
|
|
||||||
*/
|
|
||||||
export const findAll = async (): Promise<Products> => {
|
export const findAll = async (): Promise<Products> => {
|
||||||
let conn;
|
let conn;
|
||||||
let prodRows = [];
|
let prodRows = [];
|
||||||
|
@ -77,10 +74,6 @@ export const findAll = async (): Promise<Products> => {
|
||||||
return prodRows;
|
return prodRows;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns the product with the specified id
|
|
||||||
* @param id The id of the product to fetch
|
|
||||||
*/
|
|
||||||
export const find = async (id: number): Promise<Product> => {
|
export const find = async (id: number): Promise<Product> => {
|
||||||
let conn;
|
let conn;
|
||||||
let prod: any;
|
let prod: any;
|
||||||
|
@ -104,10 +97,6 @@ export const find = async (id: number): Promise<Product> => {
|
||||||
return prod;
|
return prod;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns all products that match the search term
|
|
||||||
* @param term the term to match
|
|
||||||
*/
|
|
||||||
export const findBySearchTerm = async (term: string): Promise<Products> => {
|
export const findBySearchTerm = async (term: string): Promise<Products> => {
|
||||||
let conn;
|
let conn;
|
||||||
let prodRows = [];
|
let prodRows = [];
|
||||||
|
@ -133,10 +122,6 @@ export const findBySearchTerm = async (term: string): Promise<Products> => {
|
||||||
return prodRows;
|
return prodRows;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns the product details for the given list of product ids
|
|
||||||
* @param ids The list of product ids to fetch the details for
|
|
||||||
*/
|
|
||||||
export const findList = async (ids: [number]): Promise<Products> => {
|
export const findList = async (ids: [number]): Promise<Products> => {
|
||||||
let conn;
|
let conn;
|
||||||
let prodRows = [];
|
let prodRows = [];
|
||||||
|
@ -159,3 +144,36 @@ export const findList = async (ids: [number]): Promise<Products> => {
|
||||||
|
|
||||||
return prodRows;
|
return prodRows;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// export const create = async (newItem: Product): Promise<void> => {
|
||||||
|
// let conn;
|
||||||
|
// try {
|
||||||
|
// conn = await pool.getConnection();
|
||||||
|
// await conn.query("");
|
||||||
|
//
|
||||||
|
// } catch (err) {
|
||||||
|
// throw err;
|
||||||
|
// } finally {
|
||||||
|
// if (conn) conn.end();
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// export const update = async (updatedItem: Product): Promise<void> => {
|
||||||
|
// if (models.products[updatedItem.product_id]) {
|
||||||
|
// models.products[updatedItem.product_id] = updatedItem;
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// throw new Error("No record found to update");
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// export const remove = async (id: number): Promise<void> => {
|
||||||
|
// const record: Product = models.products[id];
|
||||||
|
//
|
||||||
|
// if (record) {
|
||||||
|
// delete models.products[id];
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// throw new Error("No record found to delete");
|
||||||
|
// };
|
||||||
|
|
44
Backend/src/models/vendors/vendors.service.ts
vendored
44
Backend/src/models/vendors/vendors.service.ts
vendored
|
@ -23,9 +23,6 @@ import {Vendors} from './vendors.interface';
|
||||||
* Service Methods
|
* Service Methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns all known vendors
|
|
||||||
*/
|
|
||||||
export const findAll = async (): Promise<Vendors> => {
|
export const findAll = async (): Promise<Vendors> => {
|
||||||
let conn;
|
let conn;
|
||||||
let vendorRows = [];
|
let vendorRows = [];
|
||||||
|
@ -69,10 +66,6 @@ export const findAll = async (): Promise<Vendors> => {
|
||||||
return vendorRows;
|
return vendorRows;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns the vendor with the specified id
|
|
||||||
* @param id The id of the vendor to fetch
|
|
||||||
*/
|
|
||||||
export const find = async (id: number): Promise<Vendor> => {
|
export const find = async (id: number): Promise<Vendor> => {
|
||||||
let conn;
|
let conn;
|
||||||
let vendor: any;
|
let vendor: any;
|
||||||
|
@ -96,10 +89,6 @@ export const find = async (id: number): Promise<Vendor> => {
|
||||||
return vendor;
|
return vendor;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns all vendors that match the search term
|
|
||||||
* @param term the term to match
|
|
||||||
*/
|
|
||||||
export const findBySearchTerm = async (term: string): Promise<Vendors> => {
|
export const findBySearchTerm = async (term: string): Promise<Vendors> => {
|
||||||
let conn;
|
let conn;
|
||||||
let vendorRows = [];
|
let vendorRows = [];
|
||||||
|
@ -123,3 +112,36 @@ export const findBySearchTerm = async (term: string): Promise<Vendors> => {
|
||||||
|
|
||||||
return vendorRows;
|
return vendorRows;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// export const create = async (newItem: Product): Promise<void> => {
|
||||||
|
// let conn;
|
||||||
|
// try {
|
||||||
|
// conn = await pool.getConnection();
|
||||||
|
// await conn.query("");
|
||||||
|
//
|
||||||
|
// } catch (err) {
|
||||||
|
// throw err;
|
||||||
|
// } finally {
|
||||||
|
// if (conn) conn.end();
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// export const update = async (updatedItem: Product): Promise<void> => {
|
||||||
|
// if (models.products[updatedItem.product_id]) {
|
||||||
|
// models.products[updatedItem.product_id] = updatedItem;
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// throw new Error("No record found to update");
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// export const remove = async (id: number): Promise<void> => {
|
||||||
|
// const record: Product = models.products[id];
|
||||||
|
//
|
||||||
|
// if (record) {
|
||||||
|
// delete models.products[id];
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// throw new Error("No record found to delete");
|
||||||
|
// };
|
||||||
|
|
Loading…
Reference in New Issue
Block a user