package com.blueland.ebpm.rest;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.blueland.bpm.engine.core.model.ProcessDefinitionModel;
import com.blueland.bpm.engine.core.model.SearchProcessListDTO;
import com.blueland.bpm.engine.core.service.ProcessDefinitionService;
import com.blueland.ebpm.bean.BeansBuilder;
import com.blueland.ebpm.bean.ProcessDefinitionBean;

@RestController
@RequestMapping("/query")
public class ObjectQueryController {

	@Autowired
	private BeansBuilder beansBuilder;
	
	@Autowired
	private ProcessDefinitionService processDefinitionService;
	
	@RequestMapping(value = "/procdeflist",  method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
	public List<ProcessDefinitionBean> queryProcList(@RequestBody SearchProcessListDTO query) {
		List<ProcessDefinitionModel> result = processDefinitionService.findProcessDefs(query);
		return beansBuilder.buildProcDefList(result);
	}
	
	/*
	 * @ResponseBody
	 * 
	 * @RequestMapping(value = "/todolist", method = RequestMethod.POST, produces =
	 * "application/json;charset=UTF-8") public Page<ActivityInstanceBean>
	 * queryToDoList(
	 * 
	 * @RequestBody SearchProcessListDTO query) { if(query.getPageNumber() == 0)
	 * query.setPageSize(10); Page<ActivityInstanceModel> page = processListService
	 * .queryTodoList(query); return beansBuilder.buildActInstPage(page); }
	 * 
	 * @ResponseBody
	 * 
	 * @RequestMapping(value = "/zaibanlist", method = RequestMethod.POST, produces
	 * = "application/json;charset=UTF-8") public Page<ActivityInstanceBean>
	 * queryZaibanList(
	 * 
	 * @RequestBody SearchProcessListDTO query) { if(query.getPageNumber() == 0)
	 * query.setPageSize(10); Page<ActivityInstanceModel> page = processListService
	 * .queryZaibanList(query); return beansBuilder.buildActInstPage(page); }
	 * 
	 * @ResponseBody//2.6
	 * 
	 * @RequestMapping(value="/finishlist", method=RequestMethod.POST,
	 * produces="application/json;charset=UTF-8") public Page<ProcessInstanceBean>
	 * queryFinishList(@RequestBody SearchProcessListDTO query){
	 * if(query.getPageNumber() == 0) query.setPageSize(10);
	 * Page<ProcessInstanceModel> page = processListService.queryFinishList(query);
	 * return beansBuilder.buildInstProcPage(page); }
	 */
}
