update
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
import {
|
||||
Entity,
|
||||
Property,
|
||||
OptionalProps,
|
||||
} from '@mikro-orm/core';
|
||||
import { BaseEntity } from 'src/common/entities/base.entity';
|
||||
|
||||
@Entity({ tableName: 'order_types' })
|
||||
export class OrderType extends BaseEntity {
|
||||
[OptionalProps]?: 'createdAt' | 'deletedAt'
|
||||
|
||||
@Property({ type: 'string' })
|
||||
title: string
|
||||
|
||||
}
|
||||
@@ -15,7 +15,7 @@ import { IAttachment, OrderStatusEnum } from '../interface/order.interface';
|
||||
import { InvoiceItem } from 'src/modules/invoice/entities/invoice-item.entity';
|
||||
import { IField } from 'src/modules/request/interface/request.interface';
|
||||
import { Product } from 'src/modules/product/entities/product.entity';
|
||||
import { OrderType } from './order-type.entity';
|
||||
import { Category } from 'src/modules/product/entities/category.entity';
|
||||
|
||||
@Entity({ tableName: 'orders' })
|
||||
@Index({ properties: ['user'] })
|
||||
@@ -34,8 +34,8 @@ export class Order extends BaseEntity {
|
||||
@Property({ type: 'string', nullable: true })
|
||||
title?: string
|
||||
|
||||
@ManyToOne(() => OrderType)
|
||||
type: OrderType
|
||||
@ManyToOne(() => Category)
|
||||
type: Category
|
||||
|
||||
@ManyToOne(() => User)
|
||||
user!: User;
|
||||
|
||||
@@ -15,11 +15,10 @@ import { UserModule } from '../user/user.module';
|
||||
import { UtilsModule } from '../util/utils.module';
|
||||
import { ProductModule } from '../product/product.module';
|
||||
import { TicketModule } from '../ticket/ticket.module';
|
||||
import { OrderType } from './entities/order-type.entity';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
MikroOrmModule.forFeature([Order, OrderType]),
|
||||
MikroOrmModule.forFeature([Order]),
|
||||
AuthModule,
|
||||
forwardRef(() => PaymentModule),
|
||||
JwtModule,
|
||||
|
||||
@@ -3,10 +3,7 @@ import { EntityManager } from '@mikro-orm/postgresql';
|
||||
import { OrderRepository } from '../repositories/order.repository';
|
||||
import { FindOrdersDto } from '../dto/find-orders.dto';
|
||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||
import {
|
||||
CreateOrderAsAdminDto,
|
||||
CreateOrderItemDtoAsAdmin,
|
||||
} from '../dto/create-order.dto';
|
||||
import { CreateOrderAsAdminDto } from '../dto/create-order.dto';
|
||||
import { UserService } from 'src/modules/user/providers/user.service';
|
||||
import { OrderStatusEnum } from '../interface/order.interface';
|
||||
import { ProductService } from 'src/modules/product/providers/product.service';
|
||||
@@ -18,16 +15,15 @@ import { Order } from '../entities/order.entity';
|
||||
import { PaymentRepository } from 'src/modules/payment/repositories/payment.repository';
|
||||
import { AdminService } from 'src/modules/admin/providers/admin.service';
|
||||
import { UpdateOrderAsAdminDto } from '../dto/update-order.dto';
|
||||
import { FindOrderItemsDto } from '../dto/find-order-items.dto';
|
||||
import { PermissionService } from 'src/modules/roles/providers/permissions.service';
|
||||
import { PermissionEnum } from 'src/common/enums/permission.enum';
|
||||
import { User } from 'src/modules/user/entities/user.entity';
|
||||
import { OrderType } from '../entities/order-type.entity';
|
||||
import { Product } from 'src/modules/product/entities/product.entity';
|
||||
import { InvoiceItem } from 'src/modules/invoice/entities/invoice-item.entity';
|
||||
import { PaginatedResult } from 'src/common/interfaces/pagination.interface';
|
||||
import { UpdateStatusAsDesignerDto } from '../dto/update-status-as-designer.dto';
|
||||
import { UpdateStatusDto } from '../dto/update-status.dto';
|
||||
import { Category } from 'src/modules/product/entities/category.entity';
|
||||
|
||||
@Injectable()
|
||||
export class OrderService {
|
||||
@@ -79,7 +75,7 @@ export class OrderService {
|
||||
|
||||
const creator = await this.adminService.findOrFail(adminId);
|
||||
|
||||
const type = await this.em.findOne(OrderType, { id: dto.typeId });
|
||||
const type = await this.em.findOne(Category, { id: dto.typeId });
|
||||
if (!type) {
|
||||
throw new NotFoundException(`Order type with ID ${dto.typeId} not found.`);
|
||||
}
|
||||
@@ -157,7 +153,7 @@ export class OrderService {
|
||||
order.user = user as User;
|
||||
}
|
||||
if (dto.typeId !== undefined) {
|
||||
const type = await this.em.findOne(OrderType, { id: dto.typeId });
|
||||
const type = await this.em.findOne(Category, { id: dto.typeId });
|
||||
if (!type) {
|
||||
throw new NotFoundException(`Order type with ID ${dto.typeId} not found.`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user