提交 a3efd245 编写于 作者: KK's avatar KK

加载异常处理

上级 8c74e21f
......@@ -168,9 +168,10 @@ export class ControlServiceBase {
* @memberof ControlServiceBase
*/
public async add(action: string, context: any = {}, data: any = {}, isLoading?: boolean): Promise<HttpResponse> {
let response: HttpResponse = null as any;
await this.onBeforeAction(action, context, data, isLoading);
try{
data = this.handleRequestData(action, context, data);
let response: HttpResponse;
if (Util.isFunction(this.service[action])) {
response = await this.service[action](context, data);
} else {
......@@ -179,7 +180,11 @@ export class ControlServiceBase {
if (!response.isError && response.isError()) {
response = this.handleResponse(action, response);
}
}catch (error) {
console.error(error);
}finally{
await this.onAfterAction(action, context, response);
}
return response;
}
......@@ -194,9 +199,10 @@ export class ControlServiceBase {
* @memberof ControlServiceBase
*/
public async delete(action: string, context: any = {}, data: any = {}, isLoading?: boolean): Promise<HttpResponse> {
let response: HttpResponse = null as any;
await this.onBeforeAction(action, context, data, isLoading);
try{
data = this.handleRequestData(action, context, data);
let response: HttpResponse;
if (Util.isFunction(this.service[action])) {
response = await this.service[action](context, data);
} else {
......@@ -205,7 +211,12 @@ export class ControlServiceBase {
if (!response.isError && response.isError()) {
response = this.handleResponse(action, response);
}
}catch (error) {
console.error(error);
}finally{
await this.onAfterAction(action, context, response);
}
return response;
}
......@@ -220,9 +231,10 @@ export class ControlServiceBase {
* @memberof ControlServiceBase
*/
public async update(action: string, context: any = {}, data: any = {}, isLoading?: boolean): Promise<HttpResponse> {
let response: HttpResponse = null as any;
await this.onBeforeAction(action, context, data, isLoading);
try{
data = this.handleRequestData(action, context, data);
let response: HttpResponse;
if (Util.isFunction(this.service[action])) {
response = await this.service[action](context, data);
} else {
......@@ -231,7 +243,11 @@ export class ControlServiceBase {
if (!response.isError && response.isError()) {
response = this.handleResponse(action, response);
}
}catch(error){
console.error(error)
}finally{
await this.onAfterAction(action, context, response);
}
return response;
}
......@@ -246,7 +262,9 @@ export class ControlServiceBase {
* @memberof ControlServiceBase
*/
public async get(action: string, context: any = {}, data: any = {}, isLoading?: boolean): Promise<HttpResponse> {
let response: HttpResponse = null as any;
await this.onBeforeAction(action, context, data, isLoading);
try{
data = this.handleRequestData(action, context, data);
let response: HttpResponse;
if (Util.isFunction(this.service[action])) {
......@@ -257,7 +275,11 @@ export class ControlServiceBase {
if (!response.isError && response.isError()) {
response = this.handleResponse(action, response);
}
}catch (error) {
console.error(error);
}finally{
await this.onAfterAction(action, context, response);
}
return response;
}
......@@ -272,7 +294,10 @@ export class ControlServiceBase {
* @memberof ControlServiceBase
*/
public async loadDraft(action: string, context: any = {}, data: any = {}, isLoading?: boolean): Promise<HttpResponse> {
let response: HttpResponse = null as any;
await this.onBeforeAction(action, context, data, isLoading);
try{
data = this.handleRequestData(action, context, data);
let PrimaryKey = Util.createUUID();
//仿真主键数据
......@@ -288,8 +313,13 @@ export class ControlServiceBase {
this.mergeDefaults(response);
}
response.data[this.appDeKey] = PrimaryKey;
}catch (error) {
console.error(error);
}finally{
await this.onAfterAction(action, context, response);
}
return response;
}
/**
......@@ -302,7 +332,9 @@ export class ControlServiceBase {
* @memberof EditServiceBase
*/
public async frontLogic(action: string, context: any = {}, data: any = {}, isLoading?: boolean): Promise<HttpResponse> {
let response: HttpResponse = null as any;
await this.onBeforeAction(action, context, data, isLoading);
try{
data = this.handleRequestData(action, context, data);
let response: HttpResponse;
if (Util.isFunction(this.service[action])) {
......@@ -313,7 +345,11 @@ export class ControlServiceBase {
if (!response.isError && response.isError()) {
response = this.handleResponse(action, response, true);
}
}catch (error) {
console.error(error);
}finally{
await this.onAfterAction(action, context, response);
}
return response;
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册