package kcg.imis.nation.web;

import javax.annotation.Resource;

import kcg.imis.nation.service.NationService;
import kcg.imis.nation.vo.NationVO;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
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.RequestParam;

/**
  * @FileName : NationController.java
  * @Project : 국제해양프로젝트
  * @Date : 2018. 4. 11. 
  * @작성자 : Moon
  * @변경이력 : 
  * @프로그램 설명 :
 */
@Controller
@RequestMapping("/nation")
public class NationController {
	
	@Resource(name = "nationService")
	private NationService nationService;

	@RequestMapping(value = "/info.do", method = RequestMethod.GET)
	public String info(final Model model, @RequestParam(value="seq") String naSeq) {
		
		try {
			model.addAttribute("nation", nationService.getNationInfo(naSeq));
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return "nation/nationInfo.tiles";
	}
	
	@RequestMapping(value = "/update.do", method = RequestMethod.POST)
	public String updateNation(final Model model,  @ModelAttribute("reportVO") final NationVO nationVO) {
		
		try {
			nationService.updateNation(nationVO);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return "redirect:/nation/info.do?seq="+nationVO.getNaSeq();
	}
	
	
}
