package com.sinosig.activiti.resource;

import com.alibaba.fastjson.JSONObject;
import com.sinosig.activiti.service.IWFCoreService;
import org.activiti.api.task.model.Task;
import org.activiti.bpmn.model.SequenceFlow;
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 java.util.List;


@RestController
public class WFCoreResource {

    @Autowired
    IWFCoreService wfCoreService;

    /**
     * 工作流启动
     */
    @RequestMapping(method = RequestMethod.POST, value = "/wfstart")
    public JSONObject wfStart(@RequestBody JSONObject et){
        return wfCoreService.wfStart(et);
    }

    /**
     * 工作流提交处理
     */
    @RequestMapping(method = RequestMethod.POST, value = "/wfsubmit")
    public JSONObject wfSubmit(@RequestBody JSONObject et){
        return wfCoreService.wfSubmit(et);
    }


    /**
     * 工作流跳转
     */
    @RequestMapping(method = RequestMethod.POST, value = "/wfgoto")
    public String wfGoto(@RequestBody JSONObject et){
        return wfCoreService.wfGoto(et);
    }

    /**
     * 工作流关闭
     */
    @RequestMapping(method = RequestMethod.POST, value = "/wfclose")
    public JSONObject wfClose(@RequestBody JSONObject et){
        return wfCoreService.wfClose(et);
    }


    /**
     * 工作流重新启动
     */
    @RequestMapping(method = RequestMethod.POST, value = "/wfrestart")
    public String wfRestart(@RequestBody JSONObject et){
        return wfCoreService.wfRestart(et);
    }

    /**
     * 工作流撤回
     */
    @RequestMapping(method = RequestMethod.POST, value = "/wfrollback")
    public String wfRollback(@RequestBody JSONObject et){
        return wfCoreService.wfRollback(et);
    }

    /**
     * 工作流退回
     */
    @RequestMapping(method = RequestMethod.POST, value = "/wfsendback")
    public String wfSendBack(@RequestBody JSONObject et){
        return wfCoreService.wfSendBack(et);
    }

    /**
     * 工作流重新分配（处理人）
     */
    @RequestMapping(method = RequestMethod.POST, value = "/wfreassign")
    public String wfReassign(@RequestBody JSONObject et){
        return  wfCoreService.wfReassign(et);
    }

    /**
     * 工作流标记为已读
     */
    @RequestMapping(method = RequestMethod.POST, value = "/wfmarkread")
    public void wfMarkRead(@RequestBody JSONObject et){
        wfCoreService.wfMarkRead(et);
    }

    /**
     * 工作流部署
     */
    @RequestMapping(method = RequestMethod.POST, value = "/wfdeploy")
    public JSONObject wfDeploy(@RequestBody JSONObject et){
        return wfCoreService.wfDeploy(et);
    }

    /**
     * 获取当前用户待办
     */
    @RequestMapping(method = RequestMethod.POST, value = "/wfcurstep")
    public List<Task> getWFCurStep(@RequestBody JSONObject et){
        return wfCoreService.getWFCurStep(et);
    }

    /**
     * 获取流程历史步骤
     */
    @RequestMapping(method = RequestMethod.POST, value = "/wfhisstep")
    public List<Task> getWFHisStep(@RequestBody JSONObject et){
        return wfCoreService.getWFHisStep(et);
    }

    /**
     * 获取下一步路径
     */
    @RequestMapping(method = RequestMethod.POST, value = "/wfnextstep")
    public List<SequenceFlow> getWFNextStep(@RequestBody JSONObject et){
        return wfCoreService.getWFNextStep(et);
    }
}
