feat: add ApiService implementations

This commit is contained in:
Polianin Nikita 2024-06-05 21:45:21 +03:00
parent 5ff24d49b5
commit 3d9fabe217
8 changed files with 217 additions and 0 deletions

View File

@ -0,0 +1,18 @@
import {Injectable} from "@angular/core";
import ApiService, {AvailableVersion} from "@api/api.service";
import {CampusBasicInfoResponse} from "@api/v1/campusBasicInfoResponse";
import {CampusDetailsResponse} from "@api/v1/campusDetailsResponse";
@Injectable()
export class CampusService extends ApiService {
protected basePath = 'Campus/';
protected version = AvailableVersion.v1;
public getCampus() {
return this.get<CampusBasicInfoResponse[]>();
}
public getById(id: number) {
return this.get<CampusDetailsResponse>(id.toString());
}
}

View File

@ -0,0 +1,17 @@
import {Injectable} from "@angular/core";
import ApiService, {AvailableVersion} from "@api/api.service";
import {DisciplineResponse} from "@api/v1/disciplineResponse";
@Injectable()
export class DisciplineService extends ApiService {
protected basePath = 'Discipline/';
protected version = AvailableVersion.v1;
public getDisciplines(page: number | null = null, pageSize: number | null = null) {
return this.get<DisciplineResponse[]>('', {page: page, pageSize: pageSize});
}
public getById(id: number) {
return this.get<DisciplineResponse>(id.toString());
}
}

View File

@ -0,0 +1,19 @@
import {Injectable} from "@angular/core";
import ApiService, {AvailableVersion} from "@api/api.service";
import {FacultyResponse} from "@api/v1/facultyResponse";
import {FacultyDetailsResponse} from "@api/v1/facultyDetailsResponse";
@Injectable()
export class FacultyService extends ApiService {
protected basePath = 'Faculty/';
protected version = AvailableVersion.v1;
public getFaculties(page: number | null = null, pageSize: number | null = null) {
return this.get<FacultyResponse[]>('', {page: page, pageSize: pageSize});
}
public getById(id: number) {
return this.get<FacultyDetailsResponse>(id.toString());
}
}

View File

@ -0,0 +1,22 @@
import {Injectable} from "@angular/core";
import ApiService, {AvailableVersion} from "@api/api.service";
import {GroupResponse} from "@api/v1/groupResponse";
import {GroupDetailsResponse} from "@api/v1/groupDetailsResponse";
@Injectable()
export class GroupService extends ApiService {
protected basePath = 'Group/';
protected version = AvailableVersion.v1;
public getGroups(page: number | null = null, pageSize: number | null = null) {
return this.get<GroupResponse[]>('', {page: page, pageSize: pageSize});
}
public getById(id: number) {
return this.get<GroupDetailsResponse>(id.toString());
}
public getByFaculty(id: number) {
return this.get<GroupResponse[]>('GetByFaculty/' + id.toString());
}
}

View File

@ -0,0 +1,22 @@
import {Injectable} from "@angular/core";
import ApiService, {AvailableVersion} from "@api/api.service";
import {LectureHallResponse} from "@api/v1/lectureHallResponse";
import {LectureHallDetailsResponse} from "@api/v1/lectureHallDetailsResponse";
@Injectable()
export class LectureHallService extends ApiService {
protected basePath = 'LectureHall/';
protected version = AvailableVersion.v1;
public getLectureHalls() {
return this.get<LectureHallResponse[]>();
}
public getById(id: number) {
return this.get<LectureHallDetailsResponse>(id.toString());
}
public getByCampus(id: number) {
return this.get<LectureHallResponse[]>('GetByCampus/' + id.toString());
}
}

View File

@ -0,0 +1,17 @@
import {Injectable} from "@angular/core";
import ApiService, {AvailableVersion} from "@api/api.service";
import {ProfessorResponse} from "@api/v1/professorResponse";
@Injectable()
export class ProfessorService extends ApiService {
protected basePath = 'Professor/';
protected version = AvailableVersion.v1;
public getProfessors(page: number | null = null, pageSize: number | null = null) {
return this.get<ProfessorResponse[]>('', {page: page, pageSize: pageSize});
}
public getById(id: number) {
return this.get<ProfessorResponse>(id.toString());
}
}

View File

