Skip to content

Commit d0bcb9a

Browse files
committed
Update: Backend Working
1 parent 46b1065 commit d0bcb9a

32 files changed

Lines changed: 594 additions & 1 deletion

spring

Lines changed: 0 additions & 1 deletion
This file was deleted.

spring/pom.xml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
4+
http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<groupId>com.github.hoangsonww</groupId>
7+
<artifactId>budget-backend</artifactId>
8+
<version>1.0.0</version>
9+
<properties>
10+
<java.version>17</java.version>
11+
<spring.boot.version>2.7.12</spring.boot.version>
12+
</properties>
13+
<dependencyManagement>
14+
<dependencies>
15+
<dependency>
16+
<groupId>org.springframework.boot</groupId>
17+
<artifactId>spring-boot-dependencies</artifactId>
18+
<version>${spring.boot.version}</version>
19+
<type>pom</type>
20+
<scope>import</scope>
21+
</dependency>
22+
</dependencies>
23+
</dependencyManagement>
24+
<dependencies>
25+
<!-- Web -->
26+
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency>
27+
<!-- JPA/PostgreSQL -->
28+
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-jpa</artifactId></dependency>
29+
<dependency><groupId>org.postgresql</groupId><artifactId>postgresql</artifactId><scope>runtime</scope></dependency>
30+
<!-- MongoDB -->
31+
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-mongodb</artifactId></dependency>
32+
<!-- JWT -->
33+
<dependency><groupId>io.jsonwebtoken</groupId><artifactId>jjwt</artifactId><version>0.9.1</version></dependency>
34+
<!-- Lombok -->
35+
<dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><scope>provided</scope></dependency>
36+
<!-- Testing -->
37+
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency>
38+
</dependencies>
39+
<build>
40+
<plugins>
41+
<plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin>
42+
</plugins>
43+
</build>
44+
<distributionManagement>
45+
<repository>
46+
<id>github</id>
47+
<url>https://maven.pkg.github.com/hoangsonww/Budget-Management-Backend-API</url>
48+
</repository>
49+
</distributionManagement>
50+
</project>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.github.hoangsonww.budget;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class BudgetBackendApplication {
8+
public static void main(String[] args) {
9+
SpringApplication.run(BudgetBackendApplication.class, args);
10+
}
11+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.github.hoangsonww.budget.controller;
2+
3+
import com.github.hoangsonww.budget.model.Budget;
4+
import com.github.hoangsonww.budget.service.BudgetService;
5+
import org.springframework.web.bind.annotation.*;
6+
import java.util.List;
7+
8+
@RestController
9+
@RequestMapping("/api/budgets")
10+
public class BudgetController {
11+
private final BudgetService service;
12+
public BudgetController(BudgetService service) { this.service = service; }
13+
14+
@GetMapping
15+
public List<Budget> all() { return service.findAll(); }
16+
17+
@GetMapping("/{id}")
18+
public Budget one(@PathVariable String id) { return service.findById(id); }
19+
20+
@PostMapping
21+
public Budget create(@RequestBody Budget b) { return service.save(b); }
22+
23+
@PutMapping("/{id}")
24+
public Budget update(@PathVariable String id, @RequestBody Budget b) {
25+
b.setId(id);
26+
return service.save(b);
27+
}
28+
29+
@DeleteMapping("/{id}")
30+
public void delete(@PathVariable String id) { service.delete(id); }
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.github.hoangsonww.budget.controller;
2+
3+
import com.github.hoangsonww.budget.model.Customer;
4+
import com.github.hoangsonww.budget.service.CustomerService;
5+
import org.springframework.web.bind.annotation.*;
6+
import java.util.List;
7+
8+
@RestController
9+
@RequestMapping("/api/customers")
10+
public class CustomerController {
11+
private final CustomerService service;
12+
public CustomerController(CustomerService service) { this.service = service; }
13+
14+
@GetMapping
15+
public List<Customer> all() { return service.findAll(); }
16+
17+
@GetMapping("/{id}")
18+
public Customer one(@PathVariable String id) { return service.findById(id); }
19+
20+
@PostMapping
21+
public Customer create(@RequestBody Customer c) { return service.save(c); }
22+
23+
@PutMapping("/{id}")
24+
public Customer update(@PathVariable String id, @RequestBody Customer c) {
25+
c.setId(id);
26+
return service.save(c);
27+
}
28+
29+
@DeleteMapping("/{id}")
30+
public void delete(@PathVariable String id) { service.delete(id); }
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.github.hoangsonww.budget.controller;
2+
3+
import com.github.hoangsonww.budget.model.Expense;
4+
import com.github.hoangsonww.budget.service.ExpenseService;
5+
import org.springframework.web.bind.annotation.*;
6+
import java.util.List;
7+
8+
@RestController
9+
@RequestMapping("/api/expenses")
10+
public class ExpenseController {
11+
private final ExpenseService service;
12+
public ExpenseController(ExpenseService service) { this.service = service; }
13+
14+
@GetMapping
15+
public List<Expense> all() { return service.findAll(); }
16+
17+
@GetMapping("/{id}")
18+
public Expense one(@PathVariable String id) { return service.findById(id); }
19+
20+
@PostMapping
21+
public Expense create(@RequestBody Expense e) { return service.save(e); }
22+
23+
@PutMapping("/{id}")
24+
public Expense update(@PathVariable String id, @RequestBody Expense e) {
25+
e.setId(id);
26+
return service.save(e);
27+
}
28+
29+
@DeleteMapping("/{id}")
30+
public void delete(@PathVariable String id) { service.delete(id); }
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.github.hoangsonww.budget.controller;
2+
3+
import com.github.hoangsonww.budget.model.Order;
4+
import com.github.hoangsonww.budget.service.OrderService;
5+
import org.springframework.web.bind.annotation.*;
6+
import java.util.List;
7+
8+
@RestController
9+
@RequestMapping("/api/orders")
10+
public class OrderController {
11+
private final OrderService service;
12+
public OrderController(OrderService service) { this.service = service; }
13+
14+
@GetMapping
15+
public List<Order> all() { return service.findAll(); }
16+
17+
@GetMapping("/{id}")
18+
public Order one(@PathVariable String id) { return service.findById(id); }
19+
20+
@PostMapping
21+
public Order create(@RequestBody Order o) { return service.save(o); }
22+
23+
@PutMapping("/{id}")
24+
public Order update(@PathVariable String id, @RequestBody Order o) {
25+
o.setId(id);
26+
return service.save(o);
27+
}
28+
29+
@DeleteMapping("/{id}")
30+
public void delete(@PathVariable String id) { service.delete(id); }
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.github.hoangsonww.budget.controller;
2+
3+
import com.github.hoangsonww.budget.model.Task;
4+
import com.github.hoangsonww.budget.service.TaskService;
5+
import org.springframework.web.bind.annotation.*;
6+
import java.util.List;
7+
8+
@RestController
9+
@RequestMapping("/api/tasks")
10+
public class TaskController {
11+
private final TaskService service;
12+
public TaskController(TaskService service) { this.service = service; }
13+
14+
@GetMapping
15+
public List<Task> all() { return service.findAll(); }
16+
17+
@GetMapping("/{id}")
18+
public Task one(@PathVariable String id) { return service.findById(id); }
19+
20+
@PostMapping
21+
public Task create(@RequestBody Task t) { return service.save(t); }
22+
23+
@PutMapping("/{id}")
24+
public Task update(@PathVariable String id, @RequestBody Task t) {
25+
t.setId(id);
26+
return service.save(t);
27+
}
28+
29+
@DeleteMapping("/{id}")
30+
public void delete(@PathVariable String id) { service.delete(id); }
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.github.hoangsonww.budget.controller;
2+
3+
import com.github.hoangsonww.budget.model.Transaction;
4+
import com.github.hoangsonww.budget.service.TransactionService;
5+
import org.springframework.web.bind.annotation.*;
6+
import java.util.List;
7+
8+
@RestController
9+
@RequestMapping("/api/transactions")
10+
public class TransactionController {
11+
private final TransactionService service;
12+
public TransactionController(TransactionService service) { this.service = service; }
13+
14+
@GetMapping
15+
public List<Transaction> all() { return service.findAll(); }
16+
17+
@GetMapping("/{id}")
18+
public Transaction one(@PathVariable String id) { return service.findById(id); }
19+
20+
@PostMapping
21+
public Transaction create(@RequestBody Transaction t) { return service.save(t); }
22+
23+
@PutMapping("/{id}")
24+
public Transaction update(@PathVariable String id, @RequestBody Transaction t) {
25+
t.setId(id);
26+
return service.save(t);
27+
}
28+
29+
@DeleteMapping("/{id}")
30+
public void delete(@PathVariable String id) { service.delete(id); }
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.github.hoangsonww.budget.controller;
2+
3+
import com.github.hoangsonww.budget.model.User;
4+
import com.github.hoangsonww.budget.service.UserService;
5+
import org.springframework.web.bind.annotation.*;
6+
import java.util.List;
7+
8+
@RestController
9+
@RequestMapping("/api/users")
10+
public class UserController {
11+
private final UserService service;
12+
public UserController(UserService service) { this.service = service; }
13+
14+
@GetMapping
15+
public List<User> all() { return service.findAll(); }
16+
17+
@GetMapping("/{id}")
18+
public User one(@PathVariable String id) { return service.findById(id); }
19+
20+
@PostMapping
21+
public User create(@RequestBody User u) { return service.save(u); }
22+
23+
@PutMapping("/{id}")
24+
public User update(@PathVariable String id, @RequestBody User u) {
25+
u.setId(id);
26+
return service.save(u);
27+
}
28+
29+
@DeleteMapping("/{id}")
30+
public void delete(@PathVariable String id) { service.delete(id); }
31+
}

0 commit comments

Comments
 (0)