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.PathVariable;
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.JSON;
import com.uas.platform.b2b.mobile.model.WorkData;
import com.uas.platform.b2b.mobile.service.WorkDataService;

@Controller("mobile.workDataController")
@RequestMapping("/mobile/workData")
public class WorkDataController {

	@Autowired
	private WorkDataService workDataService;

	/**
	 * 获取员工工作时间
	 * 
	 * @param enuu
	 * @return
	 */
	@RequestMapping(value = "/getWorkData", method = RequestMethod.GET)
	@ResponseBody
	private ModelMap getWorkData(Long enuu) {
		return workDataService.getWorkDataByEnuu(enuu);
	};

	/**
	 * 通过id删除工作时间设置
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/deleteById/{id}", method = RequestMethod.POST)
	@ResponseBody
	private ModelMap deleteById(@PathVariable Long id) {
		return workDataService.deleteById(id);
	};

	/**
	 * 设置员工班次
	 * 
	 * @param formStore
	 * @return
	 */
	@RequestMapping(value = "/saveWorkData", method = RequestMethod.POST)
	@ResponseBody
	private ModelMap saveWorkData(String formStore) {
		WorkData workData = JSON.parseObject(formStore, WorkData.class);
		return workDataService.saveWorkData(workData);
	}
}
