Skip to content

Commit dfcc08c

Browse files
committed
feat: get schedules
1 parent 3ce46c1 commit dfcc08c

File tree

16 files changed

+215
-26
lines changed

16 files changed

+215
-26
lines changed

apps/server/docs/swagger.json

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@
918918
"content": {
919919
"application/json": {
920920
"schema": {
921-
"$ref": "#/components/schemas/import(\"/Users/sciberbee/Documents/otl/otlplus-server/apps/server/src/modules/notification/domain/notification\").NotificationRequest"
921+
"$ref": "#/components/schemas/import(\"/Users/parksungbin/Downloads/SPARCS_OTL/otlplus-server/apps/server/src/modules/notification/domain/notification\").NotificationRequest"
922922
}
923923
}
924924
}
@@ -936,7 +936,7 @@
936936
"content": {
937937
"application/json": {
938938
"schema": {
939-
"$ref": "#/components/schemas/import(\"/Users/sciberbee/Documents/otl/otlplus-server/apps/server/src/modules/notification/domain/notification\").FCMNotificationRequest"
939+
"$ref": "#/components/schemas/import(\"/Users/parksungbin/Downloads/SPARCS_OTL/otlplus-server/apps/server/src/modules/notification/domain/notification\").FCMNotificationRequest"
940940
}
941941
}
942942
}
@@ -963,7 +963,7 @@
963963
"content": {
964964
"application/json": {
965965
"schema": {
966-
"$ref": "#/components/schemas/import(\"/Users/sciberbee/Documents/otl/otlplus-server/apps/server/src/modules/notification/domain/notification\").UserNotification"
966+
"$ref": "#/components/schemas/import(\"/Users/parksungbin/Downloads/SPARCS_OTL/otlplus-server/apps/server/src/modules/notification/domain/notification\").UserNotification"
967967
}
968968
}
969969
}
@@ -992,7 +992,7 @@
992992
"schema": {
993993
"type": "array",
994994
"items": {
995-
"$ref": "#/components/schemas/import(\"/Users/sciberbee/Documents/otl/otlplus-server/apps/server/src/modules/agreement/domain/UserAgreement\").Agreement"
995+
"$ref": "#/components/schemas/import(\"/Users/parksungbin/Downloads/SPARCS_OTL/otlplus-server/apps/server/src/modules/agreement/domain/UserAgreement\").Agreement"
996996
}
997997
}
998998
}
@@ -1010,7 +1010,7 @@
10101010
"content": {
10111011
"application/json": {
10121012
"schema": {
1013-
"$ref": "#/components/schemas/import(\"/Users/sciberbee/Documents/otl/otlplus-server/apps/server/src/modules/notification/domain/notification\").Notification"
1013+
"$ref": "#/components/schemas/import(\"/Users/parksungbin/Downloads/SPARCS_OTL/otlplus-server/apps/server/src/modules/notification/domain/notification\").Notification"
10141014
}
10151015
}
10161016
}
@@ -1035,7 +1035,7 @@
10351035
"content": {
10361036
"application/json": {
10371037
"schema": {
1038-
"$ref": "#/components/schemas/import(\"/Users/sciberbee/Documents/otl/otlplus-server/apps/server/src/modules/notification/domain/notification\").Notification"
1038+
"$ref": "#/components/schemas/import(\"/Users/parksungbin/Downloads/SPARCS_OTL/otlplus-server/apps/server/src/modules/notification/domain/notification\").Notification"
10391039
}
10401040
}
10411041
}
@@ -1087,7 +1087,7 @@
10871087
"schema": {
10881088
"type": "array",
10891089
"items": {
1090-
"$ref": "#/components/schemas/import(\"/Users/sciberbee/Documents/otl/otlplus-server/apps/server/src/modules/notification/domain/notification\").Notification"
1090+
"$ref": "#/components/schemas/import(\"/Users/parksungbin/Downloads/SPARCS_OTL/otlplus-server/apps/server/src/modules/notification/domain/notification\").Notification"
10911091
}
10921092
}
10931093
}
@@ -1110,7 +1110,7 @@
11101110
"type": "null"
11111111
},
11121112
{
1113-
"$ref": "#/components/schemas/import(\"/Users/sciberbee/Documents/otl/otlplus-server/apps/server/src/modules/notification/domain/notification\").Notification"
1113+
"$ref": "#/components/schemas/import(\"/Users/parksungbin/Downloads/SPARCS_OTL/otlplus-server/apps/server/src/modules/notification/domain/notification\").Notification"
11141114
}
11151115
]
11161116
}
@@ -1695,6 +1695,27 @@
16951695
]
16961696
}
16971697
},
1698+
"/api/v2/schedules": {
1699+
"get": {
1700+
"summary": "SchedulesController.getSchedules",
1701+
"responses": {
1702+
"200": {
1703+
"description": "OK",
1704+
"content": {
1705+
"application/json": {
1706+
"schema": {
1707+
"type": "array",
1708+
"items": {
1709+
"$ref": "#/components/schemas/ISchedules.Basic"
1710+
}
1711+
}
1712+
}
1713+
}
1714+
}
1715+
},
1716+
"security": []
1717+
}
1718+
},
16981719
"/api/semesters": {
16991720
"get": {
17001721
"summary": "SemestersController.getSemesters",
@@ -6378,6 +6399,27 @@
63786399
"type": "object",
63796400
"required": ["content", "grade", "load", "speech"]
63806401
},
6402+
"ISchedules.Basic": {
6403+
"type": "object",
6404+
"properties": {
6405+
"year": {
6406+
"type": "number"
6407+
},
6408+
"from": {
6409+
"type": "string",
6410+
"format": "date-time"
6411+
},
6412+
"to": {
6413+
"type": "string",
6414+
"format": "date-time"
6415+
},
6416+
"name": {
6417+
"type": "string"
6418+
}
6419+
},
6420+
"required": ["year", "from", "to", "name"],
6421+
"additionalProperties": false
6422+
},
63816423
"ISemester.QueryDto": {
63826424
"properties": {
63836425
"order": {
@@ -6641,9 +6683,6 @@
66416683
"direction": {
66426684
"type": "string",
66436685
"enum": ["ltr", "rtl"]
6644-
},
6645-
"lang": {
6646-
"type": "string"
66476686
}
66486687
},
66496688
"required": [
@@ -6670,8 +6709,7 @@
66706709
"textBaseline",
66716710
"textAlign",
66726711
"canvas",
6673-
"direction",
6674-
"lang"
6712+
"direction"
66756713
],
66766714
"additionalProperties": false
66776715
},

apps/server/src/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import { NoticesModule } from './modules/notices/notices.module'
3838
import { PlannersModule } from './modules/planners/planners.module'
3939
import { RatesModule } from './modules/rates/rates.module'
4040
import { ReviewsModule } from './modules/reviews/reviews.module'
41+
import { SchedulesModule } from './modules/schedules/schedules.module'
4142
import { SemestersModule } from './modules/semesters/semesters.module'
4243
import { SemestersModuleV2 } from './modules/semesters/v2/semesters.v2.module'
4344
import { SessionModule } from './modules/session/session.module'
@@ -85,6 +86,7 @@ async function createCacheStoreWithFallback(): Promise<Keyv> {
8586
LecturesModule,
8687
ReviewsModule,
8788
UserModule,
89+
SchedulesModule,
8890
SemestersModule,
8991
SemestersModuleV2,
9092
TimetablesModule,
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export namespace ISchedules {
2+
export interface Basic {
3+
year: number
4+
from: Date
5+
to: Date
6+
name: string
7+
}
8+
}

apps/server/src/common/interfaces/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export * from './IPlanner'
88
export * from './IProfessor'
99
export * from './IRate'
1010
export * from './IReview'
11+
export * from './ISchedules'
1112
export * from './ISemester'
1213
export * from './ISession'
1314
export * from './IShare'
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { ISchedules } from '@otl/server-nest/common/interfaces'
2+
3+
import { ESchedules } from '@otl/prisma-client/entities'
4+
5+
export const toJsonSchedules = (schedule: ESchedules.Basic): ISchedules.Basic => ({
6+
year: schedule.year,
7+
from: schedule.from,
8+
to: schedule.to,
9+
name: schedule.name,
10+
})
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Controller, Get } from '@nestjs/common'
2+
import { Public } from '@otl/server-nest/common/decorators/skip-auth.decorator'
3+
import { ISchedules } from '@otl/server-nest/common/interfaces'
4+
import { toJsonSchedules } from '@otl/server-nest/common/serializer/schedule.serializer'
5+
6+
import { SchedulesService } from './schedules.service'
7+
8+
@Controller('api/v2/schedules')
9+
export class SchedulesController {
10+
constructor(private readonly schedulesService: SchedulesService) {}
11+
12+
@Get()
13+
@Public()
14+
async getSchedules(): Promise<ISchedules.Basic[]> {
15+
const schedules = await this.schedulesService.getSchedules()
16+
return schedules.map((schedule) => toJsonSchedules(schedule))
17+
}
18+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Module } from '@nestjs/common'
2+
3+
import { PrismaModule } from '@otl/prisma-client/prisma.module'
4+
5+
import { SchedulesController } from './schedules.controller'
6+
import { SchedulesService } from './schedules.service'
7+
8+
@Module({
9+
imports: [PrismaModule],
10+
controllers: [SchedulesController],
11+
providers: [SchedulesService],
12+
exports: [SchedulesService],
13+
})
14+
export class SchedulesModule {}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Injectable } from '@nestjs/common'
2+
3+
import { ScheduleRepository } from '@otl/prisma-client/repositories'
4+
5+
@Injectable()
6+
export class SchedulesService {
7+
constructor(private readonly scheduleRepository: ScheduleRepository) {}
8+
9+
async getSchedules() {
10+
const schedules = await this.scheduleRepository.getSchedules()
11+
return schedules
12+
}
13+
}

apps/server/src/swagger.json

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@
918918
"content": {
919919
"application/json": {
920920
"schema": {
921-
"$ref": "#/components/schemas/import(\"/Users/sciberbee/Documents/otl/otlplus-server/apps/server/src/modules/notification/domain/notification\").NotificationRequest"
921+
"$ref": "#/components/schemas/import(\"/Users/parksungbin/Downloads/SPARCS_OTL/otlplus-server/apps/server/src/modules/notification/domain/notification\").NotificationRequest"
922922
}
923923
}
924924
}
@@ -936,7 +936,7 @@
936936
"content": {
937937
"application/json": {
938938
"schema": {
939-
"$ref": "#/components/schemas/import(\"/Users/sciberbee/Documents/otl/otlplus-server/apps/server/src/modules/notification/domain/notification\").FCMNotificationRequest"
939+
"$ref": "#/components/schemas/import(\"/Users/parksungbin/Downloads/SPARCS_OTL/otlplus-server/apps/server/src/modules/notification/domain/notification\").FCMNotificationRequest"
940940
}
941941
}
942942
}
@@ -963,7 +963,7 @@
963963
"content": {
964964
"application/json": {
965965
"schema": {
966-
"$ref": "#/components/schemas/import(\"/Users/sciberbee/Documents/otl/otlplus-server/apps/server/src/modules/notification/domain/notification\").UserNotification"
966+
"$ref": "#/components/schemas/import(\"/Users/parksungbin/Downloads/SPARCS_OTL/otlplus-server/apps/server/src/modules/notification/domain/notification\").UserNotification"
967967
}
968968
}
969969
}
@@ -992,7 +992,7 @@
992992
"schema": {
993993
"type": "array",
994994
"items": {
995-
"$ref": "#/components/schemas/import(\"/Users/sciberbee/Documents/otl/otlplus-server/apps/server/src/modules/agreement/domain/UserAgreement\").Agreement"
995+
"$ref": "#/components/schemas/import(\"/Users/parksungbin/Downloads/SPARCS_OTL/otlplus-server/apps/server/src/modules/agreement/domain/UserAgreement\").Agreement"
996996
}
997997
}
998998
}
@@ -1010,7 +1010,7 @@
10101010
"content": {
10111011
"application/json": {
10121012
"schema": {
1013-
"$ref": "#/components/schemas/import(\"/Users/sciberbee/Documents/otl/otlplus-server/apps/server/src/modules/notification/domain/notification\").Notification"
1013+
"$ref": "#/components/schemas/import(\"/Users/parksungbin/Downloads/SPARCS_OTL/otlplus-server/apps/server/src/modules/notification/domain/notification\").Notification"
10141014
}
10151015
}
10161016
}
@@ -1035,7 +1035,7 @@
10351035
"content": {
10361036
"application/json": {
10371037
"schema": {
1038-
"$ref": "#/components/schemas/import(\"/Users/sciberbee/Documents/otl/otlplus-server/apps/server/src/modules/notification/domain/notification\").Notification"
1038+
"$ref": "#/components/schemas/import(\"/Users/parksungbin/Downloads/SPARCS_OTL/otlplus-server/apps/server/src/modules/notification/domain/notification\").Notification"
10391039
}
10401040
}
10411041
}
@@ -1087,7 +1087,7 @@
10871087
"schema": {
10881088
"type": "array",
10891089
"items": {
1090-
"$ref": "#/components/schemas/import(\"/Users/sciberbee/Documents/otl/otlplus-server/apps/server/src/modules/notification/domain/notification\").Notification"
1090+
"$ref": "#/components/schemas/import(\"/Users/parksungbin/Downloads/SPARCS_OTL/otlplus-server/apps/server/src/modules/notification/domain/notification\").Notification"
10911091
}
10921092
}
10931093
}
@@ -1110,7 +1110,7 @@
11101110
"type": "null"
11111111
},
11121112
{
1113-
"$ref": "#/components/schemas/import(\"/Users/sciberbee/Documents/otl/otlplus-server/apps/server/src/modules/notification/domain/notification\").Notification"
1113+
"$ref": "#/components/schemas/import(\"/Users/parksungbin/Downloads/SPARCS_OTL/otlplus-server/apps/server/src/modules/notification/domain/notification\").Notification"
11141114
}
11151115
]
11161116
}
@@ -1695,6 +1695,27 @@
16951695
]
16961696
}
16971697
},
1698+
"/api/v2/schedules": {
1699+
"get": {
1700+
"summary": "SchedulesController.getSchedules",
1701+
"responses": {
1702+
"200": {
1703+
"description": "OK",
1704+
"content": {
1705+
"application/json": {
1706+
"schema": {
1707+
"type": "array",
1708+
"items": {
1709+
"$ref": "#/components/schemas/ISchedules.Basic"
1710+
}
1711+
}
1712+
}
1713+
}
1714+
}
1715+
},
1716+
"security": []
1717+
}
1718+
},
16981719
"/api/semesters": {
16991720
"get": {
17001721
"summary": "SemestersController.getSemesters",
@@ -6378,6 +6399,27 @@
63786399
"type": "object",
63796400
"required": ["content", "grade", "load", "speech"]
63806401
},
6402+
"ISchedules.Basic": {
6403+
"type": "object",
6404+
"properties": {
6405+
"year": {
6406+
"type": "number"
6407+
},
6408+
"from": {
6409+
"type": "string",
6410+
"format": "date-time"
6411+
},
6412+
"to": {
6413+
"type": "string",
6414+
"format": "date-time"
6415+
},
6416+
"name": {
6417+
"type": "string"
6418+
}
6419+
},
6420+
"required": ["year", "from", "to", "name"],
6421+
"additionalProperties": false
6422+
},
63816423
"ISemester.QueryDto": {
63826424
"properties": {
63836425
"order": {
@@ -6641,9 +6683,6 @@
66416683
"direction": {
66426684
"type": "string",
66436685
"enum": ["ltr", "rtl"]
6644-
},
6645-
"lang": {
6646-
"type": "string"
66476686
}
66486687
},
66496688
"required": [
@@ -6670,8 +6709,7 @@
66706709
"textBaseline",
66716710
"textAlign",
66726711
"canvas",
6673-
"direction",
6674-
"lang"
6712+
"direction"
66756713
],
66766714
"additionalProperties": false
66776715
},
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { Prisma } from '@prisma/client'
2+
3+
export namespace ESchedules {
4+
export const Basic = Prisma.validator<Prisma.schedulesDefaultArgs>()({})
5+
export type Basic = Prisma.schedulesGetPayload<typeof Basic>
6+
}

0 commit comments

Comments
 (0)