clean foldering

This commit is contained in:
2025-11-24 20:28:49 +03:30
parent cfc7e1ffb9
commit 26b5d2b561
13 changed files with 76 additions and 118 deletions
@@ -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);
}
}
@@ -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) {}
@@ -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) {}
@@ -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 {
+3 -27
View File
@@ -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 {}
@@ -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);
}
}
@@ -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' })
@@ -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' })
@@ -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 {
+13 -5
View File
@@ -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 {}