Backend migrated to springboot from firebase

This commit is contained in:
2026-06-30 12:24:30 +05:30
parent 6c2de40239
commit 31fcc27658
44 changed files with 3055 additions and 1 deletions

View File

@@ -0,0 +1,39 @@
package com.rit.ems.controller;
import com.rit.ems.model.Venue;
import com.rit.ems.repository.VenueRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
import java.util.Random;
@RestController
@RequestMapping("/api/venues")
public class VenueController {
@Autowired
private VenueRepository venueRepository;
@GetMapping
public List<Venue> getAllVenues() {
return venueRepository.findAll();
}
@PostMapping
public ResponseEntity<?> createVenue(@RequestBody Venue venue) {
if (venue.getId() == null) {
venue.setId("v-" + (System.currentTimeMillis() + new Random().nextInt(1000)));
}
venueRepository.save(venue);
return ResponseEntity.ok(venue);
}
@DeleteMapping("/{id}")
public ResponseEntity<?> deleteVenue(@PathVariable String id) {
venueRepository.deleteById(id);
return ResponseEntity.ok(Map.of("message", "Venue deleted successfully"));
}
}