Skip to content
Snippets Groups Projects
Commit 0b9b97ea authored by BEAUVAIS ANTOINE's avatar BEAUVAIS ANTOINE
Browse files

Merge branch 'develop' into 'master'

Merge 'develop' into 'master'.

See merge request !8
parents 5555fea0 72dbeed7
Branches
1 merge request!8Merge 'develop' into 'master'.
Showing with 201 additions and 12 deletions
image: openjdk:8u302
workflow:
rules:
- if: '$CI_COMMIT_BRANCH'
pages:
tags:
- kubernetes
script:
- ./gradlew javadoc
- mv ./build/docs/javadoc public
artifacts:
paths:
- public
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
\ No newline at end of file
openapi: "3.0.0"
info:
version: 0.0.1-20210924
title: SIL ERP BACK
description: Interface API between the SIL ERP services and the BACK component.
# termsOfService: https://git.unistra.fr/erp-sil/back
contact:
name: Antoine Beauvais
email: antoine.beauvais@etu.unistra.fr
url: https://git.unistra.fr/antoine.beauvais
license:
name: CeCILL-B
url: https://cecill.info/licences/Licence_CeCILL-B_V1-en.html
paths:
/retrieveItems:
get:
description: |
Returns the list of all available items.
It is also possible to filter items by category.
operationId: retrieveItems
parameters:
- name: category
in: query
description: category ID to filter results by
required: false
schema:
type: integer
format: int32
responses:
'200':
description: List of items.
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Item'
'204':
description: No Content (no items in the given category)
'400':
description: Bad Request (invalid category parameter)
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorMessage'
'500':
description: Internal Server Error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorMessage'
/retrieveCategories:
get:
description: |
Returns the list of all existing categories.
operationId: retrieveCategories
responses:
'200':
description: List of categories.
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Category'
'500':
description: Internal Server Error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorMessage'
/submitTransaction:
post:
description: Submits a new transaction into the system.
operationId: submitTransaction
requestBody:
description: Transaction to process.
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Transaction'
responses:
'201':
description: Created transaction.
content:
application/json:
schema:
$ref: '#/components/schemas/Transaction'
'400':
description: Bad Request (invalid JSON)
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorMessage'
'500':
description: Internal Server Error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorMessage'
components:
schemas:
Category:
type: object
required:
- id
- name
properties:
id:
type: integer
example: 1
name:
type: string
example: "Boissons"
Item:
type: object
required:
- id
- name
- price
- subscriberPrice
properties:
id:
type: integer
example: 1
name:
type: string
example: "Jus d'orange"
price:
type: number
example: 1.5
subscriberPrice:
type: number
example: 0.8
Transaction:
type: object
required:
- item
- quantity
- amount
properties:
item:
type: integer
example: 1
quantity:
type: integer
example: 5
amount:
type: number
example: 4.0
ErrorMessage:
type: object
required:
- message
properties:
message:
type: string
example: "Database failure."
\ No newline at end of file
gradlew 100644 → 100755
File mode changed from 100644 to 100755
......@@ -25,7 +25,7 @@ public class DatabaseSystem {
* to the desired one.
*
* @return the instance of the database implementation.
* @throws fr.unistra.sil.erp.back.db.DatabaseConnectionException
* @throws DatabaseConnectionException if the connection to the DB failed.
*/
public static DatabaseInterface getInstance() throws DatabaseConnectionException
{
......
......@@ -48,7 +48,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
* API Mapping for retrieving all items.
*/
public static final String MAPPING_RETRIEVEALL = API_FULL_PREFIX +
"/retrieveAll";
"/retrieveItems";
/**
* API Mapping for retrieving all categories.
......
......@@ -15,9 +15,9 @@ public interface IRetrieveInfoController {
/**
* Retrieves the list of items.
* @param cat
* @return
* @throws Exception
* @param cat the optional category to filter.
* @return the list of items as a JSON response/
* @throws Exception if the request cannot be served.
*/
public ResponseEntity<Object> retrieveInfo(
@RequestParam(value = "category", defaultValue = "") String cat
......
......@@ -24,14 +24,14 @@ import org.springframework.web.bind.annotation.RestController;
* @author BEAUVAIS ANTOINE
*/
@RestController
public class ApiRetrieveInfoController implements IRetrieveInfoController {
public class ApiRetrieveItemsController implements IRetrieveInfoController {
/**
* Returns all products as a JSON response.
* @param cat an optional category.
* @return a JSON response.
* @throws fr.unistra.sil.erp.back.controller.api.ApiServerErrorException
* @throws fr.unistra.sil.erp.back.controller.api.ApiBadRequestException
* @throws ApiServerErrorException if the request could not be served.
* @throws ApiBadRequestException if the category parameter is invalid.
*/
@GetMapping(MAPPING_RETRIEVEALL)
public ResponseEntity<Object> retrieveInfo(
......@@ -42,7 +42,7 @@ public class ApiRetrieveInfoController implements IRetrieveInfoController {
try {
db = DatabaseSystem.getInstance();
} catch (DatabaseConnectionException ex) {
Logger.getLogger(ApiRetrieveInfoController.class.getName()).log(
Logger.getLogger(ApiRetrieveItemsController.class.getName()).log(
Level.SEVERE, "Could not connect to database.", ex);
throw new ApiServerErrorException("Database failure.");
}
......
......@@ -32,7 +32,7 @@ public class ApiRetrieveStocks implements IRetrieveStocks {
* @param request the HTTP request.
* @param response the HTTP response.
* @return the response.
* @throws fr.unistra.sil.erp.back.controller.api.ApiServerErrorException
* @throws ApiServerErrorException if the request could not be served.
*/
@GetMapping(MAPPING_GETSTOCKS)
@Override
......
......@@ -48,7 +48,7 @@ public interface DatabaseInterface {
/**
* Returns the stock entry of an item.
* @param id the item's ID.
* @param itemId the item's ID.
* @return the stock line.
* @throws DatabaseResourceNotFoundException when the query fails.
*/
......@@ -59,6 +59,7 @@ public interface DatabaseInterface {
* Updates the specified stock's quantity.
* @param id the stock entry's ID.
* @param quantity the new quantity.
* @throws DatabaseConnectionException when the database is unreachable.
* @throws DatabaseUpdateException when the query fails.
*/
public void updateStock(int id, int quantity)
......
......@@ -28,11 +28,22 @@ public class ApiAuthenticationInterceptor implements HandlerInterceptor {
*/
private final String apikey;
/**
* Class constructor.
* @param apikey the API key.
*/
public ApiAuthenticationInterceptor(String apikey)
{
this.apikey = apikey;
}
/**
* Code used to check the request's API key against the real one.
* @param request the HTTP Servlet request.
* @param response the HTTP Servlet response.
* @param handler the handler Object.
* @return whether the request should be continued.
*/
@Override
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response, Object handler)
......
......@@ -38,7 +38,6 @@ public class Transaction {
* Class constructor.
* @param item Item's identifier.
* @param type Transaction type.
* @param amount Transaction's amount.
* @param quantity Quantity of items involved.
*/
public Transaction(Integer item, Integer type, Integer quantity)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment