field
This commit is contained in:
@@ -7,9 +7,13 @@ import { FieldRepository } from './repository/field.repository';
|
|||||||
import { FieldOptionRepository } from './repository/field-option.repository';
|
import { FieldOptionRepository } from './repository/field-option.repository';
|
||||||
import { JwtModule } from '@nestjs/jwt';
|
import { JwtModule } from '@nestjs/jwt';
|
||||||
import { ProductModule } from '../product/product.module';
|
import { ProductModule } from '../product/product.module';
|
||||||
|
import { MikroOrmModule } from '@mikro-orm/nestjs';
|
||||||
|
import { Field } from './entities/field.entity';
|
||||||
|
import { FieldOption } from './entities/field-option.entity';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
|
MikroOrmModule.forFeature([Field, FieldOption]),
|
||||||
PrintModule,
|
PrintModule,
|
||||||
JwtModule.register({}),
|
JwtModule.register({}),
|
||||||
forwardRef(() => ProductModule),
|
forwardRef(() => ProductModule),
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { BadRequestException, Injectable, NotFoundException } from '@nestjs/comm
|
|||||||
import { EntityManager } from '@mikro-orm/postgresql';
|
import { EntityManager } from '@mikro-orm/postgresql';
|
||||||
import { RequiredEntityData } from '@mikro-orm/core';
|
import { RequiredEntityData } from '@mikro-orm/core';
|
||||||
import { FieldRepository } from '../repository/field.repository';
|
import { FieldRepository } from '../repository/field.repository';
|
||||||
import { PrintRepository } from 'src/modules/print/repository/print.repository';
|
|
||||||
import { Field } from '../entities/field.entity';
|
import { Field } from '../entities/field.entity';
|
||||||
import { CreateFieldDto } from '../dto/create-field.dto';
|
import { CreateFieldDto } from '../dto/create-field.dto';
|
||||||
import { UpdateFieldDto } from '../dto/update-field.dto';
|
import { UpdateFieldDto } from '../dto/update-field.dto';
|
||||||
@@ -17,7 +16,6 @@ import { PrintService } from 'src/modules/print/provider/Print.service';
|
|||||||
export class FieldService {
|
export class FieldService {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly sectionRepository: PrintRepository,
|
|
||||||
private readonly fieldRepository: FieldRepository,
|
private readonly fieldRepository: FieldRepository,
|
||||||
private readonly productService: ProductService,
|
private readonly productService: ProductService,
|
||||||
private readonly printService: PrintService,
|
private readonly printService: PrintService,
|
||||||
@@ -35,7 +33,7 @@ export class FieldService {
|
|||||||
entity = await this.printService.findOneOrFail(entityId)
|
entity = await this.printService.findOneOrFail(entityId)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!entity){
|
if (!entity) {
|
||||||
throw new BadRequestException("Entity not Found")
|
throw new BadRequestException("Entity not Found")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,7 +43,7 @@ export class FieldService {
|
|||||||
type,
|
type,
|
||||||
isRequired,
|
isRequired,
|
||||||
multiple,
|
multiple,
|
||||||
entityId:entity.id,
|
entityId: entity.id,
|
||||||
entityType
|
entityType
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -65,7 +63,7 @@ export class FieldService {
|
|||||||
throw new NotFoundException('Field not found');
|
throw new NotFoundException('Field not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.sectionRepository.assign(field, dto)
|
this.fieldRepository.assign(field, dto)
|
||||||
|
|
||||||
this.em.persistAndFlush(field)
|
this.em.persistAndFlush(field)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user