use of com.viadee.sonarQuest.entities.Developer in project sonarQuest by viadee.
the class DeveloperController method getDeveloperByID.
/**
* Get a Developer by Id
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public DeveloperDto getDeveloperByID(@PathVariable(value = "id") Long id) {
Developer developer = this.developerRepository.findById(id);
DeveloperDto developerDto = null;
if (developer != null) {
developerDto = this.toDeveloperDto(developer);
}
return developerDto;
}
use of com.viadee.sonarQuest.entities.Developer in project sonarQuest by viadee.
the class DeveloperController method deleteDeveloper.
@CrossOrigin
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public void deleteDeveloper(@PathVariable(value = "id") Long id) {
Developer developer = developerRepository.findById(id);
developerService.deleteDeveloper(developer);
}
use of com.viadee.sonarQuest.entities.Developer in project sonarQuest by viadee.
the class DeveloperController method updateDeveloper.
@CrossOrigin
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
public DeveloperDto updateDeveloper(@PathVariable(value = "id") Long id, @RequestBody DeveloperDto developerDto) {
Developer developer = developerRepository.findById(id);
if (developer != null) {
developer.setGold((developerDto.getGold()));
developer.setXp(developerDto.getXp());
developer.setLevel(this.levelService.getLevelByDeveloperXp(developer.getXp()));
developer.setPicture(developerDto.getPicture());
developer.setAboutMe(developerDto.getAboutMe());
developer.setAvatarClass(developerDto.getAvatarClass());
developer.setAvatarRace(developerDto.getAvatarRace());
developer.setArtefacts(developerDto.getArtefacts());
developer = this.developerRepository.save(developer);
}
return this.toDeveloperDto(developer);
}
use of com.viadee.sonarQuest.entities.Developer in project sonarQuest by viadee.
the class WorldController method getCurrentWorld.
@CrossOrigin
@RequestMapping(value = "/developer/{developer_id}", method = RequestMethod.GET)
public WorldDto getCurrentWorld(@PathVariable(value = "developer_id") Long developer_id) {
Developer d = this.developerRepository.findById(developer_id);
World w = this.worldService.getCurrentWorld(d);
return toWorldDto(w);
}
use of com.viadee.sonarQuest.entities.Developer in project sonarQuest by viadee.
the class AdventureService method addDeveloperToAdventure.
/**
* Add a developer to adventure
* @param adventureId
* @param developerId
* @return adventure
*/
public Adventure addDeveloperToAdventure(long adventureId, long developerId) {
Adventure adventure = adventureRepository.findOne(adventureId);
final Developer developer = developerRepository.findOne(developerId);
if (adventure != null && developer != null) {
final List<Developer> developerList = adventure.getDevelopers();
if (!developerList.contains(developer)) {
developerList.add(developer);
}
adventure.setDevelopers(developerList);
adventure = adventureRepository.save(adventure);
}
return adventure;
}
Aggregations