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

Simple RESTful API with test Item.

parent fefec6f7
Branches
No related merge requests found
version=1.0
license=https://cecill.info/licences/Licence_CeCILL-B_V1-fr.html
netbeans.license=cecill-b
/*
* CONTRAT DE LICENCE DE LOGICIEL LIBRE CeCILL-B
* https://cecill.info/licences/Licence_CeCILL-B_V1-fr.html
*/
package fr.unistra.sil.erp.back.api.controller;
import fr.unistra.sil.erp.back.api.model.Item;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* REST controller for the item list.
* @author BEAUVAIS ANTOINE <antoine.beauvais@etu.unistra.fr>
*/
@RestController
public class ApiRetrieveInfoController {
/**
* Returns an Item as a JSON response.
* @return an Item.
*/
@GetMapping("/erp-back/api/v1/retrieveInfo")
public Item retrieveInfo()
{
return new Item(1, "Test", 1.0, 0.5);
}
}
/*
* CONTRAT DE LICENCE DE LOGICIEL LIBRE CeCILL-B
* https://cecill.info/licences/Licence_CeCILL-B_V1-fr.html
*/
package fr.unistra.sil.erp.back.api.model;
/**
* Item description.
* @author BEAUVAIS ANTOINE <antoine.beauvais@etu.unistra.fr>
*/
public class Item {
/**
* The product's reference number.
*/
private final int ref;
/**
* The product's name.
*/
private final String name;
/**
* The product's regular price.
*/
private final double price;
/**
* The product's price for subscribers.
*/
private final double subscriberPrice;
/**
* Class constructor.
* @param ref The item's reference number.
* @param name The item's name.
* @param price The item's price.
* @param subscriberPrice The item's price for subscribers.
*/
public Item(int ref, String name, double price,
double subscriberPrice)
{
this.ref = ref;
this.name = name;
this.price = price;
this.subscriberPrice = subscriberPrice;
}
/**
* Returns the current item's reference number.
* @return the reference number.
*/
public int getRef()
{
return this.ref;
}
/**
* Returns the current item's name.
* @return the name.
*/
public String getName()
{
return this.name;
}
/**
* Returns the current item's price.
* @return the price.
*/
public double getPrice()
{
return this.price;
}
/**
* Returns the current item's price for subscribers.
* @return the price for subscribers.
*/
public double getSubscriberPrice()
{
return this.subscriberPrice;
}
}
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