Skip to content
Snippets Groups Projects
Commit e2fd3f9f authored by Andreas Kluge Svendsrud's avatar Andreas Kluge Svendsrud
Browse files

Merge branch 'feat/get-balance-from-bban' into 'master'

Feat/get balance from bban

See merge request !91
parents 2467818f 1f9c9198
No related branches found
No related tags found
1 merge request!91Feat/get balance from bban
Pipeline #284949 passed
......@@ -7,8 +7,10 @@ import java.util.List;
import lombok.extern.slf4j.Slf4j;
import no.ntnu.idi.stud.savingsapp.bank.dto.AccountRequestDTO;
import no.ntnu.idi.stud.savingsapp.bank.dto.AccountResponseDTO;
import no.ntnu.idi.stud.savingsapp.bank.dto.BalanceDTO;
import no.ntnu.idi.stud.savingsapp.bank.model.Account;
import no.ntnu.idi.stud.savingsapp.bank.service.AccountService;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.http.ResponseEntity;
......@@ -31,6 +33,9 @@ public class AccountController {
@Autowired
private AccountService accountService;
@Autowired
private ModelMapper modelMapper;
@Operation(summary = "Get user accounts", description = "Get accounts associated with a user by"
+ " providing their bank profile id")
@ApiResponses(value = {
......@@ -65,6 +70,20 @@ public class AccountController {
return ResponseEntity.ok(accounts);
}
@Operation(summary = "Create account", description = "Create account with random balance")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successfully created account"),
@ApiResponse(responseCode = "404", description = "Provided bban could not be "
+ "found")
})
@GetMapping("/balance/{bban}")
public ResponseEntity<BalanceDTO> getAccountsByBBAN(@PathVariable Long bban) {
log.info("[AccountController:getAccountsByBBAN] bban: {}", bban);
Account account = accountService.getAccountByBban(bban);
BalanceDTO balanceDTO = modelMapper.map(account, BalanceDTO.class);
return ResponseEntity.ok(balanceDTO);
}
@Operation(summary = "Create account", description = "Create account with random balance")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successfully created account"),
......
package no.ntnu.idi.stud.savingsapp.bank.dto;
import java.math.BigDecimal;
import lombok.Data;
@Data
public final class BalanceDTO {
private Long bban;
private BigDecimal balance;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment