package com.uas.platform.b2b.mobile.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.uas.platform.b2b.mobile.model.Vacation;
import com.uas.platform.b2b.mobile.service.VacationService;

/**
 * 请假单
 * 
 * @author hejq
 * @time 创建时间：2017年2月23日
 */
@Controller("mobile.VacationController")
@RequestMapping("/mobile/vacation")
public class VacationController {

	@Autowired
	private VacationService vacationService;

	/**
	 * 获取请假单列表
	 * 
	 * @param emcode
	 * @param pageNumber
	 * @param pageSize
	 * @param enuu
	 * @return
	 */
	@RequestMapping(value = "/getAllVacation", method = RequestMethod.GET)
	@ResponseBody
	private ModelMap getAllVacation(Long emcode, Integer pageNumber, Integer pageSize, Long enuu) {
		return vacationService.getAllVacation(emcode, pageNumber, pageSize, enuu);
	}

	/**
	 * 保存请假单
	 * 
	 * @param enuu
	 * @param formStore
	 * @return
	 */
	@RequestMapping(value = "/saveVacation", method = RequestMethod.POST)
	@ResponseBody
	private ModelMap saveVacation(String formStore) {
		Vacation vacation = JSONObject.parseObject(formStore, Vacation.class);
		return vacationService.saveVacation(vacation);
	}
}