@ -0,0 +1,44 @@
import {Injectable} from "@angular/core";
import ApiService, {AvailableVersion} from "@api/api.service";
import {DateOnly} from "@model/DateOnly";
import {PeriodTimes} from "@model/pairPeriodTime";
import {ScheduleRequest} from "@api/v1/scheduleRequest";
import {ScheduleResponse} from "@api/v1/scheduleResponse";
import {GroupScheduleResponse} from "@api/v1/groupScheduleResponse";
import {ProfessorScheduleResponse} from "@api/v1/professorScheduleResponse";
import {LectureHallScheduleResponse} from "@api/v1/lectureHallScheduleResponse";
import {map} from "rxjs";
@Injectable()
export class ScheduleService extends ApiService {
protected basePath = 'Schedule/';
protected version = AvailableVersion.v1;
public startTerm() {
return this.get<string>('StartTerm').pipe(map(date => new DateOnly(date)));
}
public pairPeriod() {
return this.get<PeriodTimes>('PairPeriod');
}
public postSchedule(data: ScheduleRequest) {
return this.post<ScheduleResponse[]>('', data);
}
public getByGroup(id : number, isEven: boolean | null = null, disciplines: Array<number> | null = null, professors: Array<number> | null = null, lectureHalls: Array<number> | null = null) {
return this.get<GroupScheduleResponse>('GetByGroup' + id.toString(), {isEven: isEven, disciplines: disciplines, professors: professors, lectureHalls: lectureHalls});
}
public getByProfessor(id : number, isEven: boolean | null = null, disciplines: Array<number> | null = null, groups: Array<number> | null = null, lectureHalls: Array<number> | null = null) {
return this.get<ProfessorScheduleResponse>('GetByProfessor' + id.toString(), {isEven: isEven, disciplines: disciplines, groups: groups, lectureHalls: lectureHalls});
}
public getByLectureHall(id : number, isEven: boolean | null = null, disciplines: Array<number> | null = null, groups: Array<number> | null = null, professors: Array<number> | null = null) {
return this.get<LectureHallScheduleResponse>('GetByLectureHall' + id.toString(), {isEven: isEven, disciplines: disciplines, groups: groups, professors: professors});
}
public getByDiscipline(id : number, isEven: boolean | null = null, groups: Array<number> | null = null, professors: Array<number> | null = null, lectureHalls: Array<number> | null = null) {
return this.get<GroupScheduleResponse>('GetByDiscipline' + id.toString(), {isEven: isEven, groups: groups, professors: professors, lectureHalls: lectureHalls});
}
}

View File

@ -0,0 +1,58 @@
import {Injectable} from "@angular/core";
import ApiService, {AvailableVersion} from "@api/api.service";
import {DatabaseRequest} from "@api/v1/databaseRequest";
import {CacheRequest} from "@api/v1/cacheRequest";
import {CreateUserRequest} from "@api/v1/createUserRequest";
import {LoggingRequest} from "@api/v1/loggingRequest";
import {EmailRequest} from "@api/v1/emailRequest";
import {ScheduleConfigurationRequest} from "@api/v1/scheduleConfigurationRequest";
@Injectable()
export default class SetupService extends ApiService {
protected basePath = 'v1/Setup/';
protected version = AvailableVersion.v1;
public checkToken(token: string) {
return this.get<boolean>('CheckToken', {token: token});
}
public setPsql(data: DatabaseRequest) {
return this.post<boolean>('SetPsql', data);
}
public setMysql(data: DatabaseRequest) {
return this.post<boolean>('SetMysql', data);
}
public setSqlite(path: string) {
return this.post<boolean>('SetSqlite', null, {path: path});
}
public setRedis(data: CacheRequest) {
return this.post<boolean>('SetRedis', data);
}
public setMemcached() {
return this.post<boolean>('SetMemcached', null);
}
public createAdmin(data: CreateUserRequest) {
return this.post<boolean>('CreateAdmin', data);
}
public setLogging(data: LoggingRequest) {
return this.post<boolean>('SetLogging', data);
}
public setEmail(data: EmailRequest) {
return this.post<boolean>('SetEmail', data);
}
public setSchedule(data: ScheduleConfigurationRequest) {
return this.post<boolean>('SetSchedule', data);
}
public submit() {
return this.post<boolean>('Submit', null);
}
}