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.WorkDaily;
import com.uas.platform.b2b.mobile.service.WorkDailyService;

/**
 * 工作日报
 * 
 * @author hejq
 * @time 创建时间：2017年2月22日
 */
@Controller("mobile.WorkDailyController")
@RequestMapping("/mobile/workDaily")
public class WorkDailyController {

	@Autowired
	private WorkDailyService workDailyService;

	/**
	 * 保存工作日报
	 * 
	 * @param formStore
	 * @return
	 */
	@RequestMapping(value = "/saveWorkDaily", method = RequestMethod.POST)
	@ResponseBody
	private ModelMap saveWorkDaily(String formStore) {
		WorkDaily workDaily = JSONObject.parseObject(formStore, WorkDaily.class);
		return workDailyService.saveWorkDaily(workDaily);

	}

	/**
	 * 获取工作日报
	 * 
	 * @param emcode
	 * @param pageNumber
	 * @param pageSize
	 * @param enuu
	 * @return
	 */
	@RequestMapping(value = "/getWorkDaily", method = RequestMethod.GET)
	@ResponseBody
	private ModelMap getWorkDaily(Long emcode, Integer pageNumber, Integer pageSize, Long enuu) {
		return workDailyService.getWorkDaily(emcode, pageNumber, pageSize, enuu);
	}

	/**
	 * 删除工作日报
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/deleteById", method = RequestMethod.POST)
	@ResponseBody
	private ModelMap deleteById(Long id) {
		return workDailyService.deleteById(id);
	}

	/**
	 * 通过id查看详情
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "getWorkDailyById", method = RequestMethod.GET)
	@ResponseBody
	private WorkDaily getById(Long id) {
		return workDailyService.getById(id);
	}
}
