[FEAT] add capability to set condition in update

This commit is contained in:
Edouard DUPIN 2024-04-28 11:44:01 +02:00
parent d94e526bd4
commit 29a6e7602c
2 changed files with 4 additions and 2 deletions

View File

@ -1031,9 +1031,10 @@ public class DataAccess {
final QueryOptions options = new QueryOptions(option); final QueryOptions options = new QueryOptions(option);
final Condition condition = options.get(Condition.class); final Condition condition = options.get(Condition.class);
if (condition != null) { if (condition != null) {
throw new DataAccessException("request a updateWithJson with a condition"); options.add(new Condition(new QueryAnd(getTableIdCondition(clazz, id), condition.condition)));
} else {
options.add(new Condition(getTableIdCondition(clazz, id)));
} }
options.add(new Condition(getTableIdCondition(clazz, id)));
options.add(new TransmitKey(id)); options.add(new TransmitKey(id));
return updateWhereWithJson(clazz, jsonData, options.getAllArray()); return updateWhereWithJson(clazz, jsonData, options.getAllArray());
} }

View File

@ -121,6 +121,7 @@ public class RESTApi {
final HttpRequest request = requestBuilding.method(model, BodyPublishers.ofString(body)).build(); final HttpRequest request = requestBuilding.method(model, BodyPublishers.ofString(body)).build();
final HttpResponse<String> httpResponse = client.send(request, HttpResponse.BodyHandlers.ofString()); final HttpResponse<String> httpResponse = client.send(request, HttpResponse.BodyHandlers.ofString());
if (httpResponse.statusCode() < 200 || httpResponse.statusCode() >= 300) { if (httpResponse.statusCode() < 200 || httpResponse.statusCode() >= 300) {
LOGGER.trace("Receive Error: {}", httpResponse.body());
try { try {
final RESTErrorResponseExeption out = this.mapper.readValue(httpResponse.body(), RESTErrorResponseExeption.class); final RESTErrorResponseExeption out = this.mapper.readValue(httpResponse.body(), RESTErrorResponseExeption.class);
throw out; throw out;