Add TransactionDI in the swimming pool example

This commit is contained in:
nheron 2021-05-11 13:55:02 +02:00
commit 8ce9adc389
3 changed files with 18 additions and 1 deletions

View file

@ -83,6 +83,12 @@ public class QuoteController {
return clientHttpRequest -> {
ObjectMapper mapper = new ObjectMapper();
mapper.writeValue(clientHttpRequest.getBody(), updatedInstance);
if (updatedInstance.getSessionLogging()!= null &&
updatedInstance.getSessionLogging().length()>0){
clientHttpRequest.getHeaders().add(
"transactionId", updatedInstance.getSessionLogging());
}
clientHttpRequest.getHeaders().add(
HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
clientHttpRequest.getHeaders().add(

View file

@ -177,6 +177,11 @@
<td>Subscription price :</td>
<td>{{quoteResult.subscription.price}}</td>
</tr>
<tr>
<td>TransactionID :</td>
<td>{{quoteResult.sessionLogging}}</td>
</tr>
</table>
</div>

View file

@ -107,6 +107,7 @@ productManagerModule.controller('quoteManagerController', function ($scope, $htt
$scope.calculatePrice = function () {
var myQuote = $scope.quote;
myQuote.sessionLogging=uuidv4();
$http.put(urlBase + "/quote/calculate/" + $scope.containerid + "/", myQuote).success(function (data) {
$scope.quoteResult = data;
$scope.allSessionExecutionDetails = JSON.parse(data.sessionLogging);
@ -114,7 +115,12 @@ productManagerModule.controller('quoteManagerController', function ($scope, $htt
// $scope.sessionLogging=data.sessionLogging;
})
}
function uuidv4() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
});