package com.bizofficer.apiweb.mycourses;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Service
public class MyCoursesController {
	
	@Autowired
	private MyCoursesService cclsObj;

	@Value("${rowsInPage}")
	private Integer rowsInPage;
	
	//// mycourses?organisationId=1&studentId=1
	@SuppressWarnings("unchecked")
	@RequestMapping(value = {"/mycourses"}, method = RequestMethod.GET)
	public ResponseEntity<Object> execute(@ModelAttribute("SpringWeb")MCBean objBean) {
		
		try {
			
			List<MyCoursesBean> list = (List<MyCoursesBean>) (Object) cclsObj.doExecute(objBean);
			
			HttpHeaders headers = new HttpHeaders();
	        ////headers.add("Responded", "UserController");
	        return ResponseEntity.ok().headers(headers).body(list);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
	}
	

	
	
}
