var angular = require('angular');
require('../modules');

var module = angular.module('flow.services');

module.factory('WorkflowService', function($http) {

  var WorkflowService = {
    /**
     * 获取流程信息
     *
     * @param  {String} userId   流程处理人员
     * @param  {String} flowType 流程类型
     * @param  {String} recordId 业务数据id
     * @param  {Number} subflag  流程状态位
     * @return {Promise}
     */
    getWorkFlowInfo: function(userId, flowType, recordId, subflag) {
      return $http({
        method: 'GET',
        url: '/workflow/workFlowParam',
        params: {
          flowType: flowType,
          recordId: recordId,
          subflag: subflag,
          userId: userId
        },
        timeout: 15000
      }).then(function(response) {
        return response.data;
      });
    },

    getQueryWorkFlowInfoUrl: function(userId, flowType, recordId, subflag) {
      return '/workflow/workFlowParam?userId=' + userId + '&flowType=' + flowType + '&recordId=' + recordId +
        '&subflag=' + subflag;
    }
  };

  return WorkflowService;
});
