package com.revature.controllers;

import org.omg.CORBA.PUBLIC_MEMBER;
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.RestController;

import com.revature.domain.Batch;
import com.revature.services.BatchLogic;

@RestController
@RequestMapping(value = "/api/v1/")
public class BatchController {
	
	@Autowired
	private BatchLogic batchLogic;
	
	@RequestMapping(method = RequestMethod.GET, value = "/batch/{id}")
	
		public ResponseEntity<Batch> getBatch(@PathVariable("id") String id){
			
			try{
				int value = Integer.parseInt(id);
				return ResponseEntity.ok(batchLogic.getBatchById(value));
				
			} catch(NumberFormatException e){
				
				return ResponseEntity.ok(batchLogic.getBatchByName(id));
			}
			
		} 
		
	
	
	
}

@@ -32,44 +32,8 @@
 s;%0A%0A
-import org.omg.CORBA.PUBLIC_MEMBER;%0A
 impo
@@ -91,16 +91,16 @@
 owired;%0A
+
 import o
@@ -423,16 +423,51 @@
 .Batch;%0A
+import com.revature.domain.Person;%0A
 import c
@@ -629,16 +629,60 @@
 hLogic;%0A
+%09private PersonBatchLogic personBatchLogic;%0A
 %09%0A%09@Requ
@@ -1054,16 +1054,253 @@
 %09%09%7D %0A%09%09%0A
-
 %09%0A
+%09@RequestMapping(method = RequestMethod.GET, value = %22/batch/%7Bid%7D/members%22)%0A%09%0A%09%09public ResponseEntity%3CPerson%3EgetAllBatchMembers(@PathVariable(%22id%22) int id)%7B%0A%09%09%0A%09%09%09return Responsibility.ok(personBatchLogic.getAllBatchMembers(id));%0A%09%09%7D%0A%09%7D%0A
 %09%0A%09%0A%7D%0A

add @RequestMapping for /batch/{id}/members