Implemented service, repository and controller for each entity

This commit is contained in:
2023-09-30 22:13:46 +03:00
parent b34c5884b1
commit f235921744
28 changed files with 379 additions and 464 deletions

23
pom.xml
View File

@@ -6,7 +6,7 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.3</version> <version>3.1.3</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath/>
</parent> </parent>
<groupId>com.faf223</groupId> <groupId>com.faf223</groupId>
<artifactId>ExpenseTrackerFAF</artifactId> <artifactId>ExpenseTrackerFAF</artifactId>
@@ -20,37 +20,31 @@
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
<version>3.1.4</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId> <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.microsoft.sqlserver</groupId> <groupId>org.mariadb.jdbc</groupId>
<artifactId>mssql-jdbc</artifactId> <artifactId>mariadb-java-client</artifactId>
<version>3.2.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
<version>3.1.2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId> <artifactId>spring-boot-starter-security</artifactId>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa -->
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.projectlombok</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId> <artifactId>lombok</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> </dependency>
</dependencies> </dependencies>
<build> <build>
@@ -61,5 +55,4 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

View File

@@ -1,26 +0,0 @@
package com.faf223.expensetrackerfaf.controller;
import com.faf223.expensetrackerfaf.model.BasicEntity;
import com.faf223.expensetrackerfaf.repository.BasicRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("/api/getData")
public class BasicController {
private final BasicRepository basicRepository;
@Autowired
public BasicController(BasicRepository basicRepository) {
this.basicRepository = basicRepository;
}
@GetMapping()
public List<BasicEntity> listDepartments() {
return basicRepository.findAll();
}
}

View File

@@ -0,0 +1,31 @@
package com.faf223.expensetrackerfaf.controller;
import com.faf223.expensetrackerfaf.model.Expense;
import com.faf223.expensetrackerfaf.service.ExpenseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("/expenses")
public class ExpenseController {
@Autowired
private ExpenseService expenseService;
@GetMapping("/user/{userUuid}")
public ResponseEntity<List<Expense>> getExpensesByUser(@PathVariable String userUuid) {
List<Expense> expenses = expenseService.getExpensesByUserId(userUuid);
if (!expenses.isEmpty()) {
return ResponseEntity.ok(expenses);
} else {
return ResponseEntity.notFound().build();
}
}
}

View File

@@ -0,0 +1,30 @@
package com.faf223.expensetrackerfaf.controller;
import com.faf223.expensetrackerfaf.model.Income;
import com.faf223.expensetrackerfaf.service.IncomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("/incomes")
public class IncomeController {
@Autowired
private IncomeService incomeService;
@GetMapping("/user/{userUuid}")
public ResponseEntity<List<Income>> getIncomesByUser(@PathVariable String userUuid) {
List<Income> incomes = incomeService.getIncomesByUserId(userUuid);
if (!incomes.isEmpty()) {
return ResponseEntity.ok(incomes);
} else {
return ResponseEntity.notFound().build();
}
}
}

View File

