UNPKG

@angular-jz/jz

Version:

jim jz

63 lines 3.09 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); require("rxjs/add/operator/toPromise"); var base_service_1 = require("../../service/base.service"); var CrudServiceOptions = /** @class */ (function (_super) { __extends(CrudServiceOptions, _super); function CrudServiceOptions() { return _super !== null && _super.apply(this, arguments) || this; } return CrudServiceOptions; }(base_service_1.ServiceOptions)); exports.CrudServiceOptions = CrudServiceOptions; var CrudService = /** @class */ (function (_super) { __extends(CrudService, _super); function CrudService(injector, options) { return _super.call(this, injector, options) || this; } CrudService.prototype.pageLoad = function (criteria) { criteria.page.maxResultCount = criteria.page.pageSize; criteria.page.skipCount = (criteria.page.pageNo - 1) * criteria.page.pageSize; //criteria.maxResultCount = criteria.pageSize; //criteria.skipCount = (criteria.page - 1) * criteria.pageSize; return this.http .post(this.appServiceUrl + 'pageLoad', JSON.stringify(criteria), this.requestOptions) .toPromise() .then(function (response) { return response.json().result; }) .catch(this.handleError); }; CrudService.prototype.getItems = function (criteria) { criteria.page.maxResultCount = criteria.page.pageSize; criteria.page.skipCount = (criteria.page.pageNo - 1) * criteria.page.pageSize; //criteria.maxResultCount = criteria.pageSize; //criteria.skipCount = (criteria.page - 1) * criteria.pageSize; return this.post(this.appServiceUrl + 'get' + this.options.itemType + 's', criteria); }; CrudService.prototype.createItem = function (item) { return this.post(this.appServiceUrl + 'create' + this.options.itemType, { item: item }); }; CrudService.prototype.editItem = function (item) { return this.post(this.appServiceUrl + 'edit' + this.options.itemType, { item: item }); }; CrudService.prototype.deleteItem = function (item) { return this.post(this.appServiceUrl + 'delete' + this.options.itemType, { item: item }); }; CrudService.prototype.getItem = function (item) { return this.post(this.appServiceUrl + 'get' + this.options.itemType, { item: item }); }; return CrudService; }(base_service_1.BaseService)); exports.CrudService = CrudService; //# sourceMappingURL=crud.service.js.map