This commit is contained in:
2026-02-05 11:44:55 +03:30
parent fac601030c
commit 94aa6ba5e5
5 changed files with 21 additions and 25 deletions
@@ -9,7 +9,6 @@ import { Admin } from '../entities/admin.entity';
import { PermissionEnum } from 'src/common/enums/permission.enum'; import { PermissionEnum } from 'src/common/enums/permission.enum';
import { Permissions } from 'src/common/decorators/permissions.decorator'; import { Permissions } from 'src/common/decorators/permissions.decorator';
// TODO : if admin deleted then recreated it must be doable
@Controller() @Controller()
@ApiTags('admin') @ApiTags('admin')
@UseGuards(AdminAuthGuard) @UseGuards(AdminAuthGuard)
@@ -32,8 +32,6 @@ export class Order extends BaseEntity{
@PrimaryKey({ type: 'string', columnType: 'char(26)' }) @PrimaryKey({ type: 'string', columnType: 'char(26)' })
id: string = ulid() id: string = ulid()
//TODO : need a new field for confirmation .confirmedAt
// also need another for
@ManyToOne(() => User) @ManyToOne(() => User)
user!: User; user!: User;
+9 -11
View File
@@ -14,7 +14,7 @@ export class PrintService {
constructor( constructor(
private readonly printRepository: PrintRepository, private readonly printRepository: PrintRepository,
@Inject(forwardRef(()=>FieldService)) @Inject(forwardRef(() => FieldService))
private readonly fieldService: FieldService, private readonly fieldService: FieldService,
private readonly em: EntityManager, private readonly em: EntityManager,
) { } ) { }
@@ -46,20 +46,18 @@ export class PrintService {
} }
// Todo : its not good way
async findAll(): Promise<PrintWithFields[]> { async findAll(): Promise<PrintWithFields[]> {
const sections = await this.printRepository.findAll(); const sections = await this.printRepository.findAll();
const result: PrintWithFields[] = [];
const promises = sections.map(async (section) => {
for (const section of sections) { const fields = await this.fieldService.findAll(section.id)
const fields = await this.fieldService.findAll(section.id); return {
result.push({
...section, ...section,
fields fields
}); }
} })
return result; return Promise.all(promises)
} }
@@ -50,10 +50,10 @@ export class CategoryService {
throw new NotFoundException(CategoryMessage.NOT_FOUND); throw new NotFoundException(CategoryMessage.NOT_FOUND);
} }
if (dto.parentId) { if (dto.parentId) {
console.log('pp', dto.parentId)
const parent = await this.categoryRepository.findOne({ id: dto.parentId }) const parent = await this.categoryRepository.findOne({ id: dto.parentId })
if (!parent) { if (!parent) {
throw new NotFoundException(CategoryMessage.NOT_FOUND); throw new NotFoundException(CategoryMessage.NOT_FOUND);
} }
@@ -61,12 +61,12 @@ export class CategoryService {
this.categoryRepository.assign(category, { parent }) this.categoryRepository.assign(category, { parent })
} }
this.categoryRepository.assign(category, dto) const updated = this.categoryRepository.assign(category, dto)
//TODO : which one od these are correct
// this.productRepository.nativeUpdate(productId,product)
this.em.persistAndFlush(category)
return category
await this.em.flush()
return updated
} }
@@ -60,9 +60,10 @@ export class ProductService {
} }
this.productRepository.assign(product, rest) this.productRepository.assign(product, rest)
//TODO : which one od these are correct
// this.productRepository.nativeUpdate(productId,product) await this.em.flush()
this.em.persistAndFlush(product)
return product
} }
@@ -94,7 +95,7 @@ export class ProductService {
const products = await this.productRepository.find({ const products = await this.productRepository.find({
id: { $in: productIds } id: { $in: productIds }
}) })
return products return products
} }