@@ -1,66 +1,66 @@
package com.faf223.expensetrackerfaf.controller; //package com.faf223.expensetrackerfaf.controller;
//
import com.faf223.expensetrackerfaf.model.Expense; //import com.faf223.expensetrackerfaf.model.Expense;
import com.faf223.expensetrackerfaf.model.Income; //import com.faf223.expensetrackerfaf.model.Income;
import com.faf223.expensetrackerfaf.model.Role; //import com.faf223.expensetrackerfaf.model.Role;
import com.faf223.expensetrackerfaf.model.User; //import com.faf223.expensetrackerfaf.model.User;
import org.springframework.web.bind.annotation.*; //import org.springframework.web.bind.annotation.*;
//
import java.util.List; //import java.util.List;
//
@RestController //@RestController
public class MainController { //public class MainController {
//
@GetMapping("/") // @GetMapping("/")
public String helloWorld() { // public String helloWorld() {
return "Hello, World!"; // return "Hello, World!";
} // }
//
@GetMapping("/users/get/{id}") // @GetMapping("/users/get/{id}")
public User getUser(@PathVariable int id) { // public User getUser(@PathVariable int id) {
return new User(id, "Test", null, null, null, null, null, null); // return new User(id, "Test", null, null, null, null, null, null);
} // }
//
@PostMapping("/users/set/{id}/name") // @PostMapping("/users/set/{id}/name")
public String setName(@PathVariable int id, // public String setName(@PathVariable int id,
@RequestParam("name") String name) { // @RequestParam("name") String name) {
throw new UnsupportedOperationException("Waiting for the DB."); // throw new UnsupportedOperationException("Waiting for the DB.");
} // }
//
@PostMapping("/users/set/{id}/email") // @PostMapping("/users/set/{id}/email")
public String setEmail(@PathVariable int id, // public String setEmail(@PathVariable int id,
@RequestParam("email") String email) { // @RequestParam("email") String email) {
throw new UnsupportedOperationException("Waiting for the DB."); // throw new UnsupportedOperationException("Waiting for the DB.");
} // }
//
@PostMapping("/users/set/{id}/login") // @PostMapping("/users/set/{id}/login")
public String setLogin(@PathVariable int id, // public String setLogin(@PathVariable int id,
@RequestParam("login") String login) { // @RequestParam("login") String login) {
throw new UnsupportedOperationException("Waiting for the DB."); // throw new UnsupportedOperationException("Waiting for the DB.");
} // }
//
@PostMapping("/users/set/{id}/password") // @PostMapping("/users/set/{id}/password")
public String setPassword(@PathVariable int id, // public String setPassword(@PathVariable int id,
@RequestParam("password") String password) { // @RequestParam("password") String password) {
throw new UnsupportedOperationException("Waiting for the DB."); // throw new UnsupportedOperationException("Waiting for the DB.");
} // }
//
@PostMapping("/users/set/{id}/role") // @PostMapping("/users/set/{id}/role")
public String setRole(@PathVariable int id, // public String setRole(@PathVariable int id,
@RequestParam("role") Role role) { // @RequestParam("role") Role role) {
throw new UnsupportedOperationException("Waiting for the DB."); // throw new UnsupportedOperationException("Waiting for the DB.");
} // }
//
@PostMapping("/users/set/{id}/expenses") // @PostMapping("/users/set/{id}/expenses")
public String setExpenses(@PathVariable int id, // public String setExpenses(@PathVariable int id,
@RequestParam("expenses") List<Expense> expenses) { // @RequestParam("expenses") List<Expense> expenses) {
throw new UnsupportedOperationException("Waiting for the DB."); // throw new UnsupportedOperationException("Waiting for the DB.");
} // }
//
@PostMapping("/users/set/{id}/incomes") // @PostMapping("/users/set/{id}/incomes")
public String setIncomes(@PathVariable int id, // public String setIncomes(@PathVariable int id,
@RequestParam("incomes")List<Income> incomes) { // @RequestParam("incomes")List<Income> incomes) {
throw new UnsupportedOperationException("Waiting for the DB."); // throw new UnsupportedOperationException("Waiting for the DB.");
} // }
//
} //}

View File

@@ -0,0 +1,29 @@
package com.faf223.expensetrackerfaf.controller;
import com.faf223.expensetrackerfaf.model.User;
import com.faf223.expensetrackerfaf.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/users")
public class UserController {
@Autowired
private UserService userService;
@GetMapping("/{userUuid}")
public ResponseEntity<User> getUser(@PathVariable String userUuid) {
User user = userService.getUserById(userUuid);
if (user != null) {
return ResponseEntity.ok(user);
} else {
return ResponseEntity.notFound().build();
}
}
}

View File

@@ -1,39 +0,0 @@
package com.faf223.expensetrackerfaf.custom;
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
public class UppercaseStrategy implements PhysicalNamingStrategy {
@Override
public Identifier toPhysicalCatalogName(Identifier identifier, JdbcEnvironment jdbcEnvironment) {
return identifier; // No modification for catalog name
}
@Override
public Identifier toPhysicalSchemaName(Identifier identifier, JdbcEnvironment jdbcEnvironment) {
return identifier; // No modification for schema name
}
@Override
public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment context) {
String tableName = name.getText();
return new Identifier(tableName, name.isQuoted());
}
@Override
public Identifier toPhysicalSequenceName(Identifier identifier, JdbcEnvironment jdbcEnvironment) {
return identifier; // No modification for sequence name
}
@Override
public Identifier toPhysicalColumnName(Identifier identifier, JdbcEnvironment jdbcEnvironment) {
return identifier; // No modification for column name
}
@Override
public Identifier toPhysicalTypeName(Identifier logicalName, JdbcEnvironment jdbcEnvironment) {
return PhysicalNamingStrategy.super.toPhysicalTypeName(logicalName, jdbcEnvironment);
}
}

View File

