feat(core): write all returned data from $resource to cache

This commit is contained in:
OldHawk
2018-05-02 14:10:53 +08:00
parent 7959d23a54
commit ee5124759d
25 changed files with 351 additions and 78 deletions

View File

@@ -5,12 +5,23 @@
.module('about.services')
.factory('MakerGroupService', MakerGroupService);
MakerGroupService.$inject = ['$resource'];
MakerGroupService.$inject = ['$resource', 'CacheFactory'];
function MakerGroupService($resource, CacheFactory) {
var makerCache = CacheFactory.get('makerCache') || CacheFactory.createCache('makerCache');
function MakerGroupService($resource) {
return $resource('/api/makers/:makerId', {
makerId: '@_id'
}, {
get: {
method: 'GET',
cache: makerCache
},
query: {
method: 'GET',
isArray: true,
cache: makerCache
},
update: {
method: 'PUT'
},

View File

@@ -6,12 +6,23 @@
.module('backup.services')
.factory('BackupService', BackupService);
BackupService.$inject = ['$resource'];
BackupService.$inject = ['$resource', 'CacheFactory'];
function BackupService($resource, CacheFactory) {
var backupCache = CacheFactory.get('backupCache') || CacheFactory.createCache('backupCache');
function BackupService($resource) {
var backup = $resource('/api/backup/:filename', {
filename: '@filename'
}, {
get: {
method: 'GET',
cache: backupCache
},
query: {
method: 'GET',
isArray: true,
cache: backupCache
},
update: {
method: 'PUT'
}

View File

@@ -6,12 +6,23 @@
.module('collections.services')
.factory('CollectionsService', CollectionsService);
CollectionsService.$inject = ['$resource'];
CollectionsService.$inject = ['$resource', 'CacheFactory'];
function CollectionsService($resource, CacheFactory) {
var collectionsCache = CacheFactory.get('collectionsCache') || CacheFactory.createCache('collectionsCache');
function CollectionsService($resource) {
var collection = $resource('/api/collections/:collectionId', {
collectionId: '@_id'
}, {
get: {
method: 'GET',
cache: collectionsCache
},
query: {
method: 'GET',
isArray: true,
cache: collectionsCache
},
update: {
method: 'PUT'
},

View File

@@ -194,7 +194,7 @@
angular.extend(CacheFactoryProvider.defaults, {
maxAge: cacheConfig.maxAge,
recycleFreq: cacheConfig.recycleFreq,
deleteOnExpire: 'aggressive',
deleteOnExpire: 'aggressive'
});
}

View File

@@ -1349,6 +1349,7 @@
BTN_CURR_EXAMINATION_STATUS: 'Curr examination status',
BTN_BAN_ALL_UNFINISHED: 'Ban all unfinished users',
EXAMINATION_STATUS: 'Examination status',
EXAMINATION_USERS: 'Users list',
ALL_USER: 'Total: <strong>{{all_user}}</strong> users',
FINISHED_USER: 'Finished: <strong>{{finished_user}}</strong> users',
UNFINISHED_USER: 'Unfinished: <strong>{{unfinished_user}}</strong> users',

View File

@@ -1349,6 +1349,7 @@
BTN_CURR_EXAMINATION_STATUS: '当前考核的数据状态',
BTN_BAN_ALL_UNFINISHED: '禁止掉所有未完成考核的帐户',
EXAMINATION_STATUS: '考核状态',
EXAMINATION_USERS: '用户列表',
ALL_USER: '参考用户: <strong>{{all_user}}</strong> 人',
FINISHED_USER: '考核已完成用户: <strong>{{finished_user}}</strong> 人',
UNFINISHED_USER: '考核未完成用户: <strong>{{unfinished_user}}</strong> 人',

View File

@@ -5,12 +5,23 @@
.module('forums.services')
.factory('ForumsAdminService', ForumsAdminService);
ForumsAdminService.$inject = ['$resource'];
ForumsAdminService.$inject = ['$resource', 'CacheFactory'];
function ForumsAdminService($resource, CacheFactory) {
var forumsCache = CacheFactory.get('forumsCache') || CacheFactory.createCache('forumsCache');
function ForumsAdminService($resource) {
return $resource('/api/admin/forums/:forumId', {
forumId: '@_id'
}, {
get: {
method: 'GET',
cache: forumsCache
},
query: {
method: 'GET',
isArray: true,
cache: forumsCache
},
update: {
method: 'PUT'
},
@@ -37,12 +48,23 @@
.module('forums.services')
.factory('ForumsService', ForumsService);
ForumsService.$inject = ['$resource'];
ForumsService.$inject = ['$resource', 'CacheFactory'];
function ForumsService($resource, CacheFactory) {
var forumsCache = CacheFactory.get('forumsCache') || CacheFactory.createCache('forumsCache');
function ForumsService($resource) {
return $resource('/api/forums/:forumId', {
forumId: '@_id'
}, {
get: {
method: 'GET',
cache: forumsCache
},
query: {
method: 'GET',
isArray: true,
cache: forumsCache
},
update: {
method: 'PUT'
},

View File

@@ -5,14 +5,24 @@
.module('forums.services')
.factory('RepliesService', RepliesService);
RepliesService.$inject = ['$resource'];
RepliesService.$inject = ['$resource', 'CacheFactory'];
function RepliesService($resource, CacheFactory) {
var forumsCache = CacheFactory.get('forumsCache') || CacheFactory.createCache('forumsCache');
function RepliesService($resource) {
return $resource('/api/topics/:forumId/:topicId/:replyId', {
forumId: '@forum',
topicId: '@topic',
replyId: '@_id'
}, {
get: {
method: 'GET',
cache: forumsCache
},
query: {
method: 'GET',
cache: forumsCache
},
update: {
method: 'PUT'
}

View File

@@ -5,20 +5,31 @@
.module('forums.services')
.factory('TopicsService', TopicsService);
TopicsService.$inject = ['$resource'];
TopicsService.$inject = ['$resource', 'CacheFactory'];
function TopicsService($resource, CacheFactory) {
var forumsCache = CacheFactory.get('forumsCache') || CacheFactory.createCache('forumsCache');
function TopicsService($resource) {
return $resource('/api/topics/:forumId/:topicId', {
forumId: '@forum',
topicId: '@_id'
}, {
get: {
method: 'GET',
cache: forumsCache
},
query: {
method: 'GET',
cache: forumsCache
},
update: {
method: 'PUT'
},
getGlobalTopics: {
method: 'GET',
url: '/api/globalTopics',
isArray: true
isArray: true,
cache: forumsCache
},
toggleTopicReadonly: {
method: 'PUT',
@@ -72,17 +83,20 @@
getHomeHelp: {
method: 'GET',
url: '/api/topics/getHomeHelpTopic',
isArray: true
isArray: true,
cache: forumsCache
},
getHomeNotice: {
method: 'GET',
url: '/api/topics/getHomeNoticeTopic',
isArray: true
isArray: true,
cache: forumsCache
},
getHomeNewTopic: {
method: 'GET',
url: '/api/topics/getHomeNewTopic',
isArray: true
isArray: true,
cache: forumsCache
}
});
}

View File

@@ -5,12 +5,23 @@
.module('invitations.services')
.factory('InvitationsService', InvitationsService);
InvitationsService.$inject = ['$resource'];
InvitationsService.$inject = ['$resource', 'CacheFactory'];
function InvitationsService($resource, CacheFactory) {
var invitationsCache = CacheFactory.get('invitationsCache') || CacheFactory.createCache('invitationsCache');
function InvitationsService($resource) {
return $resource('/api/invitations/:invitationId', {
invitationId: '@_id'
}, {
get: {
method: 'GET',
cache: invitationsCache
},
query: {
method: 'GET',
isArray: true,
cache: invitationsCache
},
update: {
method: 'PUT'
},
@@ -32,7 +43,8 @@
listOfficial: {
method: 'GET',
url: '/api/invitations/official/list',
isArray: true
isArray: true,
cache: invitationsCache
},
deleteExpiredOfficialInvitation: {
method: 'DELETE',

View File

@@ -5,12 +5,23 @@
.module('messages.services')
.factory('AdminMessagesService', AdminMessagesService);
AdminMessagesService.$inject = ['$resource'];
AdminMessagesService.$inject = ['$resource', 'CacheFactory'];
function AdminMessagesService($resource, CacheFactory) {
var messagesCache = CacheFactory.get('messagesCache') || CacheFactory.createCache('messagesCache');
function AdminMessagesService($resource) {
return $resource('/api/adminMessages/:adminMessageId', {
adminMessageId: '@_adminMessageId'
}, {
get: {
method: 'GET',
cache: messagesCache
},
query: {
method: 'GET',
isArray: true,
cache: messagesCache
},
update: {
method: 'PUT'
}

View File

@@ -5,12 +5,22 @@
.module('messages.services')
.factory('MessagesService', MessagesService);
MessagesService.$inject = ['$resource'];
MessagesService.$inject = ['$resource', 'CacheFactory'];
function MessagesService($resource, CacheFactory) {
var messagesCache = CacheFactory.get('messagesCache') || CacheFactory.createCache('messagesCache');
function MessagesService($resource) {
return $resource('/api/messages/:messageId', {
messageId: '@_messageId'
}, {
get: {
method: 'GET',
cache: messagesCache
},
query: {
method: 'GET',
cache: messagesCache
},
update: {
method: 'PUT'
},

View File

@@ -6,12 +6,23 @@
.module('ranking.services')
.factory('RankingService', RankingService);
RankingService.$inject = ['$resource'];
RankingService.$inject = ['$resource', 'CacheFactory'];
function RankingService($resource, CacheFactory) {
var rankingCache = CacheFactory.get('rankingCache') || CacheFactory.createCache('rankingCache');
function RankingService($resource) {
return $resource('/api/ranking', {
userId: '@_id'
}, {
get: {
method: 'GET',
cache: rankingCache
},
query: {
method: 'GET',
isArray: true,
cache: rankingCache
},
update: {
method: 'PUT'
}

View File

@@ -6,14 +6,24 @@
.module('requests.services')
.factory('RequestsCommentsService', RequestsCommentsService);
RequestsCommentsService.$inject = ['$resource'];
RequestsCommentsService.$inject = ['$resource', 'CacheFactory'];
function RequestsCommentsService($resource, CacheFactory) {
var requestsCache = CacheFactory.get('requestsCache') || CacheFactory.createCache('requestsCache');
function RequestsCommentsService($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'
}

View File

@@ -5,12 +5,22 @@
.module('requests.services')
.factory('RequestsService', RequestsService);
RequestsService.$inject = ['$resource'];
RequestsService.$inject = ['$resource', 'CacheFactory'];
function RequestsService($resource, CacheFactory) {
var requestsCache = CacheFactory.get('requestsCache') || CacheFactory.createCache('requestsCache');
function RequestsService($resource) {
return $resource('/api/requests/:requestId', {
requestId: '@_id'
}, {
get: {
method: 'GET',
cache: requestsCache
},
query: {
method: 'GET',
cache: requestsCache
},
update: {
method: 'PUT'
},

View File

@@ -5,34 +5,50 @@
.module('systems.services')
.factory('SystemsService', SystemsService);
SystemsService.$inject = ['$resource'];
SystemsService.$inject = ['$resource', 'CacheFactory'];
function SystemsService($resource, CacheFactory) {
var systemsCache = CacheFactory.get('systemsCache') || CacheFactory.createCache('systemsCache');
function SystemsService($resource) {
return $resource('/api/systems/:systemId', {
requestId: '@_id'
}, {
get: {
method: 'GET',
cache: systemsCache
},
query: {
method: 'GET',
isArray: true,
cache: systemsCache
},
update: {
method: 'PUT'
},
getSystemEnvConfigFiles: {
method: 'GET',
url: '/api/systems/systemEnvConfigFiles'
url: '/api/systems/systemEnvConfigFiles',
cache: systemsCache
},
getSystemAssetsConfigFiles: {
method: 'GET',
url: '/api/systems/systemAssetsConfigFiles'
url: '/api/systems/systemAssetsConfigFiles',
cache: systemsCache
},
getSystemTransConfigFiles: {
method: 'GET',
url: '/api/systems/systemTransConfigFiles'
url: '/api/systems/systemTransConfigFiles',
cache: systemsCache
},
getSystemTemplateFrontConfigFiles: {
method: 'GET',
url: '/api/systems/systemTemplateFrontConfigFiles'
url: '/api/systems/systemTemplateFrontConfigFiles',
cache: systemsCache
},
getSystemTemplateBackConfigFiles: {
method: 'GET',
url: '/api/systems/systemTemplateBackConfigFiles'
url: '/api/systems/systemTemplateBackConfigFiles',
cache: systemsCache
},
getSystemConfigContent: {
method: 'GET',
@@ -52,15 +68,18 @@
},
getExaminationStatus: {
method: 'GET',
url: '/api/systems/getExaminationStatus'
url: '/api/systems/getExaminationStatus',
cache: systemsCache
},
listFinishedUsers: {
method: 'GET',
url: '/api/systems/listFinishedUsers'
url: '/api/systems/listFinishedUsers',
cache: systemsCache
},
listUnfinishedUsers: {
method: 'GET',
url: '/api/systems/listUnfinishedUsers'
url: '/api/systems/listUnfinishedUsers',
cache: systemsCache
},
banAllUnfinishedUser: {
method: 'PUT',

View File

@@ -61,7 +61,7 @@
<div id="top_of_status_list">
<div class="panel panel-default panel-users" ng-if="vm.showStatusUsers">
<div class="panel-heading" translate="SYSTEMS.EXAMINATION_STATUS"></div>
<div class="panel-heading" translate="SYSTEMS.EXAMINATION_USERS"></div>
<div class="table-responsive">
<ul uib-pagination boundary-links="true" max-size="8" items-per-page="vm.itemsPerPage" total-items="vm.filterLength"
ng-model="vm.currentPage"

View File

@@ -5,13 +5,23 @@
.module('tickets.services')
.factory('MessageTicketsService', MessageTicketsService);
MessageTicketsService.$inject = ['$resource'];
MessageTicketsService.$inject = ['$resource', 'CacheFactory'];
function MessageTicketsService($resource, CacheFactory) {
var ticketsCache = CacheFactory.get('ticketsCache') || CacheFactory.createCache('ticketsCache');
function MessageTicketsService($resource) {
return $resource('/api/messageTickets/:messageTicketId/:replyId', {
messageTicketId: '@_id',
replyId: '@_rid'
}, {
get: {
method: 'GET',
cache: ticketsCache
},
query: {
method: 'GET',
cache: ticketsCache
},
update: {
method: 'PUT'
},
@@ -40,12 +50,22 @@
.module('tickets.services')
.factory('MailTicketsService', MailTicketsService);
MailTicketsService.$inject = ['$resource'];
MailTicketsService.$inject = ['$resource', 'CacheFactory'];
function MailTicketsService($resource, CacheFactory) {
var ticketsCache = CacheFactory.get('ticketsCache') || CacheFactory.createCache('ticketsCache');
function MailTicketsService($resource) {
return $resource('/api/mailTickets/:mailTicketId', {
mailTicketId: '@_id'
}, {
get: {
method: 'GET',
cache: ticketsCache
},
query: {
method: 'GET',
cache: ticketsCache
},
update: {
method: 'PUT'
},

View File

@@ -6,14 +6,24 @@
.module('torrents.services')
.factory('CommentsService', CommentsService);
CommentsService.$inject = ['$resource'];
CommentsService.$inject = ['$resource', 'CacheFactory'];
function CommentsService($resource, CacheFactory) {
var commentsCache = CacheFactory.get('commentsCache') || CacheFactory.createCache('commentsCache');
function CommentsService($resource) {
var Comments = $resource('/api/comments/:torrentId/:commentId/:subCommentId', {
torrentId: '@_torrentId',
commentId: '@_commentId',
subCommentId: '@_subCommentId'
}, {
get: {
method: 'GET',
cache: commentsCache
},
query: {
method: 'GET',
cache: commentsCache
},
update: {
method: 'PUT'
}

View File

@@ -6,12 +6,23 @@
.module('torrents.services')
.factory('CompleteService', CompleteService);
CompleteService.$inject = ['$resource'];
CompleteService.$inject = ['$resource', 'CacheFactory'];
function CompleteService($resource, CacheFactory) {
var completesCache = CacheFactory.get('completesCache') || CacheFactory.createCache('completesCache');
function CompleteService($resource) {
var completes = $resource('/api/completes/:completeId', {
completeId: '@completeId'
}, {
get: {
method: 'GET',
cache: completesCache
},
query: {
method: 'GET',
isArray: true,
cache: completesCache
},
update: {
method: 'PUT'
}

View File

@@ -6,24 +6,29 @@
.module('torrents.services')
.factory('PeersService', PeersService);
PeersService.$inject = ['$resource'];
PeersService.$inject = ['$resource', 'CacheFactory'];
function PeersService($resource, CacheFactory) {
var peersCache = CacheFactory.get('peersCache') || CacheFactory.createCache('peersCache');
function PeersService($resource) {
var Torrents = $resource('', {}, {
getMySeedingList: {
method: 'GET',
url: '/api/my/seeding',
isArray: true
isArray: true,
cache: peersCache
},
getMyDownloadingList: {
method: 'GET',
url: '/api/my/downloading',
isArray: true
isArray: true,
cache: peersCache
},
getMyWarningList: {
method: 'GET',
url: '/api/my/warning',
isArray: true
isArray: true,
cache: peersCache
},
getUserSeedingList: {
method: 'GET',
@@ -31,7 +36,8 @@
isArray: true,
params: {
userId: '@userId'
}
},
cache: peersCache
},
getUserLeechingList: {
method: 'GET',
@@ -39,7 +45,8 @@
isArray: true,
params: {
userId: '@userId'
}
},
cache: peersCache
},
getUserWarningList: {
method: 'GET',
@@ -47,7 +54,8 @@
isArray: true,
params: {
userId: '@userId'
}
},
cache: peersCache
}
});

View File

@@ -6,13 +6,24 @@
.module('torrents.services')
.factory('SubtitlesService', SubtitlesService);
SubtitlesService.$inject = ['$resource'];
SubtitlesService.$inject = ['$resource', 'CacheFactory'];
function SubtitlesService($resource, CacheFactory) {
var subtitlesCache = CacheFactory.get('subtitlesCache') || CacheFactory.createCache('subtitlesCache');
function SubtitlesService($resource) {
var Subtitles = $resource('/api/subtitles/:torrentId/:subtitleId', {
torrentId: '@_torrentId',
subtitleId: '@_subtitleId'
}, {
get: {
method: 'GET',
cache: subtitlesCache
},
query: {
method: 'GET',
isArray: true,
cache: subtitlesCache
},
update: {
method: 'PUT'
}

View File

@@ -6,12 +6,22 @@
.module('torrents.services')
.factory('TorrentsService', TorrentsService);
TorrentsService.$inject = ['$resource'];
TorrentsService.$inject = ['$resource', 'CacheFactory'];
function TorrentsService($resource, CacheFactory) {
var torrentsCache = CacheFactory.get('torrentsCache') || CacheFactory.createCache('torrentsCache');
function TorrentsService($resource) {
var Torrents = $resource('/api/torrents/:torrentId', {
torrentId: '@_id'
}, {
get: {
method: 'GET',
cache: torrentsCache
},
query: {
method: 'GET',
cache: torrentsCache
},
update: {
method: 'PUT'
},
@@ -105,25 +115,29 @@
},
siteInfo: {
method: 'GET',
url: '/api/torrents/siteInfo'
url: '/api/torrents/siteInfo',
cache: torrentsCache
},
getSeederUsers: {
method: 'GET',
url: '/api/torrents/:torrentId/seederUsers',
params: {
torrentId: '@_id'
}
},
cache: torrentsCache
},
getLeecherUsers: {
method: 'GET',
url: '/api/torrents/:torrentId/leecherUsers',
params: {
torrentId: '@_id'
}
},
cache: torrentsCache
},
getHomeTorrent: {
method: 'GET',
url: '/api/torrents/homeList'
url: '/api/torrents/homeList',
cache: torrentsCache
}
});

View File

@@ -5,12 +5,22 @@
.module('traces.services')
.factory('TracesService', TracesService);
TracesService.$inject = ['$resource'];
TracesService.$inject = ['$resource', 'CacheFactory'];
function TracesService($resource, CacheFactory) {
var tracesCache = CacheFactory.get('tracesCache') || CacheFactory.createCache('tracesCache');
function TracesService($resource) {
return $resource('/api/traces/:traceId', {
traceId: '@_id'
}, {
get: {
method: 'GET',
cache: tracesCache
},
query: {
method: 'GET',
cache: tracesCache
},
update: {
method: 'PUT'
}

View File

@@ -6,10 +6,20 @@
.module('users.services')
.factory('UsersService', UsersService);
UsersService.$inject = ['$resource'];
UsersService.$inject = ['$resource', 'CacheFactory'];
function UsersService($resource, CacheFactory) {
var usersCache = CacheFactory.get('usersCache') || CacheFactory.createCache('usersCache');
function UsersService($resource) {
var Users = $resource('/api/users', {}, {
get: {
method: 'GET',
cache: usersCache
},
query: {
method: 'GET',
cache: usersCache
},
update: {
method: 'PUT'
},
@@ -73,22 +83,26 @@
myFollowers: {
method: 'GET',
url: '/api/users/followers',
isArray: true
isArray: true,
cache: usersCache
},
myFollowing: {
method: 'GET',
url: '/api/users/following',
isArray: true
isArray: true,
cache: usersCache
},
userFollowers: {
method: 'GET',
url: '/api/users/:userId/followers',
isArray: true
isArray: true,
cache: usersCache
},
userFollowing: {
method: 'GET',
url: '/api/users/:userId/following',
isArray: true
isArray: true,
cache: usersCache
},
getMyIp: {
method: 'GET',
@@ -159,12 +173,22 @@
.module('users.admin.services')
.factory('AdminService', AdminService);
AdminService.$inject = ['$resource'];
AdminService.$inject = ['$resource', 'CacheFactory'];
function AdminService($resource, CacheFactory) {
var usersCache = CacheFactory.get('usersCache') || CacheFactory.createCache('usersCache');
function AdminService($resource) {
var Users = $resource('/api/users/:userId', {
userId: '@_id'
}, {
get: {
method: 'GET',
cache: usersCache
},
query: {
method: 'GET',
cache: usersCache
},
update: {
method: 'PUT'
},
@@ -239,7 +263,8 @@
},
uploaderList: {
method: 'GET',
url: '/api/users/uploaderList'
url: '/api/users/uploaderList',
cache: usersCache
}
});