UNPKG

anonymous-student

Version:

Anonymous student is used to retrieve and save information from our website users.

69 lines (55 loc) 2.41 kB
import { IStudent, StudentField } from '@studyportals/studentdomain'; import { IAnonymousStudentService } from '../../interfaces/application'; import { Actor, InterestType } from '../../interfaces/enumerations'; import { CatchReportAsyncException } from '../decorators/error-decorators'; import { StudentRepository } from '../domain/student-repository'; export class AnonymousStudentService implements IAnonymousStudentService { constructor( private studentRepository: StudentRepository, ) { } @CatchReportAsyncException public async setStudentData(studentData: IStudent, actor: Actor = Actor.USER): Promise<void> { await this.studentRepository.setStudentData(studentData, actor); } @CatchReportAsyncException public async getStudentData(studentFields: StudentField[]): Promise<IStudent> { return this.studentRepository.getStudentData(studentFields); } @CatchReportAsyncException public async getStudentDataCompleteness(studentFields: StudentField[]): Promise<number> { return this.studentRepository.getStudentDataCompleteness(studentFields); } @CatchReportAsyncException public async addToCollection(type: StudentField, items: any[]): Promise<void> { return this.studentRepository.addToCollection(type, items); } @CatchReportAsyncException public async removeFromCollection(type: StudentField, items: any[]): Promise<void> { return this.studentRepository.removeFromCollection(type, items); } @CatchReportAsyncException public async addDisciplines(ids: number[]): Promise<void> { return this.addToCollection(StudentField.DISCIPLINES, ids); } @CatchReportAsyncException public async removeDisciplines(ids: number[]): Promise<void> { return this.removeFromCollection(StudentField.DISCIPLINES, ids); } @CatchReportAsyncException public async addInterest(type: InterestType, ids: number[]): Promise<void> { return this.addToCollection(type as any as StudentField, ids); } @CatchReportAsyncException public async removeInterest(type: InterestType, ids: number[]): Promise<void> { return this.removeFromCollection(type as any as StudentField, ids); } @CatchReportAsyncException public async setName(name: string): Promise<void> { return this.studentRepository.setName(name); } @CatchReportAsyncException public async setGPA(grade_type: string, grade_value: any): Promise<void> { return this.studentRepository.setGPA(grade_type, grade_value); } }