package com.bizofficer.apiweb.treeview;

import java.util.List;

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 LearningTreeviewPageController {
	
	@Autowired
	private LearningTreeviewPageService cclsObj;

	////learning-treeview?templateId=1
	@SuppressWarnings("unchecked")
	@RequestMapping(value = {"/learning-treeview"}, method = RequestMethod.GET)
	public ResponseEntity<Object> execute(@ModelAttribute("SpringWeb")TreeviewBean objBean) {
		
		try {
			
			List<TreeviewPageBean> list = (List<TreeviewPageBean>) (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);
	}
	

	
	
}
