Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7ae1614

Browse files
BankSimulator: Add AmountController.java
1 parent 73a85f4 commit 7ae1614

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package prod.oldboy.controllers;
2+
3+
import io.swagger.v3.oas.annotations.Operation;
4+
import io.swagger.v3.oas.annotations.tags.Tag;
5+
import lombok.RequiredArgsConstructor;
6+
import lombok.extern.slf4j.Slf4j;
7+
import org.springframework.http.ResponseEntity;
8+
import org.springframework.validation.annotation.Validated;
9+
import org.springframework.web.bind.annotation.*;
10+
import prod.oldboy.dto.amount_dto.AmountTransferDto;
11+
import prod.oldboy.service.AmountService;
12+
import prod.oldboy.validation.group.UpdateAction;
13+
14+
@Slf4j
15+
@RestController
16+
@RequestMapping("/api/v1/users/amounts")
17+
@RequiredArgsConstructor
18+
@Tag(name = "Money transfer", description = "Method for transfer money from logged in user to another")
19+
public class AmountController {
20+
21+
private final AmountService amountService;
22+
23+
@PutMapping("/transfer")
24+
@Operation(summary = "Transfer money simulator",
25+
description = "Transfer from authenticated user to another user (amount format: ***.**)")
26+
public ResponseEntity<?> transferMoney(@Validated(UpdateAction.class)
27+
@RequestBody
28+
AmountTransferDto amountTransferDto) {
29+
30+
log.info("AmountController: method transferMoney is start");
31+
32+
ResponseEntity<?> mayBeTransfer = amountService.transferMoney(amountTransferDto)
33+
.map(content -> ResponseEntity.ok().body(content))
34+
.orElseGet(() -> ResponseEntity.noContent().build());
35+
36+
log.info("AmountController: method transferMoney is finished");
37+
38+
return mayBeTransfer;
39+
}
40+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /