From 26b5d2b56154cf6b685e5bacff456259d698e185 Mon Sep 17 00:00:00 2001 From: morteza-mortezai Date: Mon, 24 Nov 2025 20:28:49 +0330 Subject: [PATCH] clean foldering --- ...c-restaurant-shipment-method.controller.ts | 24 ------- .../public-restaurant.controller.ts | 4 +- .../controllers/public-schedule.controller.ts | 4 +- .../restaurants/entities/restaurant.entity.ts | 2 +- src/modules/restaurants/restaurants.module.ts | 30 +------- .../controllers/shipment-method.controller.ts | 35 ---------- .../controllers/shipment.controller.ts} | 69 ++++++++++++++----- .../create-restaurant-shipment-method.dto.ts | 0 .../update-restaurant-shipment-method.dto.ts | 0 .../restaurant-shipment-method.entity.ts | 4 +- .../restaurant-shipment-method.service.ts | 4 +- .../restaurant-shipment-method.repository.ts | 0 src/modules/shipments/shipments.module.ts | 18 +++-- 13 files changed, 76 insertions(+), 118 deletions(-) delete mode 100644 src/modules/restaurants/controllers/public-restaurant-shipment-method.controller.ts delete mode 100644 src/modules/shipments/controllers/shipment-method.controller.ts rename src/modules/{restaurants/controllers/restaurant-shipment-method.controller.ts => shipments/controllers/shipment.controller.ts} (62%) rename src/modules/{restaurants => shipments}/dto/create-restaurant-shipment-method.dto.ts (100%) rename src/modules/{restaurants => shipments}/dto/update-restaurant-shipment-method.dto.ts (100%) rename src/modules/{restaurants => shipments}/entities/restaurant-shipment-method.entity.ts (84%) rename src/modules/{restaurants => shipments}/providers/restaurant-shipment-method.service.ts (97%) rename src/modules/{restaurants => shipments}/repositories/restaurant-shipment-method.repository.ts (100%) diff --git a/src/modules/restaurants/controllers/public-restaurant-shipment-method.controller.ts b/src/modules/restaurants/controllers/public-restaurant-shipment-method.controller.ts deleted file mode 100644 index 9278e65..0000000 --- a/src/modules/restaurants/controllers/public-restaurant-shipment-method.controller.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Controller, Get, UseGuards } from '@nestjs/common'; -import { ApiTags, ApiOperation, ApiOkResponse, ApiBearerAuth } from '@nestjs/swagger'; -import { RestaurantShipmentMethodService } from '../providers/restaurant-shipment-method.service'; -import { RestaurantShipmentMethod } from '../entities/restaurant-shipment-method.entity'; -import { RestId } from 'src/common/decorators/rest-id.decorator'; -import { AuthGuard } from 'src/modules/auth/guards/auth.guard'; - -@UseGuards(AuthGuard) -@ApiBearerAuth() -@ApiTags('restaurant-shipment-methods') -@Controller('restaurant-shipment-methods') -export class PublicRestaurantShipmentMethodController { - constructor(private readonly restaurantShipmentMethodService: RestaurantShipmentMethodService) {} - - @Get() - @ApiOperation({ summary: 'Get restaurant shipment methods ' }) - @ApiOkResponse({ - description: 'List of restaurant shipment methods', - type: [RestaurantShipmentMethod], - }) - findAll(@RestId() restId: string) { - return this.restaurantShipmentMethodService.findAllForRestaurantId(restId); - } -} diff --git a/src/modules/restaurants/controllers/public-restaurant.controller.ts b/src/modules/restaurants/controllers/public-restaurant.controller.ts index fe7acb2..ce0920b 100644 --- a/src/modules/restaurants/controllers/public-restaurant.controller.ts +++ b/src/modules/restaurants/controllers/public-restaurant.controller.ts @@ -3,8 +3,8 @@ import { RestaurantsService } from '../providers/restaurants.service'; import { RestaurantSpecificationDto } from '../dto/restaurant-specification.dto'; import { ApiTags, ApiOperation, ApiOkResponse, ApiParam, ApiNotFoundResponse } from '@nestjs/swagger'; -@ApiTags('restaurants') -@Controller('restaurants') +@ApiTags('public/restaurants') +@Controller('public/restaurants') export class PublicRestaurantController { constructor(private readonly restaurantsService: RestaurantsService) {} diff --git a/src/modules/restaurants/controllers/public-schedule.controller.ts b/src/modules/restaurants/controllers/public-schedule.controller.ts index 852ac4f..43f4a03 100644 --- a/src/modules/restaurants/controllers/public-schedule.controller.ts +++ b/src/modules/restaurants/controllers/public-schedule.controller.ts @@ -3,8 +3,8 @@ import { ScheduleService } from '../providers/schedule.service'; import { Schedule } from '../entities/schedule.entity'; import { ApiTags, ApiOperation, ApiOkResponse, ApiParam } from '@nestjs/swagger'; -@ApiTags('schedules') -@Controller('schedules') +@ApiTags('public/schedules') +@Controller('public/schedules') export class PublicScheduleController { constructor(private readonly scheduleService: ScheduleService) {} diff --git a/src/modules/restaurants/entities/restaurant.entity.ts b/src/modules/restaurants/entities/restaurant.entity.ts index a3813af..4c069f5 100644 --- a/src/modules/restaurants/entities/restaurant.entity.ts +++ b/src/modules/restaurants/entities/restaurant.entity.ts @@ -1,7 +1,7 @@ import { Collection, Entity, ManyToMany, Property } from '@mikro-orm/core'; import { BaseEntity } from '../../../common/entities/base.entity'; import { ShipmentMethod } from '../../shipments/entities/shipment-method.entity'; -import { RestaurantShipmentMethod } from './restaurant-shipment-method.entity'; +import { RestaurantShipmentMethod } from '../../shipments/entities/restaurant-shipment-method.entity'; @Entity({ tableName: 'restaurants' }) export class Restaurant extends BaseEntity { diff --git a/src/modules/restaurants/restaurants.module.ts b/src/modules/restaurants/restaurants.module.ts index b045737..6e74309 100644 --- a/src/modules/restaurants/restaurants.module.ts +++ b/src/modules/restaurants/restaurants.module.ts @@ -7,40 +7,16 @@ import { Restaurant } from './entities/restaurant.entity'; import { RestRepository } from './repositories/rest.repository'; import { ScheduleRepository } from './repositories/schedule.repository'; import { Schedule } from './entities/schedule.entity'; -import { ShipmentMethod } from '../shipments/entities/shipment-method.entity'; -import { RestaurantShipmentMethod } from './entities/restaurant-shipment-method.entity'; import { ScheduleService } from './providers/schedule.service'; import { ScheduleController } from './controllers/schedule.controller'; import { PublicScheduleController } from './controllers/public-schedule.controller'; -import { RestaurantShipmentMethodController } from './controllers/restaurant-shipment-method.controller'; -import { RestaurantShipmentMethodService } from './providers/restaurant-shipment-method.service'; -import { RestaurantShipmentMethodRepository } from './repositories/restaurant-shipment-method.repository'; import { JwtModule } from '@nestjs/jwt'; import { AuthModule } from '../auth/auth.module'; -import { PublicRestaurantShipmentMethodController } from './controllers/public-restaurant-shipment-method.controller'; @Module({ - controllers: [ - RestaurantsController, - PublicRestaurantController, - ScheduleController, - PublicScheduleController, - RestaurantShipmentMethodController, - PublicRestaurantShipmentMethodController, - ], - providers: [ - RestaurantsService, - RestRepository, - ScheduleRepository, - ScheduleService, - RestaurantShipmentMethodService, - RestaurantShipmentMethodRepository, - ], - imports: [ - MikroOrmModule.forFeature([Restaurant, Schedule, ShipmentMethod, RestaurantShipmentMethod]), - JwtModule, - forwardRef(() => AuthModule), - ], + controllers: [RestaurantsController, PublicRestaurantController, ScheduleController, PublicScheduleController], + providers: [RestaurantsService, RestRepository, ScheduleRepository, ScheduleService], + imports: [MikroOrmModule.forFeature([Restaurant, Schedule]), JwtModule, forwardRef(() => AuthModule)], exports: [RestRepository, ScheduleRepository, ScheduleService], }) export class RestaurantsModule {} diff --git a/src/modules/shipments/controllers/shipment-method.controller.ts b/src/modules/shipments/controllers/shipment-method.controller.ts deleted file mode 100644 index 35a3bb9..0000000 --- a/src/modules/shipments/controllers/shipment-method.controller.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { Controller, Get, Param, UseGuards } from '@nestjs/common'; -import { ApiTags, ApiOperation, ApiOkResponse, ApiNotFoundResponse, ApiParam, ApiBearerAuth } from '@nestjs/swagger'; -import { AdminAuthGuard } from 'src/modules/auth/guards/adminAuth.guard'; -import { ShipmentMethod } from '../../shipments/entities/shipment-method.entity'; -import { ShipmentMethodsService } from '../providers/shipment-methods.service'; - -@UseGuards(AdminAuthGuard) -@ApiBearerAuth() -@ApiTags('admin/shipment-methods') -@Controller('admin/shipment-methods') -export class ShipmentMethodController { - constructor(private readonly shipmentMethodsService: ShipmentMethodsService) {} - - @Get() - @ApiOperation({ summary: 'Get all shipment methods' }) - @ApiOkResponse({ - description: 'List of shipment methods', - type: [ShipmentMethod], - }) - findAll() { - return this.shipmentMethodsService.findAll(); - } - - @Get(':shipmentMethodId') - @ApiOperation({ summary: 'Get a shipment method by shipment method ID' }) - @ApiParam({ name: 'shipmentMethodId', description: 'Shipment method ID' }) - @ApiOkResponse({ - description: 'shipment method details', - type: ShipmentMethod, - }) - @ApiNotFoundResponse({ description: 'Shipment method not found' }) - findOne(@Param('shipmentMethodId') shipmentMethodId: string) { - return this.shipmentMethodsService.findOne(shipmentMethodId); - } -} diff --git a/src/modules/restaurants/controllers/restaurant-shipment-method.controller.ts b/src/modules/shipments/controllers/shipment.controller.ts similarity index 62% rename from src/modules/restaurants/controllers/restaurant-shipment-method.controller.ts rename to src/modules/shipments/controllers/shipment.controller.ts index b4622f8..8f02502 100644 --- a/src/modules/restaurants/controllers/restaurant-shipment-method.controller.ts +++ b/src/modules/shipments/controllers/shipment.controller.ts @@ -13,18 +13,43 @@ import { RestaurantShipmentMethodService } from '../providers/restaurant-shipmen import { CreateRestaurantShipmentMethodDto } from '../dto/create-restaurant-shipment-method.dto'; import { UpdateRestaurantShipmentMethodDto } from '../dto/update-restaurant-shipment-method.dto'; import { RestaurantShipmentMethod } from '../entities/restaurant-shipment-method.entity'; -import { AdminAuthGuard } from 'src/modules/auth/guards/adminAuth.guard'; import { RestId } from 'src/common/decorators/rest-id.decorator'; +import { AuthGuard } from 'src/modules/auth/guards/auth.guard'; +import { AdminAuthGuard } from 'src/modules/auth/guards/adminAuth.guard'; +import { ShipmentMethodsService } from '../providers/shipment-methods.service'; -@UseGuards(AdminAuthGuard) -@ApiBearerAuth() -@ApiTags('admin/restaurant-shipment-methods') -@Controller('admin/restaurant-shipment-methods') -export class RestaurantShipmentMethodController { - constructor(private readonly restaurantShipmentMethodService: RestaurantShipmentMethodService) {} +@ApiTags('Shipment') +@Controller() +export class ShipmentController { + constructor( + private readonly restaurantShipmentMethodService: RestaurantShipmentMethodService, + private readonly shipmentMethodsService: ShipmentMethodsService, + ) {} + @UseGuards(AuthGuard) + @ApiBearerAuth() + @Get('public/shipment-methods/restaurant') + @ApiOperation({ summary: 'Get restaurant shipment methods ' }) + @ApiOkResponse({ + description: 'List of restaurant shipment methods', + type: [RestaurantShipmentMethod], + }) + findAllShipmentMethods(@RestId() restId: string) { + return this.restaurantShipmentMethodService.findAllForRestaurantId(restId); + } - @Post() - @ApiOperation({ summary: 'Create a new restaurant shipment method' }) + @Get('admin/shipment-methods') + @ApiOperation({ summary: 'Get all shipment methods' }) + @ApiOkResponse({ + description: 'List of shipment methods', + }) + findAll() { + return this.shipmentMethodsService.findAll(); + } + + @UseGuards(AdminAuthGuard) + @ApiBearerAuth() + @Post('admin/shipment-methods/restaurant') + @ApiOperation({ summary: 'Assign a shipment method to a restaurant' }) @ApiBody({ type: CreateRestaurantShipmentMethodDto }) @ApiCreatedResponse({ description: 'Restaurant shipment method created successfully', @@ -34,21 +59,25 @@ export class RestaurantShipmentMethodController { return this.restaurantShipmentMethodService.create(restId, createDto); } - @Get() + @UseGuards(AdminAuthGuard) + @ApiBearerAuth() + @Get('admin/shipment-methods/restaurant') @ApiOperation({ summary: 'Get the restaurant shipment methods' }) @ApiOkResponse({ description: 'List of restaurant shipment methods', type: [RestaurantShipmentMethod], }) - findAll(@RestId() restId: string) { + findRestaurantShipmentMethods(@RestId() restId: string) { return this.restaurantShipmentMethodService.findAllForRestaurantId(restId); } - @Get(':RestaurantShipmentMethodId') - @ApiOperation({ summary: 'Get a restaurant shipment method by shipment method ID' }) - @ApiParam({ name: 'RestaurantShipmentMethodId', description: 'RestaurantRestaurantShipmentMethodId method ID' }) + @UseGuards(AdminAuthGuard) + @ApiBearerAuth() + @Get('admin/shipment-methods/restaurant/:RestaurantShipmentMethodId') + @ApiOperation({ summary: 'Get a restaurant shipment method by restaurant shipment method ID' }) + @ApiParam({ name: 'RestaurantShipmentMethodId', description: 'Restaurant Shipment method ID' }) @ApiOkResponse({ - description: 'Restaurant shipment method details', + description: 'Restaurant Shipment method details', type: RestaurantShipmentMethod, }) @ApiNotFoundResponse({ description: 'Restaurant shipment method not found' }) @@ -56,9 +85,11 @@ export class RestaurantShipmentMethodController { return this.restaurantShipmentMethodService.findOne(restId, RestaurantShipmentMethodId); } - @Patch(':RestaurantShipmentMethodId') + @UseGuards(AdminAuthGuard) + @ApiBearerAuth() + @Patch('admin/shipment-methods/restaurant/:RestaurantShipmentMethodId') @ApiOperation({ summary: 'Update a restaurant shipment method' }) - @ApiParam({ name: 'RestaurantShipmentMethodId', description: 'Shipment method ID' }) + @ApiParam({ name: 'RestaurantShipmentMethodId', description: 'Restaurant Shipment method ID' }) @ApiBody({ type: UpdateRestaurantShipmentMethodDto }) @ApiOkResponse({ description: 'Restaurant shipment method updated successfully', @@ -73,7 +104,9 @@ export class RestaurantShipmentMethodController { return this.restaurantShipmentMethodService.update(restId, RestaurantShipmentMethodId, updateDto); } - @Delete(':RestaurantShipmentMethodId') + @UseGuards(AdminAuthGuard) + @ApiBearerAuth() + @Delete('admin/shipment-methods/restaurant/:RestaurantShipmentMethodId') @ApiOperation({ summary: 'Delete a restaurant shipment method' }) @ApiParam({ name: 'RestaurantShipmentMethodId', description: 'Shipment method ID' }) @ApiOkResponse({ description: 'Restaurant shipment method deleted successfully' }) diff --git a/src/modules/restaurants/dto/create-restaurant-shipment-method.dto.ts b/src/modules/shipments/dto/create-restaurant-shipment-method.dto.ts similarity index 100% rename from src/modules/restaurants/dto/create-restaurant-shipment-method.dto.ts rename to src/modules/shipments/dto/create-restaurant-shipment-method.dto.ts diff --git a/src/modules/restaurants/dto/update-restaurant-shipment-method.dto.ts b/src/modules/shipments/dto/update-restaurant-shipment-method.dto.ts similarity index 100% rename from src/modules/restaurants/dto/update-restaurant-shipment-method.dto.ts rename to src/modules/shipments/dto/update-restaurant-shipment-method.dto.ts diff --git a/src/modules/restaurants/entities/restaurant-shipment-method.entity.ts b/src/modules/shipments/entities/restaurant-shipment-method.entity.ts similarity index 84% rename from src/modules/restaurants/entities/restaurant-shipment-method.entity.ts rename to src/modules/shipments/entities/restaurant-shipment-method.entity.ts index d89d33b..f3ef3c8 100644 --- a/src/modules/restaurants/entities/restaurant-shipment-method.entity.ts +++ b/src/modules/shipments/entities/restaurant-shipment-method.entity.ts @@ -1,6 +1,6 @@ import { Entity, ManyToOne, Property, Unique } from '@mikro-orm/core'; -import { Restaurant } from './restaurant.entity'; -import { ShipmentMethod } from '../../shipments/entities/shipment-method.entity'; +import { Restaurant } from '../../restaurants/entities/restaurant.entity'; +import { ShipmentMethod } from './shipment-method.entity'; import { BaseEntity } from 'src/common/entities/base.entity'; @Entity({ tableName: 'restaurant_shipment_methods' }) diff --git a/src/modules/restaurants/providers/restaurant-shipment-method.service.ts b/src/modules/shipments/providers/restaurant-shipment-method.service.ts similarity index 97% rename from src/modules/restaurants/providers/restaurant-shipment-method.service.ts rename to src/modules/shipments/providers/restaurant-shipment-method.service.ts index 532693a..636a306 100644 --- a/src/modules/restaurants/providers/restaurant-shipment-method.service.ts +++ b/src/modules/shipments/providers/restaurant-shipment-method.service.ts @@ -4,8 +4,8 @@ import { RestaurantShipmentMethod } from '../entities/restaurant-shipment-method import { RestaurantShipmentMethodRepository } from '../repositories/restaurant-shipment-method.repository'; import { CreateRestaurantShipmentMethodDto } from '../dto/create-restaurant-shipment-method.dto'; import { UpdateRestaurantShipmentMethodDto } from '../dto/update-restaurant-shipment-method.dto'; -import { RestRepository } from '../repositories/rest.repository'; -import { ShipmentMethod } from '../../shipments/entities/shipment-method.entity'; +import { RestRepository } from '../../restaurants/repositories/rest.repository'; +import { ShipmentMethod } from '../entities/shipment-method.entity'; @Injectable() export class RestaurantShipmentMethodService { diff --git a/src/modules/restaurants/repositories/restaurant-shipment-method.repository.ts b/src/modules/shipments/repositories/restaurant-shipment-method.repository.ts similarity index 100% rename from src/modules/restaurants/repositories/restaurant-shipment-method.repository.ts rename to src/modules/shipments/repositories/restaurant-shipment-method.repository.ts diff --git a/src/modules/shipments/shipments.module.ts b/src/modules/shipments/shipments.module.ts index 2fb1285..65d69e6 100644 --- a/src/modules/shipments/shipments.module.ts +++ b/src/modules/shipments/shipments.module.ts @@ -1,15 +1,23 @@ import { Module } from '@nestjs/common'; -import { ShipmentMethodController } from './controllers/shipment-method.controller'; import { ShipmentMethodsService } from './providers/shipment-methods.service'; import { ShipmentMethodRepository } from './repositories/shipment-method.repository'; import { ShipmentMethod } from './entities/shipment-method.entity'; import { MikroOrmModule } from '@mikro-orm/nestjs'; import { JwtModule } from '@nestjs/jwt'; +import { ShipmentController } from './controllers/shipment.controller'; +import { RestaurantShipmentMethodService } from './providers/restaurant-shipment-method.service'; +import { RestaurantsModule } from '../restaurants/restaurants.module'; +import { RestaurantShipmentMethodRepository } from './repositories/restaurant-shipment-method.repository'; @Module({ - controllers: [ShipmentMethodController], - providers: [ShipmentMethodsService, ShipmentMethodRepository], - exports: [ShipmentMethodsService, ShipmentMethodRepository], - imports: [MikroOrmModule.forFeature([ShipmentMethod]), JwtModule], + controllers: [ShipmentController], + providers: [ + ShipmentMethodsService, + ShipmentMethodRepository, + RestaurantShipmentMethodRepository, + RestaurantShipmentMethodService, + ], + exports: [ShipmentMethodsService, ShipmentMethodRepository, RestaurantShipmentMethodService], + imports: [MikroOrmModule.forFeature([ShipmentMethod]), JwtModule, RestaurantsModule], }) export class ShipmentsModule {}