Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,16 @@
<scope>runtime</scope>
</dependency>

<dependency>
<!--<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>

</dependency>-->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>

Expand Down
13 changes: 13 additions & 0 deletions src/main/java/io/zipcoder/Enums/AccountType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package io.zipcoder.Enums;

public enum AccountType {
SAVINGS("Savings"),
CHECKING("Checking"),
CREDIT("Credit");

private String name;

AccountType(String name){
this.name = name;
}
}
13 changes: 13 additions & 0 deletions src/main/java/io/zipcoder/Enums/DepositType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package io.zipcoder.Enums;

public enum DepositType {
P2P("P2P"),
DEPOSIT("Deposit"),
WITHDRAWAL("Withdrawal");

private String name;

DepositType(String name){
this.name = name;
}
}
12 changes: 12 additions & 0 deletions src/main/java/io/zipcoder/Enums/Medium.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package io.zipcoder.Enums;

public enum Medium {
BALANCE("Balance"),
REWARDS("Rewards");

private String name;

Medium(String name){
this.name = name;
}
}
14 changes: 14 additions & 0 deletions src/main/java/io/zipcoder/Enums/Status.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package io.zipcoder.Enums;

public enum Status {
PENDING("Pending"),
CANCELLED("Cancelled"),
COMPLETED("Completed"),
RECURRING("Recurring");

private String name;

Status(String name){
this.name = name;
}
}
99 changes: 99 additions & 0 deletions src/main/java/io/zipcoder/controller/AccountController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package io.zipcoder.controller;

