diff options
| author | lucashemi <lucasxberger@gmail.com> | 2023-02-28 17:57:23 -0300 |
|---|---|---|
| committer | lucashemi <lucasxberger@gmail.com> | 2023-02-28 17:57:23 -0300 |
| commit | 74165bbd25981d06a16bc42a8bd39dec644275ae (patch) | |
| tree | 299cf610433e6ee197a906858f42742acfd20f33 | |
| parent | bc072aafa156b303b0ea2681cc23f449bc1734b3 (diff) | |
| -rw-r--r-- | README.md | 8 | ||||
| -rw-r--r-- | api/src/main/java/med/voll/api/controller/DoctorController.java | 5 | ||||
| -rw-r--r-- | api/src/main/java/med/voll/api/controller/PatientController.java | 2 | ||||
| -rw-r--r-- | api/src/main/java/med/voll/api/domain/doctor/DoctorRepository.java | 5 | ||||
| -rw-r--r-- | api/src/main/java/med/voll/api/domain/patient/PatientRepository.java | 2 | ||||
| -rw-r--r-- | web-client/voll/src/components/AppointmentModal.vue | 1 | ||||
| -rw-r--r-- | web-client/voll/src/components/AppointmentsList.vue | 9 | ||||
| -rw-r--r-- | web-client/voll/src/router/index.ts | 2 | ||||
| -rw-r--r-- | web-client/voll/src/views/AuthenticationView.vue (renamed from web-client/voll/src/views/AuthView.vue) | 7 | ||||
| -rw-r--r-- | web-client/voll/src/views/HomeView.vue | 6 |
10 files changed, 37 insertions, 10 deletions
@@ -1,10 +1,12 @@ -# Voll - Managing your clinic (WIP) +# Voll - Managing your clinic Voll is a webapp for managing medical clinics, you can register doctors and patients, schedule appointments and easily manage your clinic. The back-end is a rest api built in java/spring and the front-end is made with vue.js. -It's a work in progress, it's not possible to schedule appointments yet. +The main functions are done (doctor, patient and appointment crud). + +The front-end code needs some refactoring and things like colored notifications, more time options when scheduling a appointment. ## Tech-Stack @@ -39,7 +41,7 @@ Main technologies used in the project. ## Installation -1. Configure the application.properties file in the api src folder and create a database with the configured name. Build and run the api. +1. Configure the application.properties file in the api/src/main/resources folder and create a database with the configured name and a user to login. Build and run the api. 2. Go to the folder web-client/voll and run: diff --git a/api/src/main/java/med/voll/api/controller/DoctorController.java b/api/src/main/java/med/voll/api/controller/DoctorController.java index f87da56..f53093b 100644 --- a/api/src/main/java/med/voll/api/controller/DoctorController.java +++ b/api/src/main/java/med/voll/api/controller/DoctorController.java @@ -2,6 +2,7 @@ package med.voll.api.controller; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import jakarta.validation.Valid; +import jakarta.validation.ValidationException; import med.voll.api.domain.doctor.DoctorListingData; import med.voll.api.domain.doctor.Doctor; import med.voll.api.domain.doctor.DoctorRepository; @@ -54,6 +55,10 @@ public class DoctorController { @Transactional public ResponseEntity delete(@PathVariable Long id) { Doctor doctor = doctorRepository.getReferenceById(id); + var appointments = doctorRepository.findAnyAppointmentFromDoctor(id); + if (appointments != null) { + throw new ValidationException("Can't delete doctor with active appointments"); + } doctor.delete(); return ResponseEntity.noContent().build(); diff --git a/api/src/main/java/med/voll/api/controller/PatientController.java b/api/src/main/java/med/voll/api/controller/PatientController.java index 16c0973..7b2cd51 100644 --- a/api/src/main/java/med/voll/api/controller/PatientController.java +++ b/api/src/main/java/med/voll/api/controller/PatientController.java @@ -54,7 +54,7 @@ public class PatientController { @Transactional public ResponseEntity delete(@PathVariable Long id) { Patient patient = patientRepository.getReferenceById(id); - var appointments = patientRepository.findAnyAppointmentFrom(id); + var appointments = patientRepository.findAnyAppointmentFromPatient(id); if (appointments != null) { throw new ValidationException("Can't delete patient with active appointments"); } diff --git a/api/src/main/java/med/voll/api/domain/doctor/DoctorRepository.java b/api/src/main/java/med/voll/api/domain/doctor/DoctorRepository.java index 8cd6c46..c2f1567 100644 --- a/api/src/main/java/med/voll/api/domain/doctor/DoctorRepository.java +++ b/api/src/main/java/med/voll/api/domain/doctor/DoctorRepository.java @@ -28,4 +28,9 @@ public interface DoctorRepository extends JpaRepository<Doctor, Long> { where d.id = :id """) Boolean findActiveById(Long id); + + @Query(""" + select d.id from Doctor d join Appointment a on d.id = a.doctor.id where a.active = true and d.id = :id + """) + Long findAnyAppointmentFromDoctor(Long id); } diff --git a/api/src/main/java/med/voll/api/domain/patient/PatientRepository.java b/api/src/main/java/med/voll/api/domain/patient/PatientRepository.java index c53d47a..077dfa0 100644 --- a/api/src/main/java/med/voll/api/domain/patient/PatientRepository.java +++ b/api/src/main/java/med/voll/api/domain/patient/PatientRepository.java @@ -19,5 +19,5 @@ public interface PatientRepository extends JpaRepository<Patient, Long> { @Query(""" select p.id from Patient p join Appointment a on p.id = a.patient.id where a.active = true and p.id = :id """) - Long findAnyAppointmentFrom(Long id); + Long findAnyAppointmentFromPatient(Long id); } diff --git a/web-client/voll/src/components/AppointmentModal.vue b/web-client/voll/src/components/AppointmentModal.vue index 451c039..0b06f3b 100644 --- a/web-client/voll/src/components/AppointmentModal.vue +++ b/web-client/voll/src/components/AppointmentModal.vue @@ -76,6 +76,7 @@ export default defineComponent({ } }).then(response => { console.log(response) + this.$emit('list') }).catch(error => { console.log(error) }) diff --git a/web-client/voll/src/components/AppointmentsList.vue b/web-client/voll/src/components/AppointmentsList.vue index 3a6623b..0e17319 100644 --- a/web-client/voll/src/components/AppointmentsList.vue +++ b/web-client/voll/src/components/AppointmentsList.vue @@ -23,7 +23,7 @@ </div> </li> </ul> - <AppointmentModal ref="modal" :page="page" /> + <AppointmentModal ref="modal" :page="page" @list="list"/> </template> <script lang="ts"> @@ -34,6 +34,7 @@ import ButtonReverse from './ButtonReverse.vue'; import AppointmentModal from './AppointmentModal.vue'; import Search from './Search.vue'; import IAppointment from '@/interfaces/IAppointment'; +import handleBadRequest from '@/utilities/handleBadRequest'; export default defineComponent({ @@ -76,6 +77,9 @@ export default defineComponent({ }) }).catch(error => { console.log(error) + const code = error.response.status + const errors = error.response.data + this.handleBadRequest(code, errors) }) }, handleForbidden(code) { @@ -86,7 +90,8 @@ export default defineComponent({ }, showModal(appointment) { (this.$refs.modal as typeof AppointmentModal).showModal(appointment) - } + }, + handleBadRequest }, created() { this.list() diff --git a/web-client/voll/src/router/index.ts b/web-client/voll/src/router/index.ts index f3c9026..a9c20c6 100644 --- a/web-client/voll/src/router/index.ts +++ b/web-client/voll/src/router/index.ts @@ -1,6 +1,6 @@ import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router' import HomeView from '../views/HomeView.vue' -import LoginView from '../views/AuthView.vue' +import LoginView from '../views/AuthenticationView.vue' import DoctorsView from '../views/DoctorsView.vue' import PatientsView from '../views/PatientsView.vue' import AppointmentsView from '../views/AppointmentsView.vue' diff --git a/web-client/voll/src/views/AuthView.vue b/web-client/voll/src/views/AuthenticationView.vue index a7b52d1..a01b869 100644 --- a/web-client/voll/src/views/AuthView.vue +++ b/web-client/voll/src/views/AuthenticationView.vue @@ -9,7 +9,7 @@ <Fieldset> <label class="field-label" for="password">Password</label> <input type="password" class="field-input margin-top" id="password" v-model="password" required/> - <span class="error-message"></span> + <span ref="invalid" class="error-message"></span> </Fieldset> <div class="margin-top"> <Button @click.prevent="login()" Value="Sign In" Class="btn form-btn" Id="send" Type="submit" /> @@ -47,12 +47,17 @@ export default defineComponent({ password: this.password }) .then(response => { + (this.$refs.invalid as HTMLElement).innerHTML = '' sessionStorage.setItem("token", response.data.token) this.$router.push('/') }) .catch(error => { const errors = error.response.data const code = error.response.status + console.log(code) + if (code === 403) { + (this.$refs.invalid as HTMLElement).innerHTML = 'Invalid email or password' + } this.handleBadRequest(code, errors) }) }, diff --git a/web-client/voll/src/views/HomeView.vue b/web-client/voll/src/views/HomeView.vue index 776e83c..292c26b 100644 --- a/web-client/voll/src/views/HomeView.vue +++ b/web-client/voll/src/views/HomeView.vue @@ -1,6 +1,6 @@ <template> <Header /> - <main class="container"> + <main class="container margin-top"> <Logo Class="logo-huge" /> <Title text="Managing your clinic" Class="title"/> <p>Choose in which session you want to start:</p> @@ -69,6 +69,10 @@ export default defineComponent({ font-size: 3rem; } +.margin-top { + margin-top: 2rem; +} + @media screen and (max-width: 900px) { .cards { flex-direction: column; |
