initial Release request #1
199
apiDesign.drawio
Normal file
199
apiDesign.drawio
Normal file
@@ -0,0 +1,199 @@
|
||||
<mxfile host="65bd71144e">
|
||||
<diagram id="TZX9Tq6sZIlTxQ58HocZ" name="Page-1">
|
||||
<mxGraphModel dx="826" dy="472" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0"/>
|
||||
<mxCell id="1" parent="0"/>
|
||||
<mxCell id="2" value="ExpenseList" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#647687;fontColor=#ffffff;strokeColor=#314354;" parent="1" vertex="1">
|
||||
<mxGeometry x="360" y="60" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="5" value="add expense" style="ellipse;whiteSpace=wrap;html=1;fillColor=#fa6800;fontColor=#000000;strokeColor=#C73500;" parent="1" vertex="1">
|
||||
<mxGeometry x="550" y="190" width="90" height="50" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="6" value="id" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#76608a;fontColor=#ffffff;strokeColor=#432D57;" parent="1" vertex="1">
|
||||
<mxGeometry x="470" y="30" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="7" value="owner" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#76608a;fontColor=#ffffff;strokeColor=#432D57;" parent="1" vertex="1">
|
||||
<mxGeometry x="470" y="50" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="8" value="name" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#76608a;fontColor=#ffffff;strokeColor=#432D57;" parent="1" vertex="1">
|
||||
<mxGeometry x="470" y="70" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="9" value="sharedWith" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#76608a;fontColor=#ffffff;strokeColor=#432D57;" parent="1" vertex="1">
|
||||
<mxGeometry x="470" y="90" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="10" value="expenses" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#76608a;fontColor=#ffffff;strokeColor=#432D57;" parent="1" vertex="1">
|
||||
<mxGeometry x="470" y="110" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="11" value="List&lt;User&gt;" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f0a30a;fontColor=#000000;strokeColor=#BD7000;" parent="1" vertex="1">
|
||||
<mxGeometry x="590" y="90" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="13" value="List&lt;Expense&gt;" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f0a30a;fontColor=#000000;strokeColor=#BD7000;" parent="1" vertex="1">
|
||||
<mxGeometry x="590" y="110" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="14" value="String" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f0a30a;fontColor=#000000;strokeColor=#BD7000;" parent="1" vertex="1">
|
||||
<mxGeometry x="590" y="70" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="15" value="User" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f0a30a;fontColor=#000000;strokeColor=#BD7000;" parent="1" vertex="1">
|
||||
<mxGeometry x="590" y="50" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="16" value="Long" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f0a30a;fontColor=#000000;strokeColor=#BD7000;" parent="1" vertex="1">
|
||||
<mxGeometry x="590" y="30" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="17" value="remove expense" style="ellipse;whiteSpace=wrap;html=1;fillColor=#fa6800;fontColor=#000000;strokeColor=#C73500;" parent="1" vertex="1">
|
||||
<mxGeometry x="670" y="190" width="90" height="50" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="19" style="edgeStyle=none;html=1;" parent="1" source="18" target="5" edge="1">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="20" style="edgeStyle=none;html=1;entryX=0;entryY=1;entryDx=0;entryDy=0;" parent="1" source="18" target="17" edge="1">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="22" style="edgeStyle=none;html=1;" parent="1" source="18" target="21" edge="1">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="24" style="edgeStyle=none;html=1;" parent="1" source="18" target="23" edge="1">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="26" style="edgeStyle=none;html=1;entryX=1;entryY=1;entryDx=0;entryDy=0;" parent="1" source="18" target="25" edge="1">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="28" style="edgeStyle=none;html=1;" parent="1" source="18" target="27" edge="1">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="18" value="ExpenseList" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#647687;fontColor=#ffffff;strokeColor=#314354;" parent="1" vertex="1">
|
||||
<mxGeometry x="540" y="270" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="21" value="add User" style="ellipse;whiteSpace=wrap;html=1;fillColor=#fa6800;fontColor=#000000;strokeColor=#C73500;" parent="1" vertex="1">
|
||||
<mxGeometry x="740" y="270" width="90" height="50" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="23" value="remove User" style="ellipse;whiteSpace=wrap;html=1;fillColor=#fa6800;fontColor=#000000;strokeColor=#C73500;" parent="1" vertex="1">
|
||||
<mxGeometry x="720" y="350" width="90" height="50" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="25" value="update expense" style="ellipse;whiteSpace=wrap;html=1;fillColor=#fa6800;fontColor=#000000;strokeColor=#C73500;" parent="1" vertex="1">
|
||||
<mxGeometry x="440" y="190" width="90" height="50" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="27" value="update name" style="ellipse;whiteSpace=wrap;html=1;fillColor=#fa6800;fontColor=#000000;strokeColor=#C73500;" parent="1" vertex="1">
|
||||
<mxGeometry x="380" y="275" width="90" height="50" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="29" value="<h1>ExpenseList</h1><div>ExpenseList:</div><div><br></div><div>- create a List</div><div>- share a List</div><div>- handle Expenses</div><div><br></div><div>Expense:</div><div>- create a new Expense</div><div>- update an Expense</div><div>- delete an Expense</div><div><br></div><div>User:<br>- add User</div><div>-&nbsp;</div><div><br></div><div><br></div><div><br></div><div>&nbsp;</div>" style="text;html=1;strokeColor=none;fillColor=none;spacing=5;spacingTop=-20;whiteSpace=wrap;overflow=hidden;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="20" y="10" width="190" height="270" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="30" value="Expense" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#647687;fontColor=#ffffff;strokeColor=#314354;" parent="1" vertex="1">
|
||||
<mxGeometry x="370" y="510" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="31" value="id" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#76608a;fontColor=#ffffff;strokeColor=#432D57;" parent="1" vertex="1">
|
||||
<mxGeometry x="480" y="480" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="32" value="owner" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#76608a;fontColor=#ffffff;strokeColor=#432D57;" parent="1" vertex="1">
|
||||
<mxGeometry x="480" y="500" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="33" value="name" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#76608a;fontColor=#ffffff;strokeColor=#432D57;" parent="1" vertex="1">
|
||||
<mxGeometry x="480" y="520" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="34" value="amount" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#76608a;fontColor=#ffffff;strokeColor=#432D57;" parent="1" vertex="1">
|
||||
<mxGeometry x="480" y="540" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="35" value="deviation" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#76608a;fontColor=#ffffff;strokeColor=#432D57;" parent="1" vertex="1">
|
||||
<mxGeometry x="480" y="560" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="36" value="Double" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f0a30a;fontColor=#000000;strokeColor=#BD7000;" parent="1" vertex="1">
|
||||
<mxGeometry x="600" y="540" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="37" value="Double" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f0a30a;fontColor=#000000;strokeColor=#BD7000;" parent="1" vertex="1">
|
||||
<mxGeometry x="600" y="560" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="38" value="String" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f0a30a;fontColor=#000000;strokeColor=#BD7000;" parent="1" vertex="1">
|
||||
<mxGeometry x="600" y="520" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="39" value="User" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f0a30a;fontColor=#000000;strokeColor=#BD7000;" parent="1" vertex="1">
|
||||
<mxGeometry x="600" y="500" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="40" value="Long" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f0a30a;fontColor=#000000;strokeColor=#BD7000;" parent="1" vertex="1">
|
||||
<mxGeometry x="600" y="480" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="41" value="date" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#76608a;fontColor=#ffffff;strokeColor=#432D57;" parent="1" vertex="1">
|
||||
<mxGeometry x="480" y="580" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="42" value="Time" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f0a30a;fontColor=#000000;strokeColor=#BD7000;" parent="1" vertex="1">
|
||||
<mxGeometry x="600" y="580" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="43" value="expenseList" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#76608a;fontColor=#ffffff;strokeColor=#432D57;" parent="1" vertex="1">
|
||||
<mxGeometry x="480" y="600" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="44" value="ExpenseList" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f0a30a;fontColor=#000000;strokeColor=#BD7000;" parent="1" vertex="1">
|
||||
<mxGeometry x="600" y="600" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="45" value="" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="900" y="40" width="200" height="320" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="46" value="ExpenseList" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="910" y="50" width="120" height="40" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="47" value="ExpenseList" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="910" y="100" width="120" height="40" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="48" value="+" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="910" y="150" width="30" height="30" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="50" value="Home" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="970" y="10" width="60" height="30" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="51" value="" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="1140" y="40" width="200" height="320" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="52" value="ExpenseList" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="1180" y="50" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="53" value="<font style="font-size: 8px;">24.12.24 ; Expense ; 24,12 €</font>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#76608a;fontColor=#ffffff;strokeColor=#432D57;" parent="1" vertex="1">
|
||||
<mxGeometry x="1150" y="90" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="54" value="+" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="1300" y="285" width="30" height="30" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="55" value="ExpenseList" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="1210" y="10" width="60" height="30" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="58" value="<span style="color: rgb(255, 255, 255); font-size: 8px;">24.12.24 ; Expense ; 24,12 €</span>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f0a30a;fontColor=#000000;strokeColor=#BD7000;" parent="1" vertex="1">
|
||||
<mxGeometry x="1210" y="115" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="59" value="<span style="font-size: 8px;">24.12.24 ; Expense ; 24,12 €</span>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#76608a;fontColor=#ffffff;strokeColor=#432D57;" parent="1" vertex="1">
|
||||
<mxGeometry x="1150" y="140" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="60" value="" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="1390" y="40" width="200" height="320" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="61" value="ExpenseList" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="1430" y="50" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="62" value="<font style="font-size: 8px;">24.12.24 ; Expense ; 24,12 €</font>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#76608a;fontColor=#ffffff;strokeColor=#432D57;" parent="1" vertex="1">
|
||||
<mxGeometry x="1430" y="80" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="63" value="+" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="1540" y="320" width="30" height="30" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="64" value="Update Expense" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="1430" y="10" width="120" height="30" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="67" value="<span style="font-size: 8px;">Amount : 24,12 €<br>Title: Expense<br>Date: 24.12.24<br>From: Jessi<br>Deviation: 0 €</span>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#76608a;fontColor=#ffffff;strokeColor=#432D57;align=left;spacingLeft=12;" parent="1" vertex="1">
|
||||
<mxGeometry x="1405" y="110" width="170" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="68" value="<span style="color: rgb(255, 255, 255); font-size: 8px;">Total: 24,12 €</span>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#76608a;fontColor=#ffffff;strokeColor=#432D57;" parent="1" vertex="1">
|
||||
<mxGeometry x="1150" y="290" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="70" value="" style="endArrow=none;html=1;fontSize=8;entryX=1;entryY=0.75;entryDx=0;entryDy=0;" parent="1" edge="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="1140" y="325" as="sourcePoint"/>
|
||||
<mxPoint x="1340" y="325" as="targetPoint"/>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="72" value="<span style="color: rgb(255, 255, 255); font-size: 8px;">24.12.24 ; Expense ; 24,12 €</span>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f0a30a;fontColor=#000000;strokeColor=#BD7000;" parent="1" vertex="1">
|
||||
<mxGeometry x="1460" y="200" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="73" value="<span style="font-size: 8px;">24.12.24 ; Expense ; 24,12 €</span>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#76608a;fontColor=#ffffff;strokeColor=#432D57;" parent="1" vertex="1">
|
||||
<mxGeometry x="1399" y="226" width="120" height="20" as="geometry"/>
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
@@ -1,38 +0,0 @@
|
||||
package de.zendric.app.XpenselyServer.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import de.zendric.app.XpenselyServer.model.ExpenseList;
|
||||
import de.zendric.app.XpenselyServer.services.ExpenseListService;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/lists")
|
||||
public class ExpenseListController {
|
||||
|
||||
@Autowired
|
||||
private ExpenseListService service;
|
||||
|
||||
@GetMapping
|
||||
public List<ExpenseList> getAllLists() {
|
||||
return service.getAllLists();
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ExpenseList createList(@RequestBody ExpenseList list) {
|
||||
return service.createList(list);
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public void deleteList(@PathVariable Long id) {
|
||||
service.deleteList(id);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package de.zendric.app.XpenselyServer.model;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
public class Expense {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
private String description;
|
||||
private Double amount;
|
||||
|
||||
|
||||
@ManyToOne
|
||||
private ExpenseList expenseList;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package de.zendric.app.XpenselyServer.security;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
|
||||
@Configuration
|
||||
public class SecurityConfig {
|
||||
|
||||
@Bean
|
||||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||
http
|
||||
.csrf().disable() // Disable CSRF for testing
|
||||
.authorizeHttpRequests()
|
||||
.anyRequest().permitAll(); // Allow all requests
|
||||
return http.build();
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package de.zendric.app.XpenselyServer.services;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import de.zendric.app.XpenselyServer.model.ExpenseList;
|
||||
import de.zendric.app.XpenselyServer.repo.ExpenseListRepository;
|
||||
|
||||
@Service
|
||||
public class ExpenseListService {
|
||||
@Autowired
|
||||
private ExpenseListRepository repository;
|
||||
|
||||
public List<ExpenseList> getAllLists() {
|
||||
return repository.findAll();
|
||||
}
|
||||
|
||||
public ExpenseList createList(ExpenseList list) {
|
||||
return repository.save(list);
|
||||
}
|
||||
|
||||
public void deleteList(Long id) {
|
||||
repository.deleteById(id);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package de.zendric.app.XpenselyServer;
|
||||
package de.zendric.app.xpensely_server;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@@ -1,4 +1,4 @@
|
||||
package de.zendric.app.XpenselyServer.controller;
|
||||
package de.zendric.app.xpensely_server.controller;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -11,35 +11,39 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import de.zendric.app.XpenselyServer.model.AppUser;
|
||||
import de.zendric.app.XpenselyServer.services.UserService;
|
||||
import de.zendric.app.xpensely_server.model.AppUser;
|
||||
import de.zendric.app.xpensely_server.services.UserService;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/users")
|
||||
public class AppUserController {
|
||||
|
||||
|
||||
private UserService userService;
|
||||
|
||||
|
||||
@Autowired
|
||||
public AppUserController(UserService userService){
|
||||
this.userService= userService;
|
||||
public AppUserController(UserService userService) {
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping
|
||||
public AppUser getUser(@RequestParam Long id){
|
||||
public AppUser getUser(@RequestParam Long id) {
|
||||
return userService.getUser(id);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<AppUser> createUser(@RequestBody AppUser user){
|
||||
AppUser appUser = userService.createUser(user);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(appUser);
|
||||
@GetMapping("/byName")
|
||||
public AppUser getUserByName(@RequestParam String username) {
|
||||
return userService.getUserByName(username);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<AppUser> createUser(@RequestBody AppUser user) {
|
||||
AppUser appUser = userService.createUser(user);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(appUser);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
public String deleteUser(@RequestParam Long id){
|
||||
AppUser user = userService.deleteUserById(id);
|
||||
return "User deleted : "+ user.getUsername();
|
||||
public String deleteUser(@RequestParam Long id) {
|
||||
AppUser user = userService.deleteUserById(id);
|
||||
return "User deleted : " + user.getUsername();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package de.zendric.app.xpensely_server.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import de.zendric.app.xpensely_server.model.Expense;
|
||||
import de.zendric.app.xpensely_server.model.ExpenseList;
|
||||
import de.zendric.app.xpensely_server.services.ExpenseListService;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/expenselist")
|
||||
class ExpenseListController {
|
||||
|
||||
private ExpenseListService expenseListService;
|
||||
|
||||
@Autowired
|
||||
public ExpenseListController(ExpenseListService expenseListService) {
|
||||
this.expenseListService = expenseListService;
|
||||
}
|
||||
|
||||
@GetMapping("/all")
|
||||
public ResponseEntity<List<ExpenseList>> getAll() {
|
||||
try {
|
||||
List<ExpenseList> items = new ArrayList<>();
|
||||
|
||||
expenseListService.findAll().forEach(items::add);
|
||||
|
||||
if (items.isEmpty())
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
|
||||
return new ResponseEntity<>(items, HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/byUser")
|
||||
public ResponseEntity<List<ExpenseList>> getByUser(@RequestParam Long userId) {
|
||||
try {
|
||||
List<ExpenseList> items = expenseListService.findByUserId(userId);
|
||||
|
||||
if (items.isEmpty())
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
|
||||
return new ResponseEntity<>(items, HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/byUsername")
|
||||
public ResponseEntity<List<ExpenseList>> getByUser(@RequestParam String username) {
|
||||
try {
|
||||
List<ExpenseList> items = expenseListService.findByUsername(username);
|
||||
|
||||
if (items.isEmpty())
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
|
||||
return new ResponseEntity<>(items, HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/byId")
|
||||
public ResponseEntity<ExpenseList> getById(@RequestParam Long id) {
|
||||
Optional<ExpenseList> existingItemOptional = expenseListService.findById(id);
|
||||
|
||||
if (existingItemOptional.isPresent()) {
|
||||
return new ResponseEntity<>(existingItemOptional.get(), HttpStatus.OK);
|
||||
} else {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<ExpenseList> create(@RequestBody ExpenseList expenseList) {
|
||||
try {
|
||||
ExpenseList savedItem = (ExpenseList) expenseListService.save(expenseList);
|
||||
return new ResponseEntity<>(savedItem, HttpStatus.CREATED);
|
||||
} catch (Exception e) {
|
||||
return new ResponseEntity<>(null, HttpStatus.EXPECTATION_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("{id}")
|
||||
public ResponseEntity<HttpStatus> delete(@PathVariable("id") Long id) {
|
||||
try {
|
||||
expenseListService.deleteById(id);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
} catch (Exception e) {
|
||||
return new ResponseEntity<>(HttpStatus.EXPECTATION_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/add")
|
||||
public ResponseEntity<Expense> addExpenseToList(
|
||||
@PathVariable("id") Long expenseListId,
|
||||
@RequestBody Expense expense) {
|
||||
try {
|
||||
Expense addedExpense = expenseListService.addExpenseToList(expenseListId, expense);
|
||||
return new ResponseEntity<>(addedExpense, HttpStatus.CREATED);
|
||||
} catch (Exception e) {
|
||||
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}/delete")
|
||||
public ResponseEntity<Expense> deleteExpenseFromList(
|
||||
@PathVariable("id") Long expenseListId,
|
||||
@RequestParam("expenseId") Long expenseId) {
|
||||
try {
|
||||
expenseListService.deleteExpenseFromList(expenseListId, expenseId);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
} catch (Exception e) {
|
||||
return new ResponseEntity<>(null, HttpStatus.EXPECTATION_FAILED);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,24 @@
|
||||
package de.zendric.app.XpenselyServer.model;
|
||||
package de.zendric.app.xpensely_server.model;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
public class AppUser {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "username", nullable = false, unique = true)
|
||||
private String username;
|
||||
private String password;
|
||||
private String email;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package de.zendric.app.xpensely_server.model;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Expense {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
private String title;
|
||||
|
||||
@ManyToOne
|
||||
private AppUser owner;
|
||||
|
||||
private Double amount;
|
||||
private Double deviation;
|
||||
|
||||
private LocalDate date;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "expense_list_id", nullable = false)
|
||||
@JsonBackReference
|
||||
private ExpenseList expenseList;
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
package de.zendric.app.XpenselyServer.model;
|
||||
package de.zendric.app.xpensely_server.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
@@ -10,17 +12,21 @@ import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToMany;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ExpenseList {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
|
||||
private String name;
|
||||
|
||||
@ManyToOne
|
||||
@@ -29,6 +35,18 @@ public class ExpenseList {
|
||||
@ManyToMany
|
||||
private List<AppUser> sharedWith;
|
||||
|
||||
@OneToMany(mappedBy = "expenseList", cascade = CascadeType.ALL)
|
||||
@OneToMany(mappedBy = "expenseList", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
@JsonManagedReference
|
||||
private List<Expense> expenses;
|
||||
|
||||
public void addExpense(Expense expense) {
|
||||
expense.setExpenseList(this);
|
||||
expenses.add(expense);
|
||||
|
||||
}
|
||||
|
||||
public void removeExpense(Expense expense) {
|
||||
expenses.remove(expense);
|
||||
expense.setExpenseList(null);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,13 @@
|
||||
package de.zendric.app.XpenselyServer.repo;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import de.zendric.app.XpenselyServer.model.ExpenseList;
|
||||
package de.zendric.app.xpensely_server.repo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import de.zendric.app.xpensely_server.model.ExpenseList;
|
||||
|
||||
@Repository
|
||||
public interface ExpenseListRepository extends JpaRepository<ExpenseList, Long> {
|
||||
List<ExpenseList> findByOwnerId(Long ownerId);
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
package de.zendric.app.XpenselyServer.repo;
|
||||
package de.zendric.app.xpensely_server.repo;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import de.zendric.app.XpenselyServer.model.Expense;
|
||||
import de.zendric.app.xpensely_server.model.Expense;
|
||||
|
||||
@Repository
|
||||
public interface ExpenseRepository extends JpaRepository<Expense, Long> {}
|
||||
public interface ExpenseRepository extends JpaRepository<Expense, Long> {
|
||||
}
|
||||
@@ -1,9 +1,13 @@
|
||||
package de.zendric.app.XpenselyServer.repo;
|
||||
package de.zendric.app.xpensely_server.repo;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import de.zendric.app.XpenselyServer.model.AppUser;
|
||||
import de.zendric.app.xpensely_server.model.AppUser;
|
||||
|
||||
@Repository
|
||||
public interface UserRepository extends JpaRepository<AppUser, Long> {}
|
||||
public interface UserRepository extends JpaRepository<AppUser, Long> {
|
||||
Optional<AppUser> findByUsername(String username);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package de.zendric.app.xpensely_server.security;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
|
||||
@Configuration
|
||||
public class SecurityConfig {
|
||||
|
||||
@Bean
|
||||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||
http
|
||||
.authorizeHttpRequests(authorize -> authorize
|
||||
.anyRequest().permitAll() // Allow all requests without authentication
|
||||
)
|
||||
.csrf().disable(); // Disable CSRF for development purposes
|
||||
|
||||
return http.build();
|
||||
}
|
||||
|
||||
// @Bean
|
||||
// public SecurityFilterChain securityFilterChain(HttpSecurity http) throws
|
||||
// Exception {
|
||||
// return http.authorizeHttpRequests(auth -> {
|
||||
// auth.requestMatchers("/").permitAll();
|
||||
// auth.anyRequest().permitAll();
|
||||
// // auth.anyRequest().authenticated();
|
||||
// }).oauth2Login(Customizer.withDefaults())
|
||||
// .build();
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package de.zendric.app.xpensely_server.services;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import de.zendric.app.xpensely_server.model.AppUser;
|
||||
import de.zendric.app.xpensely_server.model.Expense;
|
||||
import de.zendric.app.xpensely_server.model.ExpenseList;
|
||||
import de.zendric.app.xpensely_server.repo.ExpenseListRepository;
|
||||
import de.zendric.app.xpensely_server.repo.ExpenseRepository;
|
||||
import jakarta.persistence.EntityManager;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class ExpenseListService {
|
||||
|
||||
private ExpenseListRepository repository;
|
||||
private final ExpenseRepository expenseRepository;
|
||||
|
||||
@Autowired
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Autowired
|
||||
public ExpenseListService(ExpenseListRepository repository, ExpenseRepository expenseRepository) {
|
||||
this.repository = repository;
|
||||
this.expenseRepository = expenseRepository;
|
||||
}
|
||||
|
||||
public List<ExpenseList> getAllLists() {
|
||||
return repository.findAll();
|
||||
}
|
||||
|
||||
public ExpenseList createList(ExpenseList list) {
|
||||
return repository.save(list);
|
||||
}
|
||||
|
||||
public void deleteList(Long id) {
|
||||
repository.deleteById(id);
|
||||
}
|
||||
|
||||
public void deleteById(Long id) {
|
||||
repository.deleteById(id);
|
||||
}
|
||||
|
||||
public Optional<ExpenseList> findById(Long id) {
|
||||
return repository.findById(id);
|
||||
}
|
||||
|
||||
public Iterable<ExpenseList> findAll() {
|
||||
return repository.findAll();
|
||||
}
|
||||
|
||||
public ExpenseList save(ExpenseList expenseList) {
|
||||
return repository.save(expenseList);
|
||||
}
|
||||
|
||||
public List<ExpenseList> findByUserId(Long id) {
|
||||
List<ExpenseList> allLists = repository.findAll();
|
||||
List<ExpenseList> userSpecificList = new ArrayList<>();
|
||||
for (ExpenseList expenseList : allLists) {
|
||||
List<AppUser> sharedWith = expenseList.getSharedWith();
|
||||
|
||||
if (expenseList.getOwner().getId().equals(id)) {
|
||||
userSpecificList.add(expenseList);
|
||||
} else {
|
||||
for (AppUser user : sharedWith) {
|
||||
if (user.getId().equals(id)) {
|
||||
userSpecificList.add(expenseList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return userSpecificList;
|
||||
}
|
||||
|
||||
public List<ExpenseList> findByUsername(String username) {
|
||||
List<ExpenseList> allLists = repository.findAll();
|
||||
List<ExpenseList> userSpecificList = new ArrayList<>();
|
||||
for (ExpenseList expenseList : allLists) {
|
||||
List<AppUser> sharedWith = expenseList.getSharedWith();
|
||||
|
||||
if (expenseList.getOwner().getUsername().equals(username)) {
|
||||
userSpecificList.add(expenseList);
|
||||
} else {
|
||||
for (AppUser user : sharedWith) {
|
||||
if (user.getUsername().equals(username)) {
|
||||
userSpecificList.add(expenseList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return userSpecificList;
|
||||
}
|
||||
|
||||
public Expense addExpenseToList(Long expenseListId, Expense expense) {
|
||||
ExpenseList expenseList = repository.findById(expenseListId)
|
||||
.orElseThrow(() -> new RuntimeException("ExpenseList not found with id: " + expenseListId));
|
||||
HashSet<Long> existingId = new HashSet<>();
|
||||
for (Expense e : expenseList.getExpenses()) {
|
||||
existingId.add(e.getId());
|
||||
}
|
||||
expenseList.addExpense(expense);
|
||||
repository.save(expenseList);
|
||||
Expense newExpense = expense;
|
||||
for (Expense e : expenseList.getExpenses()) {
|
||||
if (!existingId.contains(e.getId())) {
|
||||
newExpense = e;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return newExpense;
|
||||
}
|
||||
|
||||
public void deleteExpenseFromList(Long expenseListId, Long expenseId) {
|
||||
ExpenseList expenseList = repository.findById(expenseListId)
|
||||
.orElseThrow(() -> new RuntimeException("ExpenseList not found with id: " + expenseListId));
|
||||
Expense expenseToRemove = null;
|
||||
for (Expense expense : expenseList.getExpenses()) {
|
||||
if (expense.getId().equals(expenseId)) {
|
||||
expenseToRemove = expense;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (expenseToRemove != null) {
|
||||
expenseList.removeExpense(expenseToRemove);
|
||||
} else {
|
||||
throw new RuntimeException("Expense not found with id: " + expenseId);
|
||||
}
|
||||
repository.save(expenseList);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package de.zendric.app.xpensely_server.services;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import de.zendric.app.xpensely_server.repo.ExpenseRepository;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class ExpenseService {
|
||||
|
||||
@Autowired
|
||||
private ExpenseRepository repository;
|
||||
|
||||
public ExpenseService(ExpenseRepository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
package de.zendric.app.XpenselyServer.services;
|
||||
package de.zendric.app.xpensely_server.services;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import de.zendric.app.XpenselyServer.model.AppUser;
|
||||
import de.zendric.app.XpenselyServer.repo.UserRepository;
|
||||
import de.zendric.app.xpensely_server.model.AppUser;
|
||||
import de.zendric.app.xpensely_server.repo.UserRepository;
|
||||
|
||||
@Service
|
||||
public class UserService {
|
||||
@@ -25,19 +25,27 @@ public class UserService {
|
||||
}
|
||||
|
||||
public AppUser getUser(Long id) {
|
||||
Optional<AppUser> user= userRepository.findById(id);
|
||||
Optional<AppUser> user = userRepository.findById(id);
|
||||
if (user.isPresent()) {
|
||||
return user.get();
|
||||
}
|
||||
else return null;
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
|
||||
public AppUser deleteUserById(Long id) {
|
||||
Optional<AppUser> user= userRepository.findById(id);
|
||||
Optional<AppUser> user = userRepository.findById(id);
|
||||
if (user.isPresent()) {
|
||||
userRepository.deleteById(id);
|
||||
return user.get();
|
||||
}
|
||||
else return null;
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
|
||||
public AppUser getUserByName(String username) {
|
||||
Optional<AppUser> optUser = userRepository.findByUsername(username);
|
||||
if (optUser.isPresent()) {
|
||||
return optUser.get();
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1 +1,16 @@
|
||||
#Server
|
||||
spring.application.name=XpenselyServer
|
||||
|
||||
#Security
|
||||
spring.security.enabled=false
|
||||
#logging.level.org.springframework.security=TRACE
|
||||
|
||||
# PostgreSQL Configuration
|
||||
spring.datasource.url=jdbc:postgresql://localhost:5432/Xpensely
|
||||
spring.datasource.username=${XpenselyDBUser}
|
||||
spring.datasource.password=${XpenselyDBPW}
|
||||
spring.datasource.driver-class-name=org.postgresql.Driver
|
||||
|
||||
# Hibernate configuration
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package de.zendric.app.XpenselyServer;
|
||||
package de.zendric.app.xpensely_Server;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
Reference in New Issue
Block a user