package com.revature.controllers;

import com.revature.domain.Eval;
import com.revature.services.EvalLogic;

import java.util.ArrayList;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/api/v1/")
public class EvalController {

	@Autowired
	private EvalLogic evalLogic;

	@RequestMapping(method = RequestMethod.GET, value = "evaluations/{id}")
	public ResponseEntity<Eval> getEvaluation(@PathVariable("id") Integer id) {

		return ResponseEntity.ok(evalLogic.getEvalById(id));
	}

	@RequestMapping(method = RequestMethod.GET, value = "batches/{id}/week/{num}")
	public ResponseEntity<ArrayList<Eval>> getEvalsByWeek(@PathVariable("id") Integer id, @PathVariable("num") Integer num, @RequestParam(defaultValue="both") String type){
		return ResponseEntity.ok(evalLogic.getEvalsByWeek(id,num,type));
	}
	
	@RequestMapping(method = RequestMethod.GET, value = "batches/{id}")
	public ResponseEntity<ArrayList<Eval>> getEvalsByBatch(@PathVariable("id") Integer id, @RequestParam(defaultValue="both") String type){
		return ResponseEntity.ok(evalLogic.getEvalsByBatch(id,type));
	}
	
	@RequestMapping(method = RequestMethod.GET, value = "trainees/{id}")
	public ResponseEntity<ArrayList<Eval>> getEvalsByPerson(@PathVariable("id") Integer id, @RequestParam(defaultValue="both") String type){
		return ResponseEntity.ok(evalLogic.getEvalsByPerson(id,type));
	}
	
	@RequestMapping(method = RequestMethod.GET, value = "trainees/{id}/week/{num}")
	public ResponseEntity<ArrayList<Eval>> getTraineeEvalsByWeek(@PathVariable("id") Integer id, @PathVariable("num") Integer num, @RequestParam(defaultValue="both") String type){
		return ResponseEntity.ok(evalLogic.getPersonEvalsByWeek(id,num,type));
	}
}

@@ -602,16 +602,27 @@
 /api/v1/
+evaluations
 %22)%0Apubli
@@ -744,27 +744,16 @@
 alue = %22
-evaluations
 /%7Bid%7D%22)%0A

update url mapping for batches/{id}