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
+20 -2
View File
@@ -1,10 +1,10 @@
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 { IconsService } from "./providers/icons.service";
import { RestaurantService } from "./providers/restaurant.service";
import { CreateIconDto } from "./DTO/create-icon.dto";
import { CreateIconDto } from "./DTO/create-icon.dto";
import { UpdateIconDto } from "./DTO/update-icon.dto";
import { CreateGroupDto } from "./DTO/create-group.dto";
import { UpdateGroupDto } from "./DTO/update-group.dto";
@@ -123,6 +123,24 @@ export class DmenuController {
findAllRestaurant(@Query() queryDto: FindRestaurantsDto) {
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
@Post('dmenu/restaurants')
@ApiOperation({ summary: "Create restaurant" })
@@ -85,16 +85,14 @@ export class RestaurantService {
phone: dto.phone,
plan,
subscriptionId: dto.userSubscriptionId,
subscriptionEndDate: userSubscription.endDate,
subscriptionStartDate: userSubscription.startDate,
subscriptionEndDate: userSubscription.endDate.toISOString(),
subscriptionStartDate: userSubscription.startDate.toISOString(),
};
try {
const { data } = await firstValueFrom(
this.httpService
.post(`${this.config.baseUrl}/super-admin/restaurants`, {
setupRestaurantDto
}, {
.post(`${this.config.baseUrl}/super-admin/restaurants`, setupRestaurantDto, {
headers: this.getHeaders(),
})
.pipe(
@@ -125,5 +123,27 @@ export class RestaurantService {
// 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;
}
}
}