Browse Source

Merge pull request #147 in DEC/decision-webui-dcm from ~ALAN/decision-webui-dcm:release/10.0 to release/10.0

* commit '4c69a4eeb446fd877c1a0d7daa65cbcc29c5aed8':
  fix: 修改写法
  fix: 修复url为空时地址以/结尾的bug
research/10.0
alan 5 years ago
parent
commit
85eb18baa3
  1. 11
      src/modules/crud/crud.service.ts

11
src/modules/crud/crud.service.ts

@ -1,10 +1,13 @@
import { ResultType } from './crud.typings.d'; import { ResultType } from './crud.typings.d';
import { ReqPath } from '../constants/env'; import { ReqPath } from '../constants/env';
function getFullUrl(url: string) {
return url ? `${ReqPath}/${url}` : ReqPath;
}
export function requestGet(url: string, data?: any): Promise<ResultType> { export function requestGet(url: string, data?: any): Promise<ResultType> {
return new Promise(resolve => { return new Promise(resolve => {
Dec.reqGet(`${ReqPath}/${url}`, '', re => { Dec.reqGet(getFullUrl(url), '', re => {
resolve(re); resolve(re);
}); });
}); });
@ -12,7 +15,7 @@ export function requestGet(url: string, data?: any): Promise<ResultType> {
export function requestPost(url: string, data = {}): Promise<ResultType> { export function requestPost(url: string, data = {}): Promise<ResultType> {
return new Promise(resolve => { return new Promise(resolve => {
Dec.reqPost(`${ReqPath}/${url}`, data, re => { Dec.reqPost(getFullUrl(url), data, re => {
resolve(re); resolve(re);
}); });
}); });
@ -20,7 +23,7 @@ export function requestPost(url: string, data = {}): Promise<ResultType> {
export function requestDelete(url: string, data = {}) { export function requestDelete(url: string, data = {}) {
return new Promise(resolve => { return new Promise(resolve => {
Dec.reqDelete(`${ReqPath}/${url}`, data, re => { Dec.reqDelete(getFullUrl(url), data, re => {
resolve(re); resolve(re);
}); });
}); });
@ -28,7 +31,7 @@ export function requestDelete(url: string, data = {}) {
export function requestPut(url: string, data = {}) { export function requestPut(url: string, data = {}) {
return new Promise(resolve => { return new Promise(resolve => {
Dec.reqPut(`${ReqPath}/${url}`, data, re => { Dec.reqPut(getFullUrl(url), data, re => {
resolve(re); resolve(re);
}); });
}); });

Loading…
Cancel
Save