anonymous-student
Version:
Anonymous student is used to retrieve and save information from our website users.
69 lines (55 loc) • 2.41 kB
text/typescript
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,
) {
}
public async setStudentData(studentData: IStudent, actor: Actor = Actor.USER): Promise<void> {
await this.studentRepository.setStudentData(studentData, actor);
}
public async getStudentData(studentFields: StudentField[]): Promise<IStudent> {
return this.studentRepository.getStudentData(studentFields);
}
public async getStudentDataCompleteness(studentFields: StudentField[]): Promise<number> {
return this.studentRepository.getStudentDataCompleteness(studentFields);
}
public async addToCollection(type: StudentField, items: any[]): Promise<void> {
return this.studentRepository.addToCollection(type, items);
}
public async removeFromCollection(type: StudentField, items: any[]): Promise<void> {
return this.studentRepository.removeFromCollection(type, items);
}
public async addDisciplines(ids: number[]): Promise<void> {
return this.addToCollection(StudentField.DISCIPLINES, ids);
}
public async removeDisciplines(ids: number[]): Promise<void> {
return this.removeFromCollection(StudentField.DISCIPLINES, ids);
}
public async addInterest(type: InterestType, ids: number[]): Promise<void> {
return this.addToCollection(type as any as StudentField, ids);
}
public async removeInterest(type: InterestType, ids: number[]): Promise<void> {
return this.removeFromCollection(type as any as StudentField, ids);
}
public async setName(name: string): Promise<void> {
return this.studentRepository.setName(name);
}
public async setGPA(grade_type: string, grade_value: any): Promise<void> {
return this.studentRepository.setGPA(grade_type, grade_value);
}
}