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.FeePlease;
import com.uas.platform.b2b.mobile.model.FeePleaseDetail;
import com.uas.platform.b2b.mobile.service.FeePleaseService;

/**
 * 出差申请
 * 
 * @author hejq
 * @time 创建时间：2017年2月23日
 */
@Controller("mobile.FeePleaseController")
@RequestMapping("/mobile/feePlease")
public class FeePleaseController {

	@Autowired
	private FeePleaseService feePleaseService;

	/**
	 * 保存出差申请单
	 * 
	 * @param formStore
	 * @param gridStore
	 * @return
	 */
	@RequestMapping(value = "/saveFeePlease", method = RequestMethod.POST)
	@ResponseBody
	private ModelMap saveFeePlease(String formStore, String gridStore) {
		FeePlease feePlease = JSONObject.parseObject(formStore, FeePlease.class);
		List<FeePleaseDetail> feePleaseDetails = JSONObject.parseArray(gridStore, FeePleaseDetail.class);
		return feePleaseService.saveFeePlease(feePlease, feePleaseDetails);
	}

	/**
	 * 获取出差申请单
	 * 
	 * @param enuu
	 * @param emcode
	 * @param pageNumber
	 * @param pageSize
	 * @return
	 */
	@RequestMapping(value = "/getFeePlease", method = RequestMethod.GET)
	@ResponseBody
	private ModelMap getFeePlease(Long enuu, Long emcode, Integer pageNumber, Integer pageSize) {
		return feePleaseService.getFeePlease(enuu, emcode, pageNumber, pageSize);
	}
		
}
