'use strict';

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

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

module.factory('MeetRemoteService', function($http, CoreAppConfig) {
  var service = {};
  service.get = function(weekFlag, date) {
    var path;
    if (CoreAppConfig.getAppId() === 'ggfw') {
      path = '/yzhy/list';
    } else if (CoreAppConfig.getAppId() === 'qhzx') {
      path = '/yzhy/listOfQhzx';
    } else if (CoreAppConfig.getAppId() === 'qxzx') {
      path = '/yzhy/listOfQxzx';
    } else if(CoreAppConfig.getAppId() === 'cqqx') {
      path = '/yzhy/cqqx/list';
    } else if (CoreAppConfig.getAppId()) {
      path = '/yzhy/list';
    }

    if(_.isEmpty(weekFlag) ) {
      return $http.get(path + '?lastOrNext&date', {
        timeout: 15000
      }).then(function(response) {
        return response.data;
      });
    } else {
      return $http.get(path + '?lastOrNext=' + weekFlag + '&date=' + date, {
        timeout: 15000
      }).then(function(response) {
        return response.data;
      });
    }
  }

  return service;
});
