1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- import {BaseService} from '../../commonService/base.service';
- import {AppUtil} from '../../../util/app.util';
- import {Injectable} from '@angular/core';
- import {Constant} from '../../../config/constant/constant';
- import {UrlConstant} from '../../../config/constant/url.constant';
- import { Headers } from '@angular/http';
- @Injectable()
- export class ${m1}Service extends BaseService {
- //查询列表
- queryDataList(queryData) {
- return this.httpInterceptor
- .get(UrlConstant.${m3}_LIST + ('?' + AppUtil.stringToUrl(queryData)),
- { headers: new Headers({ 'type': 'QUERY', 'Content-Type': Constant.CONTENT_TYPE_GET }) })
- .toPromise()
- .then(response => response.json())
- .catch(this.handleError);
- }
- // 新增
- addEntity(add${m1}) {
- return this.httpInterceptor
- .post(UrlConstant.${m3}_ADD,
- add${m1},
- { headers: new Headers({ 'type': 'INSERT', 'Content-Type': Constant.CONTENT_TYPE_JSON }) })
- .toPromise()
- .then(response => (console.log(response.json()), response.json()))
- .catch(this.handleError);
- }
- // 删除
- deleteEntity(${m2}Id) {
- return this.httpInterceptor
- .delete(UrlConstant.${m3}_DELETE +'/'+ ${m2}Id)
- .toPromise()
- .then(response => (console.log(response.json()), response.json()))
- .catch(this.handleError);
- }
- // 修改
- updateEntity(updateData: any): Promise<any> {
- if(!updateData.${primaryKey}){
- this.alertService.error('primaryKey 为空');
- return;
- }
- const primaryKey :any = updateData.${primaryKey};
- const paramsData = Object.assign({},updateData);
- return this.httpInterceptor
- .put(UrlConstant.${m3}_UPDATE+'/'+primaryKey,
- paramsData,
- { headers: new Headers({ 'type': 'UPDATE', 'Content-Type': Constant.CONTENT_TYPE_JSON }) })
- .toPromise()
- .then(response => (console.log(response.json()),response.json()))
- .catch(this.handleError);
- }
- }
|