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

解决服务返回 null 错误

上级 a3efd245
...@@ -168,7 +168,7 @@ export class ControlServiceBase { ...@@ -168,7 +168,7 @@ export class ControlServiceBase {
* @memberof ControlServiceBase * @memberof ControlServiceBase
*/ */
public async add(action: string, context: any = {}, data: any = {}, isLoading?: boolean): Promise<HttpResponse> { public async add(action: string, context: any = {}, data: any = {}, isLoading?: boolean): Promise<HttpResponse> {
let response: HttpResponse = null as any; let response: HttpResponse = new HttpResponse(200);
await this.onBeforeAction(action, context, data, isLoading); await this.onBeforeAction(action, context, data, isLoading);
try{ try{
data = this.handleRequestData(action, context, data); data = this.handleRequestData(action, context, data);
...@@ -199,7 +199,7 @@ export class ControlServiceBase { ...@@ -199,7 +199,7 @@ export class ControlServiceBase {
* @memberof ControlServiceBase * @memberof ControlServiceBase
*/ */
public async delete(action: string, context: any = {}, data: any = {}, isLoading?: boolean): Promise<HttpResponse> { public async delete(action: string, context: any = {}, data: any = {}, isLoading?: boolean): Promise<HttpResponse> {
let response: HttpResponse = null as any; let response: HttpResponse = new HttpResponse(200);
await this.onBeforeAction(action, context, data, isLoading); await this.onBeforeAction(action, context, data, isLoading);
try{ try{
data = this.handleRequestData(action, context, data); data = this.handleRequestData(action, context, data);
...@@ -212,7 +212,6 @@ export class ControlServiceBase { ...@@ -212,7 +212,6 @@ export class ControlServiceBase {
response = this.handleResponse(action, response); response = this.handleResponse(action, response);
} }
}catch (error) { }catch (error) {
console.error(error); console.error(error);
}finally{ }finally{
await this.onAfterAction(action, context, response); await this.onAfterAction(action, context, response);
...@@ -231,7 +230,7 @@ export class ControlServiceBase { ...@@ -231,7 +230,7 @@ export class ControlServiceBase {
* @memberof ControlServiceBase * @memberof ControlServiceBase
*/ */
public async update(action: string, context: any = {}, data: any = {}, isLoading?: boolean): Promise<HttpResponse> { public async update(action: string, context: any = {}, data: any = {}, isLoading?: boolean): Promise<HttpResponse> {
let response: HttpResponse = null as any; let response: HttpResponse = new HttpResponse(200);
await this.onBeforeAction(action, context, data, isLoading); await this.onBeforeAction(action, context, data, isLoading);
try{ try{
data = this.handleRequestData(action, context, data); data = this.handleRequestData(action, context, data);
...@@ -262,11 +261,10 @@ export class ControlServiceBase { ...@@ -262,11 +261,10 @@ export class ControlServiceBase {
* @memberof ControlServiceBase * @memberof ControlServiceBase
*/ */
public async get(action: string, context: any = {}, data: any = {}, isLoading?: boolean): Promise<HttpResponse> { public async get(action: string, context: any = {}, data: any = {}, isLoading?: boolean): Promise<HttpResponse> {
let response: HttpResponse = null as any; let response: HttpResponse = new HttpResponse(200);
await this.onBeforeAction(action, context, data, isLoading); await this.onBeforeAction(action, context, data, isLoading);
try{ try{
data = this.handleRequestData(action, context, data); data = this.handleRequestData(action, context, data);
let response: HttpResponse;
if (Util.isFunction(this.service[action])) { if (Util.isFunction(this.service[action])) {
response = await this.service[action](context, data); response = await this.service[action](context, data);
} else { } else {
...@@ -294,7 +292,7 @@ export class ControlServiceBase { ...@@ -294,7 +292,7 @@ export class ControlServiceBase {
* @memberof ControlServiceBase * @memberof ControlServiceBase
*/ */
public async loadDraft(action: string, context: any = {}, data: any = {}, isLoading?: boolean): Promise<HttpResponse> { public async loadDraft(action: string, context: any = {}, data: any = {}, isLoading?: boolean): Promise<HttpResponse> {
let response: HttpResponse = null as any; let response: HttpResponse = new HttpResponse(200);
await this.onBeforeAction(action, context, data, isLoading); await this.onBeforeAction(action, context, data, isLoading);
try{ try{
...@@ -302,9 +300,9 @@ export class ControlServiceBase { ...@@ -302,9 +300,9 @@ export class ControlServiceBase {
let PrimaryKey = Util.createUUID(); let PrimaryKey = Util.createUUID();
//仿真主键数据 //仿真主键数据
data[this.appDeKey] = PrimaryKey; data[this.appDeKey] = PrimaryKey;
let response: HttpResponse;
if (Util.isFunction(this.service[action])) { if (Util.isFunction(this.service[action])) {
response = await this.service[action](context, data); response = await this.service[action](context, data);
console.log(response);
} else { } else {
response = await this.service.GetDraft(context, data); response = await this.service.GetDraft(context, data);
} }
...@@ -332,7 +330,7 @@ export class ControlServiceBase { ...@@ -332,7 +330,7 @@ export class ControlServiceBase {
* @memberof EditServiceBase * @memberof EditServiceBase
*/ */
public async frontLogic(action: string, context: any = {}, data: any = {}, isLoading?: boolean): Promise<HttpResponse> { public async frontLogic(action: string, context: any = {}, data: any = {}, isLoading?: boolean): Promise<HttpResponse> {
let response: HttpResponse = null as any; let response: HttpResponse = new HttpResponse(200);
await this.onBeforeAction(action, context, data, isLoading); await this.onBeforeAction(action, context, data, isLoading);
try{ try{
data = this.handleRequestData(action, context, data); data = this.handleRequestData(action, context, data);
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册