Skip to content
Snippets Groups Projects
Commit 7e200c91 authored by KPOTY Kpotivi's avatar KPOTY Kpotivi
Browse files

feat: adding of services

parent 42c922ac
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,7 @@
"version": "0.0.0",
"scripts": {
"ng": "ng",
"generate-api": "rm -rf openapi-generator-cli.jar && curl --insecure https://repo.maven.apache.org/maven2/org/openapitools/openapi-generator-cli/6.6.0/openapi-generator-cli-6.6.0.jar -o openapi-generator-cli.jar && java -jar openapi-generator-cli.jar generate -i ../backend/src/main/java/com/shop/sphere/api/shop-sphere.yaml -g typescript-angular -o ./src/api --additional-properties=stringEnums=true,ngVersion=16.2.11",
"generate-api": "rm -rf openapi-generator-cli.jar && curl --insecure https://repo.maven.apache.org/maven2/org/openapitools/openapi-generator-cli/6.6.0/openapi-generator-cli-6.6.0.jar -o openapi-generator-cli.jar && java -jar openapi-generator-cli.jar generate -i ../backend/src/main/java/com/shop/sphere/api/shop-sphere.yaml -g typescript-angular -o ./src/api-client --additional-properties=stringEnums=true,ngVersion=16.2.11",
"start": "npm run generate-api && ng serve --port ",
"build": "npm run generate-api && ng build",
"watch": "ng build --watch --configuration development",
......
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { AdminDTO, AdminsService } from 'src/api-client';
@Injectable({
providedIn: 'root',
})
export class AdminService {
constructor(private adminsApiService: AdminsService) {}
/**
* Find admin by id
* @param id the id of the admin to find
* @returns an observable of admin
*/
public getAdmin(id: number): Observable<AdminDTO> {
return this.adminsApiService.getAdmin(id);
}
}
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { BuyerDTO, BuyersService, IdBuyer } from 'src/api-client';
@Injectable({
providedIn: 'root',
})
export class BuyerService {
constructor(private buyersApiService: BuyersService) {}
/**
* Create a new buyer in the database
* @param buyer to save in the databse
* @returns an obserable containing the id of the buyer created
*/
public createBuyer(buyer: BuyerDTO): Observable<IdBuyer> {
return this.buyersApiService.createBuyer(buyer);
}
/**
* Find a buyer by id
* @param id the id of the buyer
* @returns an observable of buyer
*/
public getBuyer(id: number): Observable<BuyerDTO> {
return this.buyersApiService.getBuyer(id);
}
/**
* Retrieve all buyers from the database
* @returns an observable of buyers
*/
public getBuyers(): Observable<BuyerDTO[]> {
return this.buyersApiService.getBuyers();
}
/**
* Update a buyer in the database
* @param buyer the buyer to update
*/
public updateBuyer(buyer: BuyerDTO): Observable<any> {
return this.buyersApiService.updateBuyer(buyer);
}
}
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { IdOrder, OrderDTO, OrdersService } from 'src/api-client';
@Injectable({
providedIn: 'root',
})
export class OrderService {
constructor(private ordersApiService: OrdersService) {}
/**
* Create a new order in the database
* @param order to save in the databse
* @returns an obserable containing the id of the order created
*/
public createOrder(order: OrderDTO): Observable<IdOrder> {
return this.ordersApiService.createOrder(order);
}
/**
* Delete an order in the database
* @param id of the order to delete
*/
public deleteOrder(id: number): Observable<any> {
return this.ordersApiService.deleteOrder(id);
}
/**
* Find an order by id
* @param id the id of the order to find
* @returns an observable of order
*/
public getOrder(id: number): Observable<OrderDTO> {
return this.ordersApiService.getOrder(id);
}
/**
* Retrieve all orders from the database
* @returns an observable of orders
*/
public getOrders(): Observable<OrderDTO[]> {
return this.ordersApiService.getOrders();
}
/**
* Update an order in the database
* @param order the order to update
*/
public updateOrder(order: OrderDTO): Observable<any> {
return this.ordersApiService.updateOrder(order);
}
}
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { ProductDTO, ProductsService } from 'src/api-client';
@Injectable({
providedIn: 'root',
})
export class ProductService {
constructor(private productsApiService: ProductsService) {}
/**
* Find a product by id
* @param id the id of the product to find
* @returns an observable of product
*/
public getProduct(id: number): Observable<ProductDTO> {
return this.productsApiService.getProduct(id);
}
/**
* Retrieve all products from the database
* @returns an observable of products
*/
public getProducts(): Observable<Array<ProductDTO>> {
return this.productsApiService.getProducts();
}
/**
* Update a product in the database
* @param product the product to update
*/
public updateProduct(product: ProductDTO): void {
this.productsApiService.updateProduct(product);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment