chore: add show in silder for the service
This commit is contained in:
@@ -189,6 +189,8 @@ export const enum ServiceMessage {
|
|||||||
IS_ACTIVE_SHOULD_BE_1_0 = "وضعیت سرویس باید یکی از مقادیر ۰ و ۱ باشد",
|
IS_ACTIVE_SHOULD_BE_1_0 = "وضعیت سرویس باید یکی از مقادیر ۰ و ۱ باشد",
|
||||||
IS_SUGGEST_SHOULD_BE_1_0 = "وضعیت پیشنهادی بودن سرویس باید یکی از مقادیر ۰ و ۱ باشد",
|
IS_SUGGEST_SHOULD_BE_1_0 = "وضعیت پیشنهادی بودن سرویس باید یکی از مقادیر ۰ و ۱ باشد",
|
||||||
REVIEW_STATUS_REQUIRED = "وضعیت نظر سرویس مورد نیاز است",
|
REVIEW_STATUS_REQUIRED = "وضعیت نظر سرویس مورد نیاز است",
|
||||||
|
SHOW_IN_SLIDER_REQUIRED = "وضعیت نمایش در اسلایدر سرویس مورد نیاز است",
|
||||||
|
SHOW_IN_SLIDER_BOOLEAN = "وضعیت نمایش در اسلایدر سرویس باید یک بولین باشد",
|
||||||
}
|
}
|
||||||
|
|
||||||
export const enum AnnouncementMessage {
|
export const enum AnnouncementMessage {
|
||||||
|
|||||||
@@ -70,6 +70,11 @@ export class CreateServiceDto {
|
|||||||
@ApiProperty({ description: "Is the service a Danak suggest?", example: true })
|
@ApiProperty({ description: "Is the service a Danak suggest?", example: true })
|
||||||
isDanakSuggest: boolean;
|
isDanakSuggest: boolean;
|
||||||
|
|
||||||
|
@IsNotEmpty({ message: ServiceMessage.SHOW_IN_SLIDER_REQUIRED })
|
||||||
|
@IsBoolean({ message: ServiceMessage.SHOW_IN_SLIDER_BOOLEAN })
|
||||||
|
@ApiProperty({ description: "Is the service show in slider?", example: true })
|
||||||
|
showInSlider: boolean;
|
||||||
|
|
||||||
@IsNotEmpty({ message: ServiceMessage.ICON_REQUIRED })
|
@IsNotEmpty({ message: ServiceMessage.ICON_REQUIRED })
|
||||||
@IsUrl({ protocols: ["http", "https"], require_protocol: true }, { message: ServiceMessage.ICON_SHOULD_BE_URL })
|
@IsUrl({ protocols: ["http", "https"], require_protocol: true }, { message: ServiceMessage.ICON_SHOULD_BE_URL })
|
||||||
@ApiProperty({ description: "The icon url of the service", example: "https://example.com/icon.png" })
|
@ApiProperty({ description: "The icon url of the service", example: "https://example.com/icon.png" })
|
||||||
|
|||||||
@@ -128,12 +128,27 @@ export class DanakServicesController {
|
|||||||
return this.danakServicesService.toggleServiceStatus(paramDto);
|
return this.danakServicesService.toggleServiceStatus(paramDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AuthGuards()
|
||||||
|
@PermissionsDec(PermissionEnum.SERVICES)
|
||||||
|
@ApiOperation({ summary: "toggle status of danak service slider => admin route" })
|
||||||
|
@HttpCode(HttpStatus.OK)
|
||||||
|
@Post("toggle-slider/:id")
|
||||||
|
toggleServiceSlider(@Param() paramDto: ParamDto) {
|
||||||
|
return this.danakServicesService.toggleServiceSlider(paramDto);
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation({ summary: "get services for user side" })
|
@ApiOperation({ summary: "get services for user side" })
|
||||||
@Get("suggested")
|
@Get("suggested")
|
||||||
getDanakSuggestServices() {
|
getDanakSuggestServices() {
|
||||||
return this.danakServicesService.getDanakSuggestServices();
|
return this.danakServicesService.getDanakSuggestServices();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation({ summary: "get danak service slider" })
|
||||||
|
@Get("slider")
|
||||||
|
getDanakServicesSlider() {
|
||||||
|
return this.danakServicesService.getDanakServicesSlider();
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation({ summary: "get danak service by id" })
|
@ApiOperation({ summary: "get danak service by id" })
|
||||||
@AuthGuards()
|
@AuthGuards()
|
||||||
@Get(":id")
|
@Get(":id")
|
||||||
|
|||||||
@@ -45,6 +45,9 @@ export class DanakService extends BaseEntity {
|
|||||||
@Column({ type: "boolean", default: false })
|
@Column({ type: "boolean", default: false })
|
||||||
isActive: boolean;
|
isActive: boolean;
|
||||||
|
|
||||||
|
@Column({ type: "boolean", default: false })
|
||||||
|
showInSlider: boolean;
|
||||||
|
|
||||||
@Column({ type: "varchar", length: 255, nullable: false })
|
@Column({ type: "varchar", length: 255, nullable: false })
|
||||||
link: string;
|
link: string;
|
||||||
|
|
||||||
|
|||||||
@@ -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) {
|
async createService(createDto: CreateServiceDto) {
|
||||||
const category = await this.danakServicesCategoryRepository.findOneById(createDto.categoryId);
|
const category = await this.danakServicesCategoryRepository.findOneById(createDto.categoryId);
|
||||||
if (!category) throw new BadRequestException(CategoryMessage.CATEGORY_NOT_EXIST);
|
if (!category) throw new BadRequestException(CategoryMessage.CATEGORY_NOT_EXIST);
|
||||||
@@ -358,12 +372,40 @@ export class DanakServicesService {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
order: { createdAt: "DESC" },
|
order: { createdAt: "DESC" },
|
||||||
|
withDeleted: false,
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
danakServices,
|
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) {
|
async getDanakServiceByIdWithSubs(serviceId: string, isAdmin: boolean, userId: string) {
|
||||||
const danakService = await this.danakServicesRepository.getDanakServiceById(serviceId, isAdmin);
|
const danakService = await this.danakServicesRepository.getDanakServiceById(serviceId, isAdmin);
|
||||||
|
|||||||
Reference in New Issue
Block a user