chore: add create customer and update customer for admin

This commit is contained in:
mahyargdz
2025-03-06 09:35:59 +03:30
parent c1f21e75f2
commit b92a65c22c
20 changed files with 674 additions and 399 deletions
@@ -56,6 +56,14 @@ export class DanakServicesController {
return this.danakServicesService.getCategoriesUserSide();
}
@AuthGuards()
@PermissionsDec(PermissionEnum.SERVICES)
@ApiOperation({ summary: "Get category by id => admin route" })
@Get("categories/:id")
getCategoryById(@Param() paramDto: ParamDto) {
return this.danakServicesService.getCategoryById(paramDto.id);
}
@AuthGuards()
@PermissionsDec(PermissionEnum.SERVICES)
@ApiOperation({ summary: "update category by id => admin route" })
@@ -27,7 +27,7 @@ export class DanakService extends BaseEntity {
@Column({ type: "varchar", length: 255, nullable: false })
author: string;
@Column({ type: "timestamp", nullable: false, default: () => "CURRENT_TIMESTAMP" })
@Column({ type: "timestamptz", nullable: false, default: () => "CURRENT_TIMESTAMP" })
createDate: Date;
@Column({ type: "int", nullable: false, default: 0 })
@@ -45,6 +45,16 @@ export class DanakServicesService {
}
/******************************************** */
async getCategoryById(categoryId: string) {
const category = await this.danakServicesCategoryRepository.findOneById(categoryId);
if (!category) throw new BadRequestException(CategoryMessage.CATEGORY_NOT_EXIST);
return {
category,
};
}
/******************************************** */
async updateCategory(categoryId: string, updateDto: UpdateCategoryDto) {
const category = await this.danakServicesCategoryRepository.findOneById(categoryId);
if (!category) throw new BadRequestException(CategoryMessage.CATEGORY_NOT_EXIST);