mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 10:14:54 +00:00
updated tag with relation
This commit is contained in:
1
libs/common/src/modules/tag/dtos/index.ts
Normal file
1
libs/common/src/modules/tag/dtos/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from './tag.dto';
|
||||||
@ -1,8 +1,10 @@
|
|||||||
import { Entity, Column, ManyToOne, Unique } from 'typeorm';
|
import { Entity, Column, ManyToOne, Unique, OneToMany } from 'typeorm';
|
||||||
import { ProductEntity } from '../../product/entities';
|
import { ProductEntity } from '../../product/entities';
|
||||||
import { ProjectEntity } from '../../project/entities';
|
import { ProjectEntity } from '../../project/entities';
|
||||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||||
import { NewTagDto } from '../dtos/tag.dto';
|
import { NewTagDto } from '../dtos/tag.dto';
|
||||||
|
import { SpaceModelProductAllocationEntity } from '../../space-model/entities/space-model-product-allocation.entity';
|
||||||
|
import { SubspaceProductAllocation } from '../../space';
|
||||||
|
|
||||||
@Entity({ name: 'tag' })
|
@Entity({ name: 'tag' })
|
||||||
@Unique(['name', 'project'])
|
@Unique(['name', 'project'])
|
||||||
@ -29,6 +31,18 @@ export class NewTagEntity extends AbstractEntity<NewTagDto> {
|
|||||||
})
|
})
|
||||||
public project: ProjectEntity;
|
public project: ProjectEntity;
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => SpaceModelProductAllocationEntity,
|
||||||
|
(allocation) => allocation.allowedTags,
|
||||||
|
)
|
||||||
|
public spaceModelAllocations: SpaceModelProductAllocationEntity[];
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => SubspaceProductAllocation,
|
||||||
|
(allocation) => allocation.allowedTags,
|
||||||
|
)
|
||||||
|
public subspaceAllocations: SubspaceProductAllocation[];
|
||||||
|
|
||||||
constructor(partial: Partial<NewTagEntity>) {
|
constructor(partial: Partial<NewTagEntity>) {
|
||||||
super();
|
super();
|
||||||
Object.assign(this, partial);
|
Object.assign(this, partial);
|
||||||
|
|||||||
1
libs/common/src/modules/tag/index.ts
Normal file
1
libs/common/src/modules/tag/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from './entities';
|
||||||
0
libs/common/src/modules/tag/repositories/index.ts
Normal file
0
libs/common/src/modules/tag/repositories/index.ts
Normal file
10
libs/common/src/modules/tag/repositories/tag-repository.ts
Normal file
10
libs/common/src/modules/tag/repositories/tag-repository.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { NewTagEntity } from '../entities';
|
||||||
|
import { DataSource, Repository } from 'typeorm';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class NewTagRepository extends Repository<NewTagRepository> {
|
||||||
|
constructor(private dataSource: DataSource) {
|
||||||
|
super(NewTagEntity, dataSource.createEntityManager());
|
||||||
|
}
|
||||||
|
}
|
||||||
11
libs/common/src/modules/tag/tag.repository.module.ts
Normal file
11
libs/common/src/modules/tag/tag.repository.module.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
|
import { NewTagEntity } from './entities';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
providers: [],
|
||||||
|
exports: [],
|
||||||
|
controllers: [],
|
||||||
|
imports: [TypeOrmModule.forFeature([NewTagEntity])],
|
||||||
|
})
|
||||||
|
export class NewTagRepositoryModule {}
|
||||||
Reference in New Issue
Block a user