diff --git a/.idea/sqldialects.xml b/.idea/sqldialects.xml new file mode 100644 index 000000000..32cc987d1 --- /dev/null +++ b/.idea/sqldialects.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/src/main/Queries/.DS_Store b/src/main/Queries/.DS_Store deleted file mode 100644 index ee927c563..000000000 Binary files a/src/main/Queries/.DS_Store and /dev/null differ diff --git a/src/main/Queries/MMDump.sql b/src/main/Queries/MMDump.sql deleted file mode 100644 index 9077dab2d..000000000 --- a/src/main/Queries/MMDump.sql +++ /dev/null @@ -1,137 +0,0 @@ --- MySQL dump 10.13 Distrib 8.0.22, for macos10.15 (x86_64) --- --- Host: localhost Database: moneymanagement --- ------------------------------------------------------ --- Server version 8.0.22 - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!50503 SET NAMES utf8mb4 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -Create Schema moneymanagement; --- --- Table structure for table `account` --- - -DROP TABLE IF EXISTS `account`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `account` ( - `id` bigint NOT NULL AUTO_INCREMENT, - `account_number` varchar(255) DEFAULT NULL, - `account_type` varchar(255) DEFAULT NULL, - `balance` double DEFAULT NULL, - `date_of_opening` date DEFAULT NULL, - `interest_rate` double DEFAULT NULL, - `routing_number` varchar(255) DEFAULT NULL, - `user_id` bigint DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `account` --- - -LOCK TABLES `account` WRITE; -/*!40000 ALTER TABLE `account` DISABLE KEYS */; -INSERT INTO `account` VALUES (1,'Account - 1245451','INVESTMENT',500000.22,'2004-01-22',12.5,'2001445',1); -/*!40000 ALTER TABLE `account` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `login` --- - -DROP TABLE IF EXISTS `login`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `login` ( - `id` bigint NOT NULL AUTO_INCREMENT, - `password` varchar(255) DEFAULT NULL, - `user_id` bigint DEFAULT NULL, - `username` varchar(255) DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `login` --- - -LOCK TABLES `login` WRITE; -/*!40000 ALTER TABLE `login` DISABLE KEYS */; -INSERT INTO `login` VALUES (1,'c51ChDMn',1,'lmcqueen0'),(2,'9Gi1RGOg',2,'mpentecost1'),(3,'fyMzNy7n8A8t',3,'amills2'),(4,'q0NbGZf',4,'bculross3'),(5,'yLQvlpxXIuNe',5,'gbloss4'),(6,'eQANN59g7',6,'mnolli5'),(7,'4vKaSDaX4K',7,'bdefau6'),(8,'7sBfdC',8,'svanyashin7'),(9,'eTS542J8XdVI',9,'bchavez8'),(10,'2cWHHxth',10,'dquig9'),(11,'GxSxDH',11,'bhercocka'),(12,'RZh8GTIgBE',12,'cfownesb'),(13,'QekocrR',13,'jboamc'),(14,'821sff3S6whi',14,'amckeggied'),(15,'yf9AAFSCz',15,'cswansburye'),(16,'Jf2UhD6N',16,'shanmerf'),(17,'1gBv9SwWynK',17,'tscutching'),(18,'4YUf6yym0k8F',18,'jskirvinh'),(19,'vwUorIBbE',19,'wpretoi'),(20,'AphCxH2MIgq',20,'bpargetterj'),(21,'6ttHlsQoigO',21,'dudenk'),(22,'GzazmP0TMu',22,'bpantherl'),(23,'fPWjg5e',23,'scoronasm'),(24,'H4TNZ5yA9',24,'cmcgurgann'),(25,'ZTZvoWjo',25,'mdirando'); -/*!40000 ALTER TABLE `login` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `transaction_history` --- - -DROP TABLE IF EXISTS `transaction_history`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `transaction_history` ( - `id` bigint NOT NULL AUTO_INCREMENT, - `account_type` varchar(255) DEFAULT NULL, - `balance_after_transaction` double DEFAULT NULL, - `date_of_transaction` date DEFAULT NULL, - `transaction_type` varchar(255) DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `transaction_history` --- - -LOCK TABLES `transaction_history` WRITE; -/*!40000 ALTER TABLE `transaction_history` DISABLE KEYS */; -/*!40000 ALTER TABLE `transaction_history` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `user` --- - -DROP TABLE IF EXISTS `user`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `user` ( - `id` bigint NOT NULL AUTO_INCREMENT, - `address` varchar(255) DEFAULT NULL, - `dateofbirth` date DEFAULT NULL, - `firstname` varchar(255) DEFAULT NULL, - `lastname` varchar(255) DEFAULT NULL, - `socialsecurity` varchar(255) DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `user` --- - -LOCK TABLES `user` WRITE; -/*!40000 ALTER TABLE `user` DISABLE KEYS */; -INSERT INTO `user` VALUES (1,'48 Haas Street','2001-04-11','Antoine','Oakinfold','112-555-545'),(2,'77756 Cascade Circle','1986-04-07','Yanaton','Sikorski','125-784-457'),(3,'8 Quincy Place','1988-05-14','Warde','Tilburn','154-784-541'),(4,'77413 Milwaukee Crossing','2002-04-14','Dario','Purches','451-457-581'),(5,'4173 Arapahoe Parkway','1993-05-27','Tobi','Balfre','451-874-542'),(6,'1 Village Green Avenue','1993-09-15','Lexine','Shelliday','125-784-541'),(7,'9893 Vidon Way','1978-11-09','Morey','Vela','487-458-987'),(8,'9337 Erie Park','2001-05-25','Noella','Skein','451-784-541'),(9,'9 Towne Alley','1986-08-07','Isaac','Marskell','154-784-451'),(10,'9967 Hovde Parkway','1983-07-17','Kerwin','Franckton','154-784-451'),(11,'97169 Beilfuss Pass','1988-05-31','Almeda','Lumbers','125-457-845'),(12,'6 Mayfield Point','1990-03-09','Maude','Dunn','125-487-458'),(13,'46 Anthes Road','1979-10-01','Deni','Shermore','124-784-458'),(14,'4 Sloan Avenue','2002-01-11','Jobi','Ellick','451-458-457'),(15,'163 Lake View Circle','2004-08-22','Wallie','Leyrroyd','457-548-552'),(16,'2796 Kipling Place','1981-04-20','Augustine','Shermore','154-578-945'),(17,'4 Almo Avenue','1999-09-01','Ward','Rummins','547-854-999'),(18,'5 Mcbride Parkway','1985-11-10','Gar','Duddridge','451-457-845'),(19,'39 Bultman Hill','2001-09-26','Sosanna','MacGarvey','111-245-784'),(20,'638 Shasta Terrace','1980-08-18','Greta','Cheales','4512-457-451'),(21,'17646 Sundown Avenue','2003-05-08','Reilly','McIlwreath','245-445-444'),(22,'9 Oak Valley Drive','1995-02-27','Dona','Hancke','457-445-444'),(23,'7 Debs Plaza','1986-06-05','Georgette','Marusyak','457-444-999'),(24,'87489 Dunning Junction','1991-06-06','Dasi','Allso','451-451-444'),(25,'22 Everett Way','1995-06-20','Di','Izkovitz','987-444-111'); -/*!40000 ALTER TABLE `user` ENABLE KEYS */; -UNLOCK TABLES; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - --- Dump completed on 2020-12-20 13:18:02 diff --git a/src/main/java/runner/controllers/AccountController.java b/src/main/java/runner/controllers/AccountController.java index 0398b85c9..c5824ec0b 100644 --- a/src/main/java/runner/controllers/AccountController.java +++ b/src/main/java/runner/controllers/AccountController.java @@ -1,26 +1,31 @@ package runner.controllers; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import runner.entities.Account; +import runner.entities.User; import runner.services.AccountServices; - +import java.util.Optional; @RequestMapping("/account") @RestController public class AccountController { @Autowired private AccountServices accountServices; - @GetMapping(value = "/read/{id}") public ResponseEntity readById(@PathVariable Long id) { return new ResponseEntity<>(accountServices.readAccount(id), HttpStatus.OK); } - @PostMapping(value = "/create") public ResponseEntity create(@RequestBody Account account) { return new ResponseEntity<>(accountServices.createAccount(account), HttpStatus.CREATED); } - -} + @PutMapping(value = "/update/{id}") + public ResponseEntity> update(@RequestBody Account account, @PathVariable Long id) { + return new ResponseEntity<>(accountServices.updateAccount(id,account), HttpStatus.OK); + } + @DeleteMapping(value = "/delete/{id}") + public ResponseEntity deleteById(@PathVariable Long id) { + return new ResponseEntity<>(accountServices.removeAccount(id), HttpStatus.OK); + } +} \ No newline at end of file diff --git a/src/main/java/runner/controllers/UserController.java b/src/main/java/runner/controllers/UserController.java index 63a94e41d..da53cd8ed 100644 --- a/src/main/java/runner/controllers/UserController.java +++ b/src/main/java/runner/controllers/UserController.java @@ -1,44 +1,36 @@ package runner.controllers; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import runner.entities.User; import runner.services.UserServices; +import java.util.Optional; @RequestMapping("/user") @RestController public class UserController { @Autowired private UserServices userServices; - @GetMapping(value = "/read/{id}") - public ResponseEntity readById(@PathVariable Long id) { - return new ResponseEntity<>(userServices.readUser(id), HttpStatus.OK); + public ResponseEntity readById(@PathVariable Long id) throws Exception { + if(new ResponseEntity<>(userServices.readUser(id), HttpStatus.OK) == null) throw new Exception("Error , the user id is null") ; + else + return new ResponseEntity<>(userServices.readUser(id), HttpStatus.OK); } - -//// @GetMapping(value = "/readAll") -//// public ResponseEntity> readAll() { -//// return new ResponseEntity<>(userServices.readAll(), HttpStatus.OK); -//// } -// @PostMapping(value = "/user/create") -// public ResponseEntity create(@RequestBody User user) { -// return new ResponseEntity<>(userServices.createUser(user), HttpStatus.CREATED); -// } -// -// @PutMapping(value = "/user/update/{id}") -// public ResponseEntity update(@RequestBody User user,@PathVariable Long id) { -// return new ResponseEntity<>(userServices.updateUser(id,user), HttpStatus.OK); -// } -// -// @DeleteMapping(value = "/user/delete/{id}") -// public ResponseEntity deleteById(@PathVariable Long id) { -// return new ResponseEntity<>(userServices.deleteUser(id), HttpStatus.OK); -// } - - @GetMapping(value = "/home") + @PostMapping(value = "/create") + public ResponseEntity create(@RequestBody User user) { + return new ResponseEntity<>(userServices.createUser(user), HttpStatus.CREATED); + } + @PutMapping(value = "/update/{id}") + public ResponseEntity update(@RequestBody User user,@PathVariable Long id) { + return new ResponseEntity<>(userServices.updateUser(id,user), HttpStatus.OK); + } + @DeleteMapping(value = "/delete/{id}") + public ResponseEntity deleteById(@PathVariable Long id) { + return new ResponseEntity<>(userServices.deleteUser(id), HttpStatus.OK); + } + @GetMapping(value = "/home") public String displayHome() { return "Hello World"; } - -} +} \ No newline at end of file diff --git a/src/main/java/runner/entities/Account.java b/src/main/java/runner/entities/Account.java index fea81d22f..3581d1145 100644 --- a/src/main/java/runner/entities/Account.java +++ b/src/main/java/runner/entities/Account.java @@ -1,44 +1,55 @@ package runner.entities; +import com.fasterxml.jackson.annotation.JsonBackReference; +import com.fasterxml.jackson.annotation.JsonManagedReference; import runner.enums.AccountType; import javax.persistence.*; import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; @Entity public class Account { @Id @GeneratedValue(strategy = GenerationType.AUTO) - protected Long id; - //@Column(name = "user_id") + private Long id; + @Column(nullable = false) + private String accountNumber; + @Column(nullable = false) + private String routingNumber; + @Enumerated(EnumType.STRING) + @Column(nullable = false) + private AccountType accountType; //enum + @Column(nullable = false) + private Double balance; + @Column(nullable = false) + private LocalDate dateOfOpening; + @Column(nullable = false) + private Double interestRate; + + @JsonBackReference(value = "name1") + @OneToMany(mappedBy = "account" ,cascade= CascadeType.ALL, fetch=FetchType.EAGER) + private Set transactionsList; + + @JsonBackReference (value = "name2") @ManyToOne + @JoinColumn(name = "UserId", nullable = false) private User user; - @Column(name = "account_number") - protected String accountNumber; - @Column(name = "routing_number") - protected String routingNumber; - @Enumerated(EnumType.STRING) - @Column(name = "account_type") - protected AccountType accountType; //enum - @Column(name = "balance") - protected Double balance; - @Column(name = "date_of_opening") - protected LocalDate dateOfOpening; - @Column(name = "interest_rate") - protected Double interestRate; + +// @ManyToOne(cascade=CascadeType.ALL,fetch=FetchType.EAGER) +// private User user; public Account() { } - public Long getId() { return id; } - public void setId(Long id) { this.id = id; } - - public String getAccountNumber() { + public String getAccountNumber() { return accountNumber; } @@ -85,4 +96,20 @@ public Double getInterestRate() { public void setInterestRate(Double interestRate) { this.interestRate = interestRate; } + + public Set getTransactionsList() { + return transactionsList; + } + + public void setTransactionsList(Set transactionsList) { + this.transactionsList = transactionsList; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } } \ No newline at end of file diff --git a/src/main/java/runner/entities/Address.java b/src/main/java/runner/entities/Address.java new file mode 100644 index 000000000..c3a056ec7 --- /dev/null +++ b/src/main/java/runner/entities/Address.java @@ -0,0 +1,74 @@ +package runner.entities; + +import javax.persistence.*; +import java.time.LocalDate; + +@Entity +public class Address { + @Id + @Column(name = "userId") //references userID from user + private Long id; + @Column(nullable = false) + private String firstLine; + @Column(nullable = true) + private String secondLIne; + @Column(nullable = false) + private String city; + @Column(nullable = false) + private String state; + @Column(nullable = false) + private String zipcode; + + @OneToOne + @MapsId + @JoinColumn(name = "userId") + private User user; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getFirstLine() { + return firstLine; + } + + public void setFirstLine(String firstLine) { + this.firstLine = firstLine; + } + + public String getSecondLIne() { + return secondLIne; + } + + public void setSecondLIne(String secondLIne) { + this.secondLIne = secondLIne; + } + + 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 getZipcode() { + return zipcode; + } + + public void setZipcode(String zipcode) { + this.zipcode = zipcode; + } +} diff --git a/src/main/java/runner/entities/Checking.java b/src/main/java/runner/entities/Checking.java new file mode 100644 index 000000000..f1728e7ff --- /dev/null +++ b/src/main/java/runner/entities/Checking.java @@ -0,0 +1,4 @@ +package runner.entities; + +public class Checking extends Account{ +} diff --git a/src/main/java/runner/entities/Checkings.java b/src/main/java/runner/entities/Checkings.java deleted file mode 100644 index fab3d0e59..000000000 --- a/src/main/java/runner/entities/Checkings.java +++ /dev/null @@ -1,4 +0,0 @@ -package runner.entities; - -public class Checkings extends Account{ -} diff --git a/src/main/java/runner/entities/Investment.java b/src/main/java/runner/entities/Investment.java new file mode 100644 index 000000000..0abc3cfee --- /dev/null +++ b/src/main/java/runner/entities/Investment.java @@ -0,0 +1,7 @@ +package runner.entities; + +public class Investment extends Account{ + + + +} diff --git a/src/main/java/runner/entities/Investments.java b/src/main/java/runner/entities/Investments.java deleted file mode 100644 index 6cc562504..000000000 --- a/src/main/java/runner/entities/Investments.java +++ /dev/null @@ -1,7 +0,0 @@ -package runner.entities; - -public class Investments extends Account{ - - - -} diff --git a/src/main/java/runner/entities/Login.java b/src/main/java/runner/entities/Login.java index 2ba4cd782..d65133d0b 100644 --- a/src/main/java/runner/entities/Login.java +++ b/src/main/java/runner/entities/Login.java @@ -5,12 +5,20 @@ @Entity public class Login { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "userId") //references userID from user private Long id; - private Long userId; +// @Column(nullable = false) +// private Long userId; + @Column(nullable = false) private String username; + @Column(nullable = false) private String password; + @OneToOne + @MapsId + @JoinColumn(name = "userId") + private User user; + public Login() { } @@ -22,9 +30,9 @@ public void setId(Long id) { this.id = id; } - public Long getUserId() { return userId; } - - public void setUserId(Long userId) { this.userId = userId; } +// public Long getUserId() { return userId; } +// +// public void setUserId(Long userId) { this.userId = userId; } public String getUsername() { return username; diff --git a/src/main/java/runner/entities/Transaction.java b/src/main/java/runner/entities/Transaction.java new file mode 100644 index 000000000..e409af53a --- /dev/null +++ b/src/main/java/runner/entities/Transaction.java @@ -0,0 +1,62 @@ +package runner.entities; + +import javax.persistence.*; +import java.time.LocalDate; +@Entity +public class Transaction { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + @Column(nullable = false) + private String accountNumber; + @Column(nullable = false) + private String transactionDescription; + @Column(nullable = false) + private Double transactionBalance; + @Column(nullable = false) + private LocalDate transactionDate; + + @ManyToOne + @JoinColumn(name = "AccountId", nullable = false) + private Account account; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getAccountNumber() { + return accountNumber; + } + + public void setAccountNumber(String accountNumber) { + this.accountNumber = accountNumber; + } + + public String getTransactionDescription() { + return transactionDescription; + } + + public void setTransactionDescription(String transactionDescription) { + this.transactionDescription = transactionDescription; + } + + public Double getTransactionBalance() { + return transactionBalance; + } + + public void setTransactionBalance(Double transactionBalance) { + this.transactionBalance = transactionBalance; + } + + public LocalDate getTransactionDate() { + return transactionDate; + } + + public void setTransactionDate(LocalDate transactionDate) { + this.transactionDate = transactionDate; + } +} diff --git a/src/main/java/runner/entities/TransactionHistory.java b/src/main/java/runner/entities/TransactionHistory.java deleted file mode 100644 index 1f4eb0f67..000000000 --- a/src/main/java/runner/entities/TransactionHistory.java +++ /dev/null @@ -1,19 +0,0 @@ -package runner.entities; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import java.time.LocalDate; -@Entity -public class TransactionHistory { - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - private String accountNumber; - private String transactionType; - private Double balanceAfterTransaction; - private LocalDate dateOfTransaction; - - -} diff --git a/src/main/java/runner/entities/User.java b/src/main/java/runner/entities/User.java index c0f40922c..254eed377 100644 --- a/src/main/java/runner/entities/User.java +++ b/src/main/java/runner/entities/User.java @@ -1,9 +1,12 @@ package runner.entities; +import com.fasterxml.jackson.annotation.JsonBackReference; + import javax.persistence.*; import java.time.LocalDate; import java.util.ArrayList; import java.util.List; +import java.util.Set; import static javax.persistence.CascadeType.ALL; @@ -12,36 +15,73 @@ public class User { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; - @Column(name = "firstname") + @Column(nullable = false) private String firstName; - @Column(name = "lastname") + private String middleName; + @Column(nullable = false) private String lastName; - private LocalDate dateofbirth; - @Column(name ="socialsecurity") + //@Column(nullable = false) + private LocalDate dateOfBirth; + @Column(nullable = false) private String socialSecurity; - private String address; + @Column(nullable = false) + private String email; + @Column(nullable = false) + private String phoneNumber; + + @OneToOne(mappedBy = "user", cascade = CascadeType.ALL) + @PrimaryKeyJoinColumn //sharing primary key with address since creating a new user requires address anyways + private Address address; + + @OneToOne(mappedBy = "user", cascade = CascadeType.ALL) + @PrimaryKeyJoinColumn //sharing primary key with user login since creating a new user requires a login anyways + private Login login; - @OneToMany(cascade=ALL,fetch=FetchType.EAGER,mappedBy = "user" ) - //@JoinColumn(name="Id",referencedColumnName = "Id") - private List accounts = new ArrayList<>(); + //@JsonManagedReference + @OneToMany(mappedBy = "user",cascade= CascadeType.ALL, fetch=FetchType.EAGER) + private Set accounts; + +// @JsonBackReference +// @OneToMany(cascade=ALL,fetch=FetchType.EAGER, mappedBy = "user") +// private List accounts = new ArrayList<>(); public User() { } +// public List getAccounts() { +// return accounts; +// } +// +// public void setAccounts(List accounts) { +// this.accounts = accounts; +// } + + public Set getAccounts() { + return accounts; + } + + public void setAccounts(Set accounts) { + this.accounts = accounts; + } + public Long getId() { return id; } - public void setId(Long id) { this.id = id; } - public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } + public String getMiddleName() { + return middleName; + } + public void setMiddleName(String middleName) { + this.middleName = middleName; + } public String getLastName() { return lastName; } @@ -49,10 +89,10 @@ public void setLastName(String lastName) { this.lastName = lastName; } public LocalDate getDateOfBirth() { - return dateofbirth; + return dateOfBirth; } public void setDateOfBirth(LocalDate dateOfBirth) { - this.dateofbirth = dateofbirth; + this.dateOfBirth = this.dateOfBirth; } public String getSocialSecurity() { return socialSecurity; @@ -60,10 +100,32 @@ public String getSocialSecurity() { public void setSocialSecurity(String socialSecurity) { this.socialSecurity = socialSecurity; } - public String getAddress() { + public String getEmail() { + return email; + } + public void setEmail(String address) { + this.email = address; + } + public String getPhoneNumber() { + return phoneNumber; + } + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + public Address getAddress() { return address; } - public void setAddress(String address) { + + public void setAddress(Address address) { this.address = address; } + + public Login getLogin() { + return login; + } + + public void setLogin(Login login) { + this.login = login; + } + } \ No newline at end of file diff --git a/src/main/java/runner/repositories/TransactionRepo.java b/src/main/java/runner/repositories/TransactionRepo.java index 18a975d5c..a42771c36 100644 --- a/src/main/java/runner/repositories/TransactionRepo.java +++ b/src/main/java/runner/repositories/TransactionRepo.java @@ -1,11 +1,11 @@ package runner.repositories; -import runner.entities.TransactionHistory; +import runner.entities.Transaction; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; @Repository -public interface TransactionRepo extends CrudRepository { +public interface TransactionRepo extends CrudRepository { } diff --git a/src/main/java/runner/services/AccountServices.java b/src/main/java/runner/services/AccountServices.java index 194267896..0ca0aeb52 100644 --- a/src/main/java/runner/services/AccountServices.java +++ b/src/main/java/runner/services/AccountServices.java @@ -1,42 +1,43 @@ package runner.services; - import runner.entities.Account; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import runner.entities.User; import runner.repositories.AccountRepo; - import java.util.Optional; - @Service public class AccountServices { - @Autowired private AccountRepo accountRepo; //CRUD methods - public Account createAccount(Account account) { //Re-direct to POST in ACCOUNT controller return accountRepo.save(account); } - public Account readAccount(Long id) { //Re-direct to GET in ACCOUNT controller return accountRepo.findAccountById(id); } - public Boolean removeAccount() + public Boolean removeAccount(Long id) { - //Re-direct to DELETE in ACCOUNT controller - return true; + Account accountFromDB = accountRepo.findAccountById(id); + accountRepo.delete(accountFromDB); + return accountRepo.existsById(id); } - - public Optional updateAccount() + public Optional updateAccount(Long id , Account account) { - //Re-direct to PUT in ACCOUNT controller - return null; + Account accountFromDB = accountRepo.findAccountById(id); + accountFromDB.setAccountType(account.getAccountType()); + accountFromDB.setAccountNumber(account.getAccountNumber()); + accountFromDB.setInterestRate(account.getInterestRate()); + accountFromDB.setDateOfOpening(account.getDateOfOpening()); + accountFromDB.setRoutingNumber(account.getRoutingNumber()); + accountFromDB.setBalance(account.getBalance()); + accountFromDB.setUser(account.getUser()); + return Optional.of(accountFromDB); } - public Double withdraw(Double amount, Long Id) { //Login to withdraw from the account @@ -47,12 +48,9 @@ public Double deposit(Double amount , Long Id) //Login to withdraw from the account return 0d; } - - public Double transfer(Double amount , Long fromId ,Long toId) { //Login to withdraw from the account return 0d; } - -} +} \ No newline at end of file diff --git a/src/main/java/runner/services/TransactionServices.java b/src/main/java/runner/services/TransactionServices.java index 6b6e63da0..2e3a6bf68 100644 --- a/src/main/java/runner/services/TransactionServices.java +++ b/src/main/java/runner/services/TransactionServices.java @@ -1,6 +1,6 @@ package runner.services; -import runner.entities.TransactionHistory; +import runner.entities.Transaction; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import runner.repositories.TransactionRepo; @@ -11,13 +11,13 @@ public class TransactionServices { @Autowired private TransactionRepo transactionRepo; //CRUD methods - public Optional createTransaction() + public Optional createTransaction() { //Re-direct to POST in TransactionHistory controller return null; } - public Optional readTransaction() + public Optional readTransaction() { //Re-direct to GET in TransactionHistory controller return null; @@ -28,7 +28,7 @@ public Boolean removeTransaction() return true; } - public Optional updateTransaction() + public Optional updateTransaction() { //Re-direct to PUT in TransactionHistory controller return null; diff --git a/src/main/java/runner/services/UserServices.java b/src/main/java/runner/services/UserServices.java index a70dc4cdb..23824afdf 100644 --- a/src/main/java/runner/services/UserServices.java +++ b/src/main/java/runner/services/UserServices.java @@ -1,39 +1,38 @@ package runner.services; - import runner.entities.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import runner.repositories.UserRepo; - import java.util.Optional; - @Service public class UserServices { //CRUD methods @Autowired private UserRepo userRepo; - - public Optional createUser(User user) + public User createUser(User user) { - //Re-direct to POST in USER controller - return null; + return (User) userRepo.save(user); } - public User readUser(Long id) { - //Re-direct to GET in USER controller return userRepo.findUserById(id); } public Boolean deleteUser(Long id) { - //Re-direct to DELETE in USER controller - return true; + User userFromDB = userRepo.findUserById(id); + userRepo.delete(userFromDB); + return userRepo.existsById(id); } - public Optional updateUser(Long id ,User user) + public User updateUser(Long id ,User user) { - //Re-direct to PUT in USER controller - return null; + User userFromDB = userRepo.findUserById(id); + userFromDB.setFirstName(user.getFirstName()); + userFromDB.setLastName(user.getLastName()); + userFromDB.setDateOfBirth(user.getDateOfBirth()); + userFromDB.setSocialSecurity(user.getSocialSecurity()); + userFromDB.setAddress(user.getAddress()); + userFromDB.setAccounts(user.getAccounts()); + return userFromDB; } - -} +} \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index c91a0a0d7..a5e3d5703 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,4 +1,3 @@ -spring.jpa.show-sql=true server.port=8080 spring.h2.console.enabled=true #spring.datasource.generate-unique-name=false @@ -8,13 +7,28 @@ spring.h2.console.enabled=true #spring.jpa.database-platform=org.hibernate.dialect.H2Dialect #spring.h2.console.settings.trace=false #spring.h2.console.settings.web-allow-others=false + spring.datasource.url=jdbc:mysql://localhost:3306/moneymanagement spring.datasource.username=newuser spring.datasource.password=password + spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver ### had to add this because of the .hibernate_sequence doesn't exist errors! spring.jpa.hibernate.use-new-id-generator-mappings= false -spring.jpa.hibernate.ddl-auto = create + +#set to 'none' to .ddl-auto if you want to create mysql tables from "schema.sql" files instead of from entities +spring.jpa.hibernate.ddl-auto = create-drop spring.jpa.generate-ddl=true -#spring.jpa.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect -#spring.jpa.hibernate.naming_strategy = org.hibernate.cfg.ImprovedNamingStrategy \ No newline at end of file +spring.jpa.show-sql=true +#tells hibernate where to find initial data to import into mysql if .ddl-auto method is used +spring.jpa.properties.hibernate.hbm2ddl.import_files= classpath:db/import.sql +#below is needed for JPA to read SQL language from import.sql +spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect +#spring.jpa.hibernate.naming_strategy = org.hibernate.cfg.ImprovedNamingStrategy + +#set to 'always' if you want to create mysql tables from "schema.sql" file instead of from entities +spring.datasource.initialization-mode=never + +#tells hibernate where to find the data and schema file +spring.datasource.data= classpath:db/data.sql +spring.datasource.schema = classpath:db/schema.sql diff --git a/src/main/resources/db/data.sql b/src/main/resources/db/data.sql new file mode 100644 index 000000000..dd409b410 --- /dev/null +++ b/src/main/resources/db/data.sql @@ -0,0 +1,46 @@ +-- MySQL dump 10.13 Distrib 8.0.22, for macos10.15 (x86_64) +-- +-- Host: localhost Database: moneymanagement +-- ------------------------------------------------------ +-- Server version 8.0.22 + +-- +-- Dumping data for table `account` +-- + +LOCK TABLES `account` WRITE; +/*!40000 ALTER TABLE `account` DISABLE KEYS */; +INSERT INTO `account` VALUES (1,'1245451','INVESTMENT',500000.22,'2004-01-22',12.5,'2001445',1); +/*!40000 ALTER TABLE `account` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `login` +-- + +# LOCK TABLES `login` WRITE; +# /*!40000 ALTER TABLE `login` DISABLE KEYS */; +# INSERT INTO `login` VALUES (1,'c51ChDMn',1,'lmcqueen0'),(2,'9Gi1RGOg',2,'mpentecost1'),(3,'fyMzNy7n8A8t',3,'amills2'),(4,'q0NbGZf',4,'bculross3'),(5,'yLQvlpxXIuNe',5,'gbloss4'),(6,'eQANN59g7',6,'mnolli5'),(7,'4vKaSDaX4K',7,'bdefau6'),(8,'7sBfdC',8,'svanyashin7'),(9,'eTS542J8XdVI',9,'bchavez8'),(10,'2cWHHxth',10,'dquig9'),(11,'GxSxDH',11,'bhercocka'),(12,'RZh8GTIgBE',12,'cfownesb'),(13,'QekocrR',13,'jboamc'),(14,'821sff3S6whi',14,'amckeggied'),(15,'yf9AAFSCz',15,'cswansburye'),(16,'Jf2UhD6N',16,'shanmerf'),(17,'1gBv9SwWynK',17,'tscutching'),(18,'4YUf6yym0k8F',18,'jskirvinh'),(19,'vwUorIBbE',19,'wpretoi'),(20,'AphCxH2MIgq',20,'bpargetterj'),(21,'6ttHlsQoigO',21,'dudenk'),(22,'GzazmP0TMu',22,'bpantherl'),(23,'fPWjg5e',23,'scoronasm'),(24,'H4TNZ5yA9',24,'cmcgurgann'),(25,'ZTZvoWjo',25,'mdirando'); +# /*!40000 ALTER TABLE `login` ENABLE KEYS */; +# UNLOCK TABLES; + +-- +-- Dumping data for table `transaction_history` +-- + +# LOCK TABLES `transaction_history` WRITE; +# /*!40000 ALTER TABLE `transaction_history` DISABLE KEYS */; +# /*!40000 ALTER TABLE `transaction_history` ENABLE KEYS */; +# UNLOCK TABLES; + + +-- +-- Dumping data for table `user` +-- + +# LOCK TABLES `user` WRITE; +# /*!40000 ALTER TABLE `user` DISABLE KEYS */; +# INSERT INTO `user` VALUES (1,'48 Haas Street','2001-04-11','Antoine','Oakinfold','112-555-545'),(2,'77756 Cascade Circle','1986-04-07','Yanaton','Sikorski','125-784-457'),(3,'8 Quincy Place','1988-05-14','Warde','Tilburn','154-784-541'),(4,'77413 Milwaukee Crossing','2002-04-14','Dario','Purches','451-457-581'),(5,'4173 Arapahoe Parkway','1993-05-27','Tobi','Balfre','451-874-542'),(6,'1 Village Green Avenue','1993-09-15','Lexine','Shelliday','125-784-541'),(7,'9893 Vidon Way','1978-11-09','Morey','Vela','487-458-987'),(8,'9337 Erie Park','2001-05-25','Noella','Skein','451-784-541'),(9,'9 Towne Alley','1986-08-07','Isaac','Marskell','154-784-451'),(10,'9967 Hovde Parkway','1983-07-17','Kerwin','Franckton','154-784-451'),(11,'97169 Beilfuss Pass','1988-05-31','Almeda','Lumbers','125-457-845'),(12,'6 Mayfield Point','1990-03-09','Maude','Dunn','125-487-458'),(13,'46 Anthes Road','1979-10-01','Deni','Shermore','124-784-458'),(14,'4 Sloan Avenue','2002-01-11','Jobi','Ellick','451-458-457'),(15,'163 Lake View Circle','2004-08-22','Wallie','Leyrroyd','457-548-552'),(16,'2796 Kipling Place','1981-04-20','Augustine','Shermore','154-578-945'),(17,'4 Almo Avenue','1999-09-01','Ward','Rummins','547-854-999'),(18,'5 Mcbride Parkway','1985-11-10','Gar','Duddridge','451-457-845'),(19,'39 Bultman Hill','2001-09-26','Sosanna','MacGarvey','111-245-784'),(20,'638 Shasta Terrace','1980-08-18','Greta','Cheales','4512-457-451'),(21,'17646 Sundown Avenue','2003-05-08','Reilly','McIlwreath','245-445-444'),(22,'9 Oak Valley Drive','1995-02-27','Dona','Hancke','457-445-444'),(23,'7 Debs Plaza','1986-06-05','Georgette','Marusyak','457-444-999'),(24,'87489 Dunning Junction','1991-06-06','Dasi','Allso','451-451-444'),(25,'22 Everett Way','1995-06-20','Di','Izkovitz','987-444-111'); +# /*!40000 ALTER TABLE `user` ENABLE KEYS */; +# UNLOCK TABLES; +# /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; \ No newline at end of file diff --git a/src/main/resources/db/import.sql b/src/main/resources/db/import.sql new file mode 100644 index 000000000..a4a43c5a2 --- /dev/null +++ b/src/main/resources/db/import.sql @@ -0,0 +1,37 @@ +-- MySQL dump 10.13 Distrib 8.0.22, for macos10.15 (x86_64) +-- +-- Host: localhost Database: moneymanagement +-- ------------------------------------------------------ +-- Server version 8.0.22 + +-- +-- Dumping data for table `account` +-- + +INSERT INTO `account` VALUES (1,'1245451','INVESTMENT',500000.22,'2004-01-22',12.5,'2001445',1); + +-- +-- Dumping data for table `login` +-- + +INSERT INTO `login` VALUES (1,'c51ChDMn','lmcqueen0'),(2,'9Gi1RGOg','mpentecost1'); + +-- +-- Dumping data for table `transaction_history` +-- + +INSERT INTO `transaction` VALUES (1,'1245451',10.21,'2004-01-22','testing',1); + +-- +-- Dumping data for table `user` +-- + +INSERT INTO `user` VALUES (1,'2001-04-11','test@gmail.com','Antoine','Oakinfold',Null,'215-226-4008','112555545'); + +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +-- +-- Dumping data for table `address` +-- + +INSERT INTO `address` VALUES (1,'Philadelphia','123 A st',NULL,'Pennsylvania','19147'); diff --git a/src/main/resources/db/schema.sql b/src/main/resources/db/schema.sql new file mode 100644 index 000000000..dd36fc9fc --- /dev/null +++ b/src/main/resources/db/schema.sql @@ -0,0 +1,122 @@ +-- MySQL dump 10.13 Distrib 8.0.22, for macos10.15 (x86_64) +-- +-- Host: localhost Database: moneymanagement +-- ------------------------------------------------------ +-- Server version 8.0.22 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!50503 SET NAMES utf8mb4 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `account` +-- + +DROP TABLE IF EXISTS `account`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `account` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `userId` bigint NOT NULL, + `accountNumber` varchar(255) NOT NULL, + `routingNumber` varchar(255) NOT NULL, + `accountType` varchar(255) NOT NULL, + `createdDate` date NOT NULL, + `interestRate` double NOT NULL, + `balance` double NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `login` +-- + +DROP TABLE IF EXISTS `login`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `login` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `userId` bigint NOT NULL, + `username` varchar(255) NOT NULL, + `password` varchar(255) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + + +-- +-- Table structure for table `transaction_history` +-- + +DROP TABLE IF EXISTS `transaction_history`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `transaction_history` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `accountNumber` varchar(255) NOT NULL, + `dateOfTransaction` date NOT NULL, + `description` varchar(255) NOT NULL, + `transactionAmount` varchar(255) NOT NULL, + `balance` double NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + + +-- +-- Table structure for table `user` +-- + +DROP TABLE IF EXISTS `user`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `user` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `firstName` varchar(255) NOT NULL, + `middleName` varchar(255) DEFAULT NULL, + `lastName` varchar(255) NOT NULL, + `dob` date NOT NULL, + `ssn` varchar(255) NOT NULL, + `email` varchar(255) DEFAULT NULL, + `phoneNumber` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `address` +-- + +DROP TABLE IF EXISTS `address`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `user` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `userId` bigint NOT NULL, + `firstLine` date NOT NULL, + `secondLine` varchar(255) NOT NULL, + `city` varchar(255) DEFAULT NULL, + `state` varchar(255) NOT NULL, + `zipcode` varchar(255) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2020-12-20 13:18:02 diff --git a/target/classes/application.properties b/target/classes/application.properties index b2b2310a9..a5e3d5703 100644 --- a/target/classes/application.properties +++ b/target/classes/application.properties @@ -1,4 +1,3 @@ -spring.jpa.show-sql=true server.port=8080 spring.h2.console.enabled=true #spring.datasource.generate-unique-name=false @@ -8,13 +7,28 @@ spring.h2.console.enabled=true #spring.jpa.database-platform=org.hibernate.dialect.H2Dialect #spring.h2.console.settings.trace=false #spring.h2.console.settings.web-allow-others=false + spring.datasource.url=jdbc:mysql://localhost:3306/moneymanagement -spring.datasource.username=root -spring.datasource.password=zipcode0 +spring.datasource.username=newuser +spring.datasource.password=password + spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver ### had to add this because of the .hibernate_sequence doesn't exist errors! spring.jpa.hibernate.use-new-id-generator-mappings= false -spring.jpa.hibernate.ddl-auto = create + +#set to 'none' to .ddl-auto if you want to create mysql tables from "schema.sql" files instead of from entities +spring.jpa.hibernate.ddl-auto = create-drop spring.jpa.generate-ddl=true -#spring.jpa.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect -#spring.jpa.hibernate.naming_strategy = org.hibernate.cfg.ImprovedNamingStrategy \ No newline at end of file +spring.jpa.show-sql=true +#tells hibernate where to find initial data to import into mysql if .ddl-auto method is used +spring.jpa.properties.hibernate.hbm2ddl.import_files= classpath:db/import.sql +#below is needed for JPA to read SQL language from import.sql +spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect +#spring.jpa.hibernate.naming_strategy = org.hibernate.cfg.ImprovedNamingStrategy + +#set to 'always' if you want to create mysql tables from "schema.sql" file instead of from entities +spring.datasource.initialization-mode=never + +#tells hibernate where to find the data and schema file +spring.datasource.data= classpath:db/data.sql +spring.datasource.schema = classpath:db/schema.sql diff --git a/target/classes/db/data.sql b/target/classes/db/data.sql new file mode 100644 index 000000000..dd409b410 --- /dev/null +++ b/target/classes/db/data.sql @@ -0,0 +1,46 @@ +-- MySQL dump 10.13 Distrib 8.0.22, for macos10.15 (x86_64) +-- +-- Host: localhost Database: moneymanagement +-- ------------------------------------------------------ +-- Server version 8.0.22 + +-- +-- Dumping data for table `account` +-- + +LOCK TABLES `account` WRITE; +/*!40000 ALTER TABLE `account` DISABLE KEYS */; +INSERT INTO `account` VALUES (1,'1245451','INVESTMENT',500000.22,'2004-01-22',12.5,'2001445',1); +/*!40000 ALTER TABLE `account` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `login` +-- + +# LOCK TABLES `login` WRITE; +# /*!40000 ALTER TABLE `login` DISABLE KEYS */; +# INSERT INTO `login` VALUES (1,'c51ChDMn',1,'lmcqueen0'),(2,'9Gi1RGOg',2,'mpentecost1'),(3,'fyMzNy7n8A8t',3,'amills2'),(4,'q0NbGZf',4,'bculross3'),(5,'yLQvlpxXIuNe',5,'gbloss4'),(6,'eQANN59g7',6,'mnolli5'),(7,'4vKaSDaX4K',7,'bdefau6'),(8,'7sBfdC',8,'svanyashin7'),(9,'eTS542J8XdVI',9,'bchavez8'),(10,'2cWHHxth',10,'dquig9'),(11,'GxSxDH',11,'bhercocka'),(12,'RZh8GTIgBE',12,'cfownesb'),(13,'QekocrR',13,'jboamc'),(14,'821sff3S6whi',14,'amckeggied'),(15,'yf9AAFSCz',15,'cswansburye'),(16,'Jf2UhD6N',16,'shanmerf'),(17,'1gBv9SwWynK',17,'tscutching'),(18,'4YUf6yym0k8F',18,'jskirvinh'),(19,'vwUorIBbE',19,'wpretoi'),(20,'AphCxH2MIgq',20,'bpargetterj'),(21,'6ttHlsQoigO',21,'dudenk'),(22,'GzazmP0TMu',22,'bpantherl'),(23,'fPWjg5e',23,'scoronasm'),(24,'H4TNZ5yA9',24,'cmcgurgann'),(25,'ZTZvoWjo',25,'mdirando'); +# /*!40000 ALTER TABLE `login` ENABLE KEYS */; +# UNLOCK TABLES; + +-- +-- Dumping data for table `transaction_history` +-- + +# LOCK TABLES `transaction_history` WRITE; +# /*!40000 ALTER TABLE `transaction_history` DISABLE KEYS */; +# /*!40000 ALTER TABLE `transaction_history` ENABLE KEYS */; +# UNLOCK TABLES; + + +-- +-- Dumping data for table `user` +-- + +# LOCK TABLES `user` WRITE; +# /*!40000 ALTER TABLE `user` DISABLE KEYS */; +# INSERT INTO `user` VALUES (1,'48 Haas Street','2001-04-11','Antoine','Oakinfold','112-555-545'),(2,'77756 Cascade Circle','1986-04-07','Yanaton','Sikorski','125-784-457'),(3,'8 Quincy Place','1988-05-14','Warde','Tilburn','154-784-541'),(4,'77413 Milwaukee Crossing','2002-04-14','Dario','Purches','451-457-581'),(5,'4173 Arapahoe Parkway','1993-05-27','Tobi','Balfre','451-874-542'),(6,'1 Village Green Avenue','1993-09-15','Lexine','Shelliday','125-784-541'),(7,'9893 Vidon Way','1978-11-09','Morey','Vela','487-458-987'),(8,'9337 Erie Park','2001-05-25','Noella','Skein','451-784-541'),(9,'9 Towne Alley','1986-08-07','Isaac','Marskell','154-784-451'),(10,'9967 Hovde Parkway','1983-07-17','Kerwin','Franckton','154-784-451'),(11,'97169 Beilfuss Pass','1988-05-31','Almeda','Lumbers','125-457-845'),(12,'6 Mayfield Point','1990-03-09','Maude','Dunn','125-487-458'),(13,'46 Anthes Road','1979-10-01','Deni','Shermore','124-784-458'),(14,'4 Sloan Avenue','2002-01-11','Jobi','Ellick','451-458-457'),(15,'163 Lake View Circle','2004-08-22','Wallie','Leyrroyd','457-548-552'),(16,'2796 Kipling Place','1981-04-20','Augustine','Shermore','154-578-945'),(17,'4 Almo Avenue','1999-09-01','Ward','Rummins','547-854-999'),(18,'5 Mcbride Parkway','1985-11-10','Gar','Duddridge','451-457-845'),(19,'39 Bultman Hill','2001-09-26','Sosanna','MacGarvey','111-245-784'),(20,'638 Shasta Terrace','1980-08-18','Greta','Cheales','4512-457-451'),(21,'17646 Sundown Avenue','2003-05-08','Reilly','McIlwreath','245-445-444'),(22,'9 Oak Valley Drive','1995-02-27','Dona','Hancke','457-445-444'),(23,'7 Debs Plaza','1986-06-05','Georgette','Marusyak','457-444-999'),(24,'87489 Dunning Junction','1991-06-06','Dasi','Allso','451-451-444'),(25,'22 Everett Way','1995-06-20','Di','Izkovitz','987-444-111'); +# /*!40000 ALTER TABLE `user` ENABLE KEYS */; +# UNLOCK TABLES; +# /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; \ No newline at end of file diff --git a/target/classes/db/import.sql b/target/classes/db/import.sql new file mode 100644 index 000000000..a4a43c5a2 --- /dev/null +++ b/target/classes/db/import.sql @@ -0,0 +1,37 @@ +-- MySQL dump 10.13 Distrib 8.0.22, for macos10.15 (x86_64) +-- +-- Host: localhost Database: moneymanagement +-- ------------------------------------------------------ +-- Server version 8.0.22 + +-- +-- Dumping data for table `account` +-- + +INSERT INTO `account` VALUES (1,'1245451','INVESTMENT',500000.22,'2004-01-22',12.5,'2001445',1); + +-- +-- Dumping data for table `login` +-- + +INSERT INTO `login` VALUES (1,'c51ChDMn','lmcqueen0'),(2,'9Gi1RGOg','mpentecost1'); + +-- +-- Dumping data for table `transaction_history` +-- + +INSERT INTO `transaction` VALUES (1,'1245451',10.21,'2004-01-22','testing',1); + +-- +-- Dumping data for table `user` +-- + +INSERT INTO `user` VALUES (1,'2001-04-11','test@gmail.com','Antoine','Oakinfold',Null,'215-226-4008','112555545'); + +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +-- +-- Dumping data for table `address` +-- + +INSERT INTO `address` VALUES (1,'Philadelphia','123 A st',NULL,'Pennsylvania','19147'); diff --git a/target/classes/db/schema.sql b/target/classes/db/schema.sql new file mode 100644 index 000000000..dd36fc9fc --- /dev/null +++ b/target/classes/db/schema.sql @@ -0,0 +1,122 @@ +-- MySQL dump 10.13 Distrib 8.0.22, for macos10.15 (x86_64) +-- +-- Host: localhost Database: moneymanagement +-- ------------------------------------------------------ +-- Server version 8.0.22 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!50503 SET NAMES utf8mb4 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `account` +-- + +DROP TABLE IF EXISTS `account`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `account` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `userId` bigint NOT NULL, + `accountNumber` varchar(255) NOT NULL, + `routingNumber` varchar(255) NOT NULL, + `accountType` varchar(255) NOT NULL, + `createdDate` date NOT NULL, + `interestRate` double NOT NULL, + `balance` double NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `login` +-- + +DROP TABLE IF EXISTS `login`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `login` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `userId` bigint NOT NULL, + `username` varchar(255) NOT NULL, + `password` varchar(255) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + + +-- +-- Table structure for table `transaction_history` +-- + +DROP TABLE IF EXISTS `transaction_history`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `transaction_history` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `accountNumber` varchar(255) NOT NULL, + `dateOfTransaction` date NOT NULL, + `description` varchar(255) NOT NULL, + `transactionAmount` varchar(255) NOT NULL, + `balance` double NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + + +-- +-- Table structure for table `user` +-- + +DROP TABLE IF EXISTS `user`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `user` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `firstName` varchar(255) NOT NULL, + `middleName` varchar(255) DEFAULT NULL, + `lastName` varchar(255) NOT NULL, + `dob` date NOT NULL, + `ssn` varchar(255) NOT NULL, + `email` varchar(255) DEFAULT NULL, + `phoneNumber` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `address` +-- + +DROP TABLE IF EXISTS `address`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `user` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `userId` bigint NOT NULL, + `firstLine` date NOT NULL, + `secondLine` varchar(255) NOT NULL, + `city` varchar(255) DEFAULT NULL, + `state` varchar(255) NOT NULL, + `zipcode` varchar(255) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2020-12-20 13:18:02 diff --git a/target/classes/runner/controllers/AccountController.class b/target/classes/runner/controllers/AccountController.class index 6e92dccfc..dda2b5f65 100644 Binary files a/target/classes/runner/controllers/AccountController.class and b/target/classes/runner/controllers/AccountController.class differ diff --git a/target/classes/runner/controllers/UserController.class b/target/classes/runner/controllers/UserController.class index e47d70284..84fabb8dc 100644 Binary files a/target/classes/runner/controllers/UserController.class and b/target/classes/runner/controllers/UserController.class differ diff --git a/target/classes/runner/entities/Account.class b/target/classes/runner/entities/Account.class index ded2e246c..288310b5d 100644 Binary files a/target/classes/runner/entities/Account.class and b/target/classes/runner/entities/Account.class differ diff --git a/target/classes/runner/entities/Address.class b/target/classes/runner/entities/Address.class new file mode 100644 index 000000000..a4a798b8c Binary files /dev/null and b/target/classes/runner/entities/Address.class differ diff --git a/target/classes/runner/entities/Checking.class b/target/classes/runner/entities/Checking.class new file mode 100644 index 000000000..ba06d6336 Binary files /dev/null and b/target/classes/runner/entities/Checking.class differ diff --git a/target/classes/runner/entities/Checkings.class b/target/classes/runner/entities/Checkings.class deleted file mode 100644 index 395a5135e..000000000 Binary files a/target/classes/runner/entities/Checkings.class and /dev/null differ diff --git a/target/classes/runner/entities/Investment.class b/target/classes/runner/entities/Investment.class new file mode 100644 index 000000000..53e0d1e57 Binary files /dev/null and b/target/classes/runner/entities/Investment.class differ diff --git a/target/classes/runner/entities/Investments.class b/target/classes/runner/entities/Investments.class deleted file mode 100644 index 188122fc8..000000000 Binary files a/target/classes/runner/entities/Investments.class and /dev/null differ diff --git a/target/classes/runner/entities/Login.class b/target/classes/runner/entities/Login.class index 0052813af..f276e7fc6 100644 Binary files a/target/classes/runner/entities/Login.class and b/target/classes/runner/entities/Login.class differ diff --git a/target/classes/runner/entities/Transaction.class b/target/classes/runner/entities/Transaction.class new file mode 100644 index 000000000..65103ec76 Binary files /dev/null and b/target/classes/runner/entities/Transaction.class differ diff --git a/target/classes/runner/entities/TransactionHistory.class b/target/classes/runner/entities/TransactionHistory.class deleted file mode 100644 index 7c60ffed5..000000000 Binary files a/target/classes/runner/entities/TransactionHistory.class and /dev/null differ diff --git a/target/classes/runner/entities/User.class b/target/classes/runner/entities/User.class index 432e3415c..6e7ae75cd 100644 Binary files a/target/classes/runner/entities/User.class and b/target/classes/runner/entities/User.class differ diff --git a/target/classes/runner/repositories/TransactionRepo.class b/target/classes/runner/repositories/TransactionRepo.class index e91e67380..db217d53f 100644 Binary files a/target/classes/runner/repositories/TransactionRepo.class and b/target/classes/runner/repositories/TransactionRepo.class differ diff --git a/target/classes/runner/services/AccountServices.class b/target/classes/runner/services/AccountServices.class index 3bbf3fbfd..8343a2767 100644 Binary files a/target/classes/runner/services/AccountServices.class and b/target/classes/runner/services/AccountServices.class differ diff --git a/target/classes/runner/services/TransactionServices.class b/target/classes/runner/services/TransactionServices.class index 1b31769c1..8ce6bd080 100644 Binary files a/target/classes/runner/services/TransactionServices.class and b/target/classes/runner/services/TransactionServices.class differ diff --git a/target/classes/runner/services/UserServices.class b/target/classes/runner/services/UserServices.class index 9f44790bc..1f3281bff 100644 Binary files a/target/classes/runner/services/UserServices.class and b/target/classes/runner/services/UserServices.class differ