import io.zipcoder.domain.Account;
import io.zipcoder.domain.Bill;
import io.zipcoder.domain.Deposit;
import io.zipcoder.domain.Withdrawal;
import io.zipcoder.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
public class AccountController {


AccountService service;

@Autowired
public AccountController(AccountService service){
this.service = service;
}

@RequestMapping(value = "/accounts", method = RequestMethod.GET)
public ResponseEntity<?> getAllAccounts() {
return new ResponseEntity<>(service.getAllAccounts(), HttpStatus.OK);
}

@RequestMapping(value = "/accounts/{id}", method = RequestMethod.GET)
public ResponseEntity<?> getAccount(@PathVariable Long id) {
return new ResponseEntity<>(service.getAccountById(id), HttpStatus.OK);
}

@RequestMapping(value = "/accounts/{id}", method = RequestMethod.PUT)
public ResponseEntity<?> updateAccount(@PathVariable Long id, @RequestBody Account account) {
if(service.updateAccount(id,account)){
return new ResponseEntity<>(HttpStatus.OK);
}
else{
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}

}

@RequestMapping(value = "/accounts/{id}", method = RequestMethod.DELETE)
public ResponseEntity<?> deleteAccount(@PathVariable Long id) {
if(service.removeAccount(id)){
return new ResponseEntity<>(HttpStatus.OK);
}
else{
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
}

@RequestMapping(value = "/accounts/{id}/customer", method = RequestMethod.GET)
public ResponseEntity<?> getAccountCustomer(@PathVariable Long id) {
return new ResponseEntity<>(service.getAccountCustomer(id), HttpStatus.OK);
}

@RequestMapping(value = "/accounts/{id}/bills", method = RequestMethod.GET)
public ResponseEntity<?> getAccountBills(@PathVariable Long id) {
return new ResponseEntity<>(service.getAccountBills(id), HttpStatus.OK);
}

@RequestMapping(value = "/accounts/{id}/bills", method = RequestMethod.POST)
public ResponseEntity<?> createBill(@PathVariable Long id, @RequestBody Bill bill) {
service.createBill(bill);
return new ResponseEntity<>(HttpStatus.CREATED);
}

@RequestMapping(value = "/accounts/{id}/deposits", method = RequestMethod.GET)
public ResponseEntity<?> getAllDeposits(@PathVariable Long id) {
return new ResponseEntity<>(service.getAccountDeposits(id), HttpStatus.OK);
}

@RequestMapping(value = "/accounts/{id}/deposits", method = RequestMethod.POST)
public ResponseEntity<?> createDeposit(@PathVariable Long id, @RequestBody Deposit deposit) {
service.createDeposit(deposit);
return new ResponseEntity<>(HttpStatus.CREATED);
}

@RequestMapping(value = "/accounts/{id}/withdrawals", method = RequestMethod.GET)
public ResponseEntity<?> getAllWithdrawals(@PathVariable Long id) {
return new ResponseEntity<>(service.getAccountWithdrawals(id), HttpStatus.OK);
}

@RequestMapping(value = "/accounts/{id}/withdrawals", method = RequestMethod.POST)
public ResponseEntity<?> createWithdrawal(@PathVariable Long id, @RequestBody Withdrawal withdrawal) {
service.createWithdrawal(withdrawal);
return new ResponseEntity<>(HttpStatus.CREATED);
}







}
41 changes: 41 additions & 0 deletions src/main/java/io/zipcoder/controller/BillController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package io.zipcoder.controller;


import io.zipcoder.domain.Bill;
import io.zipcoder.service.BillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
public class BillController {

private BillService billService;

@Autowired
BillController(BillService billService){
this.billService = billService;
}

@RequestMapping(value = "/bills/{billid}", method = RequestMethod.GET)
public ResponseEntity getBillById(@PathVariable Long billId){
return new ResponseEntity(this.billService.getBillById(billId), HttpStatus.OK);
}

@RequestMapping(value = "/bills/(billid}", method = RequestMethod.PUT)
public ResponseEntity updateBill(@PathVariable Long billId, @RequestBody Bill billToUpdate){
boolean wasUpdated = this.billService.updateBill(billToUpdate);
if (wasUpdated){
return new ResponseEntity(HttpStatus.OK);
} else {
return new ResponseEntity(HttpStatus.NOT_FOUND);
}
}

@RequestMapping(value = "/bills/{billid}", method = RequestMethod.DELETE)
public ResponseEntity deleteBill(@PathVariable Long billId){
this.billService.deleteBillById(billId);
return new ResponseEntity(HttpStatus.OK);
}
}
67 changes: 67 additions & 0 deletions src/main/java/io/zipcoder/controller/CustomerController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package io.zipcoder.controller;

import com.sun.deploy.net.HttpResponse;
import io.zipcoder.domain.Account;
import io.zipcoder.domain.Customer;
import io.zipcoder.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
public class CustomerController {


CustomerService service;

@Autowired
public CustomerController(CustomerService service){
this.service = service;
}

@RequestMapping(value = "/customers/{id}/accounts", method = RequestMethod.GET)
public ResponseEntity<?> getAllAcctsForCust(@PathVariable Long id) {

return new ResponseEntity<>(service.getAllAccountsForCust(id), HttpStatus.OK);
}

@RequestMapping(value = "/customers/{id}/accounts", method = RequestMethod.POST)
public ResponseEntity<?> createAccount(@PathVariable Long id, @RequestBody Account account){
service.createAccount(account);
return new ResponseEntity<>(HttpStatus.CREATED);
}

@RequestMapping(value = "/customers", method = RequestMethod.GET)
public ResponseEntity<?> getAllCustomers(){
return new ResponseEntity<>(service.getAllCustomers(), HttpStatus.OK);
}

@RequestMapping(value = "/customers/{id}", method = RequestMethod.GET)
public ResponseEntity<?> getSpecificCusomer(@PathVariable Long id){

return new ResponseEntity<>(service.getCustomerById(id), HttpStatus.OK);
}

@RequestMapping(value = "/customers", method = RequestMethod.POST)
public ResponseEntity<?> createACustomer(@RequestBody Customer customer){
service.addCustomer(customer);
return new ResponseEntity<>(HttpStatus.CREATED);
}

@RequestMapping(value = "/customer/{id}", method = RequestMethod.PUT)
public ResponseEntity<?> updateCustomer(@PathVariable Long id, @RequestBody Customer customer){
if(service.updateCustomer(id,customer)){
return new ResponseEntity<>(HttpStatus.OK);
}
else{
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
}

@RequestMapping(value = "/customer/{id}/bills", method = RequestMethod.GET)
public ResponseEntity<?> getAllBillsForCust(@PathVariable Long id){

return new ResponseEntity<>(service.getAllBillsForCustomer(id), HttpStatus.OK);
}
}
40 changes: 40 additions & 0 deletions src/main/java/io/zipcoder/controller/DepositController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package io.zipcoder.controller;

import io.zipcoder.domain.Deposit;
import io.zipcoder.service.DepositService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
public class DepositController {

private DepositService depositService;

@Autowired
DepositController(DepositService depositService){
this.depositService = depositService;
}

@RequestMapping(value = "/deposits/{depositId}", method = RequestMethod.GET)
public ResponseEntity getDepositById(@PathVariable long depositId){
return new ResponseEntity(this.depositService.getDepositById(depositId), HttpStatus.OK);
}

@RequestMapping(value = "/deposits/{depositid}", method = RequestMethod.PUT)
public ResponseEntity updateDeposit(@PathVariable long depositId, @RequestBody Deposit depositToUpdate){
boolean wasUpdated = this.depositService.updateDeposit(depositToUpdate);
if (wasUpdated) {
return new ResponseEntity(HttpStatus.OK);
} else {
return new ResponseEntity(HttpStatus.NOT_FOUND);
}
}

@RequestMapping(value = "/deposits/{depositId}", method = RequestMethod.DELETE)
public ResponseEntity deleteDepositById(@PathVariable long depositId){
this.depositService.deleteDepositById(depositId);
return new ResponseEntity(HttpStatus.OK);
}
}
40 changes: 40 additions & 0 deletions src/main/java/io/zipcoder/controller/WithdrawalController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package io.zipcoder.controller;

import io.zipcoder.domain.Withdrawal;
import io.zipcoder.service.WithdrawalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
public class WithdrawalController {

private WithdrawalService withdrawalService;

@Autowired
WithdrawalController(WithdrawalService withdrawalService){
this.withdrawalService = withdrawalService;
}

@RequestMapping(value = "/withdrawals/{withdrawalId}", method = RequestMethod.GET)
public ResponseEntity getWithdrawalById(@PathVariable long withdrawalId){
return new ResponseEntity(this.withdrawalService.getWithdrawalById(withdrawalId), HttpStatus.OK);
}

@RequestMapping(value = "/withdrawals/{withdrawalid}", method = RequestMethod.PUT)
public ResponseEntity updateWithdrawal(@PathVariable long withdrawalId, @RequestBody Withdrawal withdrawalToUpdate){
boolean wasUpdated = this.withdrawalService.updateWithdrawal(withdrawalToUpdate);
if (wasUpdated) {
return new ResponseEntity(HttpStatus.OK);
} else {
return new ResponseEntity(HttpStatus.NOT_FOUND);
}
}

@RequestMapping(value = "/withdrawals/{withdrawalId}", method = RequestMethod.DELETE)
public ResponseEntity deleteWithdrawalById(@PathVariable long withdrawalId){
this.withdrawalService.deleteWithdrawalById(withdrawalId);
return new ResponseEntity(HttpStatus.OK);
}
}
Loading