Merge branch 'master' of https://github.com/lumijiez/ExpenseTrackerFAF into daniel
# Conflicts: # src/main/java/com/faf223/expensetrackerfaf/controllers/MainController.java # src/main/resources/application.properties
This commit is contained in:
12
pom.xml
12
pom.xml
@@ -36,6 +36,18 @@
|
||||
<scope>test</scope>
|
||||
<version>3.1.2</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
<version>3.1.3</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc -->
|
||||
<dependency>
|
||||
<groupId>com.microsoft.sqlserver</groupId>
|
||||
<artifactId>mssql-jdbc</artifactId>
|
||||
<version>12.4.1.jre11</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
33
src/main/java/entities/Categories.java
Normal file
33
src/main/java/entities/Categories.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package entities;
|
||||
|
||||
public class Categories {
|
||||
|
||||
public enum ExpenseCategory {
|
||||
CREDIT, BUY, BUSINESS, ENTERTAINMENT, RESTAURANTS_AND_CAFE, COMMUNAL_PAYMENTS, SUPERMARKET, MISC;
|
||||
|
||||
public String getEffectiveName() {
|
||||
return Categories.getEffectiveName(this.name());
|
||||
}
|
||||
}
|
||||
|
||||
public enum IncomeCategory {
|
||||
P2P, SALARY, GIFT, CREDIT, MISC;
|
||||
|
||||
public String getEffectiveName() {
|
||||
return Categories.getEffectiveName(this.name());
|
||||
}
|
||||
}
|
||||
|
||||
private static String getEffectiveName(String name) {
|
||||
String[] arr = name.split("_");
|
||||
StringBuilder result = new StringBuilder();
|
||||
for(String entry : arr) {
|
||||
String[] entryArr = entry.split("");
|
||||
StringBuilder builder = new StringBuilder(entryArr[0]);
|
||||
for(int i = 1; i < entry.length(); i++) builder.append(entryArr[i].toLowerCase());
|
||||
result.append(builder).append(" ");
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
}
|
||||
41
src/main/java/entities/Expense.java
Normal file
41
src/main/java/entities/Expense.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package entities;
|
||||
|
||||
public class Expense implements IMoneyTransaction {
|
||||
|
||||
private int userId;
|
||||
private int amount;
|
||||
private Categories.ExpenseCategory category;
|
||||
|
||||
public Expense(int userId, int amount, Categories.ExpenseCategory category) {
|
||||
this.userId = userId;
|
||||
this.amount = amount;
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(int amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCategory() {
|
||||
return category.getEffectiveName();
|
||||
}
|
||||
|
||||
public void setCategory(Categories.ExpenseCategory category) {
|
||||
this.category = category;
|
||||
}
|
||||
}
|
||||
9
src/main/java/entities/IMoneyTransaction.java
Normal file
9
src/main/java/entities/IMoneyTransaction.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package entities;
|
||||
|
||||
public interface IMoneyTransaction {
|
||||
|
||||
long getUserId();
|
||||
int getAmount();
|
||||
String getCategory();
|
||||
|
||||
}
|
||||
41
src/main/java/entities/Income.java
Normal file
41
src/main/java/entities/Income.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package entities;
|
||||
|
||||
public class Income implements IMoneyTransaction {
|
||||
|
||||
private long userId;
|
||||
private int amount;
|
||||
private Categories.IncomeCategory category;
|
||||
|
||||
public Income(long userId, int amount, Categories.IncomeCategory category) {
|
||||
this.userId = userId;
|
||||
this.amount = amount;
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCategory() {
|
||||
return category.getEffectiveName();
|
||||
}
|
||||
|
||||
public void setUserId(long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public void setAmount(int amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public void setCategory(Categories.IncomeCategory category) {
|
||||
this.category = category;
|
||||
}
|
||||
}
|
||||
7
src/main/java/entities/Role.java
Normal file
7
src/main/java/entities/Role.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package entities;
|
||||
|
||||
public enum Role {
|
||||
|
||||
UNREGISTERED, REGISTERED, ADMIN;
|
||||
|
||||
}
|
||||
88
src/main/java/entities/User.java
Normal file
88
src/main/java/entities/User.java
Normal file
@@ -0,0 +1,88 @@
|
||||
package entities;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class User {
|
||||
private long id;
|
||||
private String name, email, login, password;
|
||||
private Role role;
|
||||
private List<Expense> expenses;
|
||||
private List<Income> incomes;
|
||||
|
||||
public User(long id, String name, String email, String login, String password, Role role, List<Expense> expenses, List<Income> incomes) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.email = email;
|
||||
this.login = login;
|
||||
this.password = password;
|
||||
this.role = role;
|
||||
this.expenses = expenses;
|
||||
this.incomes = incomes;
|
||||
}
|
||||
|
||||
public User() {}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getLogin() {
|
||||
return login;
|
||||
}
|
||||
|
||||
public void setLogin(String login) {
|
||||
this.login = login;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public Role getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(Role role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public List<Expense> getExpenses() {
|
||||
return expenses;
|
||||
}
|
||||
|
||||
public void setExpenses(List<Expense> expenses) {
|
||||
this.expenses = expenses;
|
||||
}
|
||||
|
||||
public List<Income> getIncomes() {
|
||||
return incomes;
|
||||
}
|
||||
|
||||
public void setIncomes(List<Income> incomes) {
|
||||
this.incomes = incomes;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user