chore: ticket service but not tested

This commit is contained in:
mahyargdz
2025-01-28 20:08:43 +03:30
parent 239099bb15
commit 1d11509371
28 changed files with 368 additions and 73 deletions
@@ -2,7 +2,7 @@ import { BadRequestException, Injectable } from "@nestjs/common";
import { FindOptionsWhere, IsNull } from "typeorm";
import { ParamDto } from "../../../common/DTO/param.dto";
import { CategoryMessage, CommonMessage } from "../../../common/enums/message.enum";
import { CategoryMessage, CommonMessage, ServiceMessage } from "../../../common/enums/message.enum";
import { PaginationUtils } from "../../utils/providers/pagination.utils";
import { CategoryListSearchQueryDto, CategorySearchQueryDto } from "../DTO/category-search-query.dto";
import { CreateCategoryDto } from "../DTO/create-category.dto";
@@ -78,6 +78,17 @@ export class DanakServicesService {
}
/******************************************** */
async getUserServices(userId: string) {
const userServices = await this.danakServicesRepository.find({
where: { users: { id: userId } },
});
return {
userServices,
};
}
/******************************************** */
async toggleCategoryStatus(paramDto: ParamDto) {
const category = await this.danakServicesCategoryRepository.findOneById(paramDto.id);
if (!category) throw new BadRequestException(CategoryMessage.CATEGORY_NOT_EXIST);
@@ -93,6 +104,9 @@ export class DanakServicesService {
const category = await this.danakServicesCategoryRepository.findOneById(createDto.categoryId);
if (!category) throw new BadRequestException(CategoryMessage.CATEGORY_NOT_EXIST);
const existService = await this.danakServicesRepository.findOneByName(createDto.name);
if (existService) throw new BadRequestException(ServiceMessage.NAME_EXIST);
const images = createDto.images.map((image) => {
return { imageUrl: image };
});
@@ -104,6 +118,13 @@ export class DanakServicesService {
service,
};
}
/******************************************** */
async getServiceByName(name: string) {
const danakService = await this.danakServicesRepository.findOneByName(name);
if (!danakService) throw new BadRequestException(ServiceMessage.SERVICE_NOT_EXIST);
return danakService;
}
/******************************************** */
/******************************************** */