chore: add new service to add subs to danak services in array
This commit is contained in:
@@ -3,6 +3,7 @@ import { FindOptionsWhere, In, IsNull } from "typeorm";
|
||||
|
||||
import { ParamDto } from "../../../common/DTO/param.dto";
|
||||
import { CategoryMessage, CommonMessage, ServiceMessage } from "../../../common/enums/message.enum";
|
||||
import { RoleEnum } from "../../users/enums/role.enum";
|
||||
import { PaginationUtils } from "../../utils/providers/pagination.utils";
|
||||
import { CategoryListSearchQueryDto, CategorySearchQueryDto } from "../DTO/category-search-query.dto";
|
||||
import { CreateCategoryDto } from "../DTO/create-category.dto";
|
||||
@@ -92,9 +93,9 @@ export class DanakServicesService {
|
||||
|
||||
async getCategoryServices(categoryId: string) {
|
||||
const category = await this.danakServicesCategoryRepository.findOne({
|
||||
where: { id: categoryId },
|
||||
where: { id: categoryId, isActive: true, danakServices: { isActive: true } },
|
||||
relations: {
|
||||
danakService: true,
|
||||
danakServices: true,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
@@ -172,9 +173,9 @@ export class DanakServicesService {
|
||||
}
|
||||
/******************************************** */
|
||||
|
||||
async getDanakServiceByID(serviceId: string) {
|
||||
async getDanakServiceByIdWithSubs(serviceId: string, role: RoleEnum) {
|
||||
const danakService = await this.danakServicesRepository.findOne({
|
||||
where: { id: serviceId, isActive: true },
|
||||
where: { id: serviceId, ...(role !== RoleEnum.ADMIN && { isActive: true, subscriptionPlans: { isActive: true } }) },
|
||||
relations: { images: true, subscriptionPlans: true },
|
||||
});
|
||||
if (!danakService) throw new BadRequestException(ServiceMessage.SERVICE_NOT_FOUND_BY_ID);
|
||||
|
||||
Reference in New Issue
Block a user