hard delete: restuarant
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { ApiPropertyOptional } from '@nestjs/swagger';
|
import { ApiPropertyOptional } from '@nestjs/swagger';
|
||||||
import { IsString, IsOptional, IsNumber, IsEnum, IsDate } from 'class-validator';
|
import { IsString, IsOptional, IsNumber, IsEnum, IsDate, IsBoolean } from 'class-validator';
|
||||||
import { Type } from 'class-transformer';
|
import { Type } from 'class-transformer';
|
||||||
import { PlanEnum } from '../interface/plan.interface';
|
import { PlanEnum } from '../interface/plan.interface';
|
||||||
|
|
||||||
@@ -24,6 +24,11 @@ export class UpdateRestaurantDto {
|
|||||||
@IsString()
|
@IsString()
|
||||||
phone?: string;
|
phone?: string;
|
||||||
|
|
||||||
|
@ApiPropertyOptional()
|
||||||
|
@IsOptional()
|
||||||
|
@IsBoolean()
|
||||||
|
isActive?: boolean;
|
||||||
|
|
||||||
@ApiPropertyOptional({ example: 'base', enum: PlanEnum, description: 'پلن رستوران' })
|
@ApiPropertyOptional({ example: 'base', enum: PlanEnum, description: 'پلن رستوران' })
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsEnum(PlanEnum)
|
@IsEnum(PlanEnum)
|
||||||
|
|||||||
@@ -156,6 +156,14 @@ export class DmenuController {
|
|||||||
return this.restaurantService.updateRestaurant(id, dto);
|
return this.restaurantService.updateRestaurant(id, dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PermissionsDec(PermissionEnum.DMENU)
|
||||||
|
@Delete('admin/dmenu/restaurants/:id/hard-delete')
|
||||||
|
@ApiOperation({ summary: "Hard delete restaurant" })
|
||||||
|
@ApiParam({ name: "id", required: true, type: String })
|
||||||
|
hardDeleteRestaurant(@Param("id") id: string) {
|
||||||
|
return this.restaurantService.hardDeleteRestaurant(id);
|
||||||
|
}
|
||||||
|
|
||||||
@PermissionsDec(PermissionEnum.DMENU)
|
@PermissionsDec(PermissionEnum.DMENU)
|
||||||
@Get('admin/dmenu/system-roles')
|
@Get('admin/dmenu/system-roles')
|
||||||
@ApiOperation({ summary: "Get system roles" })
|
@ApiOperation({ summary: "Get system roles" })
|
||||||
|
|||||||
@@ -402,6 +402,36 @@ export class RestaurantService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async hardDeleteRestaurant(id: string) {
|
||||||
|
try {
|
||||||
|
const { data } = await firstValueFrom(
|
||||||
|
this.httpService
|
||||||
|
.delete(`${this.config.baseUrl}/super-admin/restaurants/${id}/hard-delete`, {
|
||||||
|
headers: this.getHeaders(),
|
||||||
|
data: {},
|
||||||
|
})
|
||||||
|
.pipe(
|
||||||
|
catchError((err: AxiosError) => {
|
||||||
|
this.logger.error(`Failed to hard delete restaurant: ${err.message}`, err.stack);
|
||||||
|
return throwError(() => err);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return data;
|
||||||
|
} catch (error: unknown) {
|
||||||
|
if (error instanceof AxiosError && error.response) {
|
||||||
|
this.logger.error(`External API error response:`, error.response.data);
|
||||||
|
const errorResponse = {
|
||||||
|
...error.response.data,
|
||||||
|
message: error.response.data.error?.message || error.message,
|
||||||
|
};
|
||||||
|
throw new HttpException(errorResponse, error.response.status);
|
||||||
|
}
|
||||||
|
this.logger.error(`Error hard deleting restaurant: ${error instanceof Error ? error.message : "Unknown error"}`);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async directLogin(userSubscriptionId: string, userId: string) {
|
async directLogin(userSubscriptionId: string, userId: string) {
|
||||||
try {
|
try {
|
||||||
// 1. Get userSubscription by id
|
// 1. Get userSubscription by id
|
||||||
|
|||||||
Reference in New Issue
Block a user