Search in sources :

Example 1 with OapiProcessinstanceGetRequest

use of com.dingtalk.api.request.OapiProcessinstanceGetRequest in project dingtalk-app-server by nju-softeng.

the class OAApi method getOAOutCome.

public int getOAOutCome(String processInstanceId) {
    try {
        DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/processinstance/get");
        OapiProcessinstanceGetRequest req = new OapiProcessinstanceGetRequest();
        req.setProcessInstanceId(processInstanceId);
        OapiProcessinstanceGetResponse rsp = client.execute(req, getAccessToken());
        if (rsp.getProcessInstance().getStatus().equals("COMPLETED")) {
            if (rsp.getProcessInstance().getResult().equals("agree"))
                return 1;
            else
                return 0;
        } else
            return -1;
    } catch (Exception e) {
        throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage());
    }
}
Also used : DefaultDingTalkClient(com.dingtalk.api.DefaultDingTalkClient) OapiProcessinstanceGetResponse(com.dingtalk.api.response.OapiProcessinstanceGetResponse) OapiProcessinstanceGetRequest(com.dingtalk.api.request.OapiProcessinstanceGetRequest) DefaultDingTalkClient(com.dingtalk.api.DefaultDingTalkClient) DingTalkClient(com.dingtalk.api.DingTalkClient) ResponseStatusException(org.springframework.web.server.ResponseStatusException) ApiException(com.taobao.api.ApiException) ResponseStatusException(org.springframework.web.server.ResponseStatusException)

Aggregations

DefaultDingTalkClient (com.dingtalk.api.DefaultDingTalkClient)1 DingTalkClient (com.dingtalk.api.DingTalkClient)1 OapiProcessinstanceGetRequest (com.dingtalk.api.request.OapiProcessinstanceGetRequest)1 OapiProcessinstanceGetResponse (com.dingtalk.api.response.OapiProcessinstanceGetResponse)1 ApiException (com.taobao.api.ApiException)1 ResponseStatusException (org.springframework.web.server.ResponseStatusException)1