Compare commits

...

2 Commits

Author SHA1 Message Date
5129724a8a prettier 2025-02-11 11:25:20 +04:00
62f949396f removed allowed quantity and renamed tags 2025-02-11 11:23:29 +04:00
10 changed files with 13 additions and 37 deletions

View File

@ -1,10 +1,4 @@
import {
IsUUID,
IsInt,
IsOptional,
ValidateNested,
IsArray,
} from 'class-validator';
import { IsUUID, IsOptional, ValidateNested, IsArray } from 'class-validator';
import { Type } from 'class-transformer';
import { SpaceModelDto } from '../../space-model/dtos/space-model.dto';
import { ProductDto } from '../../product/dtos/product.dto';
@ -23,13 +17,10 @@ export class SpaceModelProductAllocationDto {
@Type(() => ProductDto)
product: ProductDto;
@IsInt()
allowedQuantity: number;
@IsArray()
@ValidateNested({ each: true })
@Type(() => NewTagDto)
allowedTags: NewTagDto[];
tags: NewTagDto[];
@IsOptional()
@IsArray()

View File

@ -1,4 +1,4 @@
import { IsUUID, IsInt, ValidateNested, IsArray } from 'class-validator';
import { IsUUID, ValidateNested, IsArray } from 'class-validator';
import { Type } from 'class-transformer';
import { SubSpaceModelDto } from './subspace-model.dto';
import { ProductDto } from '@app/common/modules/product/dtos';
@ -16,11 +16,8 @@ export class SubspaceModelProductAllocationDto {
@Type(() => ProductDto)
product: ProductDto;
@IsInt()
allowedQuantity: number;
@IsArray()
@ValidateNested({ each: true })
@Type(() => NewTagDto)
allowedTags: NewTagDto[];
tags: NewTagDto[];
}

View File

@ -31,12 +31,9 @@ export class SpaceModelProductAllocationEntity extends AbstractEntity<SpaceModel
@ManyToOne(() => ProductEntity, { nullable: false, onDelete: 'CASCADE' })
public product: ProductEntity;
@Column({ type: 'int', default: 1 })
public allowedQuantity: number;
@ManyToMany(() => NewTagEntity)
@JoinTable({ name: 'space_model_product_tags' })
public allowedTags: NewTagEntity[];
public tags: NewTagEntity[];
@OneToMany(
() => SpaceProductAllocationEntity,

View File

@ -27,12 +27,9 @@ export class SubspaceModelProductAllocationEntity extends AbstractEntity<Subspac
@ManyToOne(() => ProductEntity, { nullable: false, onDelete: 'CASCADE' })
public product: ProductEntity;
@Column({ type: 'int', default: 1 })
public allowedQuantity: number;
@ManyToMany(() => NewTagEntity, (tag) => tag.subspaceModelAllocations)
@JoinTable({ name: 'subspace_model_product_tags' })
public allowedTags: NewTagEntity[];
public tags: NewTagEntity[];
constructor(partial: Partial<SubspaceModelProductAllocationEntity>) {
super();

View File

@ -33,7 +33,7 @@ export class SubspaceModelEntity extends AbstractEntity<SubSpaceModelDto> {
@OneToMany(() => SubspaceEntity, (subspace) => subspace.subSpaceModel, {
cascade: true,
})
public subspaceModel: SubspaceEntity[];
public subspace: SubspaceEntity[];
@Column({
nullable: false,

View File

@ -20,5 +20,5 @@ export class SpaceProductAllocationDto {
@IsArray()
@ValidateNested({ each: true })
@Type(() => NewTagDto)
allowedTags: NewTagDto[];
tags: NewTagDto[];
}

View File

@ -20,5 +20,5 @@ export class SubspaceProductAllocationDto {
@IsArray()
@ValidateNested({ each: true })
@Type(() => NewTagDto)
allowedTags: NewTagDto[];
tags: NewTagDto[];
}

View File

@ -30,12 +30,9 @@ export class SpaceProductAllocationEntity extends AbstractEntity<SpaceProductAll
@ManyToOne(() => ProductEntity, { nullable: false, onDelete: 'CASCADE' })
public product: ProductEntity;
@Column({ type: 'int', default: 1 })
public allowedQuantity: number;
@ManyToMany(() => NewTagEntity)
@JoinTable({ name: 'space_product_tags' })
public allowedTags: NewTagEntity[];
public tags: NewTagEntity[];
constructor(partial: Partial<SpaceProductAllocationEntity>) {
super();

View File

@ -38,12 +38,9 @@ export class SubspaceProductAllocationEntity extends AbstractEntity<SubspaceProd
@ManyToOne(() => ProductEntity, { nullable: false, onDelete: 'CASCADE' })
public product: ProductEntity;
@Column({ type: 'int', default: 1 })
public allowedQuantity: number;
@ManyToMany(() => NewTagEntity)
@JoinTable({ name: 'subspace_product_tags' })
public allowedTags: NewTagEntity[];
public tags: NewTagEntity[];
constructor(partial: Partial<SubspaceProductAllocationEntity>) {
super();

View File

@ -45,13 +45,13 @@ export class NewTagEntity extends AbstractEntity<NewTagDto> {
@ManyToMany(
() => SpaceModelProductAllocationEntity,
(allocation) => allocation.allowedTags,
(allocation) => allocation.tags,
)
public spaceModelAllocations: SpaceModelProductAllocationEntity[];
@ManyToMany(
() => SubspaceModelProductAllocationEntity,
(allocation) => allocation.allowedTags,
(allocation) => allocation.tags,
)
public subspaceModelAllocations: SubspaceModelProductAllocationEntity[];