package cokr.xit.fims.wpm.web;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import cokr.xit.fims.wpm.service.WoopyonMoaService;
import cokr.xit.foundation.web.AbstractController;

@Controller
@RequestMapping("/woopyonmoa")
public class WoopyonMoaController extends AbstractController {
	@Resource(name = "woopyonMoaService")
	private WoopyonMoaService woopyonMoaService;

	@PostMapping(name="발송정보 업데이트", value="/update.do")
	public ModelAndView updateStatus(MultipartFile upload) {
		try {
			int affected = woopyonMoaService.updateStatus(upload.getInputStream());
			return new ModelAndView("jsonView")
				.addObject("affected", affected)
				.addObject("saved", affected > 0);
		} catch (Exception e) {
			throw runtimeException(e);
		}
	}
}