use of com.viadee.sonarQuest.entities.Quest 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 com.viadee.sonarQuest.entities.Quest 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 com.viadee.sonarQuest.entities.Quest 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 com.viadee.sonarQuest.entities.Quest 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 com.viadee.sonarQuest.entities.Quest in project sonarQuest by viadee.
the class QuestController method deleteWorld.
@RequestMapping(value = "/{questId}/deleteWorld", method = RequestMethod.DELETE)
public void deleteWorld(@PathVariable(value = "questId") final Long questId) {
final Quest quest = this.questRepository.findOne(questId);
if (quest != null) {
quest.setWorld(null);
this.questRepository.save(quest);
}
}
Aggregations