From 18547a311bcde649470bb157fe003c3bbda6aea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=90=EC=8A=B9=EC=9A=B0?= Date: Thu, 15 Dec 2022 17:56:51 +0900 Subject: [PATCH] update: update endDate --- .../src/dashboard/dashboard.service.ts | 26 ++++++++------ backend-api/src/database/database.service.ts | 1 + .../src/dataset/entities/dataset.entity.ts | 33 ++++++++--------- .../src/share-url/share-url.service.ts | 35 +++++++++---------- 4 files changed, 48 insertions(+), 47 deletions(-) diff --git a/backend-api/src/dashboard/dashboard.service.ts b/backend-api/src/dashboard/dashboard.service.ts index ff353d9..298f00e 100644 --- a/backend-api/src/dashboard/dashboard.service.ts +++ b/backend-api/src/dashboard/dashboard.service.ts @@ -22,7 +22,7 @@ export class DashboardService { @InjectRepository(User) private userRepository: Repository, @InjectRepository(DashboardShare) - private readonly dashboardShareRepository: Repository, + private readonly dashboardShareRepository: Repository, @InjectRepository(UserMapping) private userMappingRepository: Repository, private readonly dashboardWidgetService: DashboardWidgetService, @@ -43,17 +43,17 @@ export class DashboardService { }); const findMap = await this.userMappingRepository.findOne({ - where: { userInfoId: userData.id } - }) + where: { userInfoId: userData.id }, + }); const findTitle = await this.dashboardRepository.findOne({ where: { id: findMap.dashboardId }, }); if (findTitle.title !== createDashboardDto.title) { const share_id = await this.dashboardShareRepository.save({ - uuid: uuidv4(), // uuid의 버전 uuidv1의 결우 mac의 정보등을 담고있음. + uuid: uuidv4(), // uuid의 버전 uuidv1의 결우 mac의 정보등을 담고있음. createdAt: new Date(), - updatedAt: new Date() + updatedAt: new Date(), }); const saveObj = { title: createDashboardDto.title, @@ -61,7 +61,7 @@ export class DashboardService { delYn: YesNo.NO, shareId: share_id.id, createdAt: new Date(), - updatedAt: new Date() + updatedAt: new Date(), }; const newDashboard = await this.dashboardRepository.save(saveObj); const saveObjDW = { @@ -92,8 +92,7 @@ export class DashboardService { async findAll(userId: number) { const findUser = await this.userService.findDashboardId(userId); - const findId = findUser.map(el => - el['dashboardId']); + const findId = findUser.map(el => el['dashboardId']); const find_all = []; for (let i = 0; findId.length > i; i++) { find_all.push( @@ -120,7 +119,9 @@ export class DashboardService { const widgetList = await this.dashboardWidgetService.findWidgets(find_dashboard.id); find_dashboard.layout = JSON.parse(find_dashboard.layout); - const find_share_id = await this.dashboardShareRepository.findOne({ where : { id: find_dashboard.shareId }}) + const find_share_id = await this.dashboardShareRepository.findOne({ + where: { id: find_dashboard.shareId }, + }); const return_obj = Object.assign(find_dashboard, find_share_id, { widgets: widgetList }); return { status: ResponseStatus.SUCCESS, data: return_obj }; @@ -164,8 +165,11 @@ export class DashboardService { } else { await this.dashboardRepository.delete(id); await this.dashboardWidgetService.remove(id); - const find_dashboardId = await this.userMappingRepository.findOne({ where: { dashboardId: id }}) - await this.userMappingRepository.delete(find_dashboardId.id) + const find_dashboardId = await this.userMappingRepository.findOne({ + where: { dashboardId: id }, + }); + await this.userMappingRepository.delete(find_dashboardId.id); + await this.dashboardShareRepository.delete(find_dashboard.shareId); return { status: ResponseStatus.SUCCESS, data: { message: `This action removes a #${id} dashboard` }, diff --git a/backend-api/src/database/database.service.ts b/backend-api/src/database/database.service.ts index 947312c..dfd33eb 100644 --- a/backend-api/src/database/database.service.ts +++ b/backend-api/src/database/database.service.ts @@ -144,6 +144,7 @@ export class DatabaseService { // 연동 db 정보 const databaseInfo = await this.databaseRepository.findOne({ where: { id } }); databaseInfo.connectionConfig = JSON.parse(databaseInfo.connectionConfig).connection; + delete databaseInfo.connectionConfig['password']; return { status: ResponseStatus.SUCCESS, data: { databaseInfo } }; } diff --git a/backend-api/src/dataset/entities/dataset.entity.ts b/backend-api/src/dataset/entities/dataset.entity.ts index 1d6f524..a2590ab 100644 --- a/backend-api/src/dataset/entities/dataset.entity.ts +++ b/backend-api/src/dataset/entities/dataset.entity.ts @@ -1,26 +1,23 @@ -import {Column, Entity, JoinTable, ManyToMany, OneToMany, PrimaryGeneratedColumn} from "typeorm"; -import {Database} from "../../database/entities/database.entity"; -import {BaseEntity} from "../../common/entities/base.entity"; -import {Widget} from "../../widget/entities/widget.entity"; +import { Column, Entity, JoinTable, ManyToMany, OneToMany, PrimaryGeneratedColumn } from 'typeorm'; +import { BaseEntity } from '../../common/entities/base.entity'; @Entity() export class Dataset extends BaseEntity { - @PrimaryGeneratedColumn({comment: '데이터셋 ID'}) - id: number + @PrimaryGeneratedColumn({ comment: '데이터셋 ID' }) + id: number; - @Column({comment: '데이터셋명', nullable: true}) - title: string + @Column({ comment: '데이터셋명', nullable: true }) + title: string; - @Column({comment: '데이터베이스 ID'}) - databaseId: number + @Column({ comment: '데이터베이스 ID' }) + databaseId: number; - @Column({type: 'text', comment: '조회 sql'}) - query: string - - // @OneToMany( - // (type) => Widget, - // (widget) => widget.datasetId - // ) - // widgets!: Widget + @Column({ type: 'text', comment: '조회 sql' }) + query: string; + // @OneToMany( + // (type) => Widget, + // (widget) => widget.datasetId + // ) + // widgets!: Widget } diff --git a/backend-api/src/share-url/share-url.service.ts b/backend-api/src/share-url/share-url.service.ts index 35c2a87..dee4750 100644 --- a/backend-api/src/share-url/share-url.service.ts +++ b/backend-api/src/share-url/share-url.service.ts @@ -61,26 +61,25 @@ export class ShareUrlService { // 공유기능 off시 쉐어토큰, endDate을 없애고 사용가능여부를 N으로 저장 async shareDashboardInfo(uuid: string) { - try { - const findDashboardShareUrl = await this.dashboardShareRepository.findOne({ - where: { uuid: uuid }, - }); - const today = `${new Date().getFullYear()}-${new Date().getMonth() + 1}-${ - new Date().getDate() - 1 - }`; - if (new Date(today) > findDashboardShareUrl.endDate) { - throw new HttpException({ message: 'expired Date' }, HttpStatus.UNAUTHORIZED); - } - const findDashboard = await this.dashboardRepository.findOne({ - where: { shareId: findDashboardShareUrl.id }, - }); - if (!findDashboard) { - return 'not exist share dashboard'; - } - return this.dashboardService.findOne(+findDashboard.id); - } catch { + const findDashboardShareUrl = await this.dashboardShareRepository.findOne({ + where: { uuid: uuid }, + }); + const findDashboard = await this.dashboardRepository.findOne({ + where: { shareId: findDashboardShareUrl.id }, + }); + const today = `${new Date().getFullYear()}-${new Date().getMonth() + 1}-${ + new Date().getDate() - 1 + }`; + if (!findDashboardShareUrl) { throw new HttpException({ message: 'not exist uuid' }, HttpStatus.NOT_FOUND); } + if (!findDashboard) { + throw new HttpException({ message: 'not exist share dashboard' }, HttpStatus.NOT_FOUND); + } + if (new Date(today) > findDashboardShareUrl.endDate) { + throw new HttpException({ message: 'expired date' }, HttpStatus.UNAUTHORIZED); + } + return this.dashboardService.findOne(+findDashboard.id); } // 공유url로 접속시 대시보드의 정보를 받아오는 코드 }