@@ -1,37 +0,0 @@
package com.faf223.expensetrackerfaf.model;
import jakarta.persistence.*;
import java.util.Date;
@Entity
@Table(name = "Department", schema = "HumanResources")
public class BasicEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "DepartmentID")
private Short departmentId;
@Column(name = "GroupName", nullable = false, length = 50)
private String groupName;
@Column(name = "ModifiedDate", nullable = false)
@Temporal(TemporalType.TIMESTAMP)
private Date modifiedDate;
@Column(name = "Name", nullable = false, length = 50)
private String name;
public Short getDepartmentId() {
return departmentId;
}
public String getGroupName() {
return groupName;
}
public Date getModifiedDate() {
return modifiedDate;
}
public String getName() {
return name;
}
}

View File

@@ -1,34 +0,0 @@
package com.faf223.expensetrackerfaf.model;
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();
}
}

View File

@@ -0,0 +1,20 @@
package com.faf223.expensetrackerfaf.model;
import jakarta.persistence.*;
import lombok.Data;
@Data
@Entity(name = "credentials")
public class Credential {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long credentialId;
@ManyToOne
@JoinColumn(name = "user_uuid")
private User user;
private String email;
private String password;
}

View File

@@ -1,63 +1,26 @@
package com.faf223.expensetrackerfaf.model; package com.faf223.expensetrackerfaf.model;
import com.faf223.expensetrackerfaf.util.IMoneyTransaction;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.Data;
@Entity import java.math.BigDecimal;
@Table(name = "expense") import java.time.LocalDate;
public class Expense implements IMoneyTransaction {
@Data
@Entity(name = "expenses")
public class Expense {
@Id @Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private long id; private Long expenseId;
@ManyToOne @ManyToOne
@JoinColumn(name = "user_id", referencedColumnName = "id") @JoinColumn(name = "user_uuid")
private User user; private User user;
private int amount;
private Categories.ExpenseCategory category;
public Expense(User user, int amount, Categories.ExpenseCategory category) { @ManyToOne
this.user = user; @JoinColumn(name = "category_id")
this.amount = amount; private ExpenseCategory category;
this.category = category;
}
public Expense() {} private LocalDate date;
private BigDecimal amount;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@Override
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
@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;
}
} }

View File

@@ -0,0 +1,17 @@
package com.faf223.expensetrackerfaf.model;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import lombok.Data;
@Data
@Entity(name = "expense_categories")
public class ExpenseCategory {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long categoryId;
private String categoryName;
}

View File

@@ -1,67 +1,26 @@
package com.faf223.expensetrackerfaf.model; package com.faf223.expensetrackerfaf.model;
import com.faf223.expensetrackerfaf.util.IMoneyTransaction;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.Data;
@Entity import java.math.BigDecimal;
@Table(name = "income") import java.time.LocalDate;
public class Income implements IMoneyTransaction {
@Data
@Entity(name = "incomes")
public class Income {
@Id @Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private long id; private Long incomeId;
@ManyToOne @ManyToOne
@JoinColumn(name = "user_id", referencedColumnName = "id") @JoinColumn(name = "user_uuid")
private User user; private User user;
private int amount;
private Categories.IncomeCategory category;
public Income(User user, int amount, Categories.IncomeCategory category) { @ManyToOne
this.user = user; @JoinColumn(name = "category_id")
this.amount = amount; private IncomeCategory category;
this.category = category;
}
public Income() {} private LocalDate date;
private BigDecimal amount;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public void setUser(User user) {
this.user = user;
}
@Override
public User getUser() {
return user;
}
@Override
public int getAmount() {
return amount;
}
@Override
public String getCategory() {
return category.getEffectiveName();
}
public void setUserId(User user) {
this.user = user;
}
public void setAmount(int amount) {
this.amount = amount;
}
public void setCategory(Categories.IncomeCategory category) {
this.category = category;
}
} }

View File

@@ -0,0 +1,18 @@
package com.faf223.expensetrackerfaf.model;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import lombok.Data;
@Data
@Entity(name = "income_categories")
public class IncomeCategory {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long categoryId;
private String categoryName;
}

View File

@@ -1,101 +1,18 @@
package com.faf223.expensetrackerfaf.model; package com.faf223.expensetrackerfaf.model;
import jakarta.persistence.*;
import java.util.List; import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import lombok.Data;
@Entity @Data
@Table(name = "User") @Entity(name = "users")
public class User { public class User {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @Column(table = "users", name = "user_uuid")
private long id; private String userUuid;
private String name; private String name;
private String email; private String surname;
private String login; private String username;
private String password;
private Role role;
@OneToMany(mappedBy = "user")
private List<Expense> expenses;
@OneToMany(mappedBy = "user")
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;
}
} }

