package com.bizofficer.subscription.courses;

import org.springframework.beans.factory.annotation.Autowired;
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 CourseDetailsController {
	
	@Autowired
	private CourseDetailsService serviceObj;
	
	@RequestMapping(value = {"/web-coursedetails"}, method = {RequestMethod.GET})
	public ResponseEntity<Object> execute(@ModelAttribute("SpringWeb")ACoursesBean objBean) {
		
		try {
			
			CourseDetailsResponseBean tsrbObj = (CourseDetailsResponseBean) serviceObj.execute(objBean);
			
			///System.out.println("CoursesController ResponseTxt: "+tsrbObj.getResponseTxt());
			
			HttpHeaders headers = new HttpHeaders();
	        ////headers.add("Responded", "UserController");
	        return ResponseEntity.ok().headers(headers).body(tsrbObj);
			
		} catch (Exception e) {
			e.printStackTrace();
			/////return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e);
		}
		
		return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
	}
	

	
	
}
