24 lines
850 B
TypeScript
24 lines
850 B
TypeScript
import { BadRequestException, Injectable } from "@nestjs/common";
|
|
|
|
import { BusinessMessage } from "../../../common/enums/message.enum";
|
|
import { BusinessRepository } from "../repositories/business.repository";
|
|
|
|
@Injectable()
|
|
export class BusinessesService {
|
|
constructor(private readonly businessRepository: BusinessRepository) {}
|
|
|
|
async getBusinessByDanakSubscriptionId(danakSubscriptionId: string) {
|
|
const business = await this.businessRepository.findOne({ danakSubscriptionId, deletedAt: null });
|
|
if (!business) throw new BadRequestException(BusinessMessage.NOT_FOUND);
|
|
|
|
return business;
|
|
}
|
|
|
|
async getBusinessBySlug(slug: string) {
|
|
const business = await this.businessRepository.findOne({ slug, deletedAt: null });
|
|
if (!business) throw new BadRequestException(BusinessMessage.NOT_FOUND);
|
|
|
|
return { business };
|
|
}
|
|
}
|