248 lines
6.1 KiB
TypeScript
248 lines
6.1 KiB
TypeScript
import { TextObjectFilterResult } from "../TextObjectFilter.model";
|
|
|
|
export type FindServicesParams = {
|
|
_id?: string;
|
|
name?: string;
|
|
description?: string;
|
|
companyId?: string;
|
|
categoryId?: number;
|
|
length?: number;
|
|
price?: number;
|
|
limit?: number;
|
|
};
|
|
|
|
export type SetServiceFileParams = {
|
|
companyId: string;
|
|
serviceId: string;
|
|
sessionUser: string;
|
|
file: Express.Multer.File;
|
|
};
|
|
|
|
export type PaginateServicesParams = {
|
|
query?: string;
|
|
companyId?: string;
|
|
serviceId?: string;
|
|
categoryId?: number;
|
|
priceFrom?: number;
|
|
priceTo?: number;
|
|
lengthFrom?: number;
|
|
lengthTo?: number;
|
|
block?: string;
|
|
city?: string;
|
|
state?: string;
|
|
page: number;
|
|
limit: number;
|
|
published?: SERVICE_PUBLISHED_STATUS;
|
|
};
|
|
|
|
export type PaginateServicesResults = {
|
|
data: IService[];
|
|
page: number;
|
|
pages: number;
|
|
};
|
|
|
|
export type CreateServiceParams = {
|
|
companyId: string;
|
|
categoryId?: number;
|
|
name: string;
|
|
description: string;
|
|
length: number;
|
|
originalPrice: number;
|
|
limit: number;
|
|
block?: string;
|
|
city?: string;
|
|
state?: string;
|
|
country?: string;
|
|
zipCode?: string;
|
|
latitude?: number;
|
|
longitude?: number;
|
|
sessionUser: string;
|
|
showPublicScores?: boolean;
|
|
showPublicOpinions?: boolean;
|
|
};
|
|
|
|
export type UpdateServiceParams = {
|
|
id: string;
|
|
companyId: string;
|
|
categoryId?: number;
|
|
name?: string;
|
|
description?: string;
|
|
length?: number;
|
|
originalPrice?: number;
|
|
limit?: number;
|
|
image?: string;
|
|
color?: string;
|
|
fontColor?: string;
|
|
fontShadowColor?: string;
|
|
block?: string;
|
|
city?: string;
|
|
state?: string;
|
|
country?: string;
|
|
zipCode?: string;
|
|
latitude?: number;
|
|
longitude?: number;
|
|
sessionUser: string;
|
|
banned?: boolean;
|
|
showPublicScores?: boolean;
|
|
showPublicOpinions?: boolean;
|
|
};
|
|
|
|
export type PaginatePublicServicesParams = FindServicesParams & {
|
|
page: number;
|
|
limit: number;
|
|
};
|
|
|
|
export type PublicServicesResults = {
|
|
data: PublicServiceView[];
|
|
page: number;
|
|
pages: number;
|
|
};
|
|
|
|
export type SysAdminPaginateServicesParams = PaginateServicesParams & {
|
|
banned?: boolean;
|
|
};
|
|
|
|
export type SysAdminSetServiceBannedParams = {
|
|
id: string;
|
|
banned: boolean;
|
|
};
|
|
|
|
export type DeleteServicesByCompany = {
|
|
companyId: string;
|
|
};
|
|
|
|
export enum SERVICE_PUBLISHED_STATUS {
|
|
PUBLISHED = "published",
|
|
PRIVATE = "private",
|
|
}
|
|
|
|
export type SetPublishedStatusParams = {
|
|
serviceId: string;
|
|
published: SERVICE_PUBLISHED_STATUS;
|
|
sessionUser: string;
|
|
};
|
|
|
|
export type ApplyDiscountParams = {
|
|
companyId: string;
|
|
serviceId: string;
|
|
discountId: string;
|
|
sessionUser: string;
|
|
};
|
|
|
|
export type DeleteDiscountParams = {
|
|
companyId: string;
|
|
serviceId: string;
|
|
sessionUser: string;
|
|
};
|
|
|
|
export interface IService {
|
|
id?: string;
|
|
companyId: string;
|
|
categoryId: number;
|
|
name: string;
|
|
description: string;
|
|
length: number;
|
|
price: number;
|
|
originalPrice: number;
|
|
limit: number;
|
|
image: string;
|
|
color: string;
|
|
fontColor: string;
|
|
fontShadowColor: string;
|
|
block?: string;
|
|
city?: string;
|
|
state?: string;
|
|
country?: string;
|
|
zipCode?: string;
|
|
latitude?: number;
|
|
longitude?: number;
|
|
published?: SERVICE_PUBLISHED_STATUS;
|
|
discountId?: string;
|
|
banned?: boolean;
|
|
showPublicScores?: boolean;
|
|
showPublicOpinions?: boolean;
|
|
}
|
|
|
|
export interface CompanyServiceView {
|
|
id: string;
|
|
name: string;
|
|
description: string;
|
|
length: number;
|
|
price: number;
|
|
originalPrice: number;
|
|
discountId: string;
|
|
discountName: string;
|
|
discountCode: string;
|
|
discountType: string;
|
|
discountValue: number;
|
|
limit: number;
|
|
image: string;
|
|
color: string;
|
|
fontColor: string;
|
|
fontShadowColor: string;
|
|
published: SERVICE_PUBLISHED_STATUS;
|
|
banned?: boolean;
|
|
showPublicScores: boolean;
|
|
showPublicOpinions: boolean;
|
|
}
|
|
|
|
export interface PublicServiceView {
|
|
id: string;
|
|
name: string;
|
|
description: string;
|
|
length: number;
|
|
price: number;
|
|
originalPrice: number;
|
|
discountId: string;
|
|
discountName: string;
|
|
discountCode: string;
|
|
discountType: string;
|
|
discountValue: number;
|
|
limit: number;
|
|
image: string;
|
|
organizationId: string;
|
|
organizationName: string;
|
|
categoryId: number;
|
|
color: string;
|
|
fontColor: string;
|
|
fontShadowColor: string;
|
|
banned?: boolean;
|
|
showPublicScores: boolean;
|
|
showPublicOpinions: boolean;
|
|
}
|
|
|
|
export interface FindServicesByCompanyParams {
|
|
companyId: string;
|
|
}
|
|
|
|
export interface FindServicesByIdParams {
|
|
serviceId: string;
|
|
}
|
|
|
|
export interface IServicesAdapter {
|
|
create(data: CreateServiceParams): Promise<IService>;
|
|
update(data: UpdateServiceParams): Promise<void>;
|
|
delete(id: string): Promise<void>;
|
|
find(filters: FindServicesParams): Promise<IService[]>;
|
|
findOne(filters: FindServicesParams): Promise<IService | null>;
|
|
paginate(filters: PaginateServicesParams): Promise<PaginateServicesResults>;
|
|
sysAdminPaginate(data: SysAdminPaginateServicesParams): Promise<PaginateServicesResults>;
|
|
}
|
|
|
|
export interface IServicesManager {
|
|
services: IServicesAdapter;
|
|
createService(data: CreateServiceParams): Promise<IService>;
|
|
updateService(data: UpdateServiceParams): Promise<void>;
|
|
applyDiscount(data: ApplyDiscountParams): Promise<void>;
|
|
deleteDiscount(data: DeleteDiscountParams): Promise<void>;
|
|
setServiceImage(data: SetServiceFileParams): Promise<void>;
|
|
findByCompanyId(data: FindServicesByCompanyParams): Promise<CompanyServiceView[]>;
|
|
findById(id: FindServicesByIdParams): Promise<CompanyServiceView>;
|
|
publicServices(data: PaginateServicesParams): Promise<PublicServicesResults>;
|
|
deleteServicesByCompany(data: DeleteServicesByCompany): Promise<void>;
|
|
setPublishedStatus(data: SetPublishedStatusParams): Promise<void>;
|
|
textObjectFilter(data: FindServicesParams): Promise<TextObjectFilterResult[]>;
|
|
sysAdminPaginate(data: SysAdminPaginateServicesParams): Promise<PaginateServicesResults>;
|
|
sysAdminSetBanned(data: SysAdminSetServiceBannedParams): Promise<void>;
|
|
}
|