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