form builder module
This commit is contained in:
@@ -17,6 +17,7 @@ import { NotificationsModule } from './modules/notification/notifications.module
|
|||||||
import { EventEmitterModule } from '@nestjs/event-emitter';
|
import { EventEmitterModule } from '@nestjs/event-emitter';
|
||||||
import { CacheModule } from '@nestjs/cache-manager';
|
import { CacheModule } from '@nestjs/cache-manager';
|
||||||
import { PrintModule } from './modules/print/print.module';
|
import { PrintModule } from './modules/print/print.module';
|
||||||
|
import { FormBuilderModule } from './modules/form-builder/form-builder.module';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -41,6 +42,7 @@ import { PrintModule } from './modules/print/print.module';
|
|||||||
NotificationsModule,
|
NotificationsModule,
|
||||||
EventEmitterModule.forRoot(),
|
EventEmitterModule.forRoot(),
|
||||||
PrintModule,
|
PrintModule,
|
||||||
|
FormBuilderModule,
|
||||||
],
|
],
|
||||||
controllers: [],
|
controllers: [],
|
||||||
providers: [],
|
providers: [],
|
||||||
|
|||||||
@@ -0,0 +1,93 @@
|
|||||||
|
import { Controller, Get, Post, Body, Patch, Param, Delete, UseGuards } from '@nestjs/common';
|
||||||
|
import { ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
|
||||||
|
import { AdminAuthGuard } from '../../auth/guards/adminAuth.guard';
|
||||||
|
import { FieldService } from '../provider/field.service';
|
||||||
|
import { CreateFieldDto } from '../dto/create-field.dto';
|
||||||
|
import { CreateFieldOptionDto } from '../dto/create-field-option.dto';
|
||||||
|
import { FieldOptionService } from '../provider/field-option.service';
|
||||||
|
import { UpdateFieldDto } from '../dto/update-field.dto';
|
||||||
|
import { UpdateFieldOptionDto } from '../dto/update-field-option.dto';
|
||||||
|
|
||||||
|
@Controller('admin')
|
||||||
|
@ApiBearerAuth()
|
||||||
|
export class FormBuilderController {
|
||||||
|
constructor(
|
||||||
|
private readonly fieldService: FieldService,
|
||||||
|
private readonly fieldOptionService: FieldOptionService,
|
||||||
|
) { }
|
||||||
|
|
||||||
|
|
||||||
|
/*================================ Field ========================== */
|
||||||
|
|
||||||
|
@Post('section/:id/field')
|
||||||
|
@ApiOperation({ summary: 'Create field for section' })
|
||||||
|
@UseGuards(AdminAuthGuard)
|
||||||
|
createField(@Body() dto: CreateFieldDto, @Param('id') sectionId: string) {
|
||||||
|
return this.fieldService.create(sectionId,dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('section/:id/field')
|
||||||
|
@ApiOperation({ summary: 'find all secion fields' })
|
||||||
|
@UseGuards(AdminAuthGuard)
|
||||||
|
findAllSectionFields(@Param('id') sectionId: string) {
|
||||||
|
return this.fieldService.findAll(+sectionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('section/field/:id')
|
||||||
|
@ApiOperation({ summary: 'Find one field' })
|
||||||
|
@UseGuards(AdminAuthGuard)
|
||||||
|
findOneFiled(@Param('id') id: string) {
|
||||||
|
return this.fieldService.findById(+id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Patch('section/field/:id')
|
||||||
|
@ApiOperation({ summary: 'Update field' })
|
||||||
|
@UseGuards(AdminAuthGuard)
|
||||||
|
updateField(@Param('id') id: string, @Body() dto: UpdateFieldDto) {
|
||||||
|
return this.fieldService.update(+id, dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete('section/field/:id')
|
||||||
|
@ApiOperation({ summary: 'Renopve field' })
|
||||||
|
@UseGuards(AdminAuthGuard)
|
||||||
|
removeField(@Param('id') id: string) {
|
||||||
|
return this.fieldService.remove(+id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*================================ Field Option ========================== */
|
||||||
|
|
||||||
|
@Post('field/:id/option')
|
||||||
|
@ApiOperation({ summary: 'Create field Options ' })
|
||||||
|
@UseGuards(AdminAuthGuard)
|
||||||
|
createFieldOption(@Body() dto: CreateFieldOptionDto, @Param('id') id: string) {
|
||||||
|
return this.fieldOptionService.create(+id, dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('field/:id/option')
|
||||||
|
@ApiOperation({ summary: 'find all field Option' })
|
||||||
|
@UseGuards(AdminAuthGuard)
|
||||||
|
findAllFiledOptions(@Param('id') fieldId: string) {
|
||||||
|
return this.fieldOptionService.findAll(+fieldId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('field/option/:id')
|
||||||
|
@ApiOperation({ summary: 'Find one field Option' })
|
||||||
|
@UseGuards(AdminAuthGuard)
|
||||||
|
findOneFiledOption(@Param('id') id: string) {
|
||||||
|
return this.fieldOptionService.findById(+id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Patch('field/option/:id')
|
||||||
|
@ApiOperation({ summary: 'Update field Option' })
|
||||||
|
@UseGuards(AdminAuthGuard)
|
||||||
|
updateFieldOption(@Param('id') id: string, @Body() dto: UpdateFieldOptionDto) {
|
||||||
|
return this.fieldOptionService.update(+id, dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete('field/option/:id')
|
||||||
|
@ApiOperation({ summary: 'Renopve field Option' })
|
||||||
|
@UseGuards(AdminAuthGuard)
|
||||||
|
removeFieldOption(@Param('id') id: string) {
|
||||||
|
return this.fieldOptionService.remove(+id);
|
||||||
|
}
|
||||||
|
}
|
||||||
+7
-3
@@ -1,8 +1,9 @@
|
|||||||
import { Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core';
|
import { Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core';
|
||||||
import { FieldOption } from './field-option.entity';
|
import { FieldOption } from './field-option.entity';
|
||||||
import { FieldType } from '../interface/print';
|
import { FieldType } from '../interface/print';
|
||||||
import { Section } from './section.entity';
|
import { Section } from 'src/modules/print/entities/section.entity';
|
||||||
import { BaseEntity } from 'src/common/entities/base.entity';
|
import { BaseEntity } from 'src/common/entities/base.entity';
|
||||||
|
import { Product } from 'src/modules/product/entities/product.entity';
|
||||||
|
|
||||||
|
|
||||||
@Entity({ tableName: 'field' })
|
@Entity({ tableName: 'field' })
|
||||||
@@ -13,8 +14,11 @@ export class Field extends BaseEntity {
|
|||||||
@OneToMany(() => FieldOption, (attrValue) => attrValue.field)
|
@OneToMany(() => FieldOption, (attrValue) => attrValue.field)
|
||||||
options = new Collection<FieldOption>(this)
|
options = new Collection<FieldOption>(this)
|
||||||
|
|
||||||
@ManyToOne(() => Section)
|
@ManyToOne(() => Section, { nullable: true })
|
||||||
section!: Section
|
section?: Section
|
||||||
|
|
||||||
|
@ManyToOne(() => Product, { nullable: true })
|
||||||
|
product?: Product
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
name: string;
|
name: string;
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { FormBuilderController } from './controller/form-builder.controller';
|
||||||
|
import { FieldService } from './provider/field.service';
|
||||||
|
import { FieldOptionService } from './provider/field-option.service';
|
||||||
|
import { PrintModule } from '../print/print.module';
|
||||||
|
import { FieldRepository } from './repository/field.repository';
|
||||||
|
import { FieldOptionRepository } from './repository/field-option.repository';
|
||||||
|
import { JwtModule } from '@nestjs/jwt';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [PrintModule, JwtModule.register({})],
|
||||||
|
controllers: [FormBuilderController],
|
||||||
|
providers: [FieldService, FieldOptionService, FieldRepository, FieldOptionRepository],
|
||||||
|
exports: [FieldService, FieldOptionService, FieldRepository, FieldOptionRepository],
|
||||||
|
})
|
||||||
|
export class FormBuilderModule { }
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
export enum FieldType {
|
||||||
|
text = 'text',
|
||||||
|
textarea = 'textarea',
|
||||||
|
number = 'number',
|
||||||
|
select = 'select',
|
||||||
|
radio = 'radio',
|
||||||
|
checkbox = 'checkbox',
|
||||||
|
date = 'date',
|
||||||
|
}
|
||||||
+3
-3
@@ -2,10 +2,10 @@ 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 { SectionRepository } from '../repository/section.repository';
|
import { SectionRepository } from 'src/modules/print/repository/section.repository';
|
||||||
import { UpdateSectionDto } from '../dto/update-section.dto';
|
|
||||||
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';
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@@ -41,7 +41,7 @@ export class FieldService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async update(fieldId: number, dto: UpdateSectionDto) {
|
async update(fieldId: number, dto: UpdateFieldDto) {
|
||||||
|
|
||||||
const field = await this.fieldRepository.findOne({ id: fieldId })
|
const field = await this.fieldRepository.findOne({ id: fieldId })
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ export class OrderController {
|
|||||||
@Post('admin/orders/:orderId/invoice')
|
@Post('admin/orders/:orderId/invoice')
|
||||||
@UseGuards(AdminAuthGuard)
|
@UseGuards(AdminAuthGuard)
|
||||||
@ApiOperation({ summary: 'Create Order invoice ' })
|
@ApiOperation({ summary: 'Create Order invoice ' })
|
||||||
createInvoice(@Param('orderId') orderId: string) {
|
createInvoice(@Param('orderId') orderId: string, @Body() dto: UpdateOrderDtoAsAdmin) {
|
||||||
return this.orderService.createInvoice(orderId);
|
return this.orderService.createInvoice(orderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,14 +74,14 @@ export class Order {
|
|||||||
|
|
||||||
// @Property({ type: 'decimal', precision: 10, scale: 0, default: null, nullable: true })
|
// @Property({ type: 'decimal', precision: 10, scale: 0, default: null, nullable: true })
|
||||||
// subTotal?: number;
|
// subTotal?: number;
|
||||||
@Formula(alias => `
|
@Formula(alias => `
|
||||||
(
|
(
|
||||||
SELECT COALESCE(SUM(COALESCE(oi.unit_price, 0) * oi.quantity), 0)
|
SELECT COALESCE(SUM(COALESCE(oi.unit_price, 0) * oi.quantity), 0)
|
||||||
FROM order_items oi
|
FROM order_items oi
|
||||||
WHERE oi.order_id = ${alias}.id
|
WHERE oi.order_id = ${alias}.id
|
||||||
)
|
)
|
||||||
`)
|
`)
|
||||||
subTotal!: number;
|
subTotal!: number;
|
||||||
|
|
||||||
|
|
||||||
// @Property({ type: 'decimal', precision: 10, scale: 0, default: null, nullable: true })
|
// @Property({ type: 'decimal', precision: 10, scale: 0, default: null, nullable: true })
|
||||||
@@ -202,7 +202,7 @@ subTotal!: number;
|
|||||||
attachments?: string[]
|
attachments?: string[]
|
||||||
|
|
||||||
@Property({ type: 'json', nullable: true })
|
@Property({ type: 'json', nullable: true })
|
||||||
printIds?: string[] // id of field options
|
print?: { fieldId: string, value: string }[] // id of field options
|
||||||
|
|
||||||
@Property({ type: 'string', nullable: true })
|
@Property({ type: 'string', nullable: true })
|
||||||
paymentMethod?: string;
|
paymentMethod?: string;
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
import { Product } from "src/modules/product/entities/product.entity"
|
|
||||||
import { Order } from "../entities/order.entity"
|
|
||||||
|
|
||||||
export enum OrderStatusEnum {
|
export enum OrderStatusEnum {
|
||||||
CREATED = 'created',
|
CREATED = 'created',
|
||||||
|
|
||||||
|
|||||||
@@ -285,10 +285,7 @@ export class OrderService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async createInvoice(orderId: string) {
|
async createInvoice(orderId: string) {
|
||||||
const order = await this.findOrderOrFail(orderId)
|
|
||||||
await this.updateStatus(orderId, OrderStatusEnum.INVOICED)
|
await this.updateStatus(orderId, OrderStatusEnum.INVOICED)
|
||||||
// await this.calculateOrder(order)
|
|
||||||
await this.em.flush()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getOrderAsUser(userId: string, orderId: string) {
|
async getOrderAsUser(userId: string, orderId: string) {
|
||||||
|
|||||||
@@ -3,20 +3,13 @@ import { SectionService } from '../provider/section.service';
|
|||||||
import { CreateSectionDto } from '../dto/create-section.dto';
|
import { CreateSectionDto } from '../dto/create-section.dto';
|
||||||
import { ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
|
import { ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
|
||||||
import { AdminAuthGuard } from '../../auth/guards/adminAuth.guard';
|
import { AdminAuthGuard } from '../../auth/guards/adminAuth.guard';
|
||||||
import { FieldService } from '../provider/field.service';
|
|
||||||
import { CreateFieldDto } from '../dto/create-field.dto';
|
|
||||||
import { CreateFieldOptionDto } from '../dto/create-field-option.dto';
|
|
||||||
import { FieldOptionService } from '../provider/field-option.service';
|
|
||||||
import { UpdateFieldDto } from '../dto/update-field.dto';
|
|
||||||
import { UpdateSectionDto } from '../dto/update-section.dto';
|
import { UpdateSectionDto } from '../dto/update-section.dto';
|
||||||
|
|
||||||
@Controller('admin')
|
@Controller('admin')
|
||||||
@ApiBearerAuth()
|
@ApiBearerAuth()
|
||||||
export class PrintController {
|
export class PrintController {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly sectionService: SectionService,
|
private readonly sectionService: SectionService,
|
||||||
private readonly fieldService: FieldService,
|
|
||||||
private readonly fieldOptionService: FieldOptionService,
|
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
/*================================ Section ========================== */
|
/*================================ Section ========================== */
|
||||||
@@ -56,77 +49,4 @@ import { UpdateSectionDto } from '../dto/update-section.dto';
|
|||||||
return this.sectionService.remove(+id);
|
return this.sectionService.remove(+id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*================================ Field ========================== */
|
|
||||||
|
|
||||||
@Post('section/:id/field')
|
|
||||||
@ApiOperation({ summary: 'Create field for section' })
|
|
||||||
@UseGuards(AdminAuthGuard)
|
|
||||||
createField(@Body() dto: CreateFieldDto, @Param('id') sectionId: string) {
|
|
||||||
return this.fieldService.create(sectionId,dto);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Get('section/:id/field')
|
|
||||||
@ApiOperation({ summary: 'find all secion fields' })
|
|
||||||
@UseGuards(AdminAuthGuard)
|
|
||||||
findAllSectionFields(@Param('id') sectionId: string) {
|
|
||||||
return this.fieldService.findAll(+sectionId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Get('section/field/:id')
|
|
||||||
@ApiOperation({ summary: 'Find one field' })
|
|
||||||
@UseGuards(AdminAuthGuard)
|
|
||||||
findOneFiled(@Param('id') id: string) {
|
|
||||||
return this.fieldService.findById(+id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Patch('section/field/:id')
|
|
||||||
@ApiOperation({ summary: 'Update field' })
|
|
||||||
@UseGuards(AdminAuthGuard)
|
|
||||||
updateField(@Param('id') id: string, @Body() dto: UpdateFieldDto) {
|
|
||||||
return this.fieldService.update(+id, dto);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Delete('section/field/:id')
|
|
||||||
@ApiOperation({ summary: 'Renopve field' })
|
|
||||||
@UseGuards(AdminAuthGuard)
|
|
||||||
removeField(@Param('id') id: string) {
|
|
||||||
return this.fieldService.remove(+id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*================================ Field Option ========================== */
|
|
||||||
|
|
||||||
@Post('field/:id/option')
|
|
||||||
@ApiOperation({ summary: 'Create field Options ' })
|
|
||||||
@UseGuards(AdminAuthGuard)
|
|
||||||
createFieldOption(@Body() dto: CreateFieldOptionDto, @Param('id') id: string) {
|
|
||||||
return this.fieldOptionService.create(+id, dto);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Get('field/:id/option')
|
|
||||||
@ApiOperation({ summary: 'find all field Option' })
|
|
||||||
@UseGuards(AdminAuthGuard)
|
|
||||||
findAllFiledOptions(@Param('id') fieldId: string) {
|
|
||||||
return this.fieldOptionService.findAll(+fieldId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Get('field/option/:id')
|
|
||||||
@ApiOperation({ summary: 'Find one field Option' })
|
|
||||||
@UseGuards(AdminAuthGuard)
|
|
||||||
findOneFiledOption(@Param('id') id: string) {
|
|
||||||
return this.fieldOptionService.findById(+id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Patch('field/option/:id')
|
|
||||||
@ApiOperation({ summary: 'Update field Option' })
|
|
||||||
@UseGuards(AdminAuthGuard)
|
|
||||||
updateFieldOption(@Param('id') id: string, @Body() dto: UpdateSectionDto) {
|
|
||||||
return this.fieldOptionService.update(+id, dto);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Delete('field/option/:id')
|
|
||||||
@ApiOperation({ summary: 'Renopve field Option' })
|
|
||||||
@UseGuards(AdminAuthGuard)
|
|
||||||
removeFieldOption(@Param('id') id: string) {
|
|
||||||
return this.fieldOptionService.remove(+id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Cascade, Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core';
|
import { Cascade, Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core';
|
||||||
import { Field } from './field.entity';
|
import { Field } from 'src/modules/form-builder/entities/field.entity';
|
||||||
import { BaseEntity } from 'src/common/entities/base.entity';
|
import { BaseEntity } from 'src/common/entities/base.entity';
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
export enum FieldType {
|
|
||||||
text = 'text',
|
|
||||||
textarea = 'textarea',
|
|
||||||
number = 'number',
|
|
||||||
select = 'select',
|
|
||||||
radio = 'radio',
|
|
||||||
checkbox = 'checkbox',
|
|
||||||
date = 'date',
|
|
||||||
}
|
|
||||||
@@ -2,24 +2,20 @@ import { Module } from '@nestjs/common';
|
|||||||
import { SectionService } from './provider/section.service';
|
import { SectionService } from './provider/section.service';
|
||||||
import { PrintController } from './controller/print.controller';
|
import { PrintController } from './controller/print.controller';
|
||||||
import { MikroOrmModule } from '@mikro-orm/nestjs';
|
import { MikroOrmModule } from '@mikro-orm/nestjs';
|
||||||
import { Field } from './entities/field.entity';
|
|
||||||
import { Section } from './entities/section.entity';
|
import { Section } from './entities/section.entity';
|
||||||
import { FieldOption } from './entities/field-option.entity';
|
|
||||||
import { FieldRepository } from './repository/field.repository';
|
|
||||||
import { FieldOptionRepository } from './repository/field-option.repository';
|
|
||||||
import { SectionRepository } from './repository/section.repository';
|
import { SectionRepository } from './repository/section.repository';
|
||||||
import { JwtModule } from '@nestjs/jwt';
|
import { JwtModule } from '@nestjs/jwt';
|
||||||
import { RolesModule } from '../roles/roles.module';
|
import { RolesModule } from '../roles/roles.module';
|
||||||
import { FieldService } from './provider/field.service';
|
|
||||||
import { FieldOptionService } from './provider/field-option.service';
|
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
controllers: [PrintController],
|
controllers: [PrintController],
|
||||||
providers: [SectionService, FieldRepository, FieldOptionRepository,
|
providers: [SectionService,
|
||||||
SectionRepository, FieldService, FieldOptionService],
|
SectionRepository],
|
||||||
exports: [SectionService, FieldRepository, FieldOptionRepository,
|
exports: [SectionService,
|
||||||
SectionRepository, FieldOptionService],
|
SectionRepository],
|
||||||
imports: [MikroOrmModule.forFeature([Field, Section, FieldOption]),
|
imports: [MikroOrmModule.forFeature([Section]),
|
||||||
RolesModule, JwtModule.register({})]
|
RolesModule, JwtModule.register({})]
|
||||||
})
|
})
|
||||||
export class PrintModule { }
|
export class PrintModule { }
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { Injectable, NotFoundException } from '@nestjs/common';
|
import { Injectable, NotFoundException } from '@nestjs/common';
|
||||||
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 { SectionRepository } from '../repository/section.repository';
|
import { SectionRepository } from '../repository/section.repository';
|
||||||
import { CreateSectionDto } from '../dto/create-section.dto';
|
import { CreateSectionDto } from '../dto/create-section.dto';
|
||||||
import { Section } from '../entities/section.entity';
|
import { Section } from '../entities/section.entity';
|
||||||
@@ -13,7 +12,6 @@ export class SectionService {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly sectionRepository: SectionRepository,
|
private readonly sectionRepository: SectionRepository,
|
||||||
private readonly fieldRepository: FieldRepository,
|
|
||||||
private readonly em: EntityManager,
|
private readonly em: EntityManager,
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { IsString, IsOptional, IsBoolean, IsInt, Min, IsEnum, IsNotEmpty } from 'class-validator';
|
import { IsString, IsOptional, IsBoolean, IsInt, Min, IsEnum, IsNotEmpty } from 'class-validator';
|
||||||
import { ApiPropertyOptional, ApiProperty } from '@nestjs/swagger';
|
import { ApiPropertyOptional, ApiProperty } from '@nestjs/swagger';
|
||||||
import { Type } from 'class-transformer';
|
import { Type } from 'class-transformer';
|
||||||
import { FieldType } from 'src/modules/print/interface/print';
|
import { FieldType } from 'src/modules/form-builder/interface/print';
|
||||||
|
|
||||||
export class CreateAttributeDto {
|
export class CreateAttributeDto {
|
||||||
@IsString()
|
@IsString()
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core';
|
import { Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core';
|
||||||
import { BaseEntity } from '../../../common/entities/base.entity';
|
import { BaseEntity } from '../../../common/entities/base.entity';
|
||||||
import { Product } from './product.entity';
|
import { Product } from './product.entity';
|
||||||
import { AttributeValue } from './attribute-value.entity';
|
import { AttributeValue } from './attribute-value.entity';
|
||||||
import { FieldType } from 'src/modules/print/interface/print';
|
import { FieldType } from 'src/modules/form-builder/interface/print';
|
||||||
|
|
||||||
@Entity({ tableName: 'attributes' })
|
@Entity({ tableName: 'attributes' })
|
||||||
export class Attribute extends BaseEntity {
|
export class Attribute extends BaseEntity {
|
||||||
@@ -13,10 +13,10 @@ export class Attribute extends BaseEntity {
|
|||||||
parent?: Attribute | null
|
parent?: Attribute | null
|
||||||
|
|
||||||
@OneToMany(() => Attribute, (c) => c.parent)
|
@OneToMany(() => Attribute, (c) => c.parent)
|
||||||
children=new Collection<Attribute>(this)
|
children = new Collection<Attribute>(this)
|
||||||
|
|
||||||
@OneToMany(() => AttributeValue, (attrValue) => attrValue.attribute)
|
@OneToMany(() => AttributeValue, (attrValue) => attrValue.attribute)
|
||||||
values= new Collection<AttributeValue>(this)
|
values = new Collection<AttributeValue>(this)
|
||||||
|
|
||||||
@PrimaryKey({ type: 'bigint', autoincrement: true })
|
@PrimaryKey({ type: 'bigint', autoincrement: true })
|
||||||
id: bigint;
|
id: bigint;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { FieldType } from "src/modules/print/interface/print";
|
|
||||||
|
|
||||||
export interface AttributeValueData {
|
export interface AttributeValueData {
|
||||||
value: string;
|
value: string;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { FieldType } from "src/modules/print/interface/print";
|
import { FieldType } from "src/modules/form-builder/interface/print";
|
||||||
|
|
||||||
export interface AttributeData {
|
export interface AttributeData {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user