update: update endDate
This commit is contained in:
@@ -22,7 +22,7 @@ export class DashboardService {
|
||||
@InjectRepository(User)
|
||||
private userRepository: Repository<User>,
|
||||
@InjectRepository(DashboardShare)
|
||||
private readonly dashboardShareRepository: Repository<DashboardShare>,
|
||||
private readonly dashboardShareRepository: Repository<DashboardShare>,
|
||||
@InjectRepository(UserMapping)
|
||||
private userMappingRepository: Repository<UserMapping>,
|
||||
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` },
|
||||
|
||||
@@ -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 } };
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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로 접속시 대시보드의 정보를 받아오는 코드
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user