form builder

This commit is contained in:
2026-01-31 12:47:37 +03:30
parent 1f32b8eb3f
commit aabe0b5fed
3 changed files with 44 additions and 0 deletions
@@ -10,6 +10,7 @@ import { Product } from 'src/modules/product/entities/product.entity';
import { Print } from 'src/modules/print/entities/print.entity';
import { ProductService } from 'src/modules/product/providers/product.service';
import { PrintService } from 'src/modules/print/provider/Print.service';
import { FindFieldsGroupDto } from '../dto/find-field-group.dto';
@Injectable()
@@ -78,6 +79,29 @@ export class FieldService {
{ populate: ['options'] });
}
async findAllByIds(dto: FindFieldsGroupDto) {
const fields = await this.fieldRepository.find({
entityId: { $in: dto.entityIds }
},
{ populate: ['options'] },
);
// const fieldMap = new Map(fields.map(f => [f.entityId, f]))
const result: { entityId: number, fields: Field[] }[] = []
fields.forEach(field => {
if (!result.find((r => r.entityId == Number(field.entityId)))) {
result.push({
entityId: Number(field.entityId),
fields: fields.filter(f => f.entityId == field.entityId)
})
}
})
return result
}
async findById(fieldId: number): Promise<Field> {
const field = await this.fieldRepository.findOne({ id: fieldId },
{ populate: [] });