diff --git a/src/database/model/enums.ts b/src/database/model/enums.ts index 9fae0fa..c48ab57 100644 --- a/src/database/model/enums.ts +++ b/src/database/model/enums.ts @@ -1,33 +1,33 @@ export enum CourseMethod { - OnlineAsynchronous, - OnlineSynchronous, - FaceToFace, - Others, + OnlineAsynchronous = 'OnlineAsynchronous', + OnlineSynchronous = 'OnlineSynchronous', + FaceToFace = 'FaceToFace', + Others = 'Others', } export enum Module { - SpringA, - SpringB, - SpringC, - FallA, - FallB, - FallC, - SummerVacation, - SpringVacation, - Annual, - Unknown, + SpringA = 'SpringA', + SpringB = 'SpringB', + SpringC = 'SpringC', + FallA = 'FallA', + FallB = 'FallB', + FallC = 'FallC', + SummerVacation = 'SummerVacation', + SpringVacation = 'SpringVacation', + Annual = 'Annual', + Unknown = 'Unknown', } export enum Day { - Sun, - Mon, - Tue, - Wed, - Thu, - Fri, - Sat, - Intensive, - Appointment, - AnyTime, - Unknown, + Sun = 'Sun', + Mon = 'Mon', + Tue = 'Tue', + Wed = 'Wed', + Thu = 'Thu', + Fri = 'Fri', + Sat = 'Sat', + Intensive = 'Intensive', + Appointment = 'Appointment', + AnyTime = 'AnyTime', + Unknown = 'Unknown', } diff --git a/src/grpc/converter.ts b/src/grpc/converter.ts index 3ce51d9..103cd10 100644 --- a/src/grpc/converter.ts +++ b/src/grpc/converter.ts @@ -27,8 +27,7 @@ import { */ export function createDBModule(m: PModule): Module { return ( - Module[Module[Object.values(PModule).indexOf(m)] as keyof typeof Module] ?? - Module.Unknown + Object.values(Module)[Object.values(PModule).indexOf(m)] ?? Module.Unknown ) } @@ -37,9 +36,7 @@ export function createDBModule(m: PModule): Module { * @param d パーサのDay */ export function createDBDay(d: PDay): Day { - return ( - Day[Day[Object.values(PDay).indexOf(d)] as keyof typeof Day] ?? Day.Unknown - ) + return Object.values(Day)[Object.values(PDay).indexOf(d)] ?? Day.Unknown } /** diff --git a/src/grpc/course.service.ts b/src/grpc/course.service.ts index 86c08d2..681eace 100644 --- a/src/grpc/course.service.ts +++ b/src/grpc/course.service.ts @@ -30,7 +30,7 @@ import { } from '../../generated' import { toGrpcError } from './converter' import { searchCourseUseCase } from '../usecase/searchCourse' -import { Day, Module } from '../database/model/enums' +import { CourseMethod, Day, Module } from '../database/model/enums' /** * grpcサーバのCourseService実装 @@ -129,8 +129,12 @@ function createGrpcCourse({ return { lastUpdate: lastUpdate.toISOString(), recommendedGrades: recommendedGrades.map((r) => r.grade), - methods: methods.map((m) => m.method), - schedules: (schedules as unknown) as ICourseSchedule[], + methods: methods.map((m) => Object.values(CourseMethod).indexOf(m.method)), + schedules: schedules.map(({ module, day, ...s }) => ({ + module: Object.keys(Module).indexOf(module), + day: Object.keys(Day).indexOf(day), + ...s, + })), ...c, } }