Merge pull request #2 from lumijiez/dimas
Add new entities
This commit was merged in pull request #2.
This commit is contained in:
12
pom.xml
12
pom.xml
@@ -27,6 +27,18 @@
|
|||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
<version>3.1.2</version>
|
<version>3.1.2</version>
|
||||||
</dependency>
|
</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>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ public class MainController {
|
|||||||
return "Hello, World!";
|
return "Hello, World!";
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/users/{id}")
|
@GetMapping("/users/get/{id}")
|
||||||
public User getUser(@PathVariable int id) {
|
public User getUser(@PathVariable int id) {
|
||||||
return new User(id, "Test");
|
return new User(id, "Test", null, null, null, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
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 extends MoneyTransaction {
|
||||||
|
|
||||||
|
private int userId;
|
||||||
|
private int amount;
|
||||||
|
private ExpensesCategory category;
|
||||||
|
|
||||||
|
public Expense(int userId, int amount, ExpensesCategory 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.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCategory(ExpensesCategory category) {
|
||||||
|
this.category = category;
|
||||||
|
}
|
||||||
|
}
|
||||||
5
src/main/java/entities/ExpensesCategory.java
Normal file
5
src/main/java/entities/ExpensesCategory.java
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
package entities;
|
||||||
|
|
||||||
|
public enum ExpensesCategory {
|
||||||
|
MISC;
|
||||||
|
}
|
||||||
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 extends MoneyTransaction {
|
||||||
|
|
||||||
|
private long userId;
|
||||||
|
private int amount;
|
||||||
|
private IncomeCategory category;
|
||||||
|
|
||||||
|
public Income(long userId, int amount, 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.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserId(long userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAmount(int amount) {
|
||||||
|
this.amount = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCategory(IncomeCategory category) {
|
||||||
|
this.category = category;
|
||||||
|
}
|
||||||
|
}
|
||||||
5
src/main/java/entities/IncomeCategory.java
Normal file
5
src/main/java/entities/IncomeCategory.java
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
package entities;
|
||||||
|
|
||||||
|
public enum IncomeCategory {
|
||||||
|
MISC;
|
||||||
|
}
|
||||||
9
src/main/java/entities/MoneyTransaction.java
Normal file
9
src/main/java/entities/MoneyTransaction.java
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package entities;
|
||||||
|
|
||||||
|
public abstract class MoneyTransaction {
|
||||||
|
|
||||||
|
public abstract long getUserId();
|
||||||
|
public abstract int getAmount();
|
||||||
|
public abstract String getCategory();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,19 +1,27 @@
|
|||||||
package entities;
|
package entities;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class User {
|
public class User {
|
||||||
|
|
||||||
private long id;
|
private long id;
|
||||||
private String name;
|
private String name, email, login, password;
|
||||||
private String email;
|
|
||||||
private String login;
|
|
||||||
private String password;
|
|
||||||
private Role role;
|
private Role role;
|
||||||
|
private List<Expense> expenses;
|
||||||
|
private List<Income> incomes;
|
||||||
|
|
||||||
public User(long id, String name) {
|
public User(long id, String name, String email, String login, String password, Role role, List<Expense> expenses, List<Income> incomes) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
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() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -29,4 +37,52 @@ public class User {
|
|||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
|
spring.datasource.url=jdbc:sqlserver://DESKTOP-53DT8GT\\SQLEXPRESS:1433;databaseName=ExpensesApp;integratedSecurity=true
|
||||||
|
spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||||||
|
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.SQLServer2008Dialect
|
||||||
Reference in New Issue
Block a user