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

解决服务返回 null 错误

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