Skip to content

Commit 2676f9c

Browse files
Fixed all methods in the HTTP api.
1 parent 6596fa3 commit 2676f9c

File tree

21 files changed

+116
-135
lines changed

21 files changed

+116
-135
lines changed

DataBaseCruca/.classpath

Lines changed: 0 additions & 32 deletions
This file was deleted.

DataBaseCruca/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

DataBaseCruca/.project

Lines changed: 0 additions & 23 deletions
This file was deleted.

DataBaseCruca/.settings/org.eclipse.core.resources.prefs

Lines changed: 0 additions & 2 deletions
This file was deleted.

DataBaseCruca/.settings/org.eclipse.jdt.core.prefs

Lines changed: 0 additions & 9 deletions
This file was deleted.

DataBaseCruca/target/classes/application.properties

Lines changed: 0 additions & 6 deletions
This file was deleted.

accessing-data-mysql/.classpath

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
</classpathentry>
1414
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
1515
<attributes>
16+
<attribute name="test" value="true"/>
1617
<attribute name="optional" value="true"/>
1718
<attribute name="maven.pomderived" value="true"/>
18-
<attribute name="test" value="true"/>
1919
</attributes>
2020
</classpathentry>
21-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
21+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk-11.0.4.11-hotspot">
2222
<attributes>
23+
<attribute name="module" value="true"/>
2324
<attribute name="maven.pomderived" value="true"/>
2425
</attributes>
2526
</classpathentry>
@@ -28,5 +29,7 @@
2829
<attribute name="maven.pomderived" value="true"/>
2930
</attributes>
3031
</classpathentry>
32+
<classpathentry combineaccessrules="false" kind="src" path="/apihttp"/>
33+
<classpathentry combineaccessrules="false" kind="src" path="/projectcruca"/>
3134
<classpathentry kind="output" path="target/classes"/>
3235
</classpath>

accessing-data-mysql/src/main/java/com/example/accessingdatamysql/CardService.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* @author Maria
77
*
88
*/
9+
910
import java.math.BigDecimal;
1011
import java.util.Random;
1112

@@ -59,10 +60,8 @@ public BigDecimal userBalace(int uDNI)
5960
/**
6061
* Carry out a reload on a user's card.
6162
* @param r Reload data.
62-
* @throws WrongTransactionException If the operation to be performed
63-
* fails because the data entered is incorrect.
6463
*/
65-
public void addBalance(Reload r) throws WrongTransactionException
64+
public void addBalance(Reload r)
6665
{
6766
try
6867
{
@@ -105,7 +104,7 @@ public void paymentAuthoritation(Order o, int uDNI)
105104
* @throws WrongTransactionException If the operation to be performed
106105
* fails because the data entered is incorrect.
107106
*/
108-
public void PayRegister(Payment p, int nCard) throws WrongTransactionException
107+
public void payRegister(Payment p, int nCard) throws WrongTransactionException
109108
{
110109
try
111110
{
@@ -128,7 +127,7 @@ public void PayRegister(Payment p, int nCard) throws WrongTransactionException
128127
* @throws WrongTransactionException If the operation to be performed
129128
* fails because the data entered is incorrect.
130129
*/
131-
public void payconfirm(int idord, int iduser, String code) throws WrongTransactionException,UnreachableStatusException
130+
public void payconfirm(int idord, int iduser, String code)
132131
{
133132
User u = DU.getUser(iduser);
134133
Order o = DO.getOrder(idord);
@@ -138,8 +137,7 @@ public void payconfirm(int idord, int iduser, String code) throws WrongTransacti
138137
try
139138
{
140139
OService.OrderStatus_Payed(o);
141-
PayRegister(new Payment("Pago Pedido " + idord, u , o.totalCost()), c.getCardNumber());
142-
140+
payRegister(new Payment("Pago Pedido " + idord, u , o.totalCost()), c.getCardNumber());
143141
}
144142
catch(UnreachableStatusException ex)
145143
{

accessing-data-mysql/src/main/java/com/example/accessingdatamysql/MainController.java

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -94,26 +94,11 @@ public void payregister(@RequestBody Payment p, @PathVariable int ncard) throws
9494
* Check that the payment has been made correctly and the order status has been changed to <code>PAYED</code>.
9595
* @param ou Map containing the ID of the order and the ID of the user to whom the order belongs.
9696
* @param code Validation code for the payment of the specific order
97-
* @throws WrongTransactionException If the operation to be performed
98-
* fails because the data entered is incorrect.
99-
* @throws UnreachableStatusException If the conditions to set the <code>PAYED</code> status aren't met.
10097
*/
10198
@PutMapping("/payconfirm/{code}")
102-
public void payComfirm(@RequestBody Map<Integer, Integer> ou, @PathVariable("code") String code) throws WrongTransactionException, UnreachableStatusException
99+
public void payComfirm(int userId, int orderId, @PathVariable("code") String code)
103100
{
104-
Map.Entry<Integer, Integer> entry = ou.entrySet().iterator().next();
105-
try
106-
{
107-
CService.payconfirm(entry.getKey().intValue() , entry.getValue().intValue() , code);
108-
}
109-
catch(WrongTransactionException e)
110-
{
111-
112-
}
113-
catch(UnreachableStatusException e)
114-
{
115-
116-
}
101+
CService.payconfirm(orderId, userId, code);
117102
}
118103

119104
@GetMapping("/seecard/{iduser}")

api/src/main/java/coreapi/Cafeteria.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,20 @@ public void removeProduct(Product prod)
189189

190190
/**
191191
* Registers an order as pertaining to this cafeteria.
192-
* @param newOrder The order to register to this cafeteria.
192+
* @param newOrderId The order to register to this cafeteria.
193193
*/
194-
public void registerOrder(Order newOrder)
194+
public void registerOrder(int newOrderId)
195195
{
196-
orderHistory.add(Integer.valueOf(newOrder.getId()));
196+
orderHistory.add(Integer.valueOf(newOrderId));
197+
}
198+
199+
/**
200+
* Removes the connection of an order pertaining to this cafeteria.
201+
* @param newOrderId The order to remove from this cafeteria.
202+
*/
203+
public void deleteOrder(int ordId)
204+
{
205+
orderHistory.remove(Integer.valueOf(ordId));
197206
}
198207

199208
/**

0 commit comments

Comments
 (0)