diff --git a/src/app.module.ts b/src/app.module.ts index 4690d20..0d957f2 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -19,6 +19,7 @@ import { FoodModule } from './modules/foods/food.module'; import { CartModule } from './modules/cart/cart.module'; import { RolesModule } from './modules/roles/roles.module'; import { PaymentsModule } from './modules/payments/payments.module'; +import { ShipmentsModule } from './modules/shipments/shipments.module'; @Module({ imports: [ @@ -51,6 +52,7 @@ import { PaymentsModule } from './modules/payments/payments.module'; CartModule, RolesModule, PaymentsModule, + ShipmentsModule, ], controllers: [], providers: [], diff --git a/src/modules/restaurants/controllers/public-restaurant-shipment-method.controller.ts b/src/modules/restaurants/controllers/public-restaurant-shipment-method.controller.ts index 6ab76eb..f219be9 100644 --- a/src/modules/restaurants/controllers/public-restaurant-shipment-method.controller.ts +++ b/src/modules/restaurants/controllers/public-restaurant-shipment-method.controller.ts @@ -1,14 +1,5 @@ import { Controller, Get, UseGuards } from '@nestjs/common'; -import { - ApiTags, - ApiOperation, - ApiCreatedResponse, - ApiOkResponse, - ApiNotFoundResponse, - ApiParam, - ApiBody, - ApiBearerAuth, -} from '@nestjs/swagger'; +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'; diff --git a/src/modules/restaurants/entities/restaurant-shipment-method.entity.ts b/src/modules/restaurants/entities/restaurant-shipment-method.entity.ts index 097f6bf..3a643ab 100644 --- a/src/modules/restaurants/entities/restaurant-shipment-method.entity.ts +++ b/src/modules/restaurants/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 './shipment-method.entity'; +import { ShipmentMethod } from '../../shipments/entities/shipment-method.entity'; @Entity({ tableName: 'restaurant_shipment_methods' }) @Unique({ properties: ['restaurant', 'shipmentMethod'] }) diff --git a/src/modules/restaurants/entities/restaurant.entity.ts b/src/modules/restaurants/entities/restaurant.entity.ts index 5140c76..a3813af 100644 --- a/src/modules/restaurants/entities/restaurant.entity.ts +++ b/src/modules/restaurants/entities/restaurant.entity.ts @@ -1,6 +1,6 @@ import { Collection, Entity, ManyToMany, Property } from '@mikro-orm/core'; import { BaseEntity } from '../../../common/entities/base.entity'; -import { ShipmentMethod } from './shipment-method.entity'; +import { ShipmentMethod } from '../../shipments/entities/shipment-method.entity'; import { RestaurantShipmentMethod } from './restaurant-shipment-method.entity'; @Entity({ tableName: 'restaurants' }) diff --git a/src/modules/restaurants/providers/restaurant-shipment-method.service.ts b/src/modules/restaurants/providers/restaurant-shipment-method.service.ts index 436835e..c68b59b 100644 --- a/src/modules/restaurants/providers/restaurant-shipment-method.service.ts +++ b/src/modules/restaurants/providers/restaurant-shipment-method.service.ts @@ -5,7 +5,7 @@ import { RestaurantShipmentMethodRepository } from '../repositories/restaurant-s 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 '../entities/shipment-method.entity'; +import { ShipmentMethod } from '../../shipments/entities/shipment-method.entity'; @Injectable() export class RestaurantShipmentMethodService { diff --git a/src/modules/restaurants/restaurants.module.ts b/src/modules/restaurants/restaurants.module.ts index d459c66..b045737 100644 --- a/src/modules/restaurants/restaurants.module.ts +++ b/src/modules/restaurants/restaurants.module.ts @@ -7,7 +7,7 @@ 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 './entities/shipment-method.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'; @@ -18,9 +18,7 @@ import { RestaurantShipmentMethodRepository } from './repositories/restaurant-sh import { JwtModule } from '@nestjs/jwt'; import { AuthModule } from '../auth/auth.module'; import { PublicRestaurantShipmentMethodController } from './controllers/public-restaurant-shipment-method.controller'; -import { ShipmentMethodController } from './controllers/shipment-method.controller'; -import { ShipmentMethodsService } from './providers/shipment-methods.service'; -import { ShipmentMethodRepository } from './repositories/shipment-method.repository'; + @Module({ controllers: [ RestaurantsController, @@ -29,7 +27,6 @@ import { ShipmentMethodRepository } from './repositories/shipment-method.reposit PublicScheduleController, RestaurantShipmentMethodController, PublicRestaurantShipmentMethodController, - ShipmentMethodController, ], providers: [ RestaurantsService, @@ -38,14 +35,12 @@ import { ShipmentMethodRepository } from './repositories/shipment-method.reposit ScheduleService, RestaurantShipmentMethodService, RestaurantShipmentMethodRepository, - ShipmentMethodsService, - ShipmentMethodRepository, ], imports: [ MikroOrmModule.forFeature([Restaurant, Schedule, ShipmentMethod, RestaurantShipmentMethod]), JwtModule, forwardRef(() => AuthModule), ], - exports: [RestRepository, ScheduleRepository, ScheduleService, ShipmentMethodsService], + exports: [RestRepository, ScheduleRepository, ScheduleService], }) export class RestaurantsModule {} diff --git a/src/modules/restaurants/controllers/shipment-method.controller.ts b/src/modules/shipments/controllers/shipment-method.controller.ts similarity index 94% rename from src/modules/restaurants/controllers/shipment-method.controller.ts rename to src/modules/shipments/controllers/shipment-method.controller.ts index 8ecfc85..35a3bb9 100644 --- a/src/modules/restaurants/controllers/shipment-method.controller.ts +++ b/src/modules/shipments/controllers/shipment-method.controller.ts @@ -1,7 +1,7 @@ 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 '../entities/shipment-method.entity'; +import { ShipmentMethod } from '../../shipments/entities/shipment-method.entity'; import { ShipmentMethodsService } from '../providers/shipment-methods.service'; @UseGuards(AdminAuthGuard) diff --git a/src/modules/restaurants/entities/shipment-method.entity.ts b/src/modules/shipments/entities/shipment-method.entity.ts similarity index 88% rename from src/modules/restaurants/entities/shipment-method.entity.ts rename to src/modules/shipments/entities/shipment-method.entity.ts index c0a947f..d93c426 100644 --- a/src/modules/restaurants/entities/shipment-method.entity.ts +++ b/src/modules/shipments/entities/shipment-method.entity.ts @@ -1,6 +1,6 @@ import { Entity, Property, Unique, ManyToMany, Collection } from '@mikro-orm/core'; import { BaseEntity } from '../../../common/entities/base.entity'; -import { Restaurant } from './restaurant.entity'; +import { Restaurant } from '../../restaurants/entities/restaurant.entity'; @Entity({ tableName: 'shipment_methods' }) export class ShipmentMethod extends BaseEntity { diff --git a/src/modules/restaurants/providers/shipment-methods.service.ts b/src/modules/shipments/providers/shipment-methods.service.ts similarity index 100% rename from src/modules/restaurants/providers/shipment-methods.service.ts rename to src/modules/shipments/providers/shipment-methods.service.ts diff --git a/src/modules/restaurants/repositories/shipment-method.repository.ts b/src/modules/shipments/repositories/shipment-method.repository.ts similarity index 87% rename from src/modules/restaurants/repositories/shipment-method.repository.ts rename to src/modules/shipments/repositories/shipment-method.repository.ts index 356c128..d711fa7 100644 --- a/src/modules/restaurants/repositories/shipment-method.repository.ts +++ b/src/modules/shipments/repositories/shipment-method.repository.ts @@ -1,5 +1,5 @@ import { EntityManager, EntityRepository } from '@mikro-orm/postgresql'; - import { Injectable } from '@nestjs/common'; +import { Injectable } from '@nestjs/common'; import { ShipmentMethod } from '../entities/shipment-method.entity'; @Injectable() diff --git a/src/modules/shipments/shipments.module.ts b/src/modules/shipments/shipments.module.ts new file mode 100644 index 0000000..2fb1285 --- /dev/null +++ b/src/modules/shipments/shipments.module.ts @@ -0,0 +1,15 @@ +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'; + +@Module({ + controllers: [ShipmentMethodController], + providers: [ShipmentMethodsService, ShipmentMethodRepository], + exports: [ShipmentMethodsService, ShipmentMethodRepository], + imports: [MikroOrmModule.forFeature([ShipmentMethod]), JwtModule], +}) +export class ShipmentsModule {} diff --git a/src/seeders/DatabaseSeeder.ts b/src/seeders/DatabaseSeeder.ts index f10cf59..b469f18 100644 --- a/src/seeders/DatabaseSeeder.ts +++ b/src/seeders/DatabaseSeeder.ts @@ -11,7 +11,7 @@ import { User } from '../modules/users/entities/user.entity'; import { Permission, PermissionTitles } from '../common/enums/permission.enum'; import { PaymentMethod } from '../modules/payments/entities/payment-method.entity'; import { RestaurantPaymentMethod } from '../modules/payments/entities/restaurant-payment-method.entity'; -import { ShipmentMethod } from '../modules/restaurants/entities/shipment-method.entity'; +import { ShipmentMethod } from '../modules/shipments/entities/shipment-method.entity'; export class DatabaseSeeder extends Seeder { async run(em: EntityManager) {