fix tag usage

This commit is contained in:
hannathkadher
2025-02-10 13:04:22 +04:00
parent acf8c42170
commit f5f9e9dfe3
4 changed files with 16 additions and 13 deletions

View File

@ -5,7 +5,7 @@ import { SubspaceModelEntity } from './subspace-model';
import { ProjectEntity } from '../../project/entities'; import { ProjectEntity } from '../../project/entities';
import { SpaceEntity } from '../../space/entities'; import { SpaceEntity } from '../../space/entities';
import { TagModel } from './tag-model.entity'; import { TagModel } from './tag-model.entity';
import { SpaceModelProductAllocation } from './space-model-product-allocation.entity'; import { SpaceModelProductAllocationEntity } from './space-model-product-allocation.entity';
@Entity({ name: 'space-model' }) @Entity({ name: 'space-model' })
export class SpaceModelEntity extends AbstractEntity<SpaceModelDto> { export class SpaceModelEntity extends AbstractEntity<SpaceModelDto> {
@ -53,11 +53,11 @@ export class SpaceModelEntity extends AbstractEntity<SpaceModelDto> {
tags: TagModel[]; tags: TagModel[];
@OneToMany( @OneToMany(
() => SpaceModelProductAllocation, () => SpaceModelProductAllocationEntity,
(allocation) => allocation.spaceModel, (allocation) => allocation.spaceModel,
{ cascade: true }, { cascade: true },
) )
public productAllocations: SpaceModelProductAllocation[]; public productAllocations: SpaceModelProductAllocationEntity[];
constructor(partial: Partial<SpaceModelEntity>) { constructor(partial: Partial<SpaceModelEntity>) {
super(); super();

View File

@ -4,7 +4,7 @@ import { SubSpaceModelDto } from '../../dtos';
import { SpaceModelEntity } from '../space-model.entity'; import { SpaceModelEntity } from '../space-model.entity';
import { SubspaceEntity } from '@app/common/modules/space/entities'; import { SubspaceEntity } from '@app/common/modules/space/entities';
import { TagModel } from '../tag-model.entity'; import { TagModel } from '../tag-model.entity';
import { SubspaceModelProductAllocation } from './subspace-model-product-allocation.entity'; import { SubspaceModelProductAllocationEntity } from './subspace-model-product-allocation.entity';
@Entity({ name: 'subspace-model' }) @Entity({ name: 'subspace-model' })
export class SubspaceModelEntity extends AbstractEntity<SubSpaceModelDto> { export class SubspaceModelEntity extends AbstractEntity<SubSpaceModelDto> {
@ -45,9 +45,9 @@ export class SubspaceModelEntity extends AbstractEntity<SubSpaceModelDto> {
tags: TagModel[]; tags: TagModel[];
@OneToMany( @OneToMany(
() => SubspaceModelProductAllocation, () => SubspaceModelProductAllocationEntity,
(allocation) => allocation.subspaceModel, (allocation) => allocation.subspaceModel,
{ cascade: true }, { cascade: true },
) )
public productAllocations: SubspaceModelProductAllocation[]; public productAllocations: SubspaceModelProductAllocationEntity[];
} }

View File

@ -2,9 +2,9 @@ import { DataSource, Repository } from 'typeorm';
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { import {
SpaceModelEntity, SpaceModelEntity,
SpaceModelProductAllocation, SpaceModelProductAllocationEntity,
SubspaceModelEntity, SubspaceModelEntity,
SubspaceModelProductAllocation, SubspaceModelProductAllocationEntity,
TagModel, TagModel,
} from '../entities'; } from '../entities';
@ -29,15 +29,18 @@ export class TagModelRepository extends Repository<TagModel> {
} }
@Injectable() @Injectable()
export class SpaceModelProductAllocationRepoitory extends Repository<SpaceModelProductAllocation> { export class SpaceModelProductAllocationRepoitory extends Repository<SpaceModelProductAllocationEntity> {
constructor(private dataSource: DataSource) { constructor(private dataSource: DataSource) {
super(SpaceModelProductAllocation, dataSource.createEntityManager()); super(SpaceModelProductAllocationEntity, dataSource.createEntityManager());
} }
} }
@Injectable() @Injectable()
export class SubspaceModelProductAllocationRepoitory extends Repository<SubspaceModelProductAllocation> { export class SubspaceModelProductAllocationRepoitory extends Repository<SubspaceModelProductAllocationEntity> {
constructor(private dataSource: DataSource) { constructor(private dataSource: DataSource) {
super(SubspaceModelProductAllocation, dataSource.createEntityManager()); super(
SubspaceModelProductAllocationEntity,
dataSource.createEntityManager(),
);
} }
} }

View File

@ -19,7 +19,7 @@ export class NewTagEntity extends AbstractEntity<NewTagDto> {
@Column() @Column()
name: string; name: string;
@ManyToOne(() => ProductEntity, (product) => product.tags, { @ManyToOne(() => ProductEntity, (product) => product.newTags, {
nullable: false, nullable: false,
onDelete: 'CASCADE', onDelete: 'CASCADE',
}) })