'use strict';

var angular = require('angular');
require('../modules');
  
  var module = angular.module('archivesincept.services');

module.factory('ArchivesInceptService', function(
    BaseDataServiceFactory, LinkerService, $http) {
	var ArchivesInceptService = BaseDataServiceFactory.generate({
		name: 'archivesincept',
		baseUrl: '/archives/incept',
		idPropertyName: 'id',
		subflagPropertyName: 'xiugai',
		flowType: 'xiugai'
	});

    ArchivesInceptService.signin = function(archivesincept){
      var userId = LinkerService.currentUserId;
      return $http.put('/archives/incept/' + userId +'/'+ archivesincept.id, {
        timeout: 15000
      }).then(function(response) {
        return response;
      });
    };

    ArchivesInceptService.returnback = function(archivesincept){
      var userId = LinkerService.currentUserId;
      return $http.post('/archives/incept/returnback', {
        userId: userId,
        id: archivesincept.id,
        reasonDocbackCal: archivesincept.reasonDocbackCal
      });
    };

    ArchivesInceptService.wanbi = function(archivesincept){
      return $http.post('/archives/incept/update/' + archivesincept.id, {
        timeout: 15000
      }).then(function(response) {
        return response;
      });
    };

    ArchivesInceptService.insertSW = function(archivesincept){
      var userId = LinkerService.currentUserId;
      return $http.post('/archives/incept/insertSW/' + userId + '/'+archivesincept.id, {
        timeout: 15000
      });
    };

	return ArchivesInceptService;
});
