Merge updates from master
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,66 +1,66 @@
|
||||
package com.faf223.expensetrackerfaf.controller;
|
||||
|
||||
import com.faf223.expensetrackerfaf.model.Expense;
|
||||
import com.faf223.expensetrackerfaf.model.Income;
|
||||
import com.faf223.expensetrackerfaf.model.Role;
|
||||
import com.faf223.expensetrackerfaf.model.User;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
public class MainController {
|
||||
|
||||
@GetMapping("/")
|
||||
public String helloWorld() {
|
||||
return "Hello, World!";
|
||||
}
|
||||
|
||||
@GetMapping("/users/get/{id}")
|
||||
public User getUser(@PathVariable int id) {
|
||||
return new User(id, "Test", null, null, null, null, null);
|
||||
}
|
||||
|
||||
@PostMapping("/users/set/{id}/name")
|
||||
public String setName(@PathVariable int id,
|
||||
@RequestParam("name") String name) {
|
||||
throw new UnsupportedOperationException("Waiting for the DB.");
|
||||
}
|
||||
|
||||
@PostMapping("/users/set/{id}/email")
|
||||
public String setEmail(@PathVariable int id,
|
||||
@RequestParam("email") String email) {
|
||||
throw new UnsupportedOperationException("Waiting for the DB.");
|
||||
}
|
||||
|
||||
@PostMapping("/users/set/{id}/login")
|
||||
public String setLogin(@PathVariable int id,
|
||||
@RequestParam("login") String login) {
|
||||
throw new UnsupportedOperationException("Waiting for the DB.");
|
||||
}
|
||||
|
||||
@PostMapping("/users/set/{id}/password")
|
||||
public String setPassword(@PathVariable int id,
|
||||
@RequestParam("password") String password) {
|
||||
throw new UnsupportedOperationException("Waiting for the DB.");
|
||||
}
|
||||
|
||||
@PostMapping("/users/set/{id}/role")
|
||||
public String setRole(@PathVariable int id,
|
||||
@RequestParam("role") Role role) {
|
||||
throw new UnsupportedOperationException("Waiting for the DB.");
|
||||
}
|
||||
|
||||
@PostMapping("/users/set/{id}/expenses")
|
||||
public String setExpenses(@PathVariable int id,
|
||||
@RequestParam("expenses") List<Expense> expenses) {
|
||||
throw new UnsupportedOperationException("Waiting for the DB.");
|
||||
}
|
||||
|
||||
@PostMapping("/users/set/{id}/incomes")
|
||||
public String setIncomes(@PathVariable int id,
|
||||
@RequestParam("incomes")List<Income> incomes) {
|
||||
throw new UnsupportedOperationException("Waiting for the DB.");
|
||||
}
|
||||
|
||||
}
|
||||
//package com.faf223.expensetrackerfaf.controller;
|
||||
//
|
||||
//import com.faf223.expensetrackerfaf.model.Expense;
|
||||
//import com.faf223.expensetrackerfaf.model.Income;
|
||||
//import com.faf223.expensetrackerfaf.model.Role;
|
||||
//import com.faf223.expensetrackerfaf.model.User;
|
||||
//import org.springframework.web.bind.annotation.*;
|
||||
//
|
||||
//import java.util.List;
|
||||
//
|
||||
//@RestController
|
||||
//public class MainController {
|
||||
//
|
||||
// @GetMapping("/")
|
||||
// public String helloWorld() {
|
||||
// return "Hello, World!";
|
||||
// }
|
||||
//
|
||||
// @GetMapping("/users/get/{id}")
|
||||
// public User getUser(@PathVariable int id) {
|
||||
// return new User(id, "Test", null, null, null, null, null, null);
|
||||
// }
|
||||
//
|
||||
// @PostMapping("/users/set/{id}/name")
|
||||
// public String setName(@PathVariable int id,
|
||||
// @RequestParam("name") String name) {
|
||||
// throw new UnsupportedOperationException("Waiting for the DB.");
|
||||
// }
|
||||
//
|
||||
// @PostMapping("/users/set/{id}/email")
|
||||
// public String setEmail(@PathVariable int id,
|
||||
// @RequestParam("email") String email) {
|
||||
// throw new UnsupportedOperationException("Waiting for the DB.");
|
||||
// }
|
||||
//
|
||||
// @PostMapping("/users/set/{id}/login")
|
||||
// public String setLogin(@PathVariable int id,
|
||||
// @RequestParam("login") String login) {
|
||||
// throw new UnsupportedOperationException("Waiting for the DB.");
|
||||
// }
|
||||
//
|
||||
// @PostMapping("/users/set/{id}/password")
|
||||
// public String setPassword(@PathVariable int id,
|
||||
// @RequestParam("password") String password) {
|
||||
// throw new UnsupportedOperationException("Waiting for the DB.");
|
||||
// }
|
||||
//
|
||||
// @PostMapping("/users/set/{id}/role")
|
||||
// public String setRole(@PathVariable int id,
|
||||
// @RequestParam("role") Role role) {
|
||||
// throw new UnsupportedOperationException("Waiting for the DB.");
|
||||
// }
|
||||
//
|
||||
// @PostMapping("/users/set/{id}/expenses")
|
||||
// public String setExpenses(@PathVariable int id,
|
||||
// @RequestParam("expenses") List<Expense> expenses) {
|
||||
// throw new UnsupportedOperationException("Waiting for the DB.");
|
||||
// }
|
||||
//
|
||||
// @PostMapping("/users/set/{id}/incomes")
|
||||
// public String setIncomes(@PathVariable int id,
|
||||
// @RequestParam("incomes")List<Income> incomes) {
|
||||
// throw new UnsupportedOperationException("Waiting for the DB.");
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user