package de.oaa.xxx.games.chastity.community;

import java.util.UUID;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/games/chastity/community/pillory")
public class CommunityPilloryController {

	private CommunityPilloryRepository repo;

	public CommunityPilloryController(CommunityPilloryRepository repo) {
		this.repo = repo;
	
	}
	
    @GetMapping("/{id}")
    public ResponseEntity<CommunityPilloryDTO> getPillory(@PathVariable UUID id) {
    	var pillory = repo.findById(id);
    	if (pillory.isPresent()) {
    		return ResponseEntity.ok(pillory.get().toPillory());
    	}
    	return ResponseEntity.notFound().build();
    }
}
