Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 21x 2x 2x 1x 1x 2x 2x 1x 1x 2x 2x 1x 1x 1x 2x 2x 1x 1x 1x 2x 2x 1x 1x | import { Injectable, NotFoundException } from '@nestjs/common';
import { plainToInstance } from 'class-transformer';
import { ERROR } from 'src/commons/constants/error';
import { CursorPaginatedResponseDto } from 'src/commons/dtos/cursor-paginated-response.dto';
import { ListResponseDto } from 'src/commons/dtos/list-response.dto';
import { isEmpty } from 'src/commons/util/is/is-empty';
import { PlaceEntity } from 'src/entities/place.entity';
import { ApiPlaceGetCultureDetailResponseDto } from 'src/place/dto/api-place-get-culture-detail-response.dto';
import { ApiPlaceGetCultureRequestQueryDto } from 'src/place/dto/api-place-get-culture-request-query.dto';
import { ApiPlaceGetCultureResponseDto } from 'src/place/dto/api-place-get-culture-response.dto';
import { ApiPlaceGetDetailResponseDto } from 'src/place/dto/api-place-get-detail-response.dto';
import { ApiPlaceGetExhibitionRequestQueryDto } from 'src/place/dto/api-place-get-exhibition-request-query.dto';
import { ApiPlaceGetExhibitionResponseDto } from 'src/place/dto/api-place-get-exhibition-response.dto';
import { ApiPlaceGetPopupRequestQueryDto } from 'src/place/dto/api-place-get-popup-request-query.dto';
import { ApiPlaceGetPopupResponseDto } from 'src/place/dto/api-place-get-popup-response.dto';
import { PlaceQueryRepository } from 'src/place/place.query.repository';
@Injectable()
export class PlaceService {
constructor(private readonly placeQueryRepository: PlaceQueryRepository) {}
async findCultureList(
dto: ApiPlaceGetCultureRequestQueryDto,
): Promise<ListResponseDto<ApiPlaceGetCultureResponseDto>> {
const cultureList: PlaceEntity[] = await this.placeQueryRepository.findList(dto);
if (!cultureList || cultureList.length === 0) {
return { items: [] };
}
return {
items: plainToInstance(ApiPlaceGetCultureResponseDto, cultureList, {
excludeExtraneousValues: true,
}),
};
}
async findCultureDetail(uuid: string): Promise<ApiPlaceGetCultureDetailResponseDto> {
const culture: PlaceEntity = await this.placeQueryRepository.findOne(uuid);
if (isEmpty(culture)) {
throw new NotFoundException(ERROR.NOT_EXIST_DATA);
}
return plainToInstance(ApiPlaceGetCultureDetailResponseDto, culture, {
excludeExtraneousValues: true,
});
}
async findExhibitionList(
dto: ApiPlaceGetExhibitionRequestQueryDto,
): Promise<CursorPaginatedResponseDto<ApiPlaceGetExhibitionResponseDto>> {
const totalCount: number = await this.placeQueryRepository.countExhibition();
if (totalCount === 0) {
return { items: [], total_count: 0, next_page: null };
}
const { items, nextCursor } = await this.placeQueryRepository.findExhibitionList(dto);
return {
items: plainToInstance(ApiPlaceGetExhibitionResponseDto, items, {
excludeExtraneousValues: true,
}),
total_count: totalCount,
next_page: nextCursor,
};
}
async findPopupList(
dto: ApiPlaceGetPopupRequestQueryDto,
): Promise<CursorPaginatedResponseDto<ApiPlaceGetPopupResponseDto>> {
const totalCount: number = await this.placeQueryRepository.countPopup();
if (totalCount === 0) {
return { items: [], total_count: 0, next_page: null };
}
const { items, nextCursor } = await this.placeQueryRepository.findPopupList(dto);
return {
items: plainToInstance(ApiPlaceGetPopupResponseDto, items, {
excludeExtraneousValues: true,
}),
total_count: totalCount,
next_page: nextCursor,
};
}
async findPlaceDetail(uuid: string): Promise<ApiPlaceGetDetailResponseDto> {
const placeDetail: PlaceEntity = await this.placeQueryRepository.findOne(uuid);
if (isEmpty(placeDetail)) {
throw new NotFoundException(ERROR.NOT_EXIST_DATA);
}
return plainToInstance(ApiPlaceGetDetailResponseDto, placeDetail, {
excludeExtraneousValues: true,
});
}
}
|