mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-17 03:05:13 +00:00
clean model entities
This commit is contained in:
@ -12,10 +12,7 @@ import { SceneDeviceRepository } from './modules/scene-device/repositories';
|
|||||||
import { SpaceProductItemRepository, SpaceRepository } from './modules/space';
|
import { SpaceProductItemRepository, SpaceRepository } from './modules/space';
|
||||||
import {
|
import {
|
||||||
SpaceModelRepository,
|
SpaceModelRepository,
|
||||||
SpaceProductModelRepository,
|
|
||||||
SubspaceModelRepository,
|
SubspaceModelRepository,
|
||||||
SubspaceProductItemModelRepository,
|
|
||||||
SubspaceProductModelRepository,
|
|
||||||
} from './modules/space-model';
|
} from './modules/space-model';
|
||||||
import { SubspaceRepository } from './modules/space/repositories/subspace.repository';
|
import { SubspaceRepository } from './modules/space/repositories/subspace.repository';
|
||||||
@Module({
|
@Module({
|
||||||
@ -28,10 +25,7 @@ import { SubspaceRepository } from './modules/space/repositories/subspace.reposi
|
|||||||
SpaceRepository,
|
SpaceRepository,
|
||||||
SubspaceRepository,
|
SubspaceRepository,
|
||||||
SubspaceModelRepository,
|
SubspaceModelRepository,
|
||||||
SubspaceProductModelRepository,
|
|
||||||
SubspaceProductItemModelRepository,
|
|
||||||
SpaceModelRepository,
|
SpaceModelRepository,
|
||||||
SpaceProductModelRepository,
|
|
||||||
SpaceProductItemRepository,
|
SpaceProductItemRepository,
|
||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
@ -45,10 +39,7 @@ import { SubspaceRepository } from './modules/space/repositories/subspace.reposi
|
|||||||
SpaceRepository,
|
SpaceRepository,
|
||||||
SubspaceRepository,
|
SubspaceRepository,
|
||||||
SubspaceModelRepository,
|
SubspaceModelRepository,
|
||||||
SubspaceProductModelRepository,
|
|
||||||
SubspaceProductItemModelRepository,
|
|
||||||
SpaceModelRepository,
|
SpaceModelRepository,
|
||||||
SpaceProductModelRepository,
|
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
ConfigModule.forRoot({
|
ConfigModule.forRoot({
|
||||||
|
@ -32,11 +32,8 @@ import { SpaceProductEntity } from '../modules/space/entities/space-product.enti
|
|||||||
import { ProjectEntity } from '../modules/project/entities';
|
import { ProjectEntity } from '../modules/project/entities';
|
||||||
import {
|
import {
|
||||||
SpaceModelEntity,
|
SpaceModelEntity,
|
||||||
SpaceProductItemModelEntity,
|
|
||||||
SpaceProductModelEntity,
|
|
||||||
SubspaceModelEntity,
|
SubspaceModelEntity,
|
||||||
SubspaceProductItemModelEntity,
|
TagModel,
|
||||||
SubspaceProductModelEntity,
|
|
||||||
} from '../modules/space-model/entities';
|
} from '../modules/space-model/entities';
|
||||||
import {
|
import {
|
||||||
InviteUserEntity,
|
InviteUserEntity,
|
||||||
@ -82,13 +79,10 @@ import {
|
|||||||
SceneIconEntity,
|
SceneIconEntity,
|
||||||
SceneDeviceEntity,
|
SceneDeviceEntity,
|
||||||
SpaceModelEntity,
|
SpaceModelEntity,
|
||||||
SpaceProductModelEntity,
|
|
||||||
SpaceProductItemModelEntity,
|
|
||||||
SubspaceModelEntity,
|
SubspaceModelEntity,
|
||||||
|
TagModel,
|
||||||
SpaceProductEntity,
|
SpaceProductEntity,
|
||||||
SpaceProductItemEntity,
|
SpaceProductItemEntity,
|
||||||
SubspaceProductModelEntity,
|
|
||||||
SubspaceProductItemModelEntity,
|
|
||||||
SubspaceProductEntity,
|
SubspaceProductEntity,
|
||||||
SubspaceProductItemEntity,
|
SubspaceProductItemEntity,
|
||||||
InviteUserEntity,
|
InviteUserEntity,
|
||||||
|
@ -3,8 +3,7 @@ import { ProductDto } from '../dtos';
|
|||||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||||
import { DeviceEntity } from '../../device/entities';
|
import { DeviceEntity } from '../../device/entities';
|
||||||
import { SpaceProductEntity } from '../../space/entities/space-product.entity';
|
import { SpaceProductEntity } from '../../space/entities/space-product.entity';
|
||||||
import { SpaceProductModelEntity } from '../../space-model/entities';
|
import { TagModel } from '../../space-model';
|
||||||
import { SubspaceProductModelEntity } from '../../space-model/entities/subspace-model/subspace-product-model.entity';
|
|
||||||
|
|
||||||
@Entity({ name: 'product' })
|
@Entity({ name: 'product' })
|
||||||
export class ProductEntity extends AbstractEntity<ProductDto> {
|
export class ProductEntity extends AbstractEntity<ProductDto> {
|
||||||
@ -32,17 +31,8 @@ export class ProductEntity extends AbstractEntity<ProductDto> {
|
|||||||
@OneToMany(() => SpaceProductEntity, (spaceProduct) => spaceProduct.product)
|
@OneToMany(() => SpaceProductEntity, (spaceProduct) => spaceProduct.product)
|
||||||
spaceProducts: SpaceProductEntity[];
|
spaceProducts: SpaceProductEntity[];
|
||||||
|
|
||||||
@OneToMany(
|
@OneToMany(() => TagModel, (tag) => tag.product)
|
||||||
() => SpaceProductModelEntity,
|
tagModels: TagModel[];
|
||||||
(spaceProductModel) => spaceProductModel.product,
|
|
||||||
)
|
|
||||||
spaceProductModels: SpaceProductModelEntity[];
|
|
||||||
|
|
||||||
@OneToMany(
|
|
||||||
() => SubspaceProductModelEntity,
|
|
||||||
(subspaceProductModel) => subspaceProductModel.product,
|
|
||||||
)
|
|
||||||
subpaceProductModels: SubspaceProductModelEntity[];
|
|
||||||
|
|
||||||
@OneToMany(
|
@OneToMany(
|
||||||
() => DeviceEntity,
|
() => DeviceEntity,
|
||||||
|
@ -1,4 +1,2 @@
|
|||||||
export * from './subspace-model';
|
export * from './subspace-model';
|
||||||
export * from './space-model.dto';
|
export * from './space-model.dto';
|
||||||
export * from './space-product-item-model.dto';
|
|
||||||
export * from './space-product-model.dto';
|
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
import { IsString, IsNotEmpty } from 'class-validator';
|
|
||||||
|
|
||||||
export class SpaceProductItemModelDto {
|
|
||||||
@IsString()
|
|
||||||
@IsNotEmpty()
|
|
||||||
uuid: string;
|
|
||||||
|
|
||||||
@IsString()
|
|
||||||
@IsNotEmpty()
|
|
||||||
tag: string;
|
|
||||||
|
|
||||||
@IsString()
|
|
||||||
@IsNotEmpty()
|
|
||||||
spaceProductModelUuid: string;
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
import { ApiProperty } from '@nestjs/swagger';
|
|
||||||
import { IsNotEmpty, IsString } from 'class-validator';
|
|
||||||
import { SpaceProductItemModelDto } from './space-product-item-model.dto';
|
|
||||||
|
|
||||||
export class SpaceProductModelDto {
|
|
||||||
@IsString()
|
|
||||||
@IsNotEmpty()
|
|
||||||
uuid: string;
|
|
||||||
|
|
||||||
@IsString()
|
|
||||||
@IsNotEmpty()
|
|
||||||
productUuid: string;
|
|
||||||
|
|
||||||
@ApiProperty({
|
|
||||||
description: 'List of individual items with specific names for the product',
|
|
||||||
type: [SpaceProductItemModelDto],
|
|
||||||
})
|
|
||||||
items: SpaceProductItemModelDto[];
|
|
||||||
}
|
|
@ -1,3 +1 @@
|
|||||||
export * from './subspace-model.dto';
|
export * from './subspace-model.dto';
|
||||||
export * from './subspace-product-item-model.dto';
|
|
||||||
export * from './subspace-product-model.dto';
|
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
import { IsString, IsNotEmpty } from 'class-validator';
|
|
||||||
|
|
||||||
export class SubspaceProductItemModelDto {
|
|
||||||
@IsString()
|
|
||||||
@IsNotEmpty()
|
|
||||||
uuid: string;
|
|
||||||
|
|
||||||
@IsString()
|
|
||||||
@IsNotEmpty()
|
|
||||||
tag: string;
|
|
||||||
|
|
||||||
@IsString()
|
|
||||||
@IsNotEmpty()
|
|
||||||
subspaceProductModelUuid: string;
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
import { ApiProperty } from '@nestjs/swagger';
|
|
||||||
import { IsNotEmpty, IsString } from 'class-validator';
|
|
||||||
import { SubspaceProductItemModelDto } from './subspace-product-item-model.dto';
|
|
||||||
|
|
||||||
export class SubpaceProductModelDto {
|
|
||||||
@IsString()
|
|
||||||
@IsNotEmpty()
|
|
||||||
uuid: string;
|
|
||||||
|
|
||||||
@IsString()
|
|
||||||
@IsNotEmpty()
|
|
||||||
productUuid: string;
|
|
||||||
|
|
||||||
@ApiProperty({
|
|
||||||
description: 'List of individual items with specific names for the product',
|
|
||||||
type: [SubspaceProductItemModelDto],
|
|
||||||
})
|
|
||||||
items: SubspaceProductItemModelDto[];
|
|
||||||
}
|
|
21
libs/common/src/modules/space-model/dtos/tag-model.dto.ts
Normal file
21
libs/common/src/modules/space-model/dtos/tag-model.dto.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import { IsNotEmpty, IsString } from 'class-validator';
|
||||||
|
|
||||||
|
export class TagModelDto {
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public uuid: string;
|
||||||
|
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public name: string;
|
||||||
|
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public productUuid: string;
|
||||||
|
|
||||||
|
@IsString()
|
||||||
|
spaceModelUuid: string;
|
||||||
|
|
||||||
|
@IsString()
|
||||||
|
subspaceModelUuid: string;
|
||||||
|
}
|
@ -1,4 +1,3 @@
|
|||||||
export * from './space-model.entity';
|
export * from './space-model.entity';
|
||||||
export * from './space-product-item-model.entity';
|
|
||||||
export * from './space-product-model.entity';
|
|
||||||
export * from './subspace-model';
|
export * from './subspace-model';
|
||||||
|
export * from './tag-model.entity';
|
||||||
|
@ -9,9 +9,9 @@ import {
|
|||||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||||
import { SpaceModelDto } from '../dtos';
|
import { SpaceModelDto } from '../dtos';
|
||||||
import { SubspaceModelEntity } from './subspace-model';
|
import { SubspaceModelEntity } from './subspace-model';
|
||||||
import { SpaceProductModelEntity } from './space-product-model.entity';
|
|
||||||
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';
|
||||||
|
|
||||||
@Entity({ name: 'space-model' })
|
@Entity({ name: 'space-model' })
|
||||||
@Unique(['modelName', 'project'])
|
@Unique(['modelName', 'project'])
|
||||||
@ -51,17 +51,11 @@ export class SpaceModelEntity extends AbstractEntity<SpaceModelDto> {
|
|||||||
)
|
)
|
||||||
public subspaceModels: SubspaceModelEntity[];
|
public subspaceModels: SubspaceModelEntity[];
|
||||||
|
|
||||||
@OneToMany(
|
|
||||||
() => SpaceProductModelEntity,
|
|
||||||
(productModel) => productModel.spaceModel,
|
|
||||||
{
|
|
||||||
nullable: true,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
public spaceProductModels: SpaceProductModelEntity[];
|
|
||||||
|
|
||||||
@OneToMany(() => SpaceEntity, (space) => space.spaceModel, {
|
@OneToMany(() => SpaceEntity, (space) => space.spaceModel, {
|
||||||
cascade: true,
|
cascade: true,
|
||||||
})
|
})
|
||||||
public spaces: SpaceEntity[];
|
public spaces: SpaceEntity[];
|
||||||
|
|
||||||
|
@OneToMany(() => TagModel, (tag) => tag.spaceModel)
|
||||||
|
tags: TagModel[];
|
||||||
}
|
}
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
import { Entity, Column, ManyToOne, OneToMany } from 'typeorm';
|
|
||||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
|
||||||
import { SpaceProductItemModelDto } from '../dtos';
|
|
||||||
import { SpaceProductModelEntity } from './space-product-model.entity';
|
|
||||||
import { SpaceProductItemEntity } from '../../space/entities';
|
|
||||||
|
|
||||||
@Entity({ name: 'space-product-item-model' })
|
|
||||||
export class SpaceProductItemModelEntity extends AbstractEntity<SpaceProductItemModelDto> {
|
|
||||||
@Column({
|
|
||||||
nullable: false,
|
|
||||||
})
|
|
||||||
public tag: string;
|
|
||||||
|
|
||||||
@ManyToOne(
|
|
||||||
() => SpaceProductModelEntity,
|
|
||||||
(spaceProductModel) => spaceProductModel.items,
|
|
||||||
{
|
|
||||||
nullable: false,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
public spaceProductModel: SpaceProductModelEntity;
|
|
||||||
|
|
||||||
@Column({
|
|
||||||
nullable: false,
|
|
||||||
default: false,
|
|
||||||
})
|
|
||||||
public disabled: boolean;
|
|
||||||
|
|
||||||
@OneToMany(
|
|
||||||
() => SpaceProductItemEntity,
|
|
||||||
(spaceProductItem) => spaceProductItem.spaceProductItemModel,
|
|
||||||
{ cascade: true },
|
|
||||||
)
|
|
||||||
public items: SpaceProductItemEntity[];
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
import { Entity, Column, ManyToOne, OneToMany } from 'typeorm';
|
|
||||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
|
||||||
import { ProductEntity } from '../../product/entities';
|
|
||||||
import { SpaceModelEntity } from './space-model.entity';
|
|
||||||
import { SpaceProductItemModelEntity } from './space-product-item-model.entity';
|
|
||||||
import { SpaceProductModelDto } from '../dtos';
|
|
||||||
import { SpaceProductEntity } from '../../space/entities';
|
|
||||||
|
|
||||||
@Entity({ name: 'space-product-model' })
|
|
||||||
export class SpaceProductModelEntity extends AbstractEntity<SpaceProductModelDto> {
|
|
||||||
@ManyToOne(
|
|
||||||
() => SpaceModelEntity,
|
|
||||||
(spaceModel) => spaceModel.spaceProductModels,
|
|
||||||
{
|
|
||||||
nullable: false,
|
|
||||||
onDelete: 'CASCADE',
|
|
||||||
},
|
|
||||||
)
|
|
||||||
public spaceModel: SpaceModelEntity;
|
|
||||||
|
|
||||||
@ManyToOne(() => ProductEntity, (product) => product.spaceProductModels, {
|
|
||||||
nullable: false,
|
|
||||||
onDelete: 'CASCADE',
|
|
||||||
})
|
|
||||||
public product: ProductEntity;
|
|
||||||
|
|
||||||
@Column({
|
|
||||||
nullable: false,
|
|
||||||
default: false,
|
|
||||||
})
|
|
||||||
public disabled: boolean;
|
|
||||||
|
|
||||||
@OneToMany(
|
|
||||||
() => SpaceProductItemModelEntity,
|
|
||||||
(item) => item.spaceProductModel,
|
|
||||||
{
|
|
||||||
cascade: true,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
public items: SpaceProductItemModelEntity[];
|
|
||||||
|
|
||||||
@OneToMany(
|
|
||||||
() => SpaceProductEntity,
|
|
||||||
(spaceProduct) => spaceProduct.spaceProductModel,
|
|
||||||
{
|
|
||||||
cascade: true,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
public spaceProducts: SpaceProductEntity[];
|
|
||||||
}
|
|
@ -1,3 +1,2 @@
|
|||||||
export * from './subspace-model.entity';
|
export * from './subspace-model.entity';
|
||||||
export * from './subspace-product-item-model.entity';
|
|
||||||
export * from './subspace-product-model.entity';
|
|
@ -3,7 +3,7 @@ import { Column, Entity, ManyToOne, OneToMany, Unique } from 'typeorm';
|
|||||||
import { SubSpaceModelDto } from '../../dtos';
|
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 { SubspaceProductModelEntity } from './subspace-product-model.entity';
|
import { TagModel } from '../tag-model.entity';
|
||||||
|
|
||||||
@Entity({ name: 'subspace-model' })
|
@Entity({ name: 'subspace-model' })
|
||||||
@Unique(['subspaceName', 'spaceModel'])
|
@Unique(['subspaceName', 'spaceModel'])
|
||||||
@ -41,12 +41,6 @@ export class SubspaceModelEntity extends AbstractEntity<SubSpaceModelDto> {
|
|||||||
})
|
})
|
||||||
public disabled: boolean;
|
public disabled: boolean;
|
||||||
|
|
||||||
@OneToMany(
|
@OneToMany(() => TagModel, (tag) => tag.subspaceModel)
|
||||||
() => SubspaceProductModelEntity,
|
tags: TagModel[];
|
||||||
(productModel) => productModel.subspaceModel,
|
|
||||||
{
|
|
||||||
nullable: true,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
public productModels: SubspaceProductModelEntity[];
|
|
||||||
}
|
}
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
import { AbstractEntity } from '@app/common/modules/abstract/entities/abstract.entity';
|
|
||||||
import { Entity, Column, ManyToOne, OneToMany } from 'typeorm';
|
|
||||||
import { SubspaceProductItemModelDto } from '../../dtos';
|
|
||||||
import { SubspaceProductModelEntity } from './subspace-product-model.entity';
|
|
||||||
import { SubspaceProductItemEntity } from '@app/common/modules/space/entities';
|
|
||||||
|
|
||||||
@Entity({ name: 'subspace-product-item-model' })
|
|
||||||
export class SubspaceProductItemModelEntity extends AbstractEntity<SubspaceProductItemModelDto> {
|
|
||||||
@Column({
|
|
||||||
nullable: false,
|
|
||||||
})
|
|
||||||
public tag: string;
|
|
||||||
|
|
||||||
@Column({
|
|
||||||
nullable: false,
|
|
||||||
default: false,
|
|
||||||
})
|
|
||||||
public disabled: boolean;
|
|
||||||
|
|
||||||
@ManyToOne(
|
|
||||||
() => SubspaceProductModelEntity,
|
|
||||||
(productModel) => productModel.itemModels,
|
|
||||||
{
|
|
||||||
nullable: false,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
public subspaceProductModel: SubspaceProductModelEntity;
|
|
||||||
|
|
||||||
@OneToMany(() => SubspaceProductItemEntity, (item) => item.subspaceProduct, {
|
|
||||||
nullable: true,
|
|
||||||
})
|
|
||||||
items: SubspaceProductItemEntity[];
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
import { Entity, Column, ManyToOne, OneToMany } from 'typeorm';
|
|
||||||
import { SubpaceProductModelDto } from '../../dtos';
|
|
||||||
import { AbstractEntity } from '@app/common/modules/abstract/entities/abstract.entity';
|
|
||||||
import { SubspaceModelEntity } from './subspace-model.entity';
|
|
||||||
import { ProductEntity } from '@app/common/modules/product/entities';
|
|
||||||
import { SubspaceProductEntity } from '@app/common/modules/space/entities';
|
|
||||||
import { SubspaceProductItemModelEntity } from './subspace-product-item-model.entity';
|
|
||||||
|
|
||||||
@Entity({ name: 'subspace-product-model' })
|
|
||||||
export class SubspaceProductModelEntity extends AbstractEntity<SubpaceProductModelDto> {
|
|
||||||
@Column({
|
|
||||||
nullable: false,
|
|
||||||
default: false,
|
|
||||||
})
|
|
||||||
public disabled: boolean;
|
|
||||||
|
|
||||||
@ManyToOne(
|
|
||||||
() => SubspaceModelEntity,
|
|
||||||
(spaceModel) => spaceModel.productModels,
|
|
||||||
{
|
|
||||||
nullable: false,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
public subspaceModel: SubspaceModelEntity;
|
|
||||||
|
|
||||||
@ManyToOne(() => ProductEntity, (product) => product.subpaceProductModels, {
|
|
||||||
nullable: false,
|
|
||||||
})
|
|
||||||
public product: ProductEntity;
|
|
||||||
|
|
||||||
@OneToMany(() => SubspaceProductEntity, (product) => product.model, {
|
|
||||||
nullable: true,
|
|
||||||
})
|
|
||||||
public subspaceProducts: SubspaceProductEntity[];
|
|
||||||
|
|
||||||
@OneToMany(
|
|
||||||
() => SubspaceProductItemModelEntity,
|
|
||||||
(product) => product.subspaceProductModel,
|
|
||||||
{
|
|
||||||
nullable: true,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
public itemModels: SubspaceProductItemModelEntity[];
|
|
||||||
}
|
|
@ -0,0 +1,29 @@
|
|||||||
|
import { Column, Entity, JoinColumn, ManyToOne, Unique } from 'typeorm';
|
||||||
|
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||||
|
import { TagModelDto } from '../dtos/tag-model.dto';
|
||||||
|
import { SpaceModelEntity } from './space-model.entity';
|
||||||
|
import { SubspaceModelEntity } from './subspace-model';
|
||||||
|
import { ProductEntity } from '../../product/entities';
|
||||||
|
|
||||||
|
@Entity({ name: 'tag_model' })
|
||||||
|
@Unique(['tag', 'product', 'spaceModel', 'subspaceModel'])
|
||||||
|
export class TagModel extends AbstractEntity<TagModelDto> {
|
||||||
|
@Column({ type: 'varchar', length: 255 })
|
||||||
|
tag: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => ProductEntity, (product) => product.tagModels, {
|
||||||
|
nullable: false,
|
||||||
|
})
|
||||||
|
@JoinColumn({ name: 'product_id' })
|
||||||
|
product: ProductEntity;
|
||||||
|
|
||||||
|
@ManyToOne(() => SpaceModelEntity, (space) => space.tags, { nullable: true })
|
||||||
|
@JoinColumn({ name: 'space_id' })
|
||||||
|
spaceModel: SpaceModelEntity;
|
||||||
|
|
||||||
|
@ManyToOne(() => SubspaceModelEntity, (subspace) => subspace.tags, {
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
@JoinColumn({ name: 'subspace_id' })
|
||||||
|
subspaceModel: SubspaceModelEntity;
|
||||||
|
}
|
@ -1,13 +1,6 @@
|
|||||||
import { DataSource, Repository } from 'typeorm';
|
import { DataSource, Repository } from 'typeorm';
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import {
|
import { SpaceModelEntity, SubspaceModelEntity, TagModel } from '../entities';
|
||||||
SpaceModelEntity,
|
|
||||||
SpaceProductItemModelEntity,
|
|
||||||
SpaceProductModelEntity,
|
|
||||||
SubspaceModelEntity,
|
|
||||||
SubspaceProductItemModelEntity,
|
|
||||||
SubspaceProductModelEntity,
|
|
||||||
} from '../entities';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SpaceModelRepository extends Repository<SpaceModelEntity> {
|
export class SpaceModelRepository extends Repository<SpaceModelEntity> {
|
||||||
@ -23,28 +16,8 @@ export class SubspaceModelRepository extends Repository<SubspaceModelEntity> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SubspaceProductModelRepository extends Repository<SubspaceProductModelEntity> {
|
export class TagModelRepository extends Repository<TagModel> {
|
||||||
constructor(private dataSource: DataSource) {
|
constructor(private dataSource: DataSource) {
|
||||||
super(SubspaceProductModelEntity, dataSource.createEntityManager());
|
super(TagModel, dataSource.createEntityManager());
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class SubspaceProductItemModelRepository extends Repository<SubspaceProductItemModelEntity> {
|
|
||||||
constructor(private dataSource: DataSource) {
|
|
||||||
super(SubspaceProductItemModelEntity, dataSource.createEntityManager());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class SpaceProductModelRepository extends Repository<SpaceProductModelEntity> {
|
|
||||||
constructor(private dataSource: DataSource) {
|
|
||||||
super(SpaceProductModelEntity, dataSource.createEntityManager());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Injectable()
|
|
||||||
export class SpaceProductItemModelRepository extends Repository<SpaceProductItemModelEntity> {
|
|
||||||
constructor(private dataSource: DataSource) {
|
|
||||||
super(SpaceProductItemModelEntity, dataSource.createEntityManager());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
import {
|
import { SpaceModelEntity, SubspaceModelEntity, TagModel } from './entities';
|
||||||
SpaceModelEntity,
|
|
||||||
SpaceProductItemModelEntity,
|
|
||||||
SpaceProductModelEntity,
|
|
||||||
SubspaceModelEntity,
|
|
||||||
} from './entities';
|
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
@ -12,12 +7,7 @@ import { Module } from '@nestjs/common';
|
|||||||
exports: [],
|
exports: [],
|
||||||
controllers: [],
|
controllers: [],
|
||||||
imports: [
|
imports: [
|
||||||
TypeOrmModule.forFeature([
|
TypeOrmModule.forFeature([SpaceModelEntity, SubspaceModelEntity, TagModel]),
|
||||||
SpaceModelEntity,
|
|
||||||
SubspaceModelEntity,
|
|
||||||
SpaceProductModelEntity,
|
|
||||||
SpaceProductItemModelEntity,
|
|
||||||
]),
|
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class SpaceModelRepositoryModule {}
|
export class SpaceModelRepositoryModule {}
|
||||||
|
@ -2,7 +2,6 @@ import { Column, Entity, ManyToOne, OneToOne } from 'typeorm';
|
|||||||
import { SpaceProductEntity } from './space-product.entity';
|
import { SpaceProductEntity } from './space-product.entity';
|
||||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||||
import { SpaceProductItemDto } from '../dtos';
|
import { SpaceProductItemDto } from '../dtos';
|
||||||
import { SpaceProductItemModelEntity } from '../../space-model';
|
|
||||||
import { DeviceEntity } from '../../device/entities';
|
import { DeviceEntity } from '../../device/entities';
|
||||||
|
|
||||||
@Entity({ name: 'space-product-item' })
|
@Entity({ name: 'space-product-item' })
|
||||||
@ -23,15 +22,6 @@ export class SpaceProductItemEntity extends AbstractEntity<SpaceProductItemDto>
|
|||||||
})
|
})
|
||||||
public disabled: boolean;
|
public disabled: boolean;
|
||||||
|
|
||||||
@ManyToOne(
|
|
||||||
() => SpaceProductItemModelEntity,
|
|
||||||
(spaceProductItemModel) => spaceProductItemModel.items,
|
|
||||||
{
|
|
||||||
nullable: true,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
public spaceProductItemModel?: SpaceProductItemModelEntity;
|
|
||||||
|
|
||||||
@OneToOne(() => DeviceEntity, (device) => device.tag, {
|
@OneToOne(() => DeviceEntity, (device) => device.tag, {
|
||||||
nullable: true,
|
nullable: true,
|
||||||
})
|
})
|
||||||
|
@ -3,7 +3,6 @@ import { SpaceEntity } from './space.entity';
|
|||||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||||
import { ProductEntity } from '../../product/entities';
|
import { ProductEntity } from '../../product/entities';
|
||||||
import { SpaceProductItemEntity } from './space-product-item.entity';
|
import { SpaceProductItemEntity } from './space-product-item.entity';
|
||||||
import { SpaceProductModelEntity } from '../../space-model';
|
|
||||||
|
|
||||||
@Entity({ name: 'space-product' })
|
@Entity({ name: 'space-product' })
|
||||||
export class SpaceProductEntity extends AbstractEntity<SpaceProductEntity> {
|
export class SpaceProductEntity extends AbstractEntity<SpaceProductEntity> {
|
||||||
@ -32,16 +31,6 @@ export class SpaceProductEntity extends AbstractEntity<SpaceProductEntity> {
|
|||||||
})
|
})
|
||||||
public items: SpaceProductItemEntity[];
|
public items: SpaceProductItemEntity[];
|
||||||
|
|
||||||
@ManyToOne(
|
|
||||||
() => SpaceProductModelEntity,
|
|
||||||
(spaceProductModel) => spaceProductModel.spaceProducts,
|
|
||||||
{
|
|
||||||
nullable: true,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
@JoinColumn({ name: 'space_product_model_uuid' })
|
|
||||||
public spaceProductModel?: SpaceProductModelEntity;
|
|
||||||
|
|
||||||
constructor(partial: Partial<SpaceProductEntity>) {
|
constructor(partial: Partial<SpaceProductEntity>) {
|
||||||
super();
|
super();
|
||||||
Object.assign(this, partial);
|
Object.assign(this, partial);
|
||||||
|
@ -2,7 +2,6 @@ import { AbstractEntity } from '@app/common/modules/abstract/entities/abstract.e
|
|||||||
import { SpaceProductItemDto } from '../../dtos';
|
import { SpaceProductItemDto } from '../../dtos';
|
||||||
import { Column, Entity, ManyToOne } from 'typeorm';
|
import { Column, Entity, ManyToOne } from 'typeorm';
|
||||||
import { SubspaceProductEntity } from './subspace-product.entity';
|
import { SubspaceProductEntity } from './subspace-product.entity';
|
||||||
import { SubspaceProductItemModelEntity } from '@app/common/modules/space-model';
|
|
||||||
|
|
||||||
@Entity({ name: 'subspace-product-item' })
|
@Entity({ name: 'subspace-product-item' })
|
||||||
export class SubspaceProductItemEntity extends AbstractEntity<SpaceProductItemDto> {
|
export class SubspaceProductItemEntity extends AbstractEntity<SpaceProductItemDto> {
|
||||||
@ -26,11 +25,6 @@ export class SubspaceProductItemEntity extends AbstractEntity<SpaceProductItemDt
|
|||||||
})
|
})
|
||||||
public disabled: boolean;
|
public disabled: boolean;
|
||||||
|
|
||||||
@ManyToOne(() => SubspaceProductItemModelEntity, (model) => model.items, {
|
|
||||||
nullable: true,
|
|
||||||
})
|
|
||||||
model: SubspaceProductItemModelEntity;
|
|
||||||
|
|
||||||
constructor(partial: Partial<SubspaceProductItemEntity>) {
|
constructor(partial: Partial<SubspaceProductItemEntity>) {
|
||||||
super();
|
super();
|
||||||
Object.assign(this, partial);
|
Object.assign(this, partial);
|
||||||
|
@ -3,7 +3,6 @@ import { Column, Entity, ManyToOne, OneToMany } from 'typeorm';
|
|||||||
import { SubspaceEntity } from './subspace.entity';
|
import { SubspaceEntity } from './subspace.entity';
|
||||||
import { AbstractEntity } from '@app/common/modules/abstract/entities/abstract.entity';
|
import { AbstractEntity } from '@app/common/modules/abstract/entities/abstract.entity';
|
||||||
import { SubspaceProductItemEntity } from './subspace-product-item.entity';
|
import { SubspaceProductItemEntity } from './subspace-product-item.entity';
|
||||||
import { SubspaceProductModelEntity } from '@app/common/modules/space-model';
|
|
||||||
import { SpaceProductModelDto } from '../../dtos';
|
import { SpaceProductModelDto } from '../../dtos';
|
||||||
|
|
||||||
@Entity({ name: 'subspace-product' })
|
@Entity({ name: 'subspace-product' })
|
||||||
@ -26,7 +25,7 @@ export class SubspaceProductEntity extends AbstractEntity<SpaceProductModelDto>
|
|||||||
})
|
})
|
||||||
public subspace: SubspaceEntity;
|
public subspace: SubspaceEntity;
|
||||||
|
|
||||||
@ManyToOne(() => ProductEntity, (product) => product.subpaceProductModels, {
|
@ManyToOne(() => ProductEntity, (product) => product.spaceProducts, {
|
||||||
nullable: false,
|
nullable: false,
|
||||||
})
|
})
|
||||||
public product: ProductEntity;
|
public product: ProductEntity;
|
||||||
@ -36,12 +35,4 @@ export class SubspaceProductEntity extends AbstractEntity<SpaceProductModelDto>
|
|||||||
})
|
})
|
||||||
public items: SubspaceProductItemEntity[];
|
public items: SubspaceProductItemEntity[];
|
||||||
|
|
||||||
@ManyToOne(
|
|
||||||
() => SubspaceProductModelEntity,
|
|
||||||
(model) => model.subspaceProducts,
|
|
||||||
{
|
|
||||||
nullable: true,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
model: SubspaceProductModelEntity;
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user