Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
37 changes: 36 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.7</java.version>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
Expand All @@ -44,11 +50,40 @@
<scope>runtime</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.18.0</version>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-test -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>4.3.13.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test-autoconfigure</artifactId>
<version>1.5.9.RELEASE</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/io/zipcoder/ZcwbankApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class ZcwbankApplication {

public static void main(String[] args) {
SpringApplication.run(ZcwbankApplication.class, args);
}


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


import io.zipcoder.domain.Account;
import io.zipcoder.domain.Customer;
import io.zipcoder.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
public class AccountController {
@Autowired
private AccountService accountService;


public AccountController(AccountService accountService){
this.accountService = accountService;
}

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

@RequestMapping(value = "/accounts/{accountId}", method = RequestMethod.GET)
public ResponseEntity<?> getAccountById(@PathVariable("accountId") Long accountId){
return accountService.getAccountById(accountId);
}

@RequestMapping(value = "/customers/{customerId}/accounts", method = RequestMethod.GET)
public ResponseEntity<?> getAccountsForCustomer(@PathVariable("customerId") Long customerId){
return accountService.getAccountsOfCustomer(customerId);
}

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

@RequestMapping(value = "/accounts/{accountId}", method = RequestMethod.PUT)
public ResponseEntity<?> updateAccount(@PathVariable("accountId") Long accountId, @RequestBody Account account){
return accountService.updateAccount(account, accountId);
}

@RequestMapping(value = "/accounts/{accountId}", method = RequestMethod.DELETE)
public ResponseEntity<?> deleteAccount(@PathVariable("accountId") Long accountId){
return accountService.deleteAccount(accountId);
}
}
53 changes: 53 additions & 0 deletions src/main/java/io/zipcoder/controller/BillController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
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.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
public class BillController {

@Autowired
private BillService billService;

public BillController() {}

public BillController(BillService billService) {
this.billService = billService;
}

@RequestMapping(value="/accounts/{accountId}/bills", method= RequestMethod.GET)
public ResponseEntity<Iterable<Bill>> getAllBillsForAccount(@PathVariable("accountId") Long accountId) {
return billService.getAllBillsForAccount(accountId);
}

@RequestMapping(value="/bills/{billId}", method= RequestMethod.GET)
public ResponseEntity<Bill> getBillById(@PathVariable("billId") Long billId) {
return billService.getBillById(billId);
}

@RequestMapping(value="/customers/{customerId}/bills", method= RequestMethod.GET)
public ResponseEntity<Iterable<Bill>> getAllBillsForCustomer(@PathVariable Long customerId) {
return billService.getAllBillsForCustomer();
}

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

@RequestMapping(value = "/bills/{billId}", method = RequestMethod.PUT)
public ResponseEntity<?> updateBill(@PathVariable Long billId, @RequestBody Bill bill) {
return billService.updateBill(bill);
}

@RequestMapping(value = "/bills/{billId}", method = RequestMethod.DELETE)
public ResponseEntity<?> deleteBill(@PathVariable Long billId) {
return billService.deleteBill(billId);
}



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


import io.zipcoder.domain.Account;
import io.zipcoder.domain.Customer;
import io.zipcoder.repository.CustomerRepository;
import io.zipcoder.service.AccountService;
import io.zipcoder.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
public class CustomerController {

private CustomerService customerService;

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

@RequestMapping(value = "/customers", method = RequestMethod.GET)
public ResponseEntity<Iterable<Customer>> getAllCustomers(){
return customerService.getAllCustomers();
}

@RequestMapping(value = "/customers/{id}", method = RequestMethod.GET)
public ResponseEntity<Customer> getCustomerById(@PathVariable("id") Long id){
return customerService.getCustomerById(id);
}

@RequestMapping(value = "/accounts/{accountId}/customer", method = RequestMethod.GET)
public ResponseEntity<Customer> getCustomer(@PathVariable("accountId") Long accountId){
return customerService.getCustomerOfAccount(accountId);
}

@RequestMapping(value = "/customers", method = RequestMethod.POST)
public ResponseEntity<?> createCustomer(@RequestBody Customer customer){
return customerService.createCustomer(customer);
}

@RequestMapping(value = "/customers/{id}", method = RequestMethod.PUT)
public ResponseEntity<?> updateCustomer(@PathVariable("id") Long id, @RequestBody Customer customer){
return customerService.updateCustomer(customer, id);
}
}
76 changes: 76 additions & 0 deletions src/main/java/io/zipcoder/domain/Account.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package io.zipcoder.domain;

import javax.persistence.*;

@Entity
public class Account {

@Id
@GeneratedValue
@Column(name ="ACCOUNT_ID")
private Long id;

@Column(name = "ACCOUNT_TYPE")
private String type;

@Column(name = "NICKNAME")
private String nickname;

@Column(name = "REWARDS")
private Integer rewards;

@Column(name="BALANCE")
private Double balance;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "CUSTOMER_ID")
private Customer customer;

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public String getNickname() {
return nickname;
}

public void setNickname(String nickname) {
this.nickname = nickname;
}

public Integer getRewards() {
return rewards;
}

public void setRewards(Integer rewards) {
this.rewards = rewards;
}

public Double getBalance() {
return balance;
}

public void setBalance(Double balance) {
this.balance = balance;
}

public Customer getCustomer() {
return customer;
}

public void setCustomer(Customer customer) {
this.customer = customer;
}
}
10 changes: 10 additions & 0 deletions src/main/java/io/zipcoder/domain/AccountType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.zipcoder.domain;

public enum AccountType {
SAVINGS("savings"), CHECKING("checking"), CREDIT("credit");

private String type;
AccountType(String type){
this.type = type;
}
}
77 changes: 77 additions & 0 deletions src/main/java/io/zipcoder/domain/Address.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package io.zipcoder.domain;


import javax.persistence.*;

@Entity
public class Address {

@Id
@GeneratedValue
@Column(name = "ADDRESS_ID")
private Long id;

@Column(name = "STREET_NUMBER")
private String street_number;

@Column(name = "STREET_NAME")
private String street_name;

@Column(name = "CITY")
private String city;

@Column(name = "STATE")
private String state;

@Column(name = "ZIP")
private String zip;


public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getStreet_number() {
return street_number;
}

public void setStreet_number(String street_number) {
this.street_number = street_number;
}

public String getStreet_name() {
return street_name;
}

public void setStreet_name(String street_name) {
this.street_name = street_name;
}

public String getCity() {
return city;
}

public void setCity(String city) {
this.city = city;
}

public String getState() {
return state;
}

public void setState(String state) {
this.state = state;
}

public String getZip() {
return zip;
}

public void setZip(String zip) {
this.zip = zip;
}
}
Loading