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 { 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;
|
||||||
|
|||||||
@@ -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[] = [];
|
|
||||||
|
|
||||||
for (const section of sections) {
|
const promises = sections.map(async (section) => {
|
||||||
const fields = await this.fieldService.findAll(section.id);
|
const fields = await this.fieldService.findAll(section.id)
|
||||||
result.push({
|
return {
|
||||||
...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
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user