chore: add show in silder for the service
This commit is contained in:
@@ -250,6 +250,20 @@ export class DanakServicesService {
|
||||
};
|
||||
}
|
||||
/******************************************** */
|
||||
async toggleServiceSlider(paramDto: ParamDto) {
|
||||
const service = await this.danakServicesRepository.findServiceById(paramDto.id);
|
||||
if (!service) throw new BadRequestException(ServiceMessage.SERVICE_NOT_EXIST);
|
||||
//
|
||||
service.showInSlider = !service.showInSlider;
|
||||
//
|
||||
await this.danakServicesRepository.save(service);
|
||||
//
|
||||
return {
|
||||
message: CommonMessage.UPDATE_SUCCESS,
|
||||
showInSlider: service.showInSlider,
|
||||
};
|
||||
}
|
||||
/******************************************** */
|
||||
async createService(createDto: CreateServiceDto) {
|
||||
const category = await this.danakServicesCategoryRepository.findOneById(createDto.categoryId);
|
||||
if (!category) throw new BadRequestException(CategoryMessage.CATEGORY_NOT_EXIST);
|
||||
@@ -358,12 +372,40 @@ export class DanakServicesService {
|
||||
},
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
withDeleted: false,
|
||||
});
|
||||
return {
|
||||
danakServices,
|
||||
};
|
||||
}
|
||||
/******************************************** */
|
||||
async getDanakServicesSlider() {
|
||||
const danakServices = await this.danakServicesRepository.find({
|
||||
where: { showInSlider: true, isActive: true, deletedAt: IsNull(), category: { isActive: true, deletedAt: IsNull() } },
|
||||
relations: { category: true },
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
title: true,
|
||||
description: true,
|
||||
createDate: true,
|
||||
icon: true,
|
||||
createdAt: true,
|
||||
isActive: true,
|
||||
isDanakSuggest: true,
|
||||
showInSlider: true,
|
||||
metaDescription: true,
|
||||
category: {
|
||||
id: true,
|
||||
title: true,
|
||||
},
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
withDeleted: false,
|
||||
});
|
||||
return { danakServices };
|
||||
}
|
||||
/******************************************** */
|
||||
|
||||
async getDanakServiceByIdWithSubs(serviceId: string, isAdmin: boolean, userId: string) {
|
||||
const danakService = await this.danakServicesRepository.getDanakServiceById(serviceId, isAdmin);
|
||||
|
||||
Reference in New Issue
Block a user