mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-01-23 07:42:23 +01:00
52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
(function () {
|
|
'use strict';
|
|
|
|
// Users service used for communicating with the users REST endpoint
|
|
angular
|
|
.module('requests.services')
|
|
.factory('RequestsCommentsService', RequestsCommentsService);
|
|
|
|
RequestsCommentsService.$inject = ['$resource', 'CacheFactory', 'RequestsService'];
|
|
|
|
function RequestsCommentsService($resource, CacheFactory, RequestsService) {
|
|
var requestsCache = CacheFactory.get('requestsCache') || CacheFactory.createCache('requestsCache');
|
|
var removeCache = function (res) {
|
|
requestsCache.removeAll();
|
|
return new RequestsService(res.resource);
|
|
};
|
|
|
|
var Comments = $resource('/api/reqComments/:requestId/:commentId/:subCommentId', {
|
|
requestId: '@_requestId',
|
|
commentId: '@_commentId',
|
|
subCommentId: '@_subCommentId'
|
|
}, {
|
|
get: {
|
|
method: 'GET',
|
|
cache: requestsCache
|
|
},
|
|
query: {
|
|
method: 'GET',
|
|
cache: requestsCache
|
|
},
|
|
update: {
|
|
method: 'PUT',
|
|
interceptor: {response: removeCache}
|
|
},
|
|
save: {
|
|
method: 'POST',
|
|
interceptor: {response: removeCache}
|
|
},
|
|
remove: {
|
|
method: 'DELETE',
|
|
interceptor: {response: removeCache}
|
|
},
|
|
delete: {
|
|
method: 'DELETE',
|
|
interceptor: {response: removeCache}
|
|
}
|
|
});
|
|
|
|
return Comments;
|
|
}
|
|
}());
|