View File

@@ -1,12 +0,0 @@
package com.faf223.expensetrackerfaf.repository;
import com.faf223.expensetrackerfaf.model.BasicEntity;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
public interface BasicRepository extends JpaRepository<BasicEntity, Short> {
// You can define custom query methods here if needed
}

View File

@@ -0,0 +1,9 @@
package com.faf223.expensetrackerfaf.repository;
import com.faf223.expensetrackerfaf.model.Credential;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface CredentialRepository extends JpaRepository<Credential, Long> {
}

View File

@@ -0,0 +1,9 @@
package com.faf223.expensetrackerfaf.repository;
import com.faf223.expensetrackerfaf.model.ExpenseCategory;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface ExpenseCategoryRepository extends JpaRepository<ExpenseCategory, Long> {
}

View File

@@ -0,0 +1,12 @@
package com.faf223.expensetrackerfaf.repository;
import com.faf223.expensetrackerfaf.model.Expense;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface ExpenseRepository extends JpaRepository<Expense, Long> {
List<Expense> findByUserUserUuid(String userUuid);
}

View File

@@ -0,0 +1,9 @@
package com.faf223.expensetrackerfaf.repository;
import com.faf223.expensetrackerfaf.model.IncomeCategory;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface IncomeCategoryRepository extends JpaRepository<IncomeCategory, Long> {
}

View File

@@ -0,0 +1,12 @@
package com.faf223.expensetrackerfaf.repository;
import com.faf223.expensetrackerfaf.model.Income;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface IncomeRepository extends JpaRepository<Income, Long> {
List<Income> findByUserUserUuid(String userUuid);
}

View File

@@ -0,0 +1,9 @@
package com.faf223.expensetrackerfaf.repository;
import com.faf223.expensetrackerfaf.model.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface UserRepository extends JpaRepository<User, String> {
}

View File

@@ -1,9 +0,0 @@
package com.faf223.expensetrackerfaf.service;
import com.faf223.expensetrackerfaf.model.BasicEntity;
import java.util.List;
public interface BasicService {
List<BasicEntity> getAllData();
}

View File

@@ -1,23 +0,0 @@
package com.faf223.expensetrackerfaf.service;
import com.faf223.expensetrackerfaf.model.BasicEntity;
import com.faf223.expensetrackerfaf.repository.BasicRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class BasicServiceImpl implements BasicService {
private final BasicRepository basicRepository;
@Autowired
public BasicServiceImpl(BasicRepository basicRepository) {
this.basicRepository = basicRepository;
}
@Override
public List<BasicEntity> getAllData() {
return basicRepository.findAll();
}
}

View File

@@ -0,0 +1,19 @@
package com.faf223.expensetrackerfaf.service;
import com.faf223.expensetrackerfaf.model.Expense;
import com.faf223.expensetrackerfaf.repository.ExpenseRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ExpenseService {
@Autowired
private ExpenseRepository expenseRepository;
public List<Expense> getExpensesByUserId(String userUuid) {
return expenseRepository.findByUserUserUuid(userUuid);
}
}

View File

@@ -0,0 +1,18 @@
package com.faf223.expensetrackerfaf.service;
import com.faf223.expensetrackerfaf.model.Income;
import com.faf223.expensetrackerfaf.repository.IncomeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class IncomeService {
@Autowired
private IncomeRepository incomeRepository;
public List<Income> getIncomesByUserId(String userUuid) {
return incomeRepository.findByUserUserUuid(userUuid);
}
}

View File

@@ -0,0 +1,17 @@
package com.faf223.expensetrackerfaf.service;
import com.faf223.expensetrackerfaf.model.User;
import com.faf223.expensetrackerfaf.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class UserService {
@Autowired
private UserRepository userRepository;
public User getUserById(String userUuid) {
return userRepository.findById(userUuid).orElse(null);
}
}

View File

@@ -1,5 +1,9 @@
spring.datasource.url=jdbc:sqlserver://DANIEL-LAPTOP\\SQLEXPRESS01:1433;databaseName=AdventureWorks2022;encrypt=true;user=Daniel1;password=daniel;trustServerCertificate=true; # MySQL Connection Configuration
spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver spring.datasource.url=jdbc:mariadb://194.195.242.137:3306/expensetracker
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.SQLServer2008Dialect spring.datasource.username=root
spring.jpa.hibernate.naming.physical-strategy=com.faf223.expensetrackerfaf.custom.UppercaseStrategy spring.datasource.password=daniel$$$javatop
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
# Hibernate Configuration
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
server.port=8081