Skip to content

Commit

Permalink
feat/ start record and finish record tutoring (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
seongyunlee authored Oct 20, 2023
1 parent 3067223 commit 9a7d170
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export class Success extends Response {
}

export class Fail extends Response {
constructor(message: string) {
super(message, false);
constructor(message: string, errorCode?: number) {
if (errorCode) super(message, false, { errorCode });
else super(message, false);
}
}
18 changes: 16 additions & 2 deletions src/tutoring/tutoring.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,26 @@ export class TutoringService {

async classrroomInfo(tutoringId: string, userId: string) {
try {
const userInfo = await this.userRepository.get(userId);

const tutoring = await this.tutoringRepository.get(tutoringId);

if (tutoring == null) {
return new Fail('존재하지 않는 과외입니다.', 100);
}

if (userInfo.role == 'student' && tutoring.status == 'reserved') {
return new Fail('아직 수업이 시작되지 않았습니다.', 200);
}
if (userInfo.role == 'student' && tutoring.status == 'finished') {
return new Fail('이미 종료된 수업입니다.', 300);
}
return new Success(
'수업 정보를 가져왔습니다.',
await this.classroomChannel(tutoringId, userId),
this.classroomChannel(tutoringId, userId),
);
} catch (e) {
return new Fail('수업 정보를 가져오는데 실패했습니다.');
return new Fail('수업 정보를 가져오는데 실패했습니다.' + e.message);
}
}

Expand Down

0 comments on commit 9a7d170

Please sign in to comment.