package com.leanwo.activiti.rest.base;

import javax.inject.Inject;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.leanwo.activiti.dto.BaseRangeResponse;
import com.leanwo.activiti.dto.BaseResponse;
import com.leanwo.activiti.dto.base.TaskDto;
import com.leanwo.activiti.service.base.MTaskService;

@RestController
@RequestMapping("/workflow-prodog/MTaskResource")
public class MTaskResource {
	
	@Inject
	private MTaskService mTaskService;
	
	/**
	 * 根据类别查询任务
	 * 
	 * @param assigneeId 任务执行人
	 * @param category 任务的类别
	 * @return
	 */
	@RequestMapping(value = "/listByAssigneeIdCategory", method = RequestMethod.GET, consumes = "application/json", produces = "application/json")
	public BaseRangeResponse<TaskDto> listByAssigneeIdCategory(@RequestParam(value = "assigneeId") String assigneeId, @RequestParam(value = "category") String category) {
		return mTaskService.listByAssigneeIdCategory(assigneeId, category);
	}
	

	/**
	 * 完成任务
	 * 
	 * @param assigneeId 任务执行人
	 * @param taskId 任务id
	 * @return
	 */
	@RequestMapping(value = "/finishTask", method = RequestMethod.GET, consumes = "application/json", produces = "application/json")
	public BaseResponse finishTask(@RequestParam(value = "assigneeId") String assigneeId, @RequestParam(value = "taskId") String taskId){
		return mTaskService.finishTask(assigneeId, taskId);
	}
	
	
}
