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

import java.util.List;

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.WorkOvertime;
import com.uas.platform.b2b.mobile.model.WorkOvertimeDet;
import com.uas.platform.b2b.mobile.service.WorkOvertimeService;

/**
 * 加班申请
 * 
 * @author hejq
 * @time 创建时间：2017年2月23日
 */
@Controller("mobile.WorkOvertimeController")
@RequestMapping("/mobile/workOvertime")
public class WorkOvertimeController {

	@Autowired
	private WorkOvertimeService workOvertimeService;
	
	/**
	 * 保存加班申请
	 * 
	 * @param formStore
	 * @param gridStore
	 * @return
	 */
	@RequestMapping(value = "/saveWorkOvertime", method = RequestMethod.POST)
	@ResponseBody
	private ModelMap saveWorkOvertime(String formStore, String gridStore) {
		WorkOvertime workOvertime = JSONObject.parseObject(formStore, WorkOvertime.class);
		List<WorkOvertimeDet> workOvertimeDets = JSONObject.parseArray(gridStore, WorkOvertimeDet.class);
		return workOvertimeService.saveWorkOvertime(workOvertime, workOvertimeDets);
	}

	/**
	 * 获取加班申请
	 * 
	 * @param enuu
	 * @param emcode
	 * @param pageNumber
	 * @param pageSize
	 * @return
	 */
	@RequestMapping(value = "/getWorkOvertime", method = RequestMethod.GET)
	@ResponseBody
	private ModelMap getWorkOvertime(Long enuu, Long emcode, Integer pageNumber, Integer pageSize) {
		return workOvertimeService.getWorkOvertime(enuu, emcode, pageNumber, pageSize);
	}
}
