Commit ff54f59a authored by nanahira's avatar nanahira

delete 200

parent 5d538e3b
...@@ -36,10 +36,7 @@ export const Inner = (name: string): RelationDef => { ...@@ -36,10 +36,7 @@ export const Inner = (name: string): RelationDef => {
export type ValidCrudEntity<T> = Record<string, any> & { export type ValidCrudEntity<T> = Record<string, any> & {
id: any; id: any;
} & QueryWise<T> & } & Partial<QueryWise<T> & DeletionWise & EntityHooks & PageSettingsFactory>;
DeletionWise &
EntityHooks &
PageSettingsFactory;
export interface CrudOptions<T extends ValidCrudEntity<T>> { export interface CrudOptions<T extends ValidCrudEntity<T>> {
relations?: (string | RelationDef)[]; relations?: (string | RelationDef)[];
......
...@@ -2,6 +2,7 @@ import { ...@@ -2,6 +2,7 @@ import {
Body, Body,
Delete, Delete,
Get, Get,
HttpCode,
Param, Param,
ParseIntPipe, ParseIntPipe,
Patch, Patch,
...@@ -89,12 +90,13 @@ export class RestfulFactory<T> { ...@@ -89,12 +90,13 @@ export class RestfulFactory<T> {
create(extras: Partial<OperationObject> = {}): MethodDecorator { create(extras: Partial<OperationObject> = {}): MethodDecorator {
return MergeMethodDecorators([ return MergeMethodDecorators([
Post(), Post(),
HttpCode(200),
ApiOperation({ ApiOperation({
summary: `Create a new ${this.entityClass.name}`, summary: `Create a new ${this.entityClass.name}`,
...extras, ...extras,
}), }),
ApiBody({ type: this.createDto }), ApiBody({ type: this.createDto }),
ApiCreatedResponse({ type: this.entityReturnMessageDto }), ApiOkResponse({ type: this.entityReturnMessageDto }),
]); ]);
} }
...@@ -137,6 +139,7 @@ export class RestfulFactory<T> { ...@@ -137,6 +139,7 @@ export class RestfulFactory<T> {
update(extras: Partial<OperationObject> = {}): MethodDecorator { update(extras: Partial<OperationObject> = {}): MethodDecorator {
return MergeMethodDecorators([ return MergeMethodDecorators([
Patch(':id'), Patch(':id'),
HttpCode(200),
ApiOperation({ ApiOperation({
summary: `Update a ${this.entityClass.name} by id`, summary: `Update a ${this.entityClass.name} by id`,
...extras, ...extras,
...@@ -154,12 +157,13 @@ export class RestfulFactory<T> { ...@@ -154,12 +157,13 @@ export class RestfulFactory<T> {
delete(extras: Partial<OperationObject> = {}): MethodDecorator { delete(extras: Partial<OperationObject> = {}): MethodDecorator {
return MergeMethodDecorators([ return MergeMethodDecorators([
Delete(':id'), Delete(':id'),
HttpCode(200),
ApiOperation({ ApiOperation({
summary: `Delete a ${this.entityClass.name} by id`, summary: `Delete a ${this.entityClass.name} by id`,
...extras, ...extras,
}), }),
ApiParam({ name: 'id', type: this.idType, required: true }), ApiParam({ name: 'id', type: this.idType, required: true }),
ApiNoContentResponse({ type: BlankReturnMessageDto }), ApiOkResponse({ type: BlankReturnMessageDto }),
]); ]);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment