menu.svc.js 1.77 KB
Newer Older
frank.xa.zhang's avatar
frank.xa.zhang committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
// web service proxy for menu
webservices.factory('menuService', ['$http', '$q', 'apiConfig', 'httpCacheService',
    function ($http, $q, apiConfig, httpCacheService) {
        'use strict';

        return {
            getMenusForDisplay: function (serviceId, userId) {
                return httpCacheService.get('/menu/display?serviceId=' + serviceId + "&userId=" + userId);
                //return $http.get('/menu/display?serviceId=' + serviceId, apiConfig.create());
            },
            getMenus: function (serviceId) {
                //return $http.get('/menu?serviceId=' + serviceId, apiConfig.create());
                return httpCacheService.get('/menu?serviceId=' + serviceId);
            },
            getMenusNew: function (serviceId, fn) {
                return httpCacheService.getCache('/menu?serviceId=' + serviceId, false, fn);
            },
            getAccessMenus: function (serviceId, userId, fn) {
                return httpCacheService.getCache('/menu/role?serviceId=' + serviceId + '&userId=' + userId, false, fn);
            },
            GetMenusForIvhTree: function (serviceId) {
                return $http.get('/menu/GetMenusForIvhTree?serviceId=' + serviceId, apiConfig.create());
            },
            updateMenu: function (menu) {
                return $http.put('/menu', menu, apiConfig.create());
            },
            addMenu: function (menu) {
                return $http.post('/menu/Add', menu, apiConfig.create());
            },
            deleteMenu: function (menuID) {
                return $http.post('/menu/Delete', menuID, apiConfig.create());
            },
            deleteMenus: function (menuIDs) {
                return $http.post('/menu/DeleteMulti', menuIDs, apiConfig.create());
            }
        };
    }]);