use of org.springframework.web.bind.annotation.CrossOrigin in project sonarQuest by viadee.
the class QuestController method deleteQuest.
@CrossOrigin
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public void deleteQuest(@PathVariable(value = "id") final Long id) {
final Quest quest = this.questRepository.findOne(id);
if (quest != null) {
final List<Task> tasks = quest.getTasks();
tasks.forEach(task -> task.setStatus(TaskStates.CREATED));
this.questRepository.delete(quest);
}
}
use of org.springframework.web.bind.annotation.CrossOrigin in project sonarQuest by viadee.
the class QuestController method addAdventure.
@CrossOrigin
@RequestMapping(value = "/{questId}/addAdventure/{adventureId}", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
public QuestDto addAdventure(@PathVariable(value = "questId") final Long questId, @PathVariable(value = "adventureId") final Long adventureId) {
Quest quest = this.questRepository.findOne(questId);
if (quest != null) {
final Adventure adventure = this.adventureRepository.findOne(adventureId);
quest.setAdventure(adventure);
quest = this.questRepository.save(quest);
}
return toQuestDto(quest);
}
use of org.springframework.web.bind.annotation.CrossOrigin in project sonarQuest by viadee.
the class QuestController method deleteAdventure.
@CrossOrigin
@RequestMapping(value = "/{questId}/removeAdventure", method = RequestMethod.DELETE)
public void deleteAdventure(@PathVariable(value = "questId") final Long questId) {
final Quest quest = this.questRepository.findOne(questId);
if (quest != null) {
quest.setAdventure(null);
this.questRepository.save(quest);
}
}
use of org.springframework.web.bind.annotation.CrossOrigin in project sonarQuest by viadee.
the class QuestController method updateQuest.
@CrossOrigin
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
public Quest updateQuest(@PathVariable(value = "id") final Long id, @RequestBody final QuestDto questDto) {
Quest quest = this.questRepository.findOne(id);
if (quest != null) {
quest.setTitle(questDto.getTitle());
quest.setGold(questDto.getGold());
quest.setXp(questDto.getXp());
quest.setStory(questDto.getStory());
quest.setImage(questDto.getImage());
quest = this.questRepository.save(quest);
}
return quest;
}
use of org.springframework.web.bind.annotation.CrossOrigin in project sonarQuest by viadee.
the class TaskController method updateStandardTasksForWorld.
@CrossOrigin
@RequestMapping(value = "/updateStandardTasks/{worldId}", method = RequestMethod.GET)
public List<TaskDto> updateStandardTasksForWorld(@PathVariable(value = "worldId") final Long worldId) {
final World world = worldRepository.findOne(worldId);
List<TaskDto> taskDtos = null;
if (world != null) {
standardTaskService.updateStandardTasks(world);
final List<Task> savedTasks = taskRepository.findAll();
taskDtos = savedTasks.stream().map(task -> toTaskDto(task)).collect(Collectors.toList());
}
return taskDtos;
}
Aggregations