controllers added
This commit is contained in:
parent
15718aa186
commit
1c8050bdff
@ -2,6 +2,8 @@ package de.roko.archiv.kibubackend.controller;
|
||||
|
||||
import de.roko.archiv.kibubackend.model.Archiv;
|
||||
import de.roko.archiv.kibubackend.repository.ArchivRepository;
|
||||
import de.roko.archiv.kibubackend.service.ArchivService;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
@ -12,14 +14,11 @@ import java.util.List;
|
||||
public class ArchivController {
|
||||
|
||||
private final ArchivRepository archivRepository;
|
||||
private final ArchivService archivService;
|
||||
|
||||
public ArchivController(ArchivRepository archivRepository) {
|
||||
public ArchivController(ArchivRepository archivRepository, ArchivService archivService) {
|
||||
this.archivRepository = archivRepository;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public List<Archiv> getAll() {
|
||||
return archivRepository.findAll();
|
||||
this.archivService = archivService;
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@ -27,4 +26,33 @@ public class ArchivController {
|
||||
return archivRepository.save(archiv);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public List<Archiv> getAll() {
|
||||
return archivRepository.findAll();
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<Archiv> getById(@PathVariable Long id) {
|
||||
return archivService.findById(id)
|
||||
.map(ResponseEntity::ok)
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public ResponseEntity<Archiv> update(@PathVariable Long id, @RequestBody Archiv updatedArchiv) {
|
||||
updatedArchiv.setId(id);
|
||||
return ResponseEntity.ok(archivService.save(updatedArchiv));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Void> delete(@PathVariable Long id) {
|
||||
|
||||
if(archivRepository.existsById(id)) {
|
||||
archivRepository.deleteById(id);
|
||||
return ResponseEntity.noContent().build();
|
||||
}else {
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,59 @@
|
||||
package de.roko.archiv.kibubackend.controller;
|
||||
|
||||
import de.roko.archiv.kibubackend.model.Bild;
|
||||
import de.roko.archiv.kibubackend.service.BildService;
|
||||
import de.roko.archiv.kibubackend.service.OrtService;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("api/bilder")
|
||||
public class BildController {
|
||||
|
||||
private final BildService bildService;
|
||||
|
||||
public BildController(BildService bildService) {
|
||||
this.bildService = bildService;
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<Bild> create(@RequestBody Bild bild) {
|
||||
return ResponseEntity.ok(bildService.save(bild));
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<List<Bild>> getAll() {
|
||||
return bildService.findAll();
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<Bild> getById(@PathVariable Long id) {
|
||||
return bildService.findById(id)
|
||||
.map(ResponseEntity::ok)
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public ResponseEntity<Bild> update(@PathVariable Long id, @RequestBody Bild updatedBild) {
|
||||
return bildService.findById(id)
|
||||
.map(existing -> {
|
||||
updatedBild.setId(id);
|
||||
return ResponseEntity.ok(bildService.save(updatedBild));
|
||||
})
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Bild> delete(@PathVariable Long id) {
|
||||
|
||||
if(bildService.findById(id).isPresent()) {
|
||||
bildService.deleteById(id);
|
||||
return ResponseEntity.noContent().build();
|
||||
}else {
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
package de.roko.archiv.kibubackend.controller;
|
||||
|
||||
import de.roko.archiv.kibubackend.model.Buch;
|
||||
import de.roko.archiv.kibubackend.service.BuchService;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("api/buecher")
|
||||
public class BuchController {
|
||||
|
||||
private final BuchService buchService;
|
||||
|
||||
public BuchController(BuchService buchService) {
|
||||
this.buchService = buchService;
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<Buch> create(@RequestBody Buch buch) {
|
||||
return ResponseEntity.ok(buchService.save(buch));
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public List<Buch> getAll() {
|
||||
return buchService.findAll();
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<Buch> getById(@PathVariable Long id) {
|
||||
return buchService.findById(id)
|
||||
.map(ResponseEntity::ok)
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public ResponseEntity<Buch> update(@PathVariable Long id, @RequestBody Buch updatedBuch) {
|
||||
return buchService.findById(id)
|
||||
.map(existing -> {
|
||||
updatedBuch.setId(id); // ID setzen für die Aktualisierung
|
||||
return ResponseEntity.ok(buchService.save(updatedBuch)); // updatedBuch speichern!
|
||||
})
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Void> delete(@PathVariable Long id) {
|
||||
|
||||
if(buchService.findById(id).isPresent()) {
|
||||
buchService.deleteById(id);
|
||||
return ResponseEntity.noContent().build();
|
||||
} else {
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
package de.roko.archiv.kibubackend.controller;
|
||||
|
||||
import de.roko.archiv.kibubackend.model.Ort;
|
||||
import de.roko.archiv.kibubackend.service.OrtService;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("api/orte")
|
||||
public class OrtController {
|
||||
|
||||
public final OrtService ortService;
|
||||
|
||||
|
||||
public OrtController(OrtService ortService) {
|
||||
this.ortService = ortService;
|
||||
}
|
||||
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<Ort> create(@RequestBody Ort ort) {
|
||||
return ResponseEntity.ok(ortService.save(ort));
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<List<Ort>> getAll() {
|
||||
return ortService.findAll();
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<Ort> getById(@RequestParam Long id) {
|
||||
return ortService.findById(id)
|
||||
.map(ResponseEntity::ok)
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public ResponseEntity<Ort> update(@PathVariable Long id, @RequestBody Ort updatedOrt) {
|
||||
return ortService.findById(id)
|
||||
.map(existing -> {
|
||||
updatedOrt.setId(id);
|
||||
return ResponseEntity.ok(ortService.save(updatedOrt));
|
||||
})
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Void> delete(@PathVariable Long id) {
|
||||
|
||||
if(ortService.findById(id).isPresent()) {
|
||||
ortService.deleteById(id);
|
||||
return ResponseEntity.noContent().build();
|
||||
}else {
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
package de.roko.archiv.kibubackend.controller;
|
||||
|
||||
import de.roko.archiv.kibubackend.model.Seite;
|
||||
import de.roko.archiv.kibubackend.service.OrtService;
|
||||
import de.roko.archiv.kibubackend.service.SeiteService;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("api/seiten")
|
||||
public class SeiteController {
|
||||
|
||||
private final SeiteService seiteService;
|
||||
private final OrtService ortService;
|
||||
|
||||
public SeiteController(SeiteService seiteService, OrtService ortService) {
|
||||
this.seiteService = seiteService;
|
||||
this.ortService = ortService;
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<Seite> createSeite(@RequestBody Seite seite) {
|
||||
return ResponseEntity.ok((seiteService.save(seite)));
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<List<Seite>> getAll() {
|
||||
return seiteService.findAll();
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<Seite> getSeiteById(@PathVariable Long id) {
|
||||
return seiteService.findById(id)
|
||||
.map(ResponseEntity::ok)
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public ResponseEntity<Seite> updateSeite(@PathVariable Long id, @RequestBody Seite updatedSeite) {
|
||||
updatedSeite.setId(id);
|
||||
return ResponseEntity.ok(seiteService.save(updatedSeite));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Seite> deleteSeite(@PathVariable Long id) {
|
||||
ortService.deleteById(id);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
|
||||
}
|
||||
@ -16,4 +16,44 @@ public class Bild {
|
||||
|
||||
private int tileX;
|
||||
private int tileY;
|
||||
|
||||
public int getTileY() {
|
||||
return tileY;
|
||||
}
|
||||
|
||||
public void setTileY(int tileY) {
|
||||
this.tileY = tileY;
|
||||
}
|
||||
|
||||
public int getTileX() {
|
||||
return tileX;
|
||||
}
|
||||
|
||||
public void setTileX(int tileX) {
|
||||
this.tileX = tileX;
|
||||
}
|
||||
|
||||
public Seite getSeite() {
|
||||
return seite;
|
||||
}
|
||||
|
||||
public void setSeite(Seite seite) {
|
||||
this.seite = seite;
|
||||
}
|
||||
|
||||
public String getDateiname() {
|
||||
return dateiname;
|
||||
}
|
||||
|
||||
public void setDateiname(String dateiname) {
|
||||
this.dateiname = dateiname;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,4 +18,43 @@ public class Buch {
|
||||
|
||||
private String typ;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTitel() {
|
||||
return titel;
|
||||
}
|
||||
|
||||
public void setTitel(String titel) {
|
||||
this.titel = titel;
|
||||
}
|
||||
|
||||
public String getLink() {
|
||||
return link;
|
||||
}
|
||||
|
||||
public void setLink(String link) {
|
||||
this.link = link;
|
||||
}
|
||||
|
||||
public Ort getOrt() {
|
||||
return ort;
|
||||
}
|
||||
|
||||
public void setOrt(Ort ort) {
|
||||
this.ort = ort;
|
||||
}
|
||||
|
||||
public String getTyp() {
|
||||
return typ;
|
||||
}
|
||||
|
||||
public void setTyp(String typ) {
|
||||
this.typ = typ;
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,4 +13,28 @@ public class Ort {
|
||||
|
||||
@ManyToOne
|
||||
private Kreis kreis;
|
||||
|
||||
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 Kreis getKreis() {
|
||||
return kreis;
|
||||
}
|
||||
|
||||
public void setKreis(Kreis kreis) {
|
||||
this.kreis = kreis;
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,4 +15,36 @@ public class Seite {
|
||||
private Buch buch;
|
||||
|
||||
private String meta;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getSeitenNummer() {
|
||||
return seitenNummer;
|
||||
}
|
||||
|
||||
public void setSeitenNummer(int seitenNummer) {
|
||||
this.seitenNummer = seitenNummer;
|
||||
}
|
||||
|
||||
public Buch getBuch() {
|
||||
return buch;
|
||||
}
|
||||
|
||||
public void setBuch(Buch buch) {
|
||||
this.buch = buch;
|
||||
}
|
||||
|
||||
public String getMeta() {
|
||||
return meta;
|
||||
}
|
||||
|
||||
public void setMeta(String meta) {
|
||||
this.meta = meta;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
package de.roko.archiv.kibubackend.service;
|
||||
|
||||
import de.roko.archiv.kibubackend.model.Archiv;
|
||||
import de.roko.archiv.kibubackend.repository.ArchivRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class ArchivService {
|
||||
|
||||
private final ArchivRepository archivRepository;
|
||||
|
||||
public ArchivService(ArchivRepository archivRepository) {
|
||||
this.archivRepository = archivRepository;
|
||||
}
|
||||
|
||||
public Archiv save(Archiv archiv) {
|
||||
return archivRepository.save(archiv);
|
||||
}
|
||||
|
||||
|
||||
public Optional<Archiv> findById(Long id) {
|
||||
return archivRepository.findById(id);
|
||||
}
|
||||
|
||||
public void deleteById(Long id) {
|
||||
archivRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package de.roko.archiv.kibubackend.service;
|
||||
|
||||
import de.roko.archiv.kibubackend.model.Bild;
|
||||
import de.roko.archiv.kibubackend.repository.BildRepository;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class BildService {
|
||||
|
||||
private final BildRepository bildRepository;
|
||||
|
||||
public BildService(BildRepository bildRepository) {
|
||||
this.bildRepository = bildRepository;
|
||||
}
|
||||
|
||||
public Bild save(Bild bild) {
|
||||
return bildRepository.save(bild);
|
||||
}
|
||||
|
||||
public ResponseEntity<List<Bild>> findAll() {
|
||||
return ResponseEntity.ok(bildRepository.findAll());
|
||||
}
|
||||
|
||||
public Optional<Bild> findById(Long id) {
|
||||
return bildRepository.findById(id);
|
||||
}
|
||||
|
||||
public void deleteById(Long id) {
|
||||
bildRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package de.roko.archiv.kibubackend.service;
|
||||
|
||||
import de.roko.archiv.kibubackend.model.Buch;
|
||||
import de.roko.archiv.kibubackend.repository.BuchRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class BuchService {
|
||||
|
||||
private final BuchRepository buchRepository;
|
||||
|
||||
public BuchService(BuchRepository buchRepository) {
|
||||
this.buchRepository = buchRepository;
|
||||
}
|
||||
|
||||
public Buch save(Buch buch) {
|
||||
return buchRepository.save(buch);
|
||||
}
|
||||
|
||||
public List<Buch> findAll() {
|
||||
return buchRepository.findAll();
|
||||
}
|
||||
|
||||
public Optional<Buch> findById(Long id) {
|
||||
return buchRepository.findById(id);
|
||||
}
|
||||
|
||||
public void deleteById(Long id) {
|
||||
buchRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package de.roko.archiv.kibubackend.service;
|
||||
|
||||
import de.roko.archiv.kibubackend.model.Buch;
|
||||
import de.roko.archiv.kibubackend.model.Ort;
|
||||
import de.roko.archiv.kibubackend.repository.OrtRepository;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class OrtService {
|
||||
|
||||
private final OrtRepository ortRepository;
|
||||
|
||||
public OrtService(OrtRepository ortRepository) {
|
||||
this.ortRepository = ortRepository;
|
||||
}
|
||||
|
||||
public Ort save(Ort ort) {
|
||||
return ortRepository.save(ort);
|
||||
}
|
||||
|
||||
public ResponseEntity<List<Ort>> findAll() {
|
||||
return ResponseEntity.ok(ortRepository.findAll());
|
||||
}
|
||||
|
||||
public Optional<Ort> findById(Long id) {
|
||||
return ortRepository.findById(id);
|
||||
}
|
||||
|
||||
public void deleteById(Long id) {
|
||||
ortRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package de.roko.archiv.kibubackend.service;
|
||||
|
||||
import de.roko.archiv.kibubackend.model.Seite;
|
||||
import de.roko.archiv.kibubackend.repository.SeiteRepository;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class SeiteService {
|
||||
|
||||
private final SeiteRepository seiteRpository;
|
||||
|
||||
public SeiteService(SeiteRepository seiteRpository) {
|
||||
this.seiteRpository = seiteRpository;
|
||||
}
|
||||
|
||||
public Seite save(Seite seite) {
|
||||
return seiteRpository.save(seite);
|
||||
}
|
||||
|
||||
public ResponseEntity<List<Seite>> findAll() {
|
||||
return ResponseEntity.ok(seiteRpository.findAll());
|
||||
}
|
||||
|
||||
public Optional<Seite> findById(Long id) {
|
||||
return seiteRpository.findById(id);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user