lecturer-info.service.ts 2.60 KiB
import {Injectable} from '@angular/core';
import {HttpClient, HttpHeaders} from '@angular/common/http';
import {HttpErrorService} from 'src/app/ErrorComponents/http-error.service';
import {Observable} from 'rxjs';
import {catchError} from 'rxjs/operators';
import {MinutePaperWrapperDao} from 'src/app/dao/minute-paper-wrapper.dao';
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json'
})
};
@Injectable()
export class LecturerInfoService {
constructor(private http$: HttpClient, private errorService: HttpErrorService) {
}
public getLecturerClasses(username: String): Observable<String | Object> {
return this.http$.post('http://localhost:8080/getLecturerClasses', {username: username}, httpOptions).pipe(
catchError(this.errorService.handleError)
);
}
public getClassPapers(username: String, classCode: String): Observable<String | Object> {
return this.http$.post('http://localhost:8080/getClassPapers', {username: username, classCode: classCode}, httpOptions).pipe(
catchError(this.errorService.handleError)
);
}
public getPaperQuestions(paperId: String): Observable<String | Object> {
return this.http$.post('http://localhost:8080/getPaperQuestions', {paperId: paperId}, httpOptions).pipe(
catchError(this.errorService.handleError)
);
}
public getPaperAnswers(paperId: String): Observable<String | Object> {
return this.http$.post('http://localhost:8080/getPaperAnswers', {paperId: paperId}, httpOptions).pipe(
catchError(this.errorService.handleError)
);
}
public getTemplates(username: String): Observable<String | Object> {
return this.http$.post('http://localhost:8080/getTemplates', {username: username}, httpOptions).pipe(
catchError(this.errorService.handleError)
);
}
public createPaper(request: MinutePaperWrapperDao) {
return this.http$.post('http://localhost:8080/createPaper', request, httpOptions).pipe(
catchError(this.errorService.handleError)
);
}
public deletePaper(paperId: String) {
return this.http$.post('http://localhost:8080/deletePaper', {paperId: paperId}, httpOptions).pipe(
catchError(this.errorService.handleError)
);
}
public createTemplate(request: MinutePaperWrapperDao) {
return this.http$.post('http://localhost:8080/createTemplate', request, httpOptions).pipe(
catchError(this.errorService.handleError)
);
}
public deleteTemplate(paperId: String) {
return this.http$.post('http://localhost:8080/deleteTemplate', {paperId: paperId}, httpOptions).pipe(
catchError(this.errorService.handleError)
);
}
}