Game calendar working
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
package com.mattrixwv.raidbuilder.controller;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
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.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.mattrixwv.raidbuilder.annotation.AccountAuthorization;
|
||||
import com.mattrixwv.raidbuilder.annotation.GameAuthorization;
|
||||
import com.mattrixwv.raidbuilder.entity.GameCalendarEvent;
|
||||
import com.mattrixwv.raidbuilder.service.GameCalendarEventService;
|
||||
import com.mattrixwv.raidbuilder.util.DatabaseTypeUtil.AccountPermissionType;
|
||||
import com.mattrixwv.raidbuilder.util.DatabaseTypeUtil.GamePermissionType;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/calendar")
|
||||
@RequiredArgsConstructor
|
||||
public class CalendarController{
|
||||
private final ObjectMapper mapper;
|
||||
private final GameCalendarEventService gceService;
|
||||
|
||||
|
||||
@GetMapping("/game/{gameId}")
|
||||
@AccountAuthorization(permissions = {AccountPermissionType.ADMIN, AccountPermissionType.USER})
|
||||
public List<GameCalendarEvent> getGameCalendarEvents(@PathVariable("gameId") UUID gameId){
|
||||
log.info("Getting calendar events for game {}", gameId);
|
||||
|
||||
|
||||
return gceService.getByGameId(gameId);
|
||||
}
|
||||
|
||||
@PostMapping("/game/{gameId}")
|
||||
@AccountAuthorization(permissions = {AccountPermissionType.ADMIN, AccountPermissionType.USER})
|
||||
@GameAuthorization(permissions = {GamePermissionType.ADMIN})
|
||||
public ObjectNode createGameCalendarEvent(@PathVariable("gameId") UUID gameId, @RequestBody GameCalendarEvent gameCalendarEvent){
|
||||
log.info("Creating calendar event for game {}", gameId);
|
||||
|
||||
|
||||
gameCalendarEvent.setGameId(gameId);
|
||||
gceService.createGameCalendarEvent(gameCalendarEvent);
|
||||
|
||||
ObjectNode returnNode = mapper.createObjectNode();
|
||||
returnNode.put("status", "success");
|
||||
|
||||
return returnNode;
|
||||
}
|
||||
|
||||
@PutMapping("/game/{gameId}")
|
||||
@AccountAuthorization(permissions = {AccountPermissionType.ADMIN, AccountPermissionType.USER})
|
||||
@GameAuthorization(permissions = {GamePermissionType.ADMIN})
|
||||
public ObjectNode updateGameCalendarEvent(@PathVariable("gameId") UUID gameId, @RequestBody GameCalendarEvent gameCalendarEvent){
|
||||
log.info("Updating calendar event for game {}", gameId);
|
||||
|
||||
|
||||
gameCalendarEvent.setGameId(gameId);
|
||||
gceService.updateGameCalendarEvent(gameCalendarEvent);
|
||||
|
||||
ObjectNode returnNode = mapper.createObjectNode();
|
||||
returnNode.put("status", "success");
|
||||
|
||||
return returnNode;
|
||||
}
|
||||
|
||||
@DeleteMapping("/game/{gameId}/{calendarEventId}")
|
||||
@AccountAuthorization(permissions = {AccountPermissionType.ADMIN, AccountPermissionType.USER})
|
||||
@GameAuthorization(permissions = {GamePermissionType.ADMIN})
|
||||
public ObjectNode deleteGameCalendarEvent(@PathVariable("gameId") UUID gameId, @PathVariable("calendarEventId") UUID calendarEventId){
|
||||
log.info("Deleting calendar event for game {}", gameId);
|
||||
|
||||
|
||||
gceService.deleteGameCalendarEvent(calendarEventId);
|
||||
|
||||
ObjectNode returnNode = mapper.createObjectNode();
|
||||
returnNode.put("status", "success");
|
||||
|
||||
return returnNode;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user