add: member by superrior
This commit is contained in:
@@ -2,17 +2,15 @@ import {
|
||||
Entity,
|
||||
Column,
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
DeleteDateColumn,
|
||||
VersionColumn,
|
||||
CreateDateColumn,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
} from 'typeorm';
|
||||
import { ProductCategories } from './product-category.entity';
|
||||
import { BaseModel } from '../../config/basemodel.entity';
|
||||
import { Product } from './product.entity';
|
||||
|
||||
@Entity()
|
||||
export class ProductSubCategories extends BaseModel{
|
||||
export class ProductSubCategories extends BaseModel {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@@ -21,4 +19,7 @@ export class ProductSubCategories extends BaseModel{
|
||||
|
||||
@ManyToOne(() => ProductCategories, (categories) => categories.subCategories)
|
||||
category: ProductCategories;
|
||||
|
||||
@OneToMany(() => Product, (product) => product.subCategories)
|
||||
product: Product;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import { ProductSubCategories } from './product-sub-category.entity';
|
||||
import { BaseModel } from '../../config/basemodel.entity';
|
||||
|
||||
@Entity()
|
||||
export class Product extends BaseModel{
|
||||
export class Product extends BaseModel {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@@ -30,13 +30,17 @@ export class Product extends BaseModel{
|
||||
price: number;
|
||||
|
||||
@Column({
|
||||
nullable:true
|
||||
nullable: true,
|
||||
})
|
||||
basePrice: number;
|
||||
|
||||
@ManyToOne(
|
||||
() => ProductSubCategories,
|
||||
(subCategories) => subCategories.category,
|
||||
() => {
|
||||
return ProductSubCategories;
|
||||
},
|
||||
(subCategories) => {
|
||||
return subCategories.product;
|
||||
},
|
||||
)
|
||||
subCategories: ProductSubCategories;
|
||||
}
|
||||
|
||||
@@ -55,8 +55,9 @@ export class ProductService {
|
||||
|
||||
findAllByCategories(page, categories) {
|
||||
return this.productRepository.findAndCount({
|
||||
where: {
|
||||
subCategories: categories,
|
||||
join: {
|
||||
alias: 'subCategories',
|
||||
innerJoin: { subCategories: 'roles.users' },
|
||||
},
|
||||
skip: page * 10,
|
||||
take: 10,
|
||||
@@ -130,7 +131,7 @@ export class ProductService {
|
||||
endDate: updatePriceProductDto.endDate,
|
||||
});
|
||||
|
||||
return
|
||||
return true;
|
||||
}
|
||||
|
||||
async remove(id: string) {
|
||||
|
||||
Reference in New Issue
Block a user