From 3d9fabe21796dda8d406d0ac3c7fe3bd8b6057c8 Mon Sep 17 00:00:00 2001 From: Polianin Nikita Date: Wed, 5 Jun 2024 21:45:21 +0300 Subject: [PATCH] feat: add ApiService implementations --- src/api/v1/campus.service.ts | 18 ++++++++++ src/api/v1/discipline.service.ts | 17 +++++++++ src/api/v1/faculty.service.ts | 19 ++++++++++ src/api/v1/group.service.ts | 22 ++++++++++++ src/api/v1/lectureHall.service.ts | 22 ++++++++++++ src/api/v1/professor.service.ts | 17 +++++++++ src/api/v1/schedule.service.ts | 44 +++++++++++++++++++++++ src/api/v1/setup.service.ts | 58 +++++++++++++++++++++++++++++++ 8 files changed, 217 insertions(+) create mode 100644 src/api/v1/campus.service.ts create mode 100644 src/api/v1/discipline.service.ts create mode 100644 src/api/v1/faculty.service.ts create mode 100644 src/api/v1/group.service.ts create mode 100644 src/api/v1/lectureHall.service.ts create mode 100644 src/api/v1/professor.service.ts create mode 100644 src/api/v1/schedule.service.ts create mode 100644 src/api/v1/setup.service.ts diff --git a/src/api/v1/campus.service.ts b/src/api/v1/campus.service.ts new file mode 100644 index 0000000..1a02d97 --- /dev/null +++ b/src/api/v1/campus.service.ts @@ -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(); + } + + public getById(id: number) { + return this.get(id.toString()); + } +} diff --git a/src/api/v1/discipline.service.ts b/src/api/v1/discipline.service.ts new file mode 100644 index 0000000..143c5a1 --- /dev/null +++ b/src/api/v1/discipline.service.ts @@ -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('', {page: page, pageSize: pageSize}); + } + + public getById(id: number) { + return this.get(id.toString()); + } +} diff --git a/src/api/v1/faculty.service.ts b/src/api/v1/faculty.service.ts new file mode 100644 index 0000000..64b8511 --- /dev/null +++ b/src/api/v1/faculty.service.ts @@ -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('', {page: page, pageSize: pageSize}); + + } + + public getById(id: number) { + return this.get(id.toString()); + } +} diff --git a/src/api/v1/group.service.ts b/src/api/v1/group.service.ts new file mode 100644 index 0000000..d990c0d --- /dev/null +++ b/src/api/v1/group.service.ts @@ -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('', {page: page, pageSize: pageSize}); + } + + public getById(id: number) { + return this.get(id.toString()); + } + + public getByFaculty(id: number) { + return this.get('GetByFaculty/' + id.toString()); + } +} diff --git a/src/api/v1/lectureHall.service.ts b/src/api/v1/lectureHall.service.ts new file mode 100644 index 0000000..d2e74bf --- /dev/null +++ b/src/api/v1/lectureHall.service.ts @@ -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(); + } + + public getById(id: number) { + return this.get(id.toString()); + } + + public getByCampus(id: number) { + return this.get('GetByCampus/' + id.toString()); + } +} diff --git a/src/api/v1/professor.service.ts b/src/api/v1/professor.service.ts new file mode 100644 index 0000000..fe20e32 --- /dev/null +++ b/src/api/v1/professor.service.ts @@ -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('', {page: page, pageSize: pageSize}); + } + + public getById(id: number) { + return this.get(id.toString()); + } +} diff --git a/src/api/v1/schedule.service.ts b/src/api/v1/schedule.service.ts new file mode 100644 index 0000000..a9c2b45 --- /dev/null +++ b/src/api/v1/schedule.service.ts @@ -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('StartTerm').pipe(map(date => new DateOnly(date))); + } + + public pairPeriod() { + return this.get('PairPeriod'); + } + + public postSchedule(data: ScheduleRequest) { + return this.post('', data); + } + + public getByGroup(id : number, isEven: boolean | null = null, disciplines: Array | null = null, professors: Array | null = null, lectureHalls: Array | null = null) { + return this.get('GetByGroup' + id.toString(), {isEven: isEven, disciplines: disciplines, professors: professors, lectureHalls: lectureHalls}); + } + + public getByProfessor(id : number, isEven: boolean | null = null, disciplines: Array | null = null, groups: Array | null = null, lectureHalls: Array | null = null) { + return this.get('GetByProfessor' + id.toString(), {isEven: isEven, disciplines: disciplines, groups: groups, lectureHalls: lectureHalls}); + } + + public getByLectureHall(id : number, isEven: boolean | null = null, disciplines: Array | null = null, groups: Array | null = null, professors: Array | null = null) { + return this.get('GetByLectureHall' + id.toString(), {isEven: isEven, disciplines: disciplines, groups: groups, professors: professors}); + } + + public getByDiscipline(id : number, isEven: boolean | null = null, groups: Array | null = null, professors: Array | null = null, lectureHalls: Array | null = null) { + return this.get('GetByDiscipline' + id.toString(), {isEven: isEven, groups: groups, professors: professors, lectureHalls: lectureHalls}); + } +} diff --git a/src/api/v1/setup.service.ts b/src/api/v1/setup.service.ts new file mode 100644 index 0000000..f93f221 --- /dev/null +++ b/src/api/v1/setup.service.ts @@ -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('CheckToken', {token: token}); + } + + public setPsql(data: DatabaseRequest) { + return this.post('SetPsql', data); + } + + public setMysql(data: DatabaseRequest) { + return this.post('SetMysql', data); + } + + public setSqlite(path: string) { + return this.post('SetSqlite', null, {path: path}); + } + + public setRedis(data: CacheRequest) { + return this.post('SetRedis', data); + } + + public setMemcached() { + return this.post('SetMemcached', null); + } + + public createAdmin(data: CreateUserRequest) { + return this.post('CreateAdmin', data); + } + + public setLogging(data: LoggingRequest) { + return this.post('SetLogging', data); + } + + public setEmail(data: EmailRequest) { + return this.post('SetEmail', data); + } + + public setSchedule(data: ScheduleConfigurationRequest) { + return this.post('SetSchedule', data); + } + + public submit() { + return this.post('Submit', null); + } +}