Skip to content

Commit

Permalink
feat: add & update environment validtor
Browse files Browse the repository at this point in the history
  • Loading branch information
buqiyuan committed Feb 9, 2023
1 parent ecfdff8 commit 02d3f6b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function ApiResponse(options: ApiResponseOptions = {}): MethodDecorator {
return new ResObj(data, options);
}
} catch (error) {
return new ResObj(error, { ...options, code: 1 });
return new ResObj(error, { ...options, code: error?.code ?? 1, success: false });
}
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
import { dataSource } from 'eo/workbench/browser/src/app/shared/services/storage/db/dataSource';
import { ApiResponse, ResObj } from 'eo/workbench/browser/src/app/shared/services/storage/db/decorators/api-response.decorator';
import { Environment } from 'eo/workbench/browser/src/app/shared/services/storage/db/models';
import { BaseService } from 'eo/workbench/browser/src/app/shared/services/storage/db/services/base.service';

export class EnvironmentService extends BaseService<Environment> {
baseService = new BaseService(dataSource.environment);
constructor() {
super(dataSource.environment);
}

@ApiResponse()
create(params: any) {
if (params.name?.length > 32) {
throw new ResObj(null, { code: 131000001, message: 'Environment name length needs to be less than 32' });
}
return this.baseService.create(params);
}

update(params: any) {
if (params.name?.length > 32) {
throw new ResObj(null, { code: 131000001, message: 'Environment name length needs to be less than 32' });
}
return this.baseService.update(params);
}
}

0 comments on commit 02d3f6b

Please sign in to comment.