update : routes

This commit is contained in:
2025-12-27 16:28:51 +03:30
parent 0e1aedc95d
commit 3c7ccf8455
2 changed files with 45 additions and 7 deletions
+19 -1
View File
@@ -1,5 +1,5 @@
import { Body, Controller, Delete, Get, Param, Patch, Post, Query } from "@nestjs/common"; import { Body, Controller, Delete, Get, Param, Patch, Post, Query } from "@nestjs/common";
import { ApiBearerAuth, ApiOperation, ApiParam, ApiTags } from "@nestjs/swagger"; import { ApiBearerAuth, ApiOperation, ApiParam, ApiQuery, ApiTags } from "@nestjs/swagger";
import { ContactService } from "./providers/contact.service"; import { ContactService } from "./providers/contact.service";
import { IconsService } from "./providers/icons.service"; import { IconsService } from "./providers/icons.service";
@@ -123,6 +123,24 @@ export class DmenuController {
findAllRestaurant(@Query() queryDto: FindRestaurantsDto) { findAllRestaurant(@Query() queryDto: FindRestaurantsDto) {
return this.restaurantService.findAll(queryDto); return this.restaurantService.findAll(queryDto);
} }
@ApiBearerAuth()
@Get('super-admin/restaurants/sms-count')
@ApiOperation({ summary: 'Get SMS count for each restaurant with pagination' })
@ApiQuery({ name: 'page', required: false, type: Number, description: 'Page number (default: 1)', minimum: 1 })
@ApiQuery({ name: 'limit', required: false, type: Number, description: 'Items per page (default: 10)', minimum: 1 })
async getSmsCount(
@Query('page') page?: number,
@Query('limit') limit?: number,
) {
const parsedPage = page ? parseInt(page.toString(), 10) : 1;
const parsedLimit = limit ? parseInt(limit.toString(), 10) : 10;
return await this.restaurantService.getSmsCountByRestaurant(parsedPage, parsedLimit);
}
//here
//User Endpoints //User Endpoints
@Post('dmenu/restaurants') @Post('dmenu/restaurants')
@ApiOperation({ summary: "Create restaurant" }) @ApiOperation({ summary: "Create restaurant" })
@@ -85,16 +85,14 @@ export class RestaurantService {
phone: dto.phone, phone: dto.phone,
plan, plan,
subscriptionId: dto.userSubscriptionId, subscriptionId: dto.userSubscriptionId,
subscriptionEndDate: userSubscription.endDate, subscriptionEndDate: userSubscription.endDate.toISOString(),
subscriptionStartDate: userSubscription.startDate, subscriptionStartDate: userSubscription.startDate.toISOString(),
}; };
try { try {
const { data } = await firstValueFrom( const { data } = await firstValueFrom(
this.httpService this.httpService
.post(`${this.config.baseUrl}/super-admin/restaurants`, { .post(`${this.config.baseUrl}/super-admin/restaurants`, setupRestaurantDto, {
setupRestaurantDto
}, {
headers: this.getHeaders(), headers: this.getHeaders(),
}) })
.pipe( .pipe(
@@ -125,5 +123,27 @@ export class RestaurantService {
// Add actual data structure based on your requirements // Add actual data structure based on your requirements
}; };
} }
async getSmsCountByRestaurant(page: number, limit: number) {
try {
const { data } = await firstValueFrom(
this.httpService
.get('super-admin/notifications/sms-count', {
params: { page, limit },
})
.pipe(
catchError((err: AxiosError) => {
this.logger.error("error in getting SMS count by restaurant", err);
throw new BadRequestException("Failed to fetch SMS count data");
}),
),
);
return data;
} catch (error) {
this.logger.error("error in getSmsCountByRestaurant", error);
throw error;
}
}
} }