-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from sparcs-kaist/issue/91/share-timetable-image
issue/91/share-timetable-image
- Loading branch information
Showing
24 changed files
with
1,820 additions
and
152 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Prisma } from '@prisma/client'; | ||
|
||
export namespace ETimetable { | ||
export const WithLectureClasstimes = | ||
Prisma.validator<Prisma.timetable_timetable_lecturesArgs>()({ | ||
include: { | ||
subject_lecture: { | ||
include: { | ||
subject_classtime: true, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
export type WithLectureClasstimes = | ||
Prisma.timetable_timetable_lecturesGetPayload<typeof WithLectureClasstimes>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { CanvasRenderingContext2D } from 'canvas'; | ||
import { ILecture } from './ILecture'; | ||
|
||
export namespace IShare { | ||
export interface RoundedRectangleOptions { | ||
ctx: CanvasRenderingContext2D; | ||
x: number; | ||
y: number; | ||
width: number; | ||
height: number; | ||
radius: number; | ||
color: string; | ||
} | ||
|
||
export interface TextOptions { | ||
ctx: CanvasRenderingContext2D; | ||
x: number; | ||
y: number; | ||
text: string; | ||
font: string; | ||
fontSize: number; | ||
color: string; | ||
align?: 'right' | 'left' | 'center'; // Optional parameter | ||
} | ||
|
||
export interface DrawTileOptions { | ||
ctx: CanvasRenderingContext2D; | ||
x: number; | ||
y: number; | ||
width: number; | ||
height: number; | ||
title: string; | ||
professor: string; | ||
location: string; | ||
font: string; | ||
fontSize: number; | ||
} | ||
|
||
export interface drawTimetableDatas { | ||
lectures: ILecture.Basic[]; | ||
timetableType: string; | ||
semesterName: string; | ||
isEnglish: boolean; | ||
semesterFontSize: number; | ||
tileFontSize: number; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export namespace ITimetable { | ||
export interface IClasstime { | ||
id: number; | ||
day: number; | ||
begin: Date; | ||
end: Date; | ||
type: string; | ||
building_id: string | null; | ||
building_full_name: string | null; | ||
building_full_name_en: string | null; | ||
room_name: string | null; | ||
unit_time: number | null; | ||
lecture_id: number | null; | ||
// Additional properties as needed | ||
} | ||
// Other interfaces as needed... | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Type } from 'class-transformer'; | ||
import { IsInt, IsNumber, IsOptional, IsString } from 'class-validator'; | ||
|
||
export class TimetableImageQueryDto { | ||
@Type(() => Number) | ||
@IsNumber() | ||
timetable!: number; | ||
|
||
@Type(() => Number) | ||
@IsNumber() | ||
year!: number; | ||
|
||
@Type(() => Number) | ||
@IsNumber() | ||
semester!: number; | ||
|
||
@IsString() | ||
@IsOptional() | ||
language?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
export * from './IAuth'; | ||
export * from './ICourse'; | ||
export * from './IFeed'; | ||
export * from './ITimetable'; | ||
export * from './ILecture'; | ||
export * from './IShare'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,33 @@ | ||
import { Controller } from '@nestjs/common'; | ||
import { | ||
Controller, | ||
Get, | ||
HttpException, | ||
HttpStatus, | ||
Query, | ||
Res, | ||
} from '@nestjs/common'; | ||
import { session_userprofile } from '@prisma/client'; | ||
import { GetUser } from '../../common/decorators/get-user.decorator'; | ||
import { ShareService } from './share.service'; | ||
import { TimetableRepository } from 'src/prisma/repositories/timetable.repository'; | ||
import { Response } from 'express'; | ||
import { TimetableImageQueryDto } from 'src/common/interfaces/dto/share/share.request.dto'; | ||
|
||
@Controller('share') | ||
export class ShareController {} | ||
@Controller('/api/share') | ||
export class ShareController { | ||
constructor( | ||
private readonly shareService: ShareService, | ||
private readonly timetableRepository: TimetableRepository, | ||
) {} | ||
|
||
@Get('timetable/image') | ||
async getTimetableImage( | ||
@Query() query: TimetableImageQueryDto, | ||
@GetUser() user: session_userprofile, | ||
@Res() res: Response, | ||
) { | ||
const imageBuffer = await this.shareService.createTimetableImage(query); | ||
res.setHeader('Content-Type', 'image/png'); | ||
res.send(imageBuffer); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.