Compare commits
	
		
			1 Commits
		
	
	
		
			0000-Toolt
			...
			1300-Termi
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| bfbcd5c44b | 
@@ -1,8 +1,10 @@
 | 
			
		||||
package com.vpr.server;
 | 
			
		||||
 | 
			
		||||
import org.springframework.data.jpa.repository.Modifying;
 | 
			
		||||
import org.springframework.data.jpa.repository.Query;
 | 
			
		||||
import org.springframework.data.repository.CrudRepository;
 | 
			
		||||
 | 
			
		||||
import javax.transaction.Transactional;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
// This will be AUTO IMPLEMENTED by Spring into a Bean called eventRepository
 | 
			
		||||
@@ -29,4 +31,17 @@ public interface EventRepository extends CrudRepository<Event, Integer> {
 | 
			
		||||
            "WHERE ue.user_id = ?1",
 | 
			
		||||
            nativeQuery = true)
 | 
			
		||||
    Object[] findAllByUserId(long id);
 | 
			
		||||
 | 
			
		||||
    @Modifying
 | 
			
		||||
    @Transactional
 | 
			
		||||
    @Query(value = "DELETE ue FROM user_event ue WHERE ue.event_id = ?1",
 | 
			
		||||
    nativeQuery = true)
 | 
			
		||||
    void deleteUserEventsById(long id);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Modifying
 | 
			
		||||
    @Transactional
 | 
			
		||||
    @Query(value = "DELETE e FROM event e WHERE e.id = ?1",
 | 
			
		||||
            nativeQuery = true)
 | 
			
		||||
    void deleteById(long id);
 | 
			
		||||
}
 | 
			
		||||
@@ -110,6 +110,13 @@ public class MainController {
 | 
			
		||||
        return "Saved";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @PostMapping(path="/del-event")
 | 
			
		||||
    public @ResponseBody String addEvent ( @RequestParam Integer eventId ) {
 | 
			
		||||
        eventRepository.deleteUserEventsById(Long.valueOf(eventId));
 | 
			
		||||
        eventRepository.deleteById(Long.valueOf(eventId));
 | 
			
		||||
        return "Deleted";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // GET-request at /all-users
 | 
			
		||||
    // returns JSON-data
 | 
			
		||||
    @GetMapping(path="/all-users")
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user