diff --git a/mvnw.cmd b/mvnw.cmd index c8d4337..980c359 100644 --- a/mvnw.cmd +++ b/mvnw.cmd @@ -43,7 +43,7 @@ title %0 @REM set %HOME% to equivalent of $HOME if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") -@REM Execute a user defined script before this one +@REM Execute a doctor defined script before this one if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre @REM check for pre script, once with legacy .bat ending and once with .cmd ending if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" diff --git a/readme2.docx b/readme2.docx new file mode 100644 index 0000000..8e2a8b0 Binary files /dev/null and b/readme2.docx differ diff --git a/readme2.txt b/readme2.txt new file mode 100644 index 0000000..e41069c --- /dev/null +++ b/readme2.txt @@ -0,0 +1,9 @@ +Pharmacy Database: Service for Doctors to Receive Information for Their Patients Medications and Experiences. +Team: Noah Evantash +Problem Statement: The problem this database design seeks to resolve is patients trying to relay information to their doctor about a new medication they are on. How can they effectively tell their doctor how the medication makes them feel through a web service that records the prescriptions of these patients. Doctors are then able to view their patients, prescriptions, and the symptoms of those prescriptions. The database allows doctors to record which patients are under their care for what conditions, what those patient’s prescriptions are, and the symptoms those patients are experiencing. +Solution Statement: The solution created to help track these patients taking new medication is to create a database that keeps records of these patients, their prescriptions, medications, and symptoms. To do this, I must create a database on MySQL that represents this database as done in part 1. Next, I must create a relational mapping of a java model for the database diagram that translates the SQL code into java. Lastly, and unsuccessfully, I wanted to create a UI that allowed doctors to implement new patients and write prescriptions for them. +Users: While patients are usually a User class, in the UI it exists as a relational object of the doctors, so it can be treated similarly to a domain object with one-to-many relationships to another domain object prescriptions. Doctors are the primary user implemented in this design and has objects patients that can be created and edited under the patient’s tab of whatever doctor that patients belong’ to. For each doctor, there is an inline-editor script created that allows the doctors conditions to be changed and updated in the main list interface. Under the doctors is a patient’s tab that connects to the patients list of that specific doctor. Those patients can be edited in an inline editor that updates or creates the patients’ parameters. There is a back on that list that returns to the list of all the other objects. +Domain Objects: The objects in this database are the prescriptions and the symptoms, as well as the patients described above in relation to the doctor users. For the other domain objects, the doctor user is able to create new prescriptions under the patients tab. The patients have a tab that relays which prescriptions they have and allows for creating and editing of new prescriptions with CCUD (cancel, create, update, delete) editor format. Once the prescription is made, the only updatable parameter should be the dosage. In the inline editor, it would only be allowing changing of the dosage and updating of that parameter (which returns the whole body, but only with the updated dose). This is to keep prescriptions in line and prevent changing the medication which was a difficult parameter to implement due to it being a portable enumeration. Therefore, to mitigate errors of passing an invalid medication, we only want the medication to be changed in the editor with a dropdown list of acceptable medications. If I had more time, I would have included another form for the medications that allows the doctor to create new medication names. This was an issue since I was not sure how to include the new meds in the dropdown list. The final list was the symptoms list which showed all the reactions to the prescription. Under each prescription in the list under the main screen, the user can create new symptoms for the prescription. Each symptom allows the user to relay information about the efficacy, benefits, and/or side effects of the prescription given. Such information can be used by the doctor to access their patient’s information of prescriptions and symptoms. +Note On functionality: As of today, the only services that have been working for the design UI is the doctors and patients. There was a litany of unforeseen errors and complications relating to development of the UI that made it unreadable with the index.html. The object relational mapping is working as intended and the user can receive information from the database using localhost:8080/api/… but it does not yet fully extend to the UI implementation. So far, the UI only works up to the patients list trying to get prescriptions but runs into a Reach.createElement error that has not been fixed yet. Therefore, the project is only finished and requires more time to try and correct these problems. Nonetheless, the database is set up to create new doctors, add new patients to those doctors, edit those doctors, or delete those doctors. The patients can be accessed through whichever doctor they are a part of and edited or deleted. This functionality is supposed to be extended to the prescriptions and symptoms models but isn’t able to due to the errors. + + diff --git a/src/main/java/com/example/springtemplate/daos/CourseOrmDao.java b/src/main/java/com/example/springtemplate/daos/CourseOrmDao.java deleted file mode 100644 index acf644a..0000000 --- a/src/main/java/com/example/springtemplate/daos/CourseOrmDao.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.example.springtemplate.daos; - -import com.example.springtemplate.models.Course; -import com.example.springtemplate.repositories.CourseRepository; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -@RestController -@CrossOrigin(origins = "*") -public class CourseOrmDao { - @Autowired - CourseRepository courseRepository; - - @PostMapping("/api/courses") - public Course createCourse(@RequestBody Course course) { - return courseRepository.save(course); - } - - @GetMapping("/api/courses") - public List findAllCourses() { - return (List) courseRepository.findAll(); - } - - @GetMapping("/api/courses/{courseId}") - public Course findCourseById( - @PathVariable("courseId") Integer id) { - return courseRepository.findById(id).get(); - } - - @GetMapping("/api/update/course/{courseId}/{password}") - public Course updateCourse( - @PathVariable("courseId") Integer id, - @PathVariable("password") String newPass) { - Course course = this.findCourseById(id); - course.setTitle(newPass); - return courseRepository.save(course); - } - - @PutMapping("/api/courses/{courseId}") - public Course updateCourse( - @PathVariable("courseId") Integer id, - @RequestBody() Course newCourse) { - Course course = this.findCourseById(id); - course.setTitle(newCourse.getTitle()); - return courseRepository.save(course); - } - - @DeleteMapping("/api/courses/{courseId}") - public void deleteCourse( - @PathVariable("courseId") Integer id) { - courseRepository.deleteById(id); - } -} \ No newline at end of file diff --git a/src/main/java/com/example/springtemplate/daos/DoctorJdbcDao.java b/src/main/java/com/example/springtemplate/daos/DoctorJdbcDao.java new file mode 100644 index 0000000..309390a --- /dev/null +++ b/src/main/java/com/example/springtemplate/daos/DoctorJdbcDao.java @@ -0,0 +1,167 @@ +package com.example.springtemplate.daos; + +import com.example.springtemplate.models.Doctor; + +import java.sql.*; +import java.sql.Date; +import java.util.*; + +public class DoctorJdbcDao { + static final String DRIVER = "com.mysql.cj.jdbc.Driver"; + static final String HOST = "localhost:3306"; + static final String SCHEMA = "db_project"; + static final String CONFIG = "serverTimezone=UTC"; + static final String URL = + "jdbc:mysql://"+HOST+"/"+SCHEMA+"?"+CONFIG; + static final String USERNAME = "root"; + static final String PASSWORD = "P@ssw0rd"; + + static Connection connection = null; + static PreparedStatement statement = null; + String CREATE_DOCTOR = "INSERT INTO `db_project`.`doctors`\n" + + "(`firstname`,\n" + + "`lastname`,\n" + + "`username`,\n" + + "`password`,\n" + + "`email`,\n" + + "`DOB`,\n" + + "`hospital`,\n" + + "`position`)\n" + + "VALUES\n" + + "(?,\n" + + "?,\n" + + "?,\n" + + "?,\n" + + "?,\n" + + "?,\n" + + "?,\n" + + "?);\n"; + String FIND_ALL_DOCTORS = "SELECT * FROM doctors"; + String FIND_DOCTOR_BY_ID = "SELECT * FROM doctors WHERE id=?"; + String DELETE_DOCTOR = "DELETE FROM doctors WHERE id=?"; + String UPDATE_DOCTOR_PASSWORD = "UPDATE doctors SET password=? WHERE id=?"; + String UPDATE_DOCTOR = "UPDATE doctors SET firstname=?, lastname=?, username=?, password=? " + + "email=?, DOB=?, position=?, hospital=? WHERE id=?"; + + + + private Connection getConnection() throws ClassNotFoundException, SQLException { + Class.forName(DRIVER); + return DriverManager.getConnection(URL, USERNAME, PASSWORD); + } + + private void closeConnection(Connection connection) throws SQLException { + connection.close(); + } + + public Doctor findDoctorById(Integer id) throws SQLException, ClassNotFoundException { + Doctor doctor = null; + connection = getConnection(); + statement = connection.prepareStatement(FIND_DOCTOR_BY_ID); + statement.setInt(1, id); + ResultSet resultSet = statement.executeQuery(); + if(resultSet.next()) { + doctor = new Doctor( + resultSet.getString("firstname"), + resultSet.getString("lastname"), + resultSet.getString("username"), + resultSet.getString("password"), + resultSet.getString("email"), + resultSet.getDate("DOB"), + resultSet.getString("position"), + resultSet.getString("hospital") + ); + } + closeConnection(connection); + return doctor; + } + + public Integer deleteDoctor(Integer userId) throws SQLException, ClassNotFoundException { + Integer rowsDeleted = 0; + connection = getConnection(); + statement = connection.prepareStatement(DELETE_DOCTOR); + statement.setInt(1, userId); + rowsDeleted = statement.executeUpdate(); + closeConnection(connection); + return rowsDeleted; + } + + public Integer updateDoctor(Integer userId, Doctor newDoctor) throws SQLException, ClassNotFoundException { + Integer rowsUpdated = 0; + connection = getConnection(); + statement = connection.prepareStatement(UPDATE_DOCTOR); + statement.setString(1, newDoctor.getFirstname()); + statement.setString(2, newDoctor.getLastname()); + statement.setString(3, newDoctor.getUsername()); + statement.setString(4, newDoctor.getPassword()); + statement.setString(5, newDoctor.getEmail()); + statement.setDate(6, newDoctor.getDOB()); + statement.setString(7, newDoctor.getPosition()); + statement.setString(8, newDoctor.getHospital()); + statement.setInt(9, userId); + + rowsUpdated = statement.executeUpdate(); + closeConnection(connection); + return rowsUpdated; + } + + public List findAllDoctors() throws ClassNotFoundException, SQLException { + List doctors = new ArrayList(); + connection = getConnection(); + statement = connection.prepareStatement(FIND_ALL_DOCTORS); + ResultSet resultSet = statement.executeQuery(); + while (resultSet.next()) { + Doctor doctor = new Doctor( + resultSet.getString("firstname"), + resultSet.getString("lastname"), + resultSet.getString("username"), + resultSet.getString("password"), + resultSet.getString("email"), + resultSet.getDate("DOB"), + resultSet.getString("position"), + resultSet.getString("hospital") + ); + doctors.add(doctor); + } + closeConnection(connection); + return doctors; + } + public Integer createDoctor(Doctor doctor) + throws ClassNotFoundException, SQLException { + Integer rowsUpdated = 0; + connection = getConnection(); + statement = connection.prepareStatement(CREATE_DOCTOR); + statement.setString(1, doctor.getFirstname()); + statement.setString(2, doctor.getLastname()); + statement.setString(3, doctor.getUsername()); + statement.setString(4, doctor.getPassword()); + statement.setString(5, doctor.getEmail()); + statement.setDate(6,doctor.getDOB()); + statement.setString(7, doctor.getPosition()); + statement.setString(8, doctor.getHospital()); + rowsUpdated = statement.executeUpdate(); + closeConnection(connection); + return rowsUpdated; + } + +public static void main(String[] args) throws SQLException, ClassNotFoundException{ + System.out.println("JDBC DAO"); + DoctorJdbcDao dao = new DoctorJdbcDao(); + + Doctor DrRob = new Doctor( + "Robert", + "Phoughts", + "rphoughts", + "robisnumber1", + "rpho@partners.org", + Date.valueOf("1980-10-10"), + "Lead Psychiatrist", + "Mass General"); + dao.createDoctor(DrRob); + + System.out.println(dao.findDoctorById(1).getUsername()); + +} +} + + diff --git a/src/main/java/com/example/springtemplate/daos/DoctorOrmDao.java b/src/main/java/com/example/springtemplate/daos/DoctorOrmDao.java new file mode 100644 index 0000000..56e69a6 --- /dev/null +++ b/src/main/java/com/example/springtemplate/daos/DoctorOrmDao.java @@ -0,0 +1,57 @@ +package com.example.springtemplate.daos; + +import com.example.springtemplate.models.Doctor; +import com.example.springtemplate.repositories.DoctorRepository; +import com.example.springtemplate.repositories.PatientRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import java.util.List; + +@RestController +@CrossOrigin(origins = "*") +public class DoctorOrmDao { + @Autowired + DoctorRepository doctorRepository; + + @Autowired + PatientRepository patientRepository; + + + @PostMapping("/api/doctors") + public Doctor createDoctor(@RequestBody Doctor doctor) { + return doctorRepository.save(doctor); + } + + @GetMapping("/api/doctors") + public List findAllDoctors() { + return (List) doctorRepository.findAll(); + } + + @GetMapping("/api/doctors/{userId}") + public Doctor findDoctorById( + @PathVariable("userId") Integer id) { + return doctorRepository.findById(id).get(); + } + + @PutMapping("/api/doctors/{userId}") + public Doctor updateDoctor( + @PathVariable("userId") Integer id, + @RequestBody Doctor doctorUpdates) { + Doctor doctor = doctorRepository.findById(id).get(); + doctor.setFirstname(doctorUpdates.getFirstname()); + doctor.setLastname(doctorUpdates.getLastname()); + doctor.setUsername(doctorUpdates.getUsername()); + doctor.setPassword(doctorUpdates.getPassword()); + doctor.setEmail(doctorUpdates.getEmail()); + doctor.setDOB(doctorUpdates.getDOB()); + doctor.setPosition(doctorUpdates.getPosition()); + doctor.setHospital(doctorUpdates.getHospital()); + return doctorRepository.save(doctor); + } + + @DeleteMapping("/api/doctors/{userId}") + public void deleteUser( + @PathVariable("userId") Integer id) { + doctorRepository.deleteById(id); + } +} \ No newline at end of file diff --git a/src/main/java/com/example/springtemplate/daos/MedicationDao.java b/src/main/java/com/example/springtemplate/daos/MedicationDao.java new file mode 100644 index 0000000..127444e --- /dev/null +++ b/src/main/java/com/example/springtemplate/daos/MedicationDao.java @@ -0,0 +1,44 @@ +package com.example.springtemplate.daos; + +import com.example.springtemplate.models.Medications; +import com.example.springtemplate.repositories.MedicationRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@RestController +@CrossOrigin(origins = "*") +public class MedicationDao { + @Autowired + MedicationRepository medicationRepository; + @GetMapping("/api/medications/findAllMeds") + public List findAllMeds() { + return (List) medicationRepository.findAll(); + } + @GetMapping("/api/medications/findMedById/{id}") + public Medications findMedById(@PathVariable("id") String name) { + + return medicationRepository.findMedByName(name); + } + @PostMapping("/api/medications/createMed/{name}") + public Medications createMed(@PathVariable("name") String name) { + Medications medications = new Medications(); + medications.setName(name); + medicationRepository.save(medications); + return medicationRepository.save(medications); + } + @PutMapping("/api/medications/updateMedication/{name}/{newName}") + public Medications updateMedication( + @PathVariable("id") String name, + @PathVariable("newName") String newName) { + Medications medications = medicationRepository.findMedByName(name); + medications.setName(newName); + return medicationRepository.save(medications); + } + @DeleteMapping("/api/medications/deleteMedication/{id}") + public void deleteMedication( + @PathVariable("id") Integer id) { + medicationRepository.deleteById(id); + } +} diff --git a/src/main/java/com/example/springtemplate/daos/PatientOrmDao.java b/src/main/java/com/example/springtemplate/daos/PatientOrmDao.java new file mode 100644 index 0000000..36065df --- /dev/null +++ b/src/main/java/com/example/springtemplate/daos/PatientOrmDao.java @@ -0,0 +1,73 @@ +package com.example.springtemplate.daos; + +import com.example.springtemplate.models.Doctor; +import com.example.springtemplate.models.Patient; +import com.example.springtemplate.repositories.DoctorRepository; +import com.example.springtemplate.repositories.PatientRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import java.util.List; + +@RestController +@CrossOrigin(origins = "*") +public class PatientOrmDao { + @Autowired + DoctorRepository doctorRepository; + + @Autowired + PatientRepository patientRepository; + + + @PostMapping("/api/doctors/{doctorId}/patients") + public Patient createPatientForDoctor(@PathVariable("doctorId") Integer doctorId, + @RequestBody Patient patient){ + patient = patientRepository.save(patient); + Doctor doc = doctorRepository.findById(doctorId).get(); + patient.setDoctor(doc); + return patientRepository.save(patient); + } + + @GetMapping("/api/doctors/{id}/patients") + public List findPatientsForDoctor(@PathVariable("id") Integer docId){ + Doctor doc = doctorRepository.findById(docId).get(); + return doc.getPatients(); + } + + @PostMapping("/api/patients") + public Patient createPatient(@RequestBody Patient patient) { + return patientRepository.save(patient); + } + + @GetMapping("/api/patients") + public List findAllPatients() { + return (List) patientRepository.findAll(); + } + + @GetMapping("/api/patients/{userId}") + public Patient findPatientById( + @PathVariable("userId") Integer id) { + return patientRepository.findById(id).get(); + } + + @PutMapping("/api/patients/{userId}") + public Patient updatePatient( + @PathVariable("userId") Integer id, + @RequestBody Patient patientUpdates) { + Patient patient = patientRepository.findById(id).get(); + patient.setFirstname(patientUpdates.getFirstname()); + patient.setLastname(patientUpdates.getLastname()); + patient.setUsername(patientUpdates.getUsername()); + patient.setPassword(patientUpdates.getPassword()); + patient.setEmail(patientUpdates.getEmail()); + patient.setDOB(patientUpdates.getDOB()); + patient.setDoctor(patientUpdates.getDoctor()); + patient.setConditions(patientUpdates.getConditions()); + return patientRepository.save(patient); + } + + @DeleteMapping("/api/patients/{userId}") + public void deletePatient( + @PathVariable("userId") Integer id) { + patientRepository.deleteById(id); + } +} \ No newline at end of file diff --git a/src/main/java/com/example/springtemplate/daos/PrescriptionOrmDao.java b/src/main/java/com/example/springtemplate/daos/PrescriptionOrmDao.java new file mode 100644 index 0000000..7145940 --- /dev/null +++ b/src/main/java/com/example/springtemplate/daos/PrescriptionOrmDao.java @@ -0,0 +1,85 @@ +package com.example.springtemplate.daos; + +import com.example.springtemplate.models.Patient; +import com.example.springtemplate.models.Prescription; +import com.example.springtemplate.models.Symptom; +import com.example.springtemplate.repositories.PrescriptionRepository; +import com.example.springtemplate.repositories.PatientRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@RestController +@CrossOrigin(origins = "*") +public class PrescriptionOrmDao { + @Autowired + PrescriptionRepository prescriptionRepository; + + @Autowired + PatientRepository patientRepository; + + @PostMapping("/api/prescriptions") + public Prescription createPrescription(@RequestBody Prescription prescription) { + return prescriptionRepository.save(prescription); + } + + @PostMapping("/api/patients/{id}/prescriptions") + public Prescription createPrescriptionForPatient(@PathVariable("id") Integer id, + @RequestBody Prescription prescription) { + prescription = prescriptionRepository.save(prescription); + Patient patient = patientRepository.findById(id).get(); + prescription.setPatient(patient); + return prescriptionRepository.save(prescription); + } + + @GetMapping("/api/patients/{id}/prescriptions") + public List findPrescriptionsForPatient( + @PathVariable("id") Integer patientId) { + Patient patient = patientRepository.findById(patientId).get(); + return patient.getPrescriptions(); + } + + @GetMapping("/api/prescriptions") + public List findAllPrescriptions() { + return (List) prescriptionRepository.findAll(); + } + + @GetMapping("/api/prescriptions/{id}") + public Prescription findPrescriptionsById( + @PathVariable("id") Integer id) { + return prescriptionRepository.findById(id).get(); + } + + + @PutMapping("/api/update/prescriptions/{id}/{newDose}") + public Prescription updatePrescriptionsDose( + @PathVariable("id") Integer id, + @PathVariable("newDose") Integer newDose) { + Prescription prescription = this.findPrescriptionsById(id); + prescription.setDosage(newDose); + return prescriptionRepository.save(prescription); + } + + @PutMapping("/api/prescriptions/{id}") + public Prescription updatePrescriptions( + @PathVariable("id") Integer id, + @RequestBody() Prescription newPrescription) { + Prescription prescription = this.findPrescriptionsById(id); + prescription.setPatient(newPrescription.getPatient()); + + prescription.setMedication(newPrescription.getMedication()); + prescription.setDiagnosis(newPrescription.getDiagnosis()); + prescription.setDosage(newPrescription.getDosage()); + prescription.setSymptoms(newPrescription.getSymptoms()); + return prescriptionRepository.save(prescription); + } + + @DeleteMapping("/api/prescriptions/{id}") + public void deletePrescription( + @PathVariable("id") Integer id) { + prescriptionRepository.deleteById(id); + } + + +} \ No newline at end of file diff --git a/src/main/java/com/example/springtemplate/daos/SectionOrmDao.java b/src/main/java/com/example/springtemplate/daos/SectionOrmDao.java deleted file mode 100644 index 5509c5e..0000000 --- a/src/main/java/com/example/springtemplate/daos/SectionOrmDao.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.example.springtemplate.daos; - -import com.example.springtemplate.models.Course; -import com.example.springtemplate.models.Section; -import com.example.springtemplate.repositories.CourseRepository; -import com.example.springtemplate.repositories.SectionRepository; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; -import java.util.List; - -@RestController -@CrossOrigin(origins = "*") -public class SectionOrmDao { - @Autowired - SectionRepository sectionRepository; - - @Autowired - CourseRepository courseRepository; - - @PostMapping("/api/sections") - public Section createSection(@RequestBody Section section) { - return sectionRepository.save(section); - } - - @PostMapping("/api/courses/{courseId}/sections") - public Section createSectionForCourse( - @PathVariable("courseId") Integer cid, - @RequestBody Section section) { - section = sectionRepository.save(section); - Course course = courseRepository.findById(cid).get(); - section.setCourse(course); - return sectionRepository.save(section); - } - - @GetMapping("/api/courses/{cid}/sections") - public List
findSectionsForCourse( - @PathVariable("cid") Integer courseId) { - Course course = courseRepository.findById(courseId).get(); - return course.getSections(); - } - - @GetMapping("/api/sections") - public List
findAllSections() { - return (List
) sectionRepository.findAll(); - } - - @GetMapping("/api/sections/{sectionId}") - public Section findSectionById( - @PathVariable("sectionId") Integer id) { - return sectionRepository.findById(id).get(); - } - - @PutMapping("/api/sections/{sectionId}") - public Section updateSection( - @PathVariable("sectionId") Integer id, - @RequestBody() Section newSection) { - Section section = this.findSectionById(id); - section.setName(newSection.getName()); - section.setSeats(newSection.getSeats()); - section.setSemester(newSection.getSemester()); - section.setYear(newSection.getYear()); - section.setOnline(newSection.getOnline()); -// section.setStartDate(newSection.getStartDate()); - return sectionRepository.save(section); - } - - @DeleteMapping("/api/sections/{sectionId}") - public void deleteSection( - @PathVariable("sectionId") Integer id) { - sectionRepository.deleteById(id); - } -} \ No newline at end of file diff --git a/src/main/java/com/example/springtemplate/daos/SymptomOrmDao.java b/src/main/java/com/example/springtemplate/daos/SymptomOrmDao.java new file mode 100644 index 0000000..49475bf --- /dev/null +++ b/src/main/java/com/example/springtemplate/daos/SymptomOrmDao.java @@ -0,0 +1,72 @@ +package com.example.springtemplate.daos; + + +import com.example.springtemplate.models.Prescription; +import com.example.springtemplate.models.Symptom; +import com.example.springtemplate.repositories.PrescriptionRepository; +import com.example.springtemplate.repositories.SymptomRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@RestController +@CrossOrigin(origins = "*") +public class SymptomOrmDao { + @Autowired + SymptomRepository symptomRepository; + + @Autowired + PrescriptionRepository prescriptionRepository; + + @PostMapping("/api/symptoms") + public Symptom createSymptom(@RequestBody Symptom symptom) { + return symptomRepository.save(symptom); + } + + @PostMapping("/api/prescriptions/{id}/symptoms") + public Symptom createSymptomForPrescription( + @PathVariable("id") Integer id, + @RequestBody Symptom symptom) { + symptom = symptomRepository.save(symptom); + Prescription script = prescriptionRepository.findById(id).get(); + symptom.setPrescription(script); + return symptomRepository.save(symptom); + } + + @GetMapping("/api/prescriptions/{id}/symptoms") + public List findSymptomsForPrescription( + @PathVariable("id") Integer id) { + Prescription prescription = prescriptionRepository.findById(id).get(); + return prescription.getSymptoms(); + } + + @GetMapping("/api/symptoms") + public List findAllSymptoms() { + return (List) symptomRepository.findAll(); + } + + @GetMapping("/api/symptoms/{id}") + public Symptom findSymptomById( + @PathVariable("id") Integer id) { + return symptomRepository.findById(id).get(); + } + + @PutMapping("/api/symptoms/{id}") + public Symptom updateSymptom( + @PathVariable("id") Integer id, + @RequestBody() Symptom newSymptom) { + Symptom symptom = this.findSymptomById(id); + symptom.setBenefits(newSymptom.getBenefits()); + symptom.setSideEffects(newSymptom.getSideEffects()); + symptom.setUsedFor(newSymptom.getUsedFor()); + symptom.setLastUsed(newSymptom.getLastUsed()); + return symptomRepository.save(symptom); + } + + @DeleteMapping("/api/symptoms/{id}") + public void deleteSymptom( + @PathVariable("id") Integer id) { + symptomRepository.deleteById(id); + } +} \ No newline at end of file diff --git a/src/main/java/com/example/springtemplate/daos/TodoDao.java b/src/main/java/com/example/springtemplate/daos/TodoDao.java deleted file mode 100644 index 9a0bd1a..0000000 --- a/src/main/java/com/example/springtemplate/daos/TodoDao.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.example.springtemplate.daos; - -import com.example.springtemplate.models.Todo; -import com.example.springtemplate.repositories.TodoRepository; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; - -@RestController -public class TodoDao { - @Autowired - TodoRepository repository; - @GetMapping("/findAllTodos") - public List findAllTodos() { - return repository.findAllTodos(); - } - @GetMapping("/findTodoById/{id}") - public Todo findTodoById(@PathVariable("id") Integer id) { - return repository.findTodoById(id); - } - @GetMapping("/createTodo") - public Todo createTodo() { - Todo todo = new Todo(); - todo.setTitle("New Todo"); - todo.setTodo("Chang this todo"); - return repository.save(todo); - } - @GetMapping("/updateTodo/{id}/{newTitle}/{newTodo}") - public Todo updateTodo( - @PathVariable("id") Integer id, - @PathVariable("newTitle") String newTitle, - @PathVariable("newTodo") String newTodo) { - Todo todo = repository.findTodoById(id); - todo.setTitle(newTitle); - todo.setTodo(newTodo); - return repository.save(todo); - } - @GetMapping("/deleteTodo/{id}") - public void deleteTodo( - @PathVariable("id") Integer id) { - repository.deleteById(id); - } -} diff --git a/src/main/java/com/example/springtemplate/daos/UserJdbcDao.java b/src/main/java/com/example/springtemplate/daos/UserJdbcDao.java deleted file mode 100644 index d9cf738..0000000 --- a/src/main/java/com/example/springtemplate/daos/UserJdbcDao.java +++ /dev/null @@ -1,141 +0,0 @@ -package com.example.springtemplate.daos; - -import com.example.springtemplate.models.User; - -import java.sql.*; -import java.util.*; - -public class UserJdbcDao { - static final String DRIVER = "com.mysql.cj.jdbc.Driver"; - static final String HOST = "localhost:3306"; - static final String SCHEMA = "YOUR_SCHEMA"; - static final String CONFIG = "serverTimezone=UTC"; - static final String URL = - "jdbc:mysql://"+HOST+"/"+SCHEMA+"?"+CONFIG; - static final String USERNAME = "YOUR_USERNAME"; - static final String PASSWORD = "YOUR_PASSWORD"; - - static Connection connection = null; - static PreparedStatement statement = null; - String CREATE_USER = "INSERT INTO users VALUES (null, ?, ?, ?, ?, ?, null, null)"; - String FIND_ALL_USERS = "SELECT * FROM users"; - String FIND_USER_BY_ID = "SELECT * FROM users WHERE id=?"; - String DELETE_USER = "DELETE FROM users WHERE id=?"; - String UPDATE_USER_PASSWORD = "UPDATE users SET password=? WHERE id=?"; - String UPDATE_USER = "UPDATE users SET first_name=?, last_name=?, username=?, password=? WHERE id=?"; - - private Connection getConnection() throws ClassNotFoundException, SQLException { - Class.forName(DRIVER); - return DriverManager.getConnection(URL, USERNAME, PASSWORD); - } - - private void closeConnection(Connection connection) throws SQLException { - connection.close(); - } - - public User findUserById(Integer id) throws SQLException, ClassNotFoundException { - User user = null; - connection = getConnection(); - statement = connection.prepareStatement(FIND_USER_BY_ID); - statement.setInt(1, id); - ResultSet resultSet = statement.executeQuery(); - if(resultSet.next()) { - user = new User( - resultSet.getString("username"), - resultSet.getString("password"), - resultSet.getString("first_name"), - resultSet.getString("last_name"), - resultSet.getString("profile_picture") - ); - } - closeConnection(connection); - return user; - } - - public Integer deleteUser(Integer userId) throws SQLException, ClassNotFoundException { - Integer rowsDeleted = 0; - connection = getConnection(); - statement = connection.prepareStatement(DELETE_USER); - statement.setInt(1, userId); - rowsDeleted = statement.executeUpdate(); - closeConnection(connection); - return rowsDeleted; - } - - public Integer updateUser(Integer userId, User newUser) throws SQLException, ClassNotFoundException { - Integer rowsUpdated = 0; - connection = getConnection(); - statement = connection.prepareStatement(UPDATE_USER); - statement.setString(1, newUser.getFirstName()); - statement.setString(2, newUser.getLastName()); - statement.setString(3, newUser.getFirstName()); - statement.setString(4, newUser.getLastName()); - statement.setInt(5, userId); - rowsUpdated = statement.executeUpdate(); - closeConnection(connection); - return rowsUpdated; - } - - public List findAllUsers() throws ClassNotFoundException, SQLException { - List users = new ArrayList(); - connection = getConnection(); - statement = connection.prepareStatement(FIND_ALL_USERS); - ResultSet resultSet = statement.executeQuery(); - while (resultSet.next()) { - User user = new User( - resultSet.getString("username"), - resultSet.getString("password"), - resultSet.getString("first_name"), - resultSet.getString("last_name"), - resultSet.getString("profile_picture") - ); - users.add(user); - } - closeConnection(connection); - return users; - } - public Integer createUser(User user) - throws ClassNotFoundException, SQLException { - Integer rowsUpdated = 0; - connection = getConnection(); - statement = connection.prepareStatement(CREATE_USER); - statement.setString(1, user.getUsername()); - statement.setString(2, user.getPassword()); - statement.setString(3, user.getFirstName()); - statement.setString(4, user.getLastName()); - statement.setString(5, user.getProfilePicture()); - rowsUpdated = statement.executeUpdate(); - closeConnection(connection); - return rowsUpdated; - } - public static void main(String[] args) throws SQLException, ClassNotFoundException { - System.out.println("JDBC DAO"); - UserJdbcDao dao = new UserJdbcDao(); -// User adam = new User("Adam", "Smith", "adams", "invisiblehand", "http://bbc.in/30gXhI4"); -// User catherine = new User("Catherine", "Wood", "cathie", "bitcoinisbig", "https://ark-invest.com/"); -// dao.createUser(adam); -// dao.createUser(thomas); -// dao.createUser(catherine); -// List users = dao.findAllUsers(); -// for(User user: users) { -// System.out.println(user.getUsername()); -// } -// User user = dao.findUserById(5); -// System.out.println(user.getUsername()); -// dao.deleteUser(5); -// List users = dao.findAllUsers(); -// for(User user: users) { -// System.out.println(user.getUsername()); -// } - User thomas = new User("Thomas", "Sowell", "thomas", "polymath", "http://www.tsowell.com/"); - User newTom = new User( - "Tom", - "Sowell", - "tom", - "knowitall", - thomas.getProfilePicture()); - dao.updateUser(6, newTom); - User tom = dao.findUserById(6); - System.out.println(tom.getUsername()); - } -} diff --git a/src/main/java/com/example/springtemplate/daos/UserOrmDao.java b/src/main/java/com/example/springtemplate/daos/UserOrmDao.java deleted file mode 100644 index 0317fa9..0000000 --- a/src/main/java/com/example/springtemplate/daos/UserOrmDao.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.example.springtemplate.daos; - -import com.example.springtemplate.models.User; -import com.example.springtemplate.repositories.UserRepository; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; -import java.util.List; - -@RestController -@CrossOrigin(origins = "*") -public class UserOrmDao { - @Autowired - UserRepository userRepository; - - @PostMapping("/api/users") - public User createUser(@RequestBody User user) { - return userRepository.save(user); - } - - @GetMapping("/api/users") - public List findAllUsers() { - return userRepository.findAllUsers(); - } - - @GetMapping("/api/users/{userId}") - public User findUserById( - @PathVariable("userId") Integer id) { - return userRepository.findUserById(id); - } - - @PutMapping("/api/users/{userId}") - public User updateUser( - @PathVariable("userId") Integer id, - @RequestBody User userUpdates) { - User user = userRepository.findUserById(id); - user.setFirstName(userUpdates.getFirstName()); - user.setLastName(userUpdates.getLastName()); - user.setUsername(userUpdates.getUsername()); - user.setPassword(userUpdates.getPassword()); - user.setProfilePicture(userUpdates.getProfilePicture()); - user.setHandle(userUpdates.getHandle()); - return userRepository.save(user); - } - - @DeleteMapping("/api/users/{userId}") - public void deleteUser( - @PathVariable("userId") Integer id) { - userRepository.deleteById(id); - } -} \ No newline at end of file diff --git a/src/main/java/com/example/springtemplate/models/Course.java b/src/main/java/com/example/springtemplate/models/Course.java deleted file mode 100644 index 2ca24d0..0000000 --- a/src/main/java/com/example/springtemplate/models/Course.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.example.springtemplate.models; - -import com.fasterxml.jackson.annotation.JsonIgnore; - -import javax.persistence.*; -import java.util.List; - -@Entity -@Table(name="courses") -public class Course { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Integer id; - private String title; - - @OneToMany(mappedBy = "course") - @JsonIgnore - private List
sections; - - public List
getSections() { - return sections; - } - - public void setSections(List
sections) { - this.sections = sections; - } - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } -} diff --git a/src/main/java/com/example/springtemplate/models/Doctor.java b/src/main/java/com/example/springtemplate/models/Doctor.java new file mode 100644 index 0000000..16529b4 --- /dev/null +++ b/src/main/java/com/example/springtemplate/models/Doctor.java @@ -0,0 +1,84 @@ +package com.example.springtemplate.models; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +import javax.persistence.*; +import java.sql.Date; +import java.util.List; +import java.sql.Timestamp; + +@Entity +@Table(name="doctors") +public class Doctor { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + private String firstname; + private String lastname; + private String username; + private String password; + private String email; + private Date DOB; + + private String position; + private String hospital; + + @OneToMany(mappedBy = "doctor") + @JsonIgnore + private List patients; + + + public Integer getId() { return id; } + public void setId(Integer id) { this.id = id; } + public String getFirstname() { return firstname; } + public void setFirstname(String firstName) { this.firstname = firstName; } + public String getLastname() { return lastname; } + public void setLastname(String lastName) { this.lastname = lastName; } + public String getUsername() { return username; } + public void setUsername(String username) { this.username = username; } + public String getPassword() { return password; } + public void setPassword(String password) { this.password = password; } + public String getEmail() { return email; } + public void setEmail(String email) { this.email = email; } + public String getPosition() { return position; } + public void setPosition(String position) { this.position = position; } + + public Doctor(String firstName, String lastName, String username, String password, + String email, Date DOB, String position, String hospital) { + this.username = username; + this.password = password; + this.firstname = firstName; + this.lastname = lastName; + this.email = email; + this.DOB = DOB; + this.position = position; + this.hospital = hospital; + } + + public Doctor() {} + + public Date getDOB() { + return DOB; + } + + public void setDOB(Date DOB) { + this.DOB = DOB; + } + + public String getHospital() { + return hospital; + } + + public void setHospital(String hospital) { + this.hospital = hospital; + } + + public List getPatients() { + return patients; + } + + public void setPatients(List patients) { + this.patients = patients; + } + +} diff --git a/src/main/java/com/example/springtemplate/models/Medications.java b/src/main/java/com/example/springtemplate/models/Medications.java new file mode 100644 index 0000000..2804932 --- /dev/null +++ b/src/main/java/com/example/springtemplate/models/Medications.java @@ -0,0 +1,48 @@ +package com.example.springtemplate.models; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +import javax.persistence.*; +import java.sql.Date; +import java.util.List; + +@Entity +@Table(name = "medications") +public class Medications { + @Id + private String name; + + @OneToMany(mappedBy = "medication") + @JsonIgnore + private List prescriptionList; + + @OneToMany(mappedBy = "medication") + @JsonIgnore + private List symptomList; + + public List getSymptomList() { + return symptomList; + } + + public void setSymptomList(List symptomList) { + this.symptomList = symptomList; + } + + public List getPrescriptionList() { + return prescriptionList; + } + + public void setPrescriptionList(List prescriptionList) { + this.prescriptionList = prescriptionList; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + +} diff --git a/src/main/java/com/example/springtemplate/models/Patient.java b/src/main/java/com/example/springtemplate/models/Patient.java new file mode 100644 index 0000000..69e41c9 --- /dev/null +++ b/src/main/java/com/example/springtemplate/models/Patient.java @@ -0,0 +1,82 @@ +package com.example.springtemplate.models; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +import javax.persistence.*; +import java.sql.Date; +import java.util.List; + +@Entity +@Table(name="patients") +public class Patient { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + + private String firstname; + private String lastname; + private String username; + private String password; + private String email; + private Date DOB; + private String conditions; + + @ManyToOne + @JsonIgnore + private Doctor doctor; + + + @OneToMany(mappedBy = "patient") + @JsonIgnore + private List prescriptions; + + public void setDOB(Date DOB) { + this.DOB = DOB; + } + + public List getPrescriptions() { + return prescriptions; + } + + public void setPrescriptions(List prescriptions) { + this.prescriptions = prescriptions; + } + + public Integer getId() { return id; } + public void setId(Integer id) { this.id = id; } + public String getFirstname() { return firstname; } + public void setFirstname(String firstname) { this.firstname = firstname; } + public String getLastname() { return lastname; } + public void setLastname(String lastname) { this.lastname = lastname; } + public String getUsername() { return username; } + public void setUsername(String username) { this.username = username; } + public String getPassword() { return password; } + public void setPassword(String password) { this.password = password; } + public String getEmail() { return email; } + public void setEmail(String email) { this.email = email; } + public String getConditions() { return conditions; } + public void setConditions(String handle) { this.conditions = conditions; } + public void setDob(Date date){ + this.DOB = date; + } + public Date getDOB(){return DOB;} + public void setDoctor(Doctor doctor){ + this.doctor = doctor; + } + public Doctor getDoctor(){return doctor;} + public Patient(String firstName, String lastname, String username, String password, + String email, Date DOB, String conditions, + Integer admitted) { + this.username = username; + this.password = password; + this.firstname = firstName; + this.lastname = lastname; + this.email = email; + this.conditions = conditions; + + this.DOB = DOB; + } + + public Patient() {} +} diff --git a/src/main/java/com/example/springtemplate/models/Prescription.java b/src/main/java/com/example/springtemplate/models/Prescription.java new file mode 100644 index 0000000..d137ad3 --- /dev/null +++ b/src/main/java/com/example/springtemplate/models/Prescription.java @@ -0,0 +1,82 @@ +package com.example.springtemplate.models; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +import javax.persistence.*; +import java.util.List; +import java.sql.Timestamp; + +@Entity +@Table(name="prescriptions") +public class Prescription { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + + + @ManyToOne + private Medications medication; + + private String diagnosis; + private Integer dosage; + + + @ManyToOne + @JsonIgnore + private Patient patient; + + + @OneToMany(mappedBy = "prescription") + @JsonIgnore + private List symptoms; + + public Patient getPatient() { + return patient; + } + + public void setPatient(Patient patient) { + this.patient = patient; + } + + public List getSymptoms() { + return symptoms; + } + + public void setSymptoms(List symptoms) { + this.symptoms = symptoms; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Medications getMedication() { + return medication; + } + + public void setMedication(Medications medication) { + this.medication = medication; + } + + public String getDiagnosis() { + return diagnosis; + } + + public void setDiagnosis(String diagnosis) { + this.diagnosis = diagnosis; + } + + public Integer getDosage() { + return dosage; + } + + public void setDosage(Integer dosage) { + this.dosage = dosage; + } + + +} diff --git a/src/main/java/com/example/springtemplate/models/Section.java b/src/main/java/com/example/springtemplate/models/Section.java deleted file mode 100644 index 2da0bb4..0000000 --- a/src/main/java/com/example/springtemplate/models/Section.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.example.springtemplate.models; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.sun.xml.bind.v2.model.core.ID; - -import javax.persistence.*; -import javax.persistence.criteria.CriteriaBuilder; -import java.sql.Date; -import java.sql.Timestamp; - -@Entity -@Table(name="sections") -public class Section { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Integer id; - private String name; - private Integer seats; - private String semester; - private Integer year; - @Column(columnDefinition="tinyint(1) default 1") - private Boolean online; - - @ManyToOne - @JsonIgnore - private Course course; - - public Boolean getOnline() { - return online; - } - - public void setOnline(Boolean online) { - this.online = online; - } - - public Integer getSeats() { - return seats; - } - - public void setSeats(Integer seats) { - this.seats = seats; - } - - public String getSemester() { - return semester; - } - - public void setSemester(String semester) { - this.semester = semester; - } - - public Integer getYear() { - return year; - } - - public void setYear(Integer year) { - this.year = year; - } - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Course getCourse() { - return course; - } - - public void setCourse(Course course) { - this.course = course; - } -} diff --git a/src/main/java/com/example/springtemplate/models/Symptom.java b/src/main/java/com/example/springtemplate/models/Symptom.java new file mode 100644 index 0000000..e673f82 --- /dev/null +++ b/src/main/java/com/example/springtemplate/models/Symptom.java @@ -0,0 +1,94 @@ +package com.example.springtemplate.models; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +import javax.persistence.*; +import java.sql.Timestamp; + +@Entity +@Table(name="symptoms") +public class Symptom { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + private String title; + private Timestamp lastUsed; + private String usedFor; + private String benefits; + private String sideEffects; + + @ManyToOne + private Medications medication; + + + + @ManyToOne + @JsonIgnore + private Prescription prescription; + + public Medications getMedication() { + return medication; + } + + public void setMedication(Medications medication) { + this.medication = medication; + } + + + + public Timestamp getLastUsed() { + return lastUsed; + } + + public void setLastUsed(Timestamp lastUsed) { + this.lastUsed = lastUsed; + } + + public String getUsedFor() { + return usedFor; + } + + public void setUsedFor(String usedFor) { + this.usedFor = usedFor; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public Prescription getPrescription() { + return prescription; + } + + public void setPrescription(Prescription prescription) { + this.prescription = prescription; + } + + public String getBenefits() { + return benefits; + } + + public void setBenefits(String benefits) { + this.benefits = benefits; + } + + public String getSideEffects() { + return sideEffects; + } + + public void setSideEffects(String sideEffects) { + this.sideEffects = sideEffects; + } +} diff --git a/src/main/java/com/example/springtemplate/models/Todo.java b/src/main/java/com/example/springtemplate/models/Todo.java deleted file mode 100644 index 07c48df..0000000 --- a/src/main/java/com/example/springtemplate/models/Todo.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.example.springtemplate.models; - -import javax.persistence.*; -import java.sql.Date; - -@Entity -@Table(name = "todos") -public class Todo { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Integer id; - private String title; - private String todo; - private Boolean done; - private Date dueDate; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getTodo() { - return todo; - } - - public void setTodo(String todo) { - this.todo = todo; - } - - public Boolean getDone() { - return done; - } - - public void setDone(Boolean done) { - this.done = done; - } - - public Date getDueDate() { - return dueDate; - } - - public void setDueDate(Date dueDate) { - this.dueDate = dueDate; - } -} diff --git a/src/main/java/com/example/springtemplate/models/User.java b/src/main/java/com/example/springtemplate/models/User.java deleted file mode 100644 index a276aa8..0000000 --- a/src/main/java/com/example/springtemplate/models/User.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.example.springtemplate.models; - -import javax.persistence.*; - -@Entity -@Table(name="users") -public class User { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Integer id; - private String firstName; - private String lastName; - private String username; - private String password; - private String profilePicture; - private String handle; - - public Integer getId() { return id; } - public void setId(Integer id) { this.id = id; } - public String getFirstName() { return firstName; } - public void setFirstName(String firstName) { this.firstName = firstName; } - public String getLastName() { return lastName; } - public void setLastName(String lastName) { this.lastName = lastName; } - public String getUsername() { return username; } - public void setUsername(String username) { this.username = username; } - public String getPassword() { return password; } - public void setPassword(String password) { this.password = password; } - public String getProfilePicture() { return profilePicture; } - public void setProfilePicture(String profilePicture) { this.profilePicture = profilePicture; } - public String getHandle() { return handle; } - public void setHandle(String handle) { this.handle = handle; } - - public User(String username, String password, String first_name, String last_name, String profile_picture) { - this.username = username; - this.password = password; - this.firstName = first_name; - this.lastName = last_name; - this.profilePicture = profile_picture; - } - - public User() {} -} diff --git a/src/main/java/com/example/springtemplate/models/medicine.java b/src/main/java/com/example/springtemplate/models/medicine.java new file mode 100644 index 0000000..3ee6ab7 --- /dev/null +++ b/src/main/java/com/example/springtemplate/models/medicine.java @@ -0,0 +1,4 @@ +package com.example.springtemplate.models; + +public enum medicine { +} diff --git a/src/main/java/com/example/springtemplate/repositories/CourseRepository.java b/src/main/java/com/example/springtemplate/repositories/CourseRepository.java deleted file mode 100644 index de7b25b..0000000 --- a/src/main/java/com/example/springtemplate/repositories/CourseRepository.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.example.springtemplate.repositories; - -import com.example.springtemplate.models.Course; -import com.example.springtemplate.models.User; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.query.Param; - -import java.util.List; - -public interface CourseRepository - extends CrudRepository { -} diff --git a/src/main/java/com/example/springtemplate/repositories/DoctorRepository.java b/src/main/java/com/example/springtemplate/repositories/DoctorRepository.java new file mode 100644 index 0000000..285e0ac --- /dev/null +++ b/src/main/java/com/example/springtemplate/repositories/DoctorRepository.java @@ -0,0 +1,19 @@ +package com.example.springtemplate.repositories; + +import com.example.springtemplate.models.Doctor; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; + +import java.util.List; + +public interface DoctorRepository + extends CrudRepository { + @Query(value = "SELECT * FROM doctors", + nativeQuery = true) + List findAllDoctors(); + + @Query(value = "SELECT * FROM doctors WHERE id=:userId", + nativeQuery = true) + Doctor findDoctorById(@Param("userId") Integer id); +} diff --git a/src/main/java/com/example/springtemplate/repositories/MedicationRepository.java b/src/main/java/com/example/springtemplate/repositories/MedicationRepository.java new file mode 100644 index 0000000..0c20ff8 --- /dev/null +++ b/src/main/java/com/example/springtemplate/repositories/MedicationRepository.java @@ -0,0 +1,32 @@ +package com.example.springtemplate.repositories; + +import com.example.springtemplate.models.Medications; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; + +import java.util.List; + +public interface MedicationRepository + extends CrudRepository { + @Query(value = "Select * FROM medications", nativeQuery = true) + List findAllMeds(); + @Query(value = "SELECT * FROM medications WHERE name=:userId", nativeQuery = true) + Medications findMedByName(@Param("userId") String name); + @Query(value = "Insert into medications(name) values ('Lexapro')\n" + + "Insert into medications(name) values ('Zoloft')\n" + + "Insert into medications(name) values ('Prozac')\n" + + "Insert into medications(name) values ('Celexa')\n" + + "Insert into medications(name) values ('Welbutrin')\n" + + "Insert into medications(name) values ('Effexor')\n" + + "Insert into medications(name) values ('Trazadone')\n" + + "Insert into medications(name) values ('Levora')\n" + + "Insert into medications(name) values ('Velivet')\n" + + "Insert into medications(name) values ('Ocella')\n" + + "Insert into medications(name) values ('Hydrocodeine')\n" + + "Insert into medications(name) values ('Dronabinol')\n" + + "Insert into medications(name) values ('Adderall')\n" + + "Insert into medications(name) values ('Allegra')\n" + + "Insert into medications(name) values ('Zyrtec')", nativeQuery = true) + void initialPopulation(); +} diff --git a/src/main/java/com/example/springtemplate/repositories/PatientRepository.java b/src/main/java/com/example/springtemplate/repositories/PatientRepository.java new file mode 100644 index 0000000..6753ccd --- /dev/null +++ b/src/main/java/com/example/springtemplate/repositories/PatientRepository.java @@ -0,0 +1,23 @@ +package com.example.springtemplate.repositories; + +import com.example.springtemplate.models.Doctor; +import com.example.springtemplate.models.Patient; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; + +import java.util.List; + +public interface PatientRepository + extends CrudRepository { + @Query(value = "SELECT * FROM patients", + nativeQuery = true) + List findAllPatients(); + @Query(value = "SELECT * FROM patients WHERE id=:userId", + nativeQuery = true) + Patient findPatientById(@Param("userId") Integer id); + @Query(value = "SELECT * FROM patients WHERE patients.doctor_id=:doctorId", + nativeQuery = true) + List findPatientsForDoctor(@Param("doctorId") Doctor doc); + +} diff --git a/src/main/java/com/example/springtemplate/repositories/PrescriptionRepository.java b/src/main/java/com/example/springtemplate/repositories/PrescriptionRepository.java new file mode 100644 index 0000000..e09e44a --- /dev/null +++ b/src/main/java/com/example/springtemplate/repositories/PrescriptionRepository.java @@ -0,0 +1,19 @@ +package com.example.springtemplate.repositories; + +import com.example.springtemplate.models.Doctor; +import com.example.springtemplate.models.Prescription; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; + +import java.util.List; + +public interface PrescriptionRepository + extends CrudRepository { + @Query(value = "SELECT * FROM prescriptions", + nativeQuery = true) + List findAllPrescriptions(); + @Query(value = "SELECT * FROM prescriptions WHERE patient=:userId", + nativeQuery = true) + List findPrescriptionByPatient(@Param("userId") Integer id); +} diff --git a/src/main/java/com/example/springtemplate/repositories/SectionRepository.java b/src/main/java/com/example/springtemplate/repositories/SectionRepository.java deleted file mode 100644 index 48965c5..0000000 --- a/src/main/java/com/example/springtemplate/repositories/SectionRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.example.springtemplate.repositories; - -import com.example.springtemplate.models.Course; -import com.example.springtemplate.models.Section; -import org.springframework.data.repository.CrudRepository; - -public interface SectionRepository - extends CrudRepository { -} diff --git a/src/main/java/com/example/springtemplate/repositories/SymptomRepository.java b/src/main/java/com/example/springtemplate/repositories/SymptomRepository.java new file mode 100644 index 0000000..0300804 --- /dev/null +++ b/src/main/java/com/example/springtemplate/repositories/SymptomRepository.java @@ -0,0 +1,19 @@ +package com.example.springtemplate.repositories; + +import com.example.springtemplate.models.Prescription; +import com.example.springtemplate.models.Symptom; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; + +import java.util.List; + +public interface SymptomRepository + extends CrudRepository { + @Query(value = "SELECT * FROM symptoms", + nativeQuery = true) + List findAllSymptoms(); + @Query(value = "SELECT * FROM symptoms WHERE prescription=:userId", + nativeQuery = true) + List findSymptomsByPrescription(@Param("userId") Integer id); +} diff --git a/src/main/java/com/example/springtemplate/repositories/TodoRepository.java b/src/main/java/com/example/springtemplate/repositories/TodoRepository.java deleted file mode 100644 index c903416..0000000 --- a/src/main/java/com/example/springtemplate/repositories/TodoRepository.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.example.springtemplate.repositories; - -import com.example.springtemplate.models.Todo; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.query.Param; - -import java.util.List; - -public interface TodoRepository extends CrudRepository { - @Query("SELECT todo FROM Todo todo") - public List findAllTodos(); - @Query("SELECT todo FROM Todo todo WHERE todo.id=:id") - public Todo findTodoById(@Param("id") Integer id); -} diff --git a/src/main/java/com/example/springtemplate/repositories/UserRepository.java b/src/main/java/com/example/springtemplate/repositories/UserRepository.java deleted file mode 100644 index 89b2d95..0000000 --- a/src/main/java/com/example/springtemplate/repositories/UserRepository.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.example.springtemplate.repositories; - -import com.example.springtemplate.models.User; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.query.Param; - -import java.util.List; - -public interface UserRepository - extends CrudRepository { - @Query(value = "SELECT * FROM users", - nativeQuery = true) - public List findAllUsers(); - @Query(value = "SELECT * FROM users WHERE id=:userId", - nativeQuery = true) - public User findUserById(@Param("userId") Integer id); -} diff --git a/src/main/other/sql/db_design/db_design_users.sql b/src/main/other/sql/Dump/db_project_doctors.sql similarity index 52% rename from src/main/other/sql/db_design/db_design_users.sql rename to src/main/other/sql/Dump/db_project_doctors.sql index e0f57a5..5232076 100644 --- a/src/main/other/sql/db_design/db_design_users.sql +++ b/src/main/other/sql/Dump/db_project_doctors.sql @@ -1,13 +1,13 @@ --- MySQL dump 10.13 Distrib 5.7.17, for macos10.12 (x86_64) +-- MySQL dump 10.13 Distrib 8.0.23, for Win64 (x86_64) -- --- Host: 127.0.0.1 Database: db_design +-- Host: 127.0.0.1 Database: db_project -- ------------------------------------------------------ --- Server version 5.7.19 +-- Server version 8.0.23 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; +/*!50503 SET NAMES utf8 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; @@ -16,32 +16,35 @@ /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -- --- Table structure for table `users` +-- Table structure for table `doctors` -- -DROP TABLE IF EXISTS `users`; +DROP TABLE IF EXISTS `doctors`; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `users` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `first_name` varchar(45) DEFAULT NULL, - `last_name` varchar(45) DEFAULT NULL, +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `doctors` ( + `id` int NOT NULL AUTO_INCREMENT, + `firstname` varchar(45) DEFAULT NULL, + `lastname` varchar(45) DEFAULT NULL, `username` varchar(45) DEFAULT NULL, `password` varchar(45) DEFAULT NULL, - `profile_picture` varchar(45) DEFAULT NULL, - `handle` varchar(45) DEFAULT NULL, + `email` varchar(45) DEFAULT NULL, + `DOB` date DEFAULT NULL, + `hospital` varchar(45) DEFAULT NULL, + `position` varchar(100) DEFAULT NULL, + `created` datetime DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1; +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Dumping data for table `users` +-- Dumping data for table `doctors` -- -LOCK TABLES `users` WRITE; -/*!40000 ALTER TABLE `users` DISABLE KEYS */; -INSERT INTO `users` VALUES (1,'Alice','Wonderland','alice',NULL,NULL,NULL),(2,'Bob','Hope','bob',NULL,NULL,NULL),(3,'Tim','Dod','erdayastronaut','qwer1234',NULL,'Everyday Astronaut'),(4,'Elon','Musk','elonmusk','ewq321',NULL,'Elon Musk'),(5,'Charlie','Brown','charlie','p@ssw0rd',NULL,NULL),(6,'Daniel','Craig','dan','p@007rd',NULL,NULL); -/*!40000 ALTER TABLE `users` ENABLE KEYS */; +LOCK TABLES `doctors` WRITE; +/*!40000 ALTER TABLE `doctors` DISABLE KEYS */; +INSERT INTO `doctors` VALUES (1,'Robert','Phoughts','rphoughts','robisnumber1','rpho@partners.org','1980-10-10','Mass General','Lead Psychiatrist','2021-04-14 17:43:27'),(2,'Elle','Bough','ellebough','elbow111','bough.elle@mayoclinic.org','1987-04-12','Mayo Clinic','General Physcian','2021-04-14 17:48:30'); +/*!40000 ALTER TABLE `doctors` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -53,4 +56,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-01-13 22:42:23 +-- Dump completed on 2021-04-19 16:07:18 diff --git a/src/main/other/sql/db_design/db_design_topics.sql b/src/main/other/sql/Dump/db_project_medications.sql similarity index 57% rename from src/main/other/sql/db_design/db_design_topics.sql rename to src/main/other/sql/Dump/db_project_medications.sql index 324513d..d3d0c77 100644 --- a/src/main/other/sql/db_design/db_design_topics.sql +++ b/src/main/other/sql/Dump/db_project_medications.sql @@ -1,13 +1,13 @@ --- MySQL dump 10.13 Distrib 5.7.17, for macos10.12 (x86_64) +-- MySQL dump 10.13 Distrib 8.0.23, for Win64 (x86_64) -- --- Host: 127.0.0.1 Database: db_design +-- Host: 127.0.0.1 Database: db_project -- ------------------------------------------------------ --- Server version 5.7.19 +-- Server version 8.0.23 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; +/*!50503 SET NAMES utf8 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; @@ -16,26 +16,26 @@ /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -- --- Table structure for table `topics` +-- Table structure for table `medications` -- -DROP TABLE IF EXISTS `topics`; +DROP TABLE IF EXISTS `medications`; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `topics` ( - `topic` varchar(45) NOT NULL, - PRIMARY KEY (`topic`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `medications` ( + `name` varchar(45) NOT NULL DEFAULT '', + PRIMARY KEY (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Dumping data for table `topics` +-- Dumping data for table `medications` -- -LOCK TABLES `topics` WRITE; -/*!40000 ALTER TABLE `topics` DISABLE KEYS */; -INSERT INTO `topics` VALUES ('CARS'),('SPACE'); -/*!40000 ALTER TABLE `topics` ENABLE KEYS */; +LOCK TABLES `medications` WRITE; +/*!40000 ALTER TABLE `medications` DISABLE KEYS */; +INSERT INTO `medications` VALUES ('Adderall'),('Allegra'),('Ativan'),('Celexa'),('Dronabinol'),('Effexor'),('Hydrocodeine'),('Levora'),('Lexapro'),('Ocella'),('Prozac'),('Trazadone'),('Velivet'),('Welbutrin'),('Zoloft'),('Zyrtec'); +/*!40000 ALTER TABLE `medications` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -47,4 +47,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-01-13 22:42:24 +-- Dump completed on 2021-04-19 16:07:18 diff --git a/src/main/other/sql/Dump/db_project_patients.sql b/src/main/other/sql/Dump/db_project_patients.sql new file mode 100644 index 0000000..d7b5bbf --- /dev/null +++ b/src/main/other/sql/Dump/db_project_patients.sql @@ -0,0 +1,61 @@ +-- MySQL dump 10.13 Distrib 8.0.23, for Win64 (x86_64) +-- +-- Host: 127.0.0.1 Database: db_project +-- ------------------------------------------------------ +-- Server version 8.0.23 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!50503 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `patients` +-- + +DROP TABLE IF EXISTS `patients`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `patients` ( + `id` int NOT NULL AUTO_INCREMENT, + `firstname` varchar(45) DEFAULT NULL, + `lastname` varchar(45) DEFAULT NULL, + `username` varchar(45) DEFAULT NULL, + `password` varchar(45) DEFAULT NULL, + `email` varchar(45) DEFAULT NULL, + `DOB` date DEFAULT NULL, + `doctor` int DEFAULT NULL, + `conditions` varchar(255) DEFAULT NULL, + `admitted` datetime DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + KEY `doctor_idx` (`doctor`), + CONSTRAINT `doctor` FOREIGN KEY (`doctor`) REFERENCES `doctors` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `patients` +-- + +LOCK TABLES `patients` WRITE; +/*!40000 ALTER TABLE `patients` DISABLE KEYS */; +INSERT INTO `patients` VALUES (1,'Sam','Blue','samb','everyth1ng1sblue','sblue120@gmail.com','1994-10-04',1,'Anxiety, depression','2021-04-14 18:02:52'),(2,'Lisa','Dee','LisaD','DeeLorNoDeeLisa','LisaDee2203@yahoo.com','2003-02-02',1,'Anxiety, OCD','2021-04-14 18:16:03'),(3,'Johnny','Depressed','JohnnyDep','piratesofdepressed111','Johnnydep@hotmail.com','1984-01-08',1,'Major depression','2021-04-14 18:16:36'),(4,'Syd','Shokes','SShokes','sydshmokes','shokes4396@gmail.com','1996-03-04',1,'Nicotine Dependince, ADHD','2021-04-14 18:20:42'),(5,'Nellie','Lahomes','NellHome','lahomesBells2','Nellie7700@gmail.com','2000-07-07',2,NULL,'2021-04-14 18:25:19'),(6,'Olivia','Ophelia','OOOliva','O11v1aO','OOphelia@gmail.com','1989-05-11',2,'Endometriosis','2021-04-14 18:30:49'),(7,'Ron','Ragdoll','RonDoll','Ragd0llR0n','ragdollthestuntman@aol.com','1977-04-02',2,'Multiple Broken Ribs, CTE, Broken R Arm, Fractured R femur','2021-04-14 18:31:56'),(8,'Ian','Sniff','iansf','sniffian22','ianSniff22@gmail.com','1994-12-07',2,'Allergies','2021-04-14 18:33:51'); +/*!40000 ALTER TABLE `patients` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2021-04-19 16:07:18 diff --git a/src/main/other/sql/Dump/db_project_prescriptions.sql b/src/main/other/sql/Dump/db_project_prescriptions.sql new file mode 100644 index 0000000..c49561d --- /dev/null +++ b/src/main/other/sql/Dump/db_project_prescriptions.sql @@ -0,0 +1,60 @@ +-- MySQL dump 10.13 Distrib 8.0.23, for Win64 (x86_64) +-- +-- Host: 127.0.0.1 Database: db_project +-- ------------------------------------------------------ +-- Server version 8.0.23 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!50503 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `prescriptions` +-- + +DROP TABLE IF EXISTS `prescriptions`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `prescriptions` ( + `id` int NOT NULL AUTO_INCREMENT, + `medication` varchar(45) DEFAULT NULL, + `patient` int DEFAULT NULL, + `diagnosis` varchar(45) DEFAULT NULL, + `dosage` decimal(5,2) DEFAULT NULL, + `prescribed` datetime DEFAULT CURRENT_TIMESTAMP, + `updated` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + KEY `medication_idx` (`medication`), + KEY `patient_idx` (`patient`), + CONSTRAINT `medication` FOREIGN KEY (`medication`) REFERENCES `medications` (`name`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `patient` FOREIGN KEY (`patient`) REFERENCES `patients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `prescriptions` +-- + +LOCK TABLES `prescriptions` WRITE; +/*!40000 ALTER TABLE `prescriptions` DISABLE KEYS */; +INSERT INTO `prescriptions` VALUES (1,'Zoloft',1,'Anxiety, Depression',100.00,'2021-04-19 12:22:03','2021-04-19 12:22:03'),(2,'Prozac',2,'OCD',160.00,'2021-04-19 12:26:48','2021-04-19 12:26:48'),(3,'Trazadone',2,'Anxiety',100.00,'2021-04-19 12:26:51','2021-04-19 12:26:51'),(4,'Lexapro',3,'Major Depression',20.00,'2021-04-19 12:26:52','2021-04-19 12:26:52'),(5,'Ativan',3,'Major Depression',0.50,'2021-04-19 12:29:44','2021-04-19 12:30:14'),(6,'Welbutrin',4,'Nicotine Dependency',150.00,'2021-04-19 12:32:06','2021-04-19 12:32:19'),(7,'Adderall',4,'ADHD',20.00,'2021-04-19 12:32:07','2021-04-19 12:32:19'),(8,'Ocella',5,'Birth Control',0.03,'2021-04-19 12:39:37','2021-04-19 12:40:08'),(9,'Levora',6,'Endometriosis',0.15,'2021-04-19 12:39:45','2021-04-19 12:40:08'),(10,'Hydrocodeine',7,'Acute Pain From Injuries',10.00,'2021-04-19 12:39:53','2021-04-19 12:40:08'),(11,'Dronabinol',7,'Acute Pain From Injuries',2.50,'2021-04-19 12:40:33','2021-04-19 12:40:49'),(12,'Zyrtec',7,'Breathing Issues from broken rib',10.00,'2021-04-19 12:43:28','2021-04-19 12:45:48'),(13,'Allegra',8,'Chronic Allergies',120.00,'2021-04-19 12:44:21','2021-04-19 12:45:48'); +/*!40000 ALTER TABLE `prescriptions` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2021-04-19 16:07:19 diff --git a/src/main/other/sql/Dump/db_project_symptoms.sql b/src/main/other/sql/Dump/db_project_symptoms.sql new file mode 100644 index 0000000..ae8b0c9 --- /dev/null +++ b/src/main/other/sql/Dump/db_project_symptoms.sql @@ -0,0 +1,60 @@ +-- MySQL dump 10.13 Distrib 8.0.23, for Win64 (x86_64) +-- +-- Host: 127.0.0.1 Database: db_project +-- ------------------------------------------------------ +-- Server version 8.0.23 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!50503 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `symptoms` +-- + +DROP TABLE IF EXISTS `symptoms`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `symptoms` ( + `id` int NOT NULL AUTO_INCREMENT, + `Title` varchar(255) DEFAULT NULL, + `Prescription` int DEFAULT NULL, + `medicine` varchar(45) DEFAULT NULL, + `userFor` varchar(255) DEFAULT NULL, + `benefits` varchar(255) DEFAULT NULL, + `sideEffects` varchar(255) DEFAULT NULL, + `timeUsed` datetime DEFAULT NULL, + `created` datetime DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + KEY `prescription_idx` (`medicine`,`Prescription`), + CONSTRAINT `prescribed` FOREIGN KEY (`medicine`, `Prescription`) REFERENCES `prescriptions` (`medication`, `id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `symptoms` +-- + +LOCK TABLES `symptoms` WRITE; +/*!40000 ALTER TABLE `symptoms` DISABLE KEYS */; +INSERT INTO `symptoms` VALUES (1,'Breathing problems',3,'Trazadone','Anxiety','Helps anxiety before sleeping','Shallow breathing','2021-04-18 20:15:15','2021-04-19 12:50:00'),(2,'Sleeping problems',1,'Zoloft','Anxiety, Depression','Helps with Anxiety and Depression','Unable to sleep well since using medicine','2021-03-30 21:30:10','2021-04-19 12:53:00'),(3,'Loss of Apetit',7,'Adderall','ADHD','Helps attention','Lack of apetit, loss of weight','2021-04-10 20:15:15','2021-04-19 12:55:19'),(4,'Dizziness',10,'Hydrocodeine','Broken Bone Pain','Helps alleviate pain','Dizziness and drowsiness occur when used','2021-04-19 08:15:15','2021-04-19 12:57:14'),(5,'Birth Control Causing Acne?',8,'Ocella','Birth Control','Helps with cramps','Recently have had more acne, is this from the meds?','2021-04-19 10:15:15','2021-04-19 13:02:17'),(6,'Not effective',5,'Ativan','Major Depression',NULL,'Sleepiness; not helping depression','2021-04-13 22:45:44','2021-04-19 13:04:46'),(7,'I Feel Much Better',9,'Levora','Endometriosis','Alleviates pain really well',NULL,'2021-04-19 10:30:15','2021-04-19 13:06:51'); +/*!40000 ALTER TABLE `symptoms` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2021-04-19 16:07:18 diff --git a/src/main/other/sql/db_design.zip b/src/main/other/sql/db_design.zip deleted file mode 100644 index 8f03887..0000000 Binary files a/src/main/other/sql/db_design.zip and /dev/null differ diff --git a/src/main/other/sql/db_design/db_design_blogs.sql b/src/main/other/sql/db_design/db_design_blogs.sql deleted file mode 100644 index 41ebf6d..0000000 --- a/src/main/other/sql/db_design/db_design_blogs.sql +++ /dev/null @@ -1,59 +0,0 @@ --- MySQL dump 10.13 Distrib 5.7.17, for macos10.12 (x86_64) --- --- Host: 127.0.0.1 Database: db_design --- ------------------------------------------------------ --- Server version 5.7.19 - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - --- --- Table structure for table `blogs` --- - -DROP TABLE IF EXISTS `blogs`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `blogs` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(45) DEFAULT NULL, - `topic` varchar(45) DEFAULT NULL, - `created` datetime DEFAULT CURRENT_TIMESTAMP, - `updated` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `user` int(11) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `topic_2_topics_idx` (`topic`), - KEY `blog_2_user_idx` (`user`), - CONSTRAINT `blog_2_user` FOREIGN KEY (`user`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `topic_2_topics` FOREIGN KEY (`topic`) REFERENCES `topics` (`topic`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `blogs` --- - -LOCK TABLES `blogs` WRITE; -/*!40000 ALTER TABLE `blogs` DISABLE KEYS */; -INSERT INTO `blogs` VALUES (2,'Everyday Astronaut','SPACE','2021-01-11 17:11:46','2021-01-11 17:11:46',3),(3,'SpaceX','SPACE','2021-01-11 17:12:28','2021-01-11 17:12:49',4),(4,'Tesla','CARS','2021-01-11 17:12:49','2021-01-11 17:13:01',4),(7,'Tesla Daily','CARS','2021-01-12 00:00:00','2021-01-12 00:00:00',6),(8,'Hyper Change','CARS','2021-01-12 00:00:00','2021-01-12 00:00:00',6); -/*!40000 ALTER TABLE `blogs` ENABLE KEYS */; -UNLOCK TABLES; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - --- Dump completed on 2021-01-13 22:42:24 diff --git a/src/main/other/sql/db_design/db_design_follows.sql b/src/main/other/sql/db_design/db_design_follows.sql deleted file mode 100644 index d7bc2cf..0000000 --- a/src/main/other/sql/db_design/db_design_follows.sql +++ /dev/null @@ -1,56 +0,0 @@ --- MySQL dump 10.13 Distrib 5.7.17, for macos10.12 (x86_64) --- --- Host: 127.0.0.1 Database: db_design --- ------------------------------------------------------ --- Server version 5.7.19 - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - --- --- Table structure for table `follows` --- - -DROP TABLE IF EXISTS `follows`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `follows` ( - `followed` int(11) NOT NULL, - `follower` int(11) NOT NULL, - `created` datetime DEFAULT CURRENT_TIMESTAMP, - `updated` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`followed`,`follower`), - KEY `follower_2_user_idx` (`follower`), - CONSTRAINT `followed_2_user` FOREIGN KEY (`followed`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `follower_2_user` FOREIGN KEY (`follower`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `follows` --- - -LOCK TABLES `follows` WRITE; -/*!40000 ALTER TABLE `follows` DISABLE KEYS */; -INSERT INTO `follows` VALUES (4,3,'2021-01-11 17:51:44','2021-01-11 17:51:44'); -/*!40000 ALTER TABLE `follows` ENABLE KEYS */; -UNLOCK TABLES; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - --- Dump completed on 2021-01-13 22:42:24 diff --git a/src/main/other/sql/db_design/db_design_posts.sql b/src/main/other/sql/db_design/db_design_posts.sql deleted file mode 100644 index a7b3171..0000000 --- a/src/main/other/sql/db_design/db_design_posts.sql +++ /dev/null @@ -1,57 +0,0 @@ --- MySQL dump 10.13 Distrib 5.7.17, for macos10.12 (x86_64) --- --- Host: 127.0.0.1 Database: db_design --- ------------------------------------------------------ --- Server version 5.7.19 - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - --- --- Table structure for table `posts` --- - -DROP TABLE IF EXISTS `posts`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `posts` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `title` varchar(45) DEFAULT NULL, - `post` varchar(256) DEFAULT NULL, - `created` datetime DEFAULT CURRENT_TIMESTAMP, - `updated` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `blog` int(11) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `posts_to_blog_idx` (`blog`), - CONSTRAINT `posts_to_blog` FOREIGN KEY (`blog`) REFERENCES `blogs` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `posts` --- - -LOCK TABLES `posts` WRITE; -/*!40000 ALTER TABLE `posts` DISABLE KEYS */; -INSERT INTO `posts` VALUES (1,NULL,'Can we all just stop and admire for a second that \n@SpaceX\n has a Tiki Bar that has MK1’s flaps ','2021-01-11 17:16:22','2021-01-11 17:20:33',2),(2,NULL,'SpaceX stinks!','2021-01-11 18:06:37','2021-01-11 22:12:25',2); -/*!40000 ALTER TABLE `posts` ENABLE KEYS */; -UNLOCK TABLES; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - --- Dump completed on 2021-01-13 22:42:24 diff --git a/src/main/other/sql/db_design/db_design_ratings.sql b/src/main/other/sql/db_design/db_design_ratings.sql deleted file mode 100644 index d949d54..0000000 --- a/src/main/other/sql/db_design/db_design_ratings.sql +++ /dev/null @@ -1,61 +0,0 @@ --- MySQL dump 10.13 Distrib 5.7.17, for macos10.12 (x86_64) --- --- Host: 127.0.0.1 Database: db_design --- ------------------------------------------------------ --- Server version 5.7.19 - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - --- --- Table structure for table `ratings` --- - -DROP TABLE IF EXISTS `ratings`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `ratings` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `likes` tinyint(1) DEFAULT NULL, - `score` int(11) DEFAULT NULL, - `comment` varchar(45) DEFAULT NULL, - `user_id` int(11) DEFAULT NULL, - `post_id` int(11) DEFAULT NULL, - `created` datetime DEFAULT CURRENT_TIMESTAMP, - `updated` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`id`), - KEY `ratings_2_user_idx` (`user_id`), - KEY `ratings_2_post_idx` (`post_id`), - CONSTRAINT `ratings_2_post` FOREIGN KEY (`post_id`) REFERENCES `posts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `ratings_2_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `ratings` --- - -LOCK TABLES `ratings` WRITE; -/*!40000 ALTER TABLE `ratings` DISABLE KEYS */; -INSERT INTO `ratings` VALUES (1,1,NULL,NULL,3,1,'2021-01-11 17:54:29','2021-01-11 17:54:29'),(2,0,NULL,NULL,4,2,'2021-01-11 18:07:25','2021-01-11 18:07:25'),(3,1,NULL,NULL,2,1,'2021-01-11 23:12:10','2021-01-13 08:15:25'),(4,1,NULL,NULL,NULL,1,'2021-01-11 23:12:10','2021-01-11 23:12:10'),(5,0,NULL,NULL,1,1,'2021-01-11 23:12:10','2021-01-13 22:26:21'),(6,NULL,3,NULL,NULL,1,'2021-01-11 23:12:10','2021-01-11 23:12:10'),(7,NULL,4,NULL,NULL,1,'2021-01-11 23:12:10','2021-01-11 23:12:10'),(8,NULL,5,NULL,NULL,1,'2021-01-11 23:12:10','2021-01-11 23:12:10'),(9,NULL,5,NULL,NULL,1,'2021-01-11 23:12:10','2021-01-11 23:12:10'),(10,1,NULL,NULL,NULL,2,'2021-01-11 23:12:10','2021-01-11 23:12:10'),(11,1,NULL,NULL,NULL,2,'2021-01-11 23:12:10','2021-01-11 23:12:10'),(12,1,NULL,NULL,NULL,2,'2021-01-11 23:12:10','2021-01-11 23:12:10'),(13,0,NULL,NULL,NULL,2,'2021-01-11 23:12:10','2021-01-11 23:12:10'),(14,0,NULL,NULL,NULL,2,'2021-01-11 23:12:10','2021-01-11 23:12:10'),(15,1,NULL,NULL,NULL,2,'2021-01-11 23:12:10','2021-01-11 23:12:10'),(16,NULL,4,NULL,NULL,2,'2021-01-11 23:12:10','2021-01-11 23:12:10'),(17,NULL,4,NULL,NULL,2,'2021-01-11 23:12:10','2021-01-11 23:12:10'),(18,NULL,5,NULL,NULL,2,'2021-01-11 23:12:10','2021-01-11 23:12:10'),(19,NULL,4,NULL,NULL,2,'2021-01-11 23:12:10','2021-01-11 23:12:10'),(20,NULL,3,NULL,NULL,2,'2021-01-11 23:12:10','2021-01-11 23:12:10'); -/*!40000 ALTER TABLE `ratings` ENABLE KEYS */; -UNLOCK TABLES; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - --- Dump completed on 2021-01-13 22:42:23 diff --git a/src/main/other/sql/db_design/db_design_replies.sql b/src/main/other/sql/db_design/db_design_replies.sql deleted file mode 100644 index bcfa607..0000000 --- a/src/main/other/sql/db_design/db_design_replies.sql +++ /dev/null @@ -1,62 +0,0 @@ --- MySQL dump 10.13 Distrib 5.7.17, for macos10.12 (x86_64) --- --- Host: 127.0.0.1 Database: db_design --- ------------------------------------------------------ --- Server version 5.7.19 - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - --- --- Table structure for table `replies` --- - -DROP TABLE IF EXISTS `replies`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `replies` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `reply` varchar(256) DEFAULT NULL, - `user_id` int(11) DEFAULT NULL, - `post_id` int(11) DEFAULT NULL, - `replies_id` int(11) DEFAULT NULL, - `created` datetime DEFAULT CURRENT_TIMESTAMP, - `updated` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`id`), - KEY `replies_2_users_idx` (`user_id`), - KEY `replies_2_posts_idx` (`post_id`), - KEY `replies_2_replies_idx` (`replies_id`), - CONSTRAINT `replies_2_posts` FOREIGN KEY (`post_id`) REFERENCES `posts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `replies_2_replies` FOREIGN KEY (`replies_id`) REFERENCES `replies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `replies_2_users` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `replies` --- - -LOCK TABLES `replies` WRITE; -/*!40000 ALTER TABLE `replies` DISABLE KEYS */; -INSERT INTO `replies` VALUES (1,'That’s actually our restaurant, but SpaceX is building a futuristic bar at the top of the high bay with 360 degree windows & a glass floor looking down on the rocket factory\n',4,1,NULL,'2021-01-11 17:23:28','2021-01-11 17:23:28'),(2,'Really, how does one get to this bar when complete?\n',3,1,1,'2021-01-11 17:25:07','2021-01-11 17:25:07'),(3,'Catapult high into the air & land on the roof with a base jumping parachute (the only way to travel)\n',4,1,2,'2021-01-11 17:25:22','2021-01-11 17:25:54'),(4,'Elevator?\n',3,1,3,'2021-01-11 17:25:54','2021-01-11 17:25:54'),(5,'That too\n',4,1,4,'2021-01-11 17:26:16','2021-01-11 17:27:11'),(6,'SpaceX lowered cost of space from $10K/Kg to $1K/Kg. Starship will lower it to $100/Kg',3,2,NULL,'2021-01-11 18:09:08','2021-01-11 18:09:08'),(7,'Traveling to Mars is as rare today as it was rare to cross the Atlantic in the 1400s',3,2,6,'2021-01-11 18:11:10','2021-01-11 18:11:10'); -/*!40000 ALTER TABLE `replies` ENABLE KEYS */; -UNLOCK TABLES; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - --- Dump completed on 2021-01-13 22:42:23 diff --git a/src/main/other/sql/db_design_2.zip b/src/main/other/sql/db_design_2.zip deleted file mode 100644 index 4f253ef..0000000 Binary files a/src/main/other/sql/db_design_2.zip and /dev/null differ diff --git a/src/main/other/sql/querying-relational-databases/alter-table-blogs-add-topic-enumerated-type.sql b/src/main/other/sql/querying-relational-databases/alter-table-blogs-add-topic-enumerated-type.sql deleted file mode 100644 index d1de520..0000000 --- a/src/main/other/sql/querying-relational-databases/alter-table-blogs-add-topic-enumerated-type.sql +++ /dev/null @@ -1,8 +0,0 @@ -ALTER TABLE `db_design`.`blogs` -ADD INDEX `topic_2_topics_idx` (`topic` ASC); -ALTER TABLE `db_design`.`blogs` -ADD CONSTRAINT `topic_2_topics` - FOREIGN KEY (`topic`) - REFERENCES `db_design`.`topics` (`topic`) - ON DELETE NO ACTION - ON UPDATE CASCADE; diff --git a/src/main/other/sql/querying-relational-databases/alter-table-replies-add-replies-2-replies.sql b/src/main/other/sql/querying-relational-databases/alter-table-replies-add-replies-2-replies.sql deleted file mode 100644 index 99e0223..0000000 --- a/src/main/other/sql/querying-relational-databases/alter-table-replies-add-replies-2-replies.sql +++ /dev/null @@ -1,9 +0,0 @@ -ALTER TABLE `db_design`.`replies` -ADD COLUMN `replies_id` INT NULL AFTER `post_id`, -ADD INDEX `replies_2_replies_idx` (`replies_id` ASC); -ALTER TABLE `db_design`.`replies` -ADD CONSTRAINT `replies_2_replies` - FOREIGN KEY (`replies_id`) - REFERENCES `db_design`.`replies` (`id`) - ON DELETE CASCADE - ON UPDATE CASCADE; diff --git a/src/main/other/sql/querying-relational-databases/create-table-blogs.sql b/src/main/other/sql/querying-relational-databases/create-table-blogs.sql deleted file mode 100644 index d83011d..0000000 --- a/src/main/other/sql/querying-relational-databases/create-table-blogs.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE TABLE `db_design`.`blogs` ( - `id` INT NOT NULL AUTO_INCREMENT, - `name` VARCHAR(45) NULL, - `topic` VARCHAR(45) NULL, - `user` INT NULL, - `created` DATETIME NULL DEFAULT CURRENT_TIMESTAMP, - `updated` DATETIME NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`id`)), - INDEX `blogs_to_user_idx` (`user` ASC), - CONSTRAINT `blogs_to_user` - FOREIGN KEY (`user`) - REFERENCES `db_design`.`users` (`id`) - ON DELETE CASCADE - ON UPDATE CASCADE); diff --git a/src/main/other/sql/querying-relational-databases/create-table-follows.sql b/src/main/other/sql/querying-relational-databases/create-table-follows.sql deleted file mode 100644 index bf2a983..0000000 --- a/src/main/other/sql/querying-relational-databases/create-table-follows.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE `db_design`.`follows` ( - `followed` INT NOT NULL, - `follower` INT NOT NULL, - `created` DATETIME NULL DEFAULT CURRENT_TIMESTAMP, - `updated` DATETIME NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`followed`, `follower`), - INDEX `follower_2_user_idx` (`follower` ASC), - CONSTRAINT `follower_2_user` - FOREIGN KEY (`follower`) - REFERENCES `db_design`.`users` (`id`) - ON DELETE CASCADE - ON UPDATE CASCADE, - CONSTRAINT `followed_2_user` - FOREIGN KEY (`followed`) - REFERENCES `db_design`.`users` (`id`) - ON DELETE CASCADE - ON UPDATE CASCADE); diff --git a/src/main/other/sql/querying-relational-databases/create-table-ratings.sql b/src/main/other/sql/querying-relational-databases/create-table-ratings.sql deleted file mode 100644 index 220f5e7..0000000 --- a/src/main/other/sql/querying-relational-databases/create-table-ratings.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE TABLE `db_design`.`ratings` ( - `id` INT NOT NULL AUTO_INCREMENT, - `likes` TINYINT(1) NULL, - `score` INT NULL, - `comment` VARCHAR(45) NULL, - `user_id` INT NULL, - `post_id` INT NULL, - `created` DATETIME NULL DEFAULT CURRENT_TIMESTAMP, - `updated` DATETIME NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`id`), - INDEX `ratings_2_user_idx` (`user_id` ASC), - INDEX `ratings_2_post_idx` (`post_id` ASC), - CONSTRAINT `ratings_2_user` - FOREIGN KEY (`user_id`) - REFERENCES `db_design`.`users` (`id`) - ON DELETE CASCADE - ON UPDATE CASCADE, - CONSTRAINT `ratings_2_post` - FOREIGN KEY (`post_id`) - REFERENCES `db_design`.`posts` (`id`) - ON DELETE CASCADE - ON UPDATE CASCADE); diff --git a/src/main/other/sql/querying-relational-databases/create-table-replies.sql b/src/main/other/sql/querying-relational-databases/create-table-replies.sql deleted file mode 100644 index a512e2c..0000000 --- a/src/main/other/sql/querying-relational-databases/create-table-replies.sql +++ /dev/null @@ -1,20 +0,0 @@ -CREATE TABLE `db_design`.`replies` ( - `id` INT NOT NULL AUTO_INCREMENT, - `reply` VARCHAR(45) NULL, - `user_id` INT NULL, - `post_id` INT NULL, - `created` DATETIME NULL DEFAULT CURRENT_TIMESTAMP, - `updated` DATETIME NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`id`), - INDEX `replies_2_users_idx` (`user_id` ASC), - INDEX `replies_2_posts_idx` (`post_id` ASC), - CONSTRAINT `replies_2_users` - FOREIGN KEY (`user_id`) - REFERENCES `db_design`.`users` (`id`) - ON DELETE CASCADE - ON UPDATE CASCADE, - CONSTRAINT `replies_2_posts` - FOREIGN KEY (`post_id`) - REFERENCES `db_design`.`posts` (`id`) - ON DELETE CASCADE - ON UPDATE CASCADE); diff --git a/src/main/other/sql/querying-relational-databases/create-table-topics.sql b/src/main/other/sql/querying-relational-databases/create-table-topics.sql deleted file mode 100644 index 23d11e4..0000000 --- a/src/main/other/sql/querying-relational-databases/create-table-topics.sql +++ /dev/null @@ -1,3 +0,0 @@ -CREATE TABLE `db_design`.`topics` ( - `topic` VARCHAR(45) NOT NULL, - PRIMARY KEY (`topic`)); diff --git a/src/main/other/sql/querying-relational-databases/create-users.sql b/src/main/other/sql/querying-relational-databases/create-users.sql deleted file mode 100644 index bfc2304..0000000 --- a/src/main/other/sql/querying-relational-databases/create-users.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE `db_design`.`user` ( - `id` INT NOT NULL AUTO_INCREMENT, - `first_name` VARCHAR(45) NULL, - `last_name` VARCHAR(45) NULL, - `username` VARCHAR(45) NULL, - `password` VARCHAR(45) NULL, - `profile_picture` VARCHAR(45) NULL, - `created` DATETIME NULL DEFAULT CURRENT_TIMESTAMP, - `updated` DATETIME NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`id`)); diff --git a/src/main/other/sql/querying-relational-databases/drop-users.sql b/src/main/other/sql/querying-relational-databases/drop-users.sql deleted file mode 100644 index e03bd9f..0000000 --- a/src/main/other/sql/querying-relational-databases/drop-users.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE IF EXISTS `db_design`.`users`; diff --git a/src/main/other/sql/querying-relational-databases/insert-topics.sql b/src/main/other/sql/querying-relational-databases/insert-topics.sql deleted file mode 100644 index 4b32d3d..0000000 --- a/src/main/other/sql/querying-relational-databases/insert-topics.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT INTO `db_design`.`topics` (`topic`) VALUES ('SPACE'); -INSERT INTO `db_design`.`topics` (`topic`) VALUES ('CARS'); diff --git a/src/main/other/sql/querying-relational-databases/posts.sql b/src/main/other/sql/querying-relational-databases/posts.sql deleted file mode 100644 index d85107d..0000000 --- a/src/main/other/sql/querying-relational-databases/posts.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE TABLE `db_design`.`posts` ( - `id` INT NOT NULL AUTO_INCREMENT, - `title` VARCHAR(45) NULL, - `post` VARCHAR(45) NULL, - `created` DATETIME NULL DEFAULT CURRENT_TIMESTAMP, - `updated` DATETIME NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `blog` INT NULL, - PRIMARY KEY (`id`), - INDEX `posts_to_blog_idx` (`blog` ASC), - CONSTRAINT `posts_to_blog` - FOREIGN KEY (`blog`) - REFERENCES `db_design`.`blogs` (`id`) - ON DELETE CASCADE - ON UPDATE CASCADE); diff --git a/src/main/other/sql/querying-relational-databases/querying-relational-databases.sql b/src/main/other/sql/querying-relational-databases/querying-relational-databases.sql deleted file mode 100644 index 0a5a015..0000000 --- a/src/main/other/sql/querying-relational-databases/querying-relational-databases.sql +++ /dev/null @@ -1,97 +0,0 @@ - --- select all records from the users table -SELECT * FROM users; - -SELECT * FROM blogs; - -SELECT * FROM posts; - --- select by primary key from single table -SELECT * FROM users -WHERE users.id = 1; - --- select a blog record by its primary key -SELECT * FROM blogs -WHERE blogs.id = 2; - -SELECT * FROM posts -WHERE posts.id = 1; - --- select a user by their username -SELECT * FROM users -WHERE users.username = 'elonmusk'; - -SELECT * FROM blogs -WHERE blogs.name = 'SpaceX'; - --- explicit join --- select usernames and their blog's name -SELECT users.username, blogs.name -FROM users JOIN blogs ON users.id = blogs.user; - -SELECT blogs.name, posts.post -FROM blogs JOIN posts ON blogs.id = posts.blog; - --- implicit join -SELECT users.username, blogs.name -FROM users, blogs -WHERE users.id = blogs.user; - -SELECT blogs.name, posts.post -FROM blogs, posts -WHERE blogs.id = posts.blog; - --- implicit join single record -SELECT users.username, blogs.name -FROM users, blogs -WHERE users.id = blogs.user -AND users.username = 'elonmusk'; - -SELECT blogs.name, posts.post -FROM blogs, posts -WHERE blogs.id = posts.blog -AND blogs.name = 'Everyday Astronaut'; - --- join three tables --- select username, blog's name, and the blog's posts for a particular username -SELECT users.username, blogs.name, posts.post -FROM users, blogs, posts -WHERE users.id = blogs.user -AND blogs.id = posts.blog -AND users.username = 'erdayastronaut'; - -SELECT blogs.name, posts.post, replies.reply -FROM blogs, posts, replies -WHERE blogs.id = posts.blog -AND posts.id = replies.post_id -AND blogs.name = 'Everyday Astronaut'; - --- group sum --- calculate total likes per post -SELECT post_id, sum(ratings.likes) as `likes` -FROM ratings -GROUP BY ratings.post_id; - --- group average -SELECT post_id, avg(ratings.score) as `score` -FROM ratings -GROUP BY ratings.post_id; - --- inline views --- retrieve blog's name, posts, and total likes per post -SELECT blogs.name, posts.post, r.likes -FROM blogs, posts, ( - SELECT post_id, sum(ratings.likes) as `likes` - FROM ratings - GROUP BY ratings.post_id) as r -WHERE r.post_id = posts.id -AND posts.blog = blogs.id; - -SELECT blogs.name, posts.post, r.score -FROM blogs, posts, ( - SELECT post_id, avg(ratings.score) as `score` - FROM ratings - GROUP BY ratings.post_id) as r -WHERE r.post_id = posts.id -AND posts.blog = blogs.id; - diff --git a/src/main/other/sql/updating-relational-databases/updating-relational-databases.sql b/src/main/other/sql/updating-relational-databases/updating-relational-databases.sql deleted file mode 100644 index b60a2d4..0000000 --- a/src/main/other/sql/updating-relational-databases/updating-relational-databases.sql +++ /dev/null @@ -1,41 +0,0 @@ -INSERT INTO users (first_name, last_name, username, password) -VALUES ('Charlie', 'Brown', 'charlie', 'p@ssw0rd'); - -INSERT INTO users (first_name, last_name, username, password) -VALUES ('Daniel', 'Craig', 'dan', 'p@007rd'); - -SELECT * FROM users; - -INSERT INTO blogs -VALUES (NULL, 'Tesla Daily', 'CARS', current_date(), current_date(), 6); - -INSERT INTO blogs -VALUES (NULL, 'Hyper Change', 'CARS', current_date(), current_date(), 6); - -SELECT * FROM blogs; - -CREATE TABLE `db_design`.`unliked_posts` ( - post_id INT NOT NULL, - user_id INT NOT NULL, - blog_id INT NOT NULL, - username VARCHAR(45), - post VARCHAR(140), - blog_name VARCHAR(45), - PRIMARY KEY(post_id, user_id, blog_id), - FOREIGN KEY (post_id) REFERENCES posts(id), - FOREIGN KEY (user_id) REFERENCES users(id), - FOREIGN KEY (blog_id) REFERENCES blogs(id) -); - -INSERT INTO unliked_posts -SELECT posts.id as post_id, - users.id as user_id, - blogs.id as blog_id, - users.username, - posts.post, - blogs.name as blog_name -FROM users, blogs, posts, ratings -WHERE users.id = ratings.user_id -AND blogs.id = posts.blog -AND posts.id = ratings.post_id -AND ratings.likes = 0; diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 27267bc..ec2d8dd 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,6 +1,6 @@ -spring.datasource.url=jdbc:mysql://localhost:3306/db_design?serverTimezone=UTC -spring.datasource.username=cs3200 -spring.datasource.password=cs3200 +spring.datasource.url=jdbc:mysql://localhost:3306/db_project?serverTimezone=UTC +spring.datasource.username=root +spring.datasource.password=P@ssw0rd spring.jpa.hibernate.ddl-auto=update spring.jpa.show-sql=true spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy @@ -9,3 +9,5 @@ spring.jpa.properties.hibernate.show_sql=true spring.jpa.properties.hibernate.use_sql_comments=true spring.jpa.properties.hibernate.format_sql=true spring.jpa.properties.hibernate.type=trace +server.error.whitelabel.enabled = false + diff --git a/src/main/sql/create-table-users.sql b/src/main/sql/create-table-users.sql deleted file mode 100644 index 896bf30..0000000 --- a/src/main/sql/create-table-users.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE `user` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `created` datetime DEFAULT NULL, - `first_name` varchar(255) DEFAULT NULL, - `last_name` varchar(255) DEFAULT NULL, - `password` varchar(255) DEFAULT NULL, - `profile_picture` varchar(255) DEFAULT NULL, - `updated` datetime DEFAULT NULL, - `username` varchar(255) DEFAULT NULL, - PRIMARY KEY (`id`) -); \ No newline at end of file diff --git a/src/main/webapp/react/pharmacy/doctors/doctor-form-editor.js b/src/main/webapp/react/pharmacy/doctors/doctor-form-editor.js new file mode 100644 index 0000000..7287b49 --- /dev/null +++ b/src/main/webapp/react/pharmacy/doctors/doctor-form-editor.js @@ -0,0 +1,76 @@ +import doctorService from "./doctor-service" + +const {useState, useEffect} = React; +const {useParams, useHistory} = window.ReactRouterDOM +const DOCTORS_URL = "http://localhost:8080/api/doctors" + +const DoctorFormEditor = () => { + const history = useHistory() + const {id} = useParams() + const [doctor, setDoctor] = useState({}) + useEffect(() => { + if(id!=="new"){ + findDoctorById(id) + } + }, []); + const createDoctor = (doctor) => + doctorService.createDoctor(doctor) + .then(() => history.goBack()) + const findDoctorById = (id) => + doctorService.findDoctorById(id) + .then(doctor => setDoctor(doctor)) + const deleteDoctor = (id) => + doctorService.deleteDoctor(id) + .then(() => history.goBack()) + const updateDoctor = (id, newDoctor) => + doctorService.updateDoctor(id, newDoctor) + .then(() => history.goBack()) + + return ( +
+

Doctor Editor

+ +
+ + setDoctor(doctor => + ({...doctor, firstname: e.target.value}))} + value={doctor.firstname}/>
+ + setDoctor(doctor => + ({...doctor, lastname: e.target.value}))} + value={doctor.lastname}/>
+ + setDoctor(doctor => + ({...doctor, doctorname: e.target.value}))} + value={doctor.doctorname}/>
+ + setDoctor(doctor => + ({...doctor, password: e.target.value}))} + value={doctor.password}/>
+ + setDoctor(doctor => + ({...doctor, email: e.target.value}))} + value={doctor.email}/>
+ + setDoctor(doctor => + ({...doctor, DOB: e.target.value}))} + value={doctor.DOB}/>
+ + setDoctor(doctor => + ({...doctor, position: e.target.value}))} + value={doctor.position}/>
+ + setDoctor(doctor => + ({...doctor, hospital: e.target.value}))} + value={doctor.hospital}/>
+ + + + +
+ ) +} + +export default DoctorFormEditor \ No newline at end of file diff --git a/src/main/webapp/react/pharmacy/doctors/doctor-list.js b/src/main/webapp/react/pharmacy/doctors/doctor-list.js new file mode 100644 index 0000000..33c25f3 --- /dev/null +++ b/src/main/webapp/react/pharmacy/doctors/doctor-list.js @@ -0,0 +1,115 @@ +import doctorService from "./doctor-service" +import DoctorEditorInline from "./inline-doctor-editor" + + +const { useState, useEffect } = React; +const DOCTORS_URL = "http://localhost:8080/api/doctors" + + +const DoctorList = () => { + const [doctors, setDoctors] = useState([]) + const [newDoctor, setNewDoctor] = useState({}) + useEffect(() => { + findAllDoctors() + }, []) + const createDoctor = (doctor) => + doctorService.createDoctor(doctor) + .then(doctor => { + setNewDoctor(doctor) + setDoctors(doctors => ([...doctors, doctor])) + }) + const updateDoctor = (id, newDoctor) => + doctorService.updateDoctor(id, newDoctor).then(doctor => setDoctors(doctors => (doctors.map + (doctor => doctor.id === id? newDoctor : doctor)))) + const findAllDoctors = () => + doctorService.findAllDoctors() + .then(doctors => setDoctors(doctors)) + const deleteDoctor = (id) => + doctorService.deleteDoctor(id) + .then(doctors => setDoctors(doctors => doctors.filter(doctor => doctor.id !== id))) + + return( +
+

Doctors

+
    +
  • +
    +
    + setNewDoctor(newDoctor => ({...newDoctor, + firstname: e.target.value}))}/> +
    +
    + setNewDoctor(newDoctor => ({...newDoctor, + lastname: e.target.value}))}/> +
    +
    + setNewDoctor(newDoctor => ({...newDoctor, + username: e.target.value}))}/> +
    +
    + setNewDoctor(newDoctor => ({...newDoctor, + password: e.target.value}))}/> +
    +
    + setNewDoctor(newDoctor => ({...newDoctor, + email: e.target.value}))}/> +
    +
    + setNewDoctor(newDoctor => ({...newDoctor, + DOB: e.target.value}))}/> +
    +
    + setNewDoctor(newDoctor => ({...newDoctor, + position: e.target.value}))}/> +
    +
    + setNewDoctor(newDoctor => ({...newDoctor, + hospital: e.target.value}))}/> +
    + +
    + createDoctor(newDoctor)}> +
    +
    +
  • + { + doctors.map(doctor => +
  • + +
  • ) + } +
+
+ + + ) +} + +export default DoctorList; \ No newline at end of file diff --git a/src/main/webapp/react/pharmacy/doctors/doctor-service.js b/src/main/webapp/react/pharmacy/doctors/doctor-service.js new file mode 100644 index 0000000..5786819 --- /dev/null +++ b/src/main/webapp/react/pharmacy/doctors/doctor-service.js @@ -0,0 +1,42 @@ +// TODO: declare URL where server listens for HTTP requests +const DOCTORS_URL = "http://localhost:8080/api/doctors" + +// TODO: retrieve all docs from the server +export const findAllDoctors = () => + fetch(DOCTORS_URL).then(response => response.json()) + +// TODO: retrieve a single doc by their ID +export const findDoctorById = (id) => + fetch(`${DOCTORS_URL}/${id}`).then(response => response.json()) + +// TODO: delete a doc by their ID +export const deleteDoctor = (id) => + fetch(`${DOCTORS_URL}/${id}`, { + method: "DELETE" + }) + + +// TODO: create a new user +export const createDoctor = (doctor) => + fetch(DOCTORS_URL, { + method: 'POST', + body: JSON.stringify(doctor), + headers: {'content-type': 'application/json'} + }).then(response => response.json()) + +// TODO: update a user by their ID +export const updateDoctor = (id, doctor) => + fetch(`${DOCTORS_URL}/${id}`, { + method: 'PUT', + body: JSON.stringify(doctor), + headers: {'content-type': 'application/json'} + }).then(response => response.json()) + + +// TODO: export all functions as the API to this service +export default { +findAllDoctors, +findDoctorById, +deleteDoctor, +createDoctor, +updateDoctor} diff --git a/src/main/webapp/react/university/courses/courses.html b/src/main/webapp/react/pharmacy/doctors/doctors.html similarity index 64% rename from src/main/webapp/react/university/courses/courses.html rename to src/main/webapp/react/pharmacy/doctors/doctors.html index c599354..f2925af 100644 --- a/src/main/webapp/react/university/courses/courses.html +++ b/src/main/webapp/react/pharmacy/doctors/doctors.html @@ -3,8 +3,8 @@ React Hello World - - + +
@@ -14,9 +14,11 @@ - - - + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/webapp/react/pharmacy/index.js b/src/main/webapp/react/pharmacy/index.js new file mode 100644 index 0000000..f048aff --- /dev/null +++ b/src/main/webapp/react/pharmacy/index.js @@ -0,0 +1,47 @@ +import DoctorList from "./doctors/doctor-list"; +import DoctorFormEditor from "./doctors/doctor-form-editor"; +import PatientList from "./patients/patient-list"; +import PatientFormEditor from "./patients/patient-form-editor"; +import PrescriptionList from "./prescriptions/prescription-list"; +import SymptomsList from "./symptoms/symptoms-list"; +import PrescriptionEditorForm from "./prescriptions/prescription-editor-form"; +import SymptomEditorForm from "./symptoms/symptoms-editor-form"; + +const {HashRouter, Link, Route} = window.ReactRouterDOM; + +const App = () => { + console.log(window.ReactRouterDOM) + return ( +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ ); +} + +export default App; diff --git a/src/main/webapp/react/pharmacy/patients/inline-patient-editor.js b/src/main/webapp/react/pharmacy/patients/inline-patient-editor.js new file mode 100644 index 0000000..ca2f377 --- /dev/null +++ b/src/main/webapp/react/pharmacy/patients/inline-patient-editor.js @@ -0,0 +1,130 @@ +const {useState, useEffect } = React; +const {Link} = window.ReactRouterDOM; + +const InlinePatientEditor = ({patient, deletePatient, updatePatient}) => { + const [patientCopy, setPatientCopy] = useState(patient) + const [editing, setEditing] = useState(false) + return( +
+ { + editing && +
+
+ setPatientCopy(patientCopy => ({...patientCopy, firstname: e.target.value}))}/> +
+
+ setPatientCopy(patientCopy => ({...patientCopy, lastname: + e.target.value}))}/> +
+
+ setPatientCopy(patientCopy => ({...patientCopy, username: e.target.value}))}/> + +
+
+ setPatientCopy(patientCopy => ({...patientCopy, password: e.target.value}))}/> +
+
+ setPatientCopy(patientCopy => ({...patientCopy, email: e.target.value}))}/> +
+
+ setPatientCopy(patientCopy => ({...patientCopy, DOB: + e.target.value}))}/> +
+
+ setPatientCopy(patientCopy => ({...patientCopy, conditions: e.target.value}))}/> +
+
+ + Prescriptions + +
+ + +
+ { + setEditing(false) + updatePatient(patientCopy.id, patientCopy) + }}> + setEditing(false)}> + deletePatient(patient.id)}> +
+
+ } + { + !editing && +
+
+ + {patientCopy.firstname} + +
+
+ + {patientCopy.lastname} + +
+
+ + {patientCopy.username} + +
+
+ + {patientCopy.password} + +
+
+ + {patientCopy.email} + +
+
+ + {patientCopy.DOB} + +
+
+ + {patientCopy.conditions} + +
+
+ + Prescriptions + +
+
+ setEditing(true)}> +
+
+ } +
+ ) +} + +export default InlinePatientEditor; \ No newline at end of file diff --git a/src/main/webapp/react/pharmacy/patients/patient-form-editor.js b/src/main/webapp/react/pharmacy/patients/patient-form-editor.js new file mode 100644 index 0000000..0ae6131 --- /dev/null +++ b/src/main/webapp/react/pharmacy/patients/patient-form-editor.js @@ -0,0 +1,84 @@ +import patientService from "./patient-service" + +const {useState, useEffect} = React +const {useParams, useHistory} = window.ReactRouterDOM; + +const PatientEditorForm = () => { + const [patient, setPatient] = useState({}) + const {id} = useParams() + const history = useHistory() + useEffect(() => {if(id!=="new"){ + findPatientById(id) + } + }, []); + const findPatientById = (id) => + patientService.findPatientById(id) + .then(patient => setPatient(patient)) + const updatePatient = (id, newPatient) => + patientService.updatePatient(id, newPatient) + .then(() => history.goBack()) + const deletePatient = (id) => + patientService.deletePatient(id) + .then(() => history.goBack()) + + return ( +
+

+ Patient Editor +

+ + + + + onChange={(e) => setPatient(patient => ({...patient, firstname: e.target.value}))} + + setPatient(patient => ({...patient, lastname: e.target.value}))}/> + + setPatient(patient => ({...patient, username: e.target.value}))}/> + + setPatient(patient => ({...patient, password: e.target.value}))}/> + + setPatient(patient => ({...patient, DOB: e.target.value})) + }/> + + setPatient(patient => ({...patient, conditions: e.target.value})) + }/> + + +
+ + + +
+ ) +} + +export default PatientEditorForm \ No newline at end of file diff --git a/src/main/webapp/react/pharmacy/patients/patient-list.js b/src/main/webapp/react/pharmacy/patients/patient-list.js new file mode 100644 index 0000000..f97dbf8 --- /dev/null +++ b/src/main/webapp/react/pharmacy/patients/patient-list.js @@ -0,0 +1,109 @@ +import PatientEditorInline from "./inline-patient-editor"; +import patientService, {createPatientForDoctor} from "./patient-service" + +const DOCTOR_URL = "http://localhost:8080/api/patients" +const { useState, useEffect } = React; +const {Link, useParams, useHistory} = window.ReactRouterDOM; + +const PatientList = () => { + const [patients, setPatients] = useState([]) + const [newPatient, setNewPatient] = useState({}) + const {id} = useParams() + useEffect(() => { + findPatientsForDoctor(id) + }, []) + const createPatientForDoctor = (patient) => + patientService.createPatientForDoctor(id, patient) + .then(patient => { + setNewPatient({firstname:''}) + setPatients(patients => ([...patients, patient])) + }) + const updatePatient = (id, newPatient) => + patientService.updatePatient(id, newPatient) + .then(patient => setPatients(patients => (patients.map(patient => patient.id === id ? newPatient : patient)))) + const findPatientsForDoctor = (id) => + patientService.findPatientsForDoctor(id) + .then(patients => setPatients(patients)) + const deletePatient = (id) => + patientService.deletePatient(id) + .then(patients => setPatients(patients => patients.filter(patient => patient.id !== id))) + return( +
+

+ history.back()}> + + + Patients +

+
    +
  • +
    +
    + setNewPatient(newPatient => ({...newPatient, firstname: e.target.value}))}/> +
    +
    + setNewPatient(newPatient => ({...newPatient, lastname: e.target.value}))}/> +
    +
    + setNewPatient(newPatient => ({...newPatient, username: e.target.value}))}/> +
    +
    + setNewPatient(newPatient => ({...newPatient, password: e.target.value}))}/> +
    +
    + setNewPatient(newPatient => ({...newPatient, email: e.target.value}))}/> +
    +
    + setNewPatient(newPatient => ({...newPatient, DOB: e.target.value}))}/> +
    +
    + setNewPatient(newPatient => ({...newPatient, conditions: e.target.value}))}/> +
    +
    + createPatientForDoctor(newPatient)}> +
    +
    +
  • + { + patients.map(patient => +
  • + +
  • ) + } +
+
+ ) +} + +export default PatientList; \ No newline at end of file diff --git a/src/main/webapp/react/pharmacy/patients/patient-service.js b/src/main/webapp/react/pharmacy/patients/patient-service.js new file mode 100644 index 0000000..bb3baeb --- /dev/null +++ b/src/main/webapp/react/pharmacy/patients/patient-service.js @@ -0,0 +1,39 @@ +const DOCTOR_URL = "http://localhost:8080/api/doctors" +const PATIENT_URL = "http://localhost:8080/api/patients" + +export const createPatientForDoctor = (id, patient) => + fetch(`${DOCTOR_URL}/${id}/patients`, { + method: 'POST', + body: JSON.stringify(patient), + headers: {'content-type': 'application/json'} + }) + .then(response => response.json()) + +export const findPatientsForDoctor = (id) => + fetch(`${DOCTOR_URL}/${id}/patients`) + .then(response => response.json()) + +export const findPatientById = (id) => + fetch(`${PATIENT_URL}/${id}`) + .then(response => response.json()) + +export const updatePatient = (id, patient) => + fetch(`${PATIENT_URL}/${id}`, { + method: 'PUT', + body: JSON.stringify(patient), + headers: {'content-type': 'application/json'} + }) + .then(response => response.json()) + +const deletePatient = (id) => + fetch(`${PATIENT_URL}/${id}`, { + method: "DELETE" + }) + +export default { + createPatientForDoctor, + findPatientsForDoctor, + findPatientById, + updatePatient, + deletePatient +} \ No newline at end of file diff --git a/src/main/webapp/react/pharmacy/prescriptions/prescription-editor-form.js b/src/main/webapp/react/pharmacy/prescriptions/prescription-editor-form.js new file mode 100644 index 0000000..87f2754 --- /dev/null +++ b/src/main/webapp/react/pharmacy/prescriptions/prescription-editor-form.js @@ -0,0 +1,84 @@ +import prescriptionService from "./prescription-service" + +const {useState, useEffect} = React +const {useParams, useHistory} = window.ReactRouterDOM; + +const PrescriptionEditorForm = () => { + const [prescription, setPrescription] = useState({}) + const {id} = useParams() + const history = useHistory() + useEffect(() => {if(id!=="new"){ + findPrescriptionById(id) + } + }, []); + const findPrescriptionById = (id) => + prescriptionService.findPrescriptionById(id) + .then(prescription => setPrescription(prescription)) + const updatePrescription = (id, newPrescription) => + prescriptionService.updatePrescription(id, newPrescription) + .then(() => history.goBack()) + const deletePrescription = (id) => + prescriptionService.deletePrescription(id) + .then(() => history.goBack()) + + return ( +
+

+ Prescription Editor +

+ + + + + + setPrescription(prescription => ({...prescription, diagnosis: e.target.value}))}/> + + setPrescription(prescription => ({...prescription, dosage: parseInt(e.target.value)}))}/> + +
+ + + +
+ ) +} + +export default PrescriptionEditorForm \ No newline at end of file diff --git a/src/main/webapp/react/pharmacy/prescriptions/prescription-editor-inline.js b/src/main/webapp/react/pharmacy/prescriptions/prescription-editor-inline.js new file mode 100644 index 0000000..bbf1ccc --- /dev/null +++ b/src/main/webapp/react/pharmacy/prescriptions/prescription-editor-inline.js @@ -0,0 +1,100 @@ +const {useState, useEffect } = React; +const {Link} = window.ReactRouterDOM; + +const PrescriptionEditorInline = ({prescription, deletePrescription, updatePrescription}) => { + const [prescriptionCopy, setPrescriptionCopy] = useState(prescription) + const [editing, setEditing] = useState(false) + return( +
+ { + editing && +
+
+ +
+
+ setPrescriptionCopy(prescriptionCopy => ({...prescriptionCopy, diagnosis: e.target.value}))}/> +
+
+ setPrescriptionCopy(prescriptionCopy => ({...prescriptionCopy, Dosage: parseInt(e.target.value)}))}/> +
+
+ + Symptoms + +
+
+ { + setEditing(false) + updatePrescription(prescriptionCopy.id, prescriptionCopy) + }}> + setEditing(false)}> + deletePrescription(prescription.id)}> +
+
+ } + { + !editing && +
+
+ + {prescriptionCopy.medication_name} + +
+
+ + {prescriptionCopy.diagnosis} + +
+
+ + {prescriptionCopy.dosage} + +
+
+ + Symptoms + +
+ +
+ setEditing(true)}> +
+
+ } +
+ ) +} + +export default PrescriptionEditorInline; \ No newline at end of file diff --git a/src/main/webapp/react/pharmacy/prescriptions/prescription-list.js b/src/main/webapp/react/pharmacy/prescriptions/prescription-list.js new file mode 100644 index 0000000..013643a --- /dev/null +++ b/src/main/webapp/react/pharmacy/prescriptions/prescription-list.js @@ -0,0 +1,99 @@ +import PrescriptionEditorInline from "./prescription-editor-inline"; +import prescriptionService, {createPrescriptionForPatient} from "./prescription-service" + +const PRESCRIPTION_URL = "http://localhost:8080/api/prescriptions" +const { useState, useEffect } = React; +const {Link, useParams, useHistory} = window.ReactRouterDOM; + +const PrescriptionList = () => { + const [prescriptions, setPrescriptions] = useState([]) + const [newPrescription, setNewPrescription] = useState({}) + const {id} = useParams() + useEffect(() => { + findPrescriptionsForPatient(id) + }, []) + const createPrescriptionForPatient = (prescription) => + prescriptionService.createPrescriptionForPatient(id, prescription) + .then(prescription => { + setNewPrescription({diagnosis:''}) + setPrescriptions(prescriptions => ([...prescriptions, prescription])) + }) + const updatePrescription = (id, newPrescription) => + prescriptionService.updatePrescription(id, newPrescription) + .then(prescription => setPrescriptions(prescriptions => (prescriptions.map(prescription => prescription.id === id ? newPrescription : prescription)))) + const findPrescriptionsForPatient = (id) => + prescriptionService.findPrescriptionsForPatient(id) + .then(prescriptions => setPrescriptions(prescriptions)) + const deletePrescription = (id) => + prescriptionService.deletePrescription(id) + .then(prescriptions => setPrescriptions(prescriptions => prescriptions.filter(prescription => prescription.id !== id))) + return( +
+

+ history.back()}> + + + Prescriptions +

+
    +
  • +
    +
    + +
    +
    + SetNewPrescription(newPrescription => ({...newPrescription, diagnosis: e.target.value}))}/> +
    +
    + SetNewPrescription(newPrescription => ({...newPrescription, Dosage: parseInt(e.target.value)}))}/> +
    +
    + createPrescriptionForPatient(newPrescription)}> +
    +
    +
  • + { + prescriptions.map(prescription => +
  • + +
  • ) + } +
+
+ ) +} + +export default PrescriptionList; \ No newline at end of file diff --git a/src/main/webapp/react/pharmacy/prescriptions/prescription-service.js b/src/main/webapp/react/pharmacy/prescriptions/prescription-service.js new file mode 100644 index 0000000..694a078 --- /dev/null +++ b/src/main/webapp/react/pharmacy/prescriptions/prescription-service.js @@ -0,0 +1,39 @@ +const PATIENT_URL = "http://localhost:8080/api/patients" +const PRESCRIPTION_URL = "http://localhost:8080/api/prescriptions" + +export const createPrescriptionForPatient = (id, prescription) => + fetch(`${PATIENT_URL}/${id}/prescriptions`, { + method: 'POST', + body: JSON.stringify(prescription), + headers: {'content-type': 'application/json'} + }) + .then(response => response.json()) + +export const findPrescriptionsForPatient = (id) => + fetch(`${PATIENT_URL}/${id}/prescriptions`) + .then(response => response.json()) + +export const findPrescriptionById = (id) => + fetch(`${PRESCRIPTION_URL}/${id}`) + .then(response => response.json()) + +export const updatePrescription = (id, prescription) => + fetch(`${PRESCRIPTION_URL}/${id}`, { + method: 'PUT', + body: JSON.stringify(prescription), + headers: {'content-type': 'application/json'} + }) + .then(response => response.json()) + +const deletePrescription = (id) => + fetch(`${PRESCRIPTION_URL}/${id}`, { + method: "DELETE" + }) + +export default { + createPrescriptionForPatient, + findPrescriptionsForPatient, + findPrescriptionById, + updatePrescription, + deletePrescription +} \ No newline at end of file diff --git a/src/main/webapp/react/pharmacy/symptoms/symptom-service.js b/src/main/webapp/react/pharmacy/symptoms/symptom-service.js new file mode 100644 index 0000000..ada8eda --- /dev/null +++ b/src/main/webapp/react/pharmacy/symptoms/symptom-service.js @@ -0,0 +1,39 @@ +const PRESCRIPTION_URL = "http://localhost:8080/api/prescriptions" +const SYMPTOM_URL = "http://localhost:8080/api/symptoms" + +export const createSymptomForPrescription = (id, symptom) => + fetch(`${PRESCRIPTION_URL}/${id}/symptoms`, { + method: 'POST', + body: JSON.stringify(symptom), + headers: {'content-type': 'application/json'} + }) + .then(response => response.json()) + +export const findSymptomsForPrescription = (id) => + fetch(`${PRESCRIPTION_URL}/${id}/symptoms`) + .then(response => response.json()) + +export const findSymptomById = (id) => + fetch(`${SYMPTOM_URL}/${id}`) + .then(response => response.json()) + +export const updateSymptom = (id, symptom) => + fetch(`${SYMPTOM_URL}/${id}`, { + method: 'PUT', + body: JSON.stringify(symptom), + headers: {'content-type': 'application/json'} + }) + .then(response => response.json()) + +const deleteSymptom = (id) => + fetch(`${SYMPTOM_URL}/${id}`, { + method: "DELETE" + }) + +export default { + createSymptomForPrescription, + findSymptomsForPrescription, + findSymptomById, + updateSymptom, + deleteSymptom +} \ No newline at end of file diff --git a/src/main/webapp/react/pharmacy/symptoms/symptoms-editor-form.js b/src/main/webapp/react/pharmacy/symptoms/symptoms-editor-form.js new file mode 100644 index 0000000..5756336 --- /dev/null +++ b/src/main/webapp/react/pharmacy/symptoms/symptoms-editor-form.js @@ -0,0 +1,101 @@ +import symptomService from "./symptoms-service" + +const {useState, useEffect} = React +const {useParams, useHistory} = window.ReactRouterDOM; + +const SymptomEditorForm = () => { + const [symptom, setSymptom] = useState({}) + const {id} = useParams() + const history = useHistory() + useEffect(() => { + if(id!=="new"){ + findSymptomById(id) + } + }, []); + const findSymptomById = (id) => + symptomService.findSymptomById(id) + .then(symptom => setSymptom(symptom)) + const updateSymptom = (id, newSymptom) => + symptomService.updateSymptom(id, newSymptom) + .then(() => history.goBack()) + const deleteSymptom = (id) => + symptomService.deleteSymptom(id) + .then(() => history.goBack()) + + return ( +
+

+ Symptom Editor +

+ + + + setSymptom(symptom => ({...symptom, title: e.target.value}))}/> + + + + + setSymptom(symptom => ({...symptom, usedFor: e.target.value}))}/> + + setSymptom(symptom => ({...symptom, benefits: e.target.value}))}/> + + + setSymptom(symptom => ({...symptom, sideEffects: e.target.value}))}/> + + setSymptom(symptom=> ({...symptom, lastUsed: parseInt(e.target.value) + }))}/> +
+ + + +
+ ) +} + +export default SymptomEditorForm \ No newline at end of file diff --git a/src/main/webapp/react/pharmacy/symptoms/symptoms-editor-inline.js b/src/main/webapp/react/pharmacy/symptoms/symptoms-editor-inline.js new file mode 100644 index 0000000..9341381 --- /dev/null +++ b/src/main/webapp/react/pharmacy/symptoms/symptoms-editor-inline.js @@ -0,0 +1,125 @@ +const {useState, useEffect } = React; +const {Link} = window.ReactRouterDOM; + +const SymptomEditorInline = ({symptom, deleteSymptom, updateSymptom}) => { + const [symptomCopy, setSymptomCopy] = useState(symptom) + const [editing, setEditing] = useState(false) + return( +
+ { + editing && +
+
+ setSymptom(symptom => ({...symptom, title: e.target.value}))}/> + +
+
+ +
+
+ setSymptomCopy(symptomCopy => ({...symptomCopy, usedFor: e.target.value}))}/> +
+
+ setSymptomCopy(symptomCopy => ({...symptomCopy, benefits: e.target.value}))}/> +
+
+ setSymptomCopy(symptomCopy => ({...symptomCopy, sideEffects: e.target.value}))}/> +
+
+ setSymptomCopy(symptomCopy => ({...symptomCopy, Dosage: parseInt(e.target.value)}))}/> +
+
+ { + setEditing(false) + updateSymptom(symptomCopy.id, symptomCopy) + }}> + setEditing(false)}> + deleteSymptom(symptom.id)}> +
+
+ + } + { + !editing && +
+
+ + {symptomCopy.title} + +
+
+ + {symptomCopy.medication_name} + +
+
+ + {symptomCopy.usedFor} + +
+
+ + {symptomCopy.benefits} + +
+
+ + {symptomCopy.sideEffects} + +
+
+ + {symptomCopy.lastUsed} + +
+ +
+ setEditing(true)}> +
+
+ } +
+ ) +} + +export default SymptomEditorInline; \ No newline at end of file diff --git a/src/main/webapp/react/pharmacy/symptoms/symptoms-list.js b/src/main/webapp/react/pharmacy/symptoms/symptoms-list.js new file mode 100644 index 0000000..5df7512 --- /dev/null +++ b/src/main/webapp/react/pharmacy/symptoms/symptoms-list.js @@ -0,0 +1,120 @@ +import SymptomEditorInline from "./symptom-editor-inline"; +import symptomService, {createSymptomForPrescription} from "./symptom-service" + +const SYMPTOMS_URL = "http://localhost:8080/api/symptoms" +const { useState, useEffect } = React; +const {Link, useParams, useHistory} = window.ReactRouterDOM; + +const SymptomsList = () => { + const [symptoms, setSymptoms] = useState([]) + const [newSymptom, setNewSymptom] = useState({}) + const {id} = useParams() + useEffect(() => { + findSymptomsForPrescription(id) + }, []) + const createSymptomForPrescription = (symptom) => + symptomService.createSymptomForPrescription(id, symptom) + .then(symptom => { + setNewSymptom({title:''}) + setSymptoms(symptoms => ([...symptoms, symptom])) + }) + const updateSymptom = (id, newSymptom) => + symptomService.updateSymptom(id, newSymptom) + .then(symptom => setSymptoms(symptoms => (symptoms.map(symptom => symptom.id === id ? newSymptom : symptom)))) + const findSymptomsForPrescription = (id) => + symptomService.findSymptomsForPrescription(id) + .then(symptoms => setSymptoms(symptoms)) + const deleteSymptom = (id) => + symptomService.deleteSymptom(id) + .then(symptoms => setSymptoms(symptoms => symptoms.filter(symptom => symptom.id !== id))) + return( +
+

+ history.back()}> + + + Symptoms +

+
    +
  • +
    +
    + SetNewSymptom(newSymptom => ({...newSymptom, title: e.target.value}))}/> +
    +
    + +
    +
    + SetNewSymptom(newSymptom => ({...newSymptom, usedFor: e.target.value}))}/> +
    +
    + SetNewSymptom(newSymptom => ({...newSymptom, benefits: e.target.value}))}/> +
    +
    + SetNewSymptom(newSymptom => ({...newSymptom, sideEffects: e.target.value}))}/> +
    +
    + SetNewSymptom(newSymptom => ({...newSymptom, lastUsed: parseInt(e.target.value)}))}/> +
    +
    + createSymptomForPrescription(newSymptom)}> +
    +
    +
  • + { + symptoms.map(symptom => +
  • + +
  • ) + } +
+
+ ) +} + +export default SymptomsList; \ No newline at end of file diff --git a/src/main/webapp/react/social/index.html b/src/main/webapp/react/social/index.html deleted file mode 100644 index a73e068..0000000 --- a/src/main/webapp/react/social/index.html +++ /dev/null @@ -1,30 +0,0 @@ - - - CRUD User - - - - - -
- - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/webapp/react/social/index.js b/src/main/webapp/react/social/index.js deleted file mode 100644 index baad47e..0000000 --- a/src/main/webapp/react/social/index.js +++ /dev/null @@ -1,19 +0,0 @@ -import UserList from "./users/user-list"; -import UserFormEditor from "./users/user-form-editor"; -const {HashRouter, Route} = window.ReactRouterDOM; -const App = () => { - return ( -
- - - - - - - - -
- ); -} - -export default App; diff --git a/src/main/webapp/react/social/users/inline-user-editor.js b/src/main/webapp/react/social/users/inline-user-editor.js deleted file mode 100644 index 21e6131..0000000 --- a/src/main/webapp/react/social/users/inline-user-editor.js +++ /dev/null @@ -1,81 +0,0 @@ -const {useState, useEffect } = React; -const {Link} = window.ReactRouterDOM; - -const InlineUserEditor = ({user, deleteUser, updateUser}) => { - const [userCopy, setUserCopy] = useState(user) - const [editing, setEditing] = useState(false) - return( -
- { - editing && -
-
- setUserCopy(userCopy => ({...userCopy, firstName: e.target.value}))}/> -
-
- setUserCopy(userCopy => ({...userCopy, lastName: e.target.value}))}/> -
-
- setUserCopy(userCopy => ({...userCopy, username: e.target.value}))}/> -
-
- - Blogs - -
-
- { - setEditing(false) - updateUser(userCopy.id, userCopy) - }}> - setEditing(false)}> - deleteUser(user.id)}> -
-
- } - { - !editing && -
-
- - {userCopy.firstName} - -
-
- - {userCopy.lastName} - -
-
- - {userCopy.username} - -
-
- - Blogs - -
-
- setEditing(true)}> -
-
- } -
- ) -} - -export default InlineUserEditor; \ No newline at end of file diff --git a/src/main/webapp/react/social/users/user-form-editor.js b/src/main/webapp/react/social/users/user-form-editor.js deleted file mode 100644 index 1d54eef..0000000 --- a/src/main/webapp/react/social/users/user-form-editor.js +++ /dev/null @@ -1,24 +0,0 @@ -const UserFormEditor = () => { - return ( -
-

User Editor

- - - - - - - - - - -
- - - - -
- ) -} - -export default UserFormEditor \ No newline at end of file diff --git a/src/main/webapp/react/social/users/user-list.js b/src/main/webapp/react/social/users/user-list.js deleted file mode 100644 index 69be289..0000000 --- a/src/main/webapp/react/social/users/user-list.js +++ /dev/null @@ -1,31 +0,0 @@ -const {Link} = window.ReactRouterDOM; - -const UserList = () => { - return( -
-

User List

- -
    -
  • - - Thomas Sowell - -
  • -
  • - - Cathie Wood - -
  • -
  • - - Adam Smith - -
  • -
-
- ) -} - -export default UserList; \ No newline at end of file diff --git a/src/main/webapp/react/social/users/user-service.js b/src/main/webapp/react/social/users/user-service.js deleted file mode 100644 index 5ccde05..0000000 --- a/src/main/webapp/react/social/users/user-service.js +++ /dev/null @@ -1,20 +0,0 @@ -// TODO: declare URL where server listens for HTTP requests -const USERS_URL = "" - -// TODO: retrieve all users from the server -export const findAllUsers = () => {} - -// TODO: retrieve a single user by their ID -export const findUserById = (id) => {} - -// TODO: delete a user by their ID -export const deleteUser = () => {} - -// TODO: create a new user -export const createUser = (user) => {} - -// TODO: update a user by their ID -export const updateUser = (id, user) => {} - -// TODO: export all functions as the API to this service -export default {} diff --git a/src/main/webapp/react/university/courses/course-editor-form.js b/src/main/webapp/react/university/courses/course-editor-form.js deleted file mode 100644 index eeaaab7..0000000 --- a/src/main/webapp/react/university/courses/course-editor-form.js +++ /dev/null @@ -1,54 +0,0 @@ -import courseService from "./course-service" - -const {useState, useEffect} = React -const {useParams, useHistory} = window.ReactRouterDOM; -const COURSE_URL = "http://localhost:8080/api/courses" - -const CourseEditorForm = () => { - const [course, setCourse] = useState({}) - const {id} = useParams() - const history = useHistory() - useEffect(() => { - findCourseById(id) - }, []); - const findCourseById = (id) => - courseService.findCourseById(id) - .then(course => setCourse(course)) - const updateCourse = (id, newCourse) => - courseService.updateCourse(id, newCourse) - .then(() => history.goBack()) - const deleteCourse = (id) => - courseService.deleteCourse(id) - .then(() => history.goBack()) - - return ( -
-

- Course Editor -

- - - - setCourse(course => ({...course, title: e.target.value}))} - value={course.title}/> - - - -
- ) -} - -export default CourseEditorForm \ No newline at end of file diff --git a/src/main/webapp/react/university/courses/course-editor-inline.js b/src/main/webapp/react/university/courses/course-editor-inline.js deleted file mode 100644 index cea7e6e..0000000 --- a/src/main/webapp/react/university/courses/course-editor-inline.js +++ /dev/null @@ -1,59 +0,0 @@ -const {useState, useEffect } = React; -const {Link} = window.ReactRouterDOM; - -const CourseEditorInline = ({course, deleteCourse, updateCourse}) => { - const [courseCopy, setCourseCopy] = useState(course) - const [editing, setEditing] = useState(false) - return( -
- { - editing && -
-
- setCourseCopy(courseCopy => ({...courseCopy, title: e.target.value}))}/> -
-
- - Sections - -
-
- { - setEditing(false) - updateCourse(courseCopy.id, courseCopy) - }}> - setEditing(false)}> - deleteCourse(course.id)}> -
-
- } - { - !editing && -
-
- - {courseCopy.title} - -
-
- - Sections - -
-
- setEditing(true)}> -
-
- } -
- ) -} - -export default CourseEditorInline; \ No newline at end of file diff --git a/src/main/webapp/react/university/courses/course-list.js b/src/main/webapp/react/university/courses/course-list.js deleted file mode 100644 index cfdc64c..0000000 --- a/src/main/webapp/react/university/courses/course-list.js +++ /dev/null @@ -1,58 +0,0 @@ -import CourseEditorInline from "./course-editor-inline"; -import courseService from "./course-service" - -const COURSE_URL = "http://localhost:8080/api/courses" -const { useState, useEffect } = React; - -const CourseList = () => { - const [courses, setCourses] = useState([]) - const [newCourse, setNewCourse] = useState({}) - useEffect(() => { - findAllCourses() - }, []) - const createCourse = (course) => - courseService.createCourse(course) - .then(course => { - setNewCourse({title:''}) - setCourses(courses => ([...courses, course])) - }) - const updateCourse = (id, newCourse) => - courseService.updateCourse(id, newCourse) - .then(course => setCourses(courses => (courses.map(course => course.id === id ? newCourse : course)))) - const findAllCourses = () => - courseService.findAllCourses() - .then(courses => setCourses(courses)) - const deleteCourse = (id) => - courseService.deleteCourse(id) - .then(courses => setCourses(courses => courses.filter(course => course.id !== id))) - return( -
-

Courses

-
    -
  • -
    -
    - setNewCourse(newCourse => ({...newCourse, title: e.target.value}))}/> -
    -
    - createCourse(newCourse)}> -
    -
    -
  • - { - courses.map(course => -
  • - -
  • ) - } -
-
- ) -} - -export default CourseList; \ No newline at end of file diff --git a/src/main/webapp/react/university/courses/course-service.js b/src/main/webapp/react/university/courses/course-service.js deleted file mode 100644 index a5a3aca..0000000 --- a/src/main/webapp/react/university/courses/course-service.js +++ /dev/null @@ -1,38 +0,0 @@ -const COURSE_URL = "http://localhost:8080/api/courses" - -export const createCourse = (course) => - fetch(COURSE_URL, { - method: 'POST', - body: JSON.stringify(course), - headers: {'content-type': 'application/json'} - }) - .then(response => response.json()) - -export const findAllCourses = () => - fetch(COURSE_URL) - .then(response => response.json()) - -export const findCourseById = (id) => - fetch(`${COURSE_URL}/${id}`) - .then(response => response.json()) - -export const updateCourse = (id, course) => - fetch(`${COURSE_URL}/${id}`, { - method: 'PUT', - body: JSON.stringify(course), - headers: {'content-type': 'application/json'} - }) - .then(response => response.json()) - -const deleteCourse = (id) => - fetch(`${COURSE_URL}/${id}`, { - method: "DELETE" - }) - -export default { - createCourse, - findAllCourses, - findCourseById, - updateCourse, - deleteCourse -} \ No newline at end of file diff --git a/src/main/webapp/react/university/courses/generic-editor.js b/src/main/webapp/react/university/courses/generic-editor.js deleted file mode 100644 index e0f8a7f..0000000 --- a/src/main/webapp/react/university/courses/generic-editor.js +++ /dev/null @@ -1,47 +0,0 @@ -const {useState, useEffect} = React -const {useParams} = window.ReactRouterDOM; -const COURSE_URL = "http://localhost:8080/api/courses" - -const CourseEditor = ( - { - schema = { - title: {type: "text"}, - // id: {type: "text"} - } - }) => { - const [item, setItem] = useState({}) - const {id} = useParams() - useEffect(() => { - findById(id) - }, []); - const findById = (id) => - fetch(`${COURSE_URL}/${id}`) - .then(response => response.json()) - .then(item => setItem(item)) - return ( -
-

Course Editor {id}

- {JSON.stringify(item)} -
    - { - Object.keys(item).map((key, ndx) => { - if(!schema[key]) return null - return( -
  • - { - - } - -
  • ) - - }) - } -
-
- ) -} - -export default CourseEditor \ No newline at end of file diff --git a/src/main/webapp/react/university/index.css b/src/main/webapp/react/university/index.css deleted file mode 100644 index b834b9e..0000000 --- a/src/main/webapp/react/university/index.css +++ /dev/null @@ -1,23 +0,0 @@ -.form-control { - /*margin-bottom: 10px;*/ -} - -.margin-bottom-10px { - margin-bottom: 10px; -} - -.margin-left-10px { - margin-left: 10px; -} - -.margin-right-10px { - margin-right: 10px; -} - -.float-right { - float: right; -} - -.float-left { - float: left; -} \ No newline at end of file diff --git a/src/main/webapp/react/university/index.html b/src/main/webapp/react/university/index.html deleted file mode 100644 index 06a4d20..0000000 --- a/src/main/webapp/react/university/index.html +++ /dev/null @@ -1,38 +0,0 @@ - - - React Hello World - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/webapp/react/university/index.js b/src/main/webapp/react/university/index.js deleted file mode 100644 index d364f5a..0000000 --- a/src/main/webapp/react/university/index.js +++ /dev/null @@ -1,30 +0,0 @@ -import CourseList from "./courses/course-list"; -import SectionList from "./sections/section-list"; -import CourseEditorForm from "./courses/course-editor-form"; -import SectionEditorForm from "./sections/section-editor-form"; - -const {HashRouter, Link, Route} = window.ReactRouterDOM; - -const App = () => { - console.log(window.ReactRouterDOM) - return ( -
- - - - - - - - - - - - - - -
- ); -} - -export default App; diff --git a/src/main/webapp/react/university/sections/section-editor-form.js b/src/main/webapp/react/university/sections/section-editor-form.js deleted file mode 100644 index 0f4b868..0000000 --- a/src/main/webapp/react/university/sections/section-editor-form.js +++ /dev/null @@ -1,82 +0,0 @@ -import sectionService from "./section-service" - -const {useState, useEffect} = React -const {useParams, useHistory} = window.ReactRouterDOM; - -const SectionEditorForm = () => { - const [section, setSection] = useState({}) - const {sectionId} = useParams() - const history = useHistory() - useEffect(() => { - findSectionById(sectionId) - }, []); - const findSectionById = (id) => - sectionService.findSectionById(id) - .then(section => setSection(section)) - const updateSection = (id, newSection) => - sectionService.updateSection(id, newSection) - .then(() => history.goBack()) - const deleteSection = (id) => - sectionService.deleteSection(id) - .then(() => history.goBack()) - - return ( -
-

- Section Editor -

- - - - setSection(section => ({...section, name: e.target.value}))} - value={section.name}/> - - setSection(section => ({...section, seats: parseInt(e.target.value)}))}/> - - - - setSection(section => ({...section, year: parseInt(e.target.value)}))}/> - -
- - - -
- ) -} - -export default SectionEditorForm \ No newline at end of file diff --git a/src/main/webapp/react/university/sections/section-editor-inline.js b/src/main/webapp/react/university/sections/section-editor-inline.js deleted file mode 100644 index f7098a0..0000000 --- a/src/main/webapp/react/university/sections/section-editor-inline.js +++ /dev/null @@ -1,111 +0,0 @@ -const {useState, useEffect } = React; -const {Link} = window.ReactRouterDOM; - -const SectionEditorInline = ({section, deleteSection, updateSection}) => { - const [sectionCopy, setSectionCopy] = useState(section) - const [editing, setEditing] = useState(false) - return( -
- { - editing && -
-
- setSectionCopy(sectionCopy => ({...sectionCopy, name: e.target.value}))}/> -
-
- setSectionCopy(sectionCopy => ({...sectionCopy, seats: parseInt(e.target.value)}))}/> -
-
- -
-
- setSectionCopy(sectionCopy => ({...sectionCopy, year: parseInt(e.target.value)}))}/> -
-
- -
-
- setSectionCopy(sectionCopy => ({...sectionCopy, startDate: e.target.value}))}/> -
-
- { - setEditing(false) - updateSection(sectionCopy.id, sectionCopy) - }}> - setEditing(false)}> - deleteSection(section.id)}> -
-
- } - { - !editing && -
-
- - {sectionCopy.name} - -
-
- - {sectionCopy.seats} - -
-
- - {sectionCopy.semester} - -
-
- - {sectionCopy.year} - -
-
- - {sectionCopy.online && 'Online'} - {!sectionCopy.online && 'On Campus'} - -
-
- setEditing(true)}> -
-
- } -
- ) -} - -export default SectionEditorInline; \ No newline at end of file diff --git a/src/main/webapp/react/university/sections/section-list.js b/src/main/webapp/react/university/sections/section-list.js deleted file mode 100644 index 98bb5c7..0000000 --- a/src/main/webapp/react/university/sections/section-list.js +++ /dev/null @@ -1,67 +0,0 @@ -import SectionEditorInline from "./section-editor-inline"; -import sectionService, {createSectionForCourse} from "./section-service" - -const COURSE_URL = "http://localhost:8080/api/sections" -const { useState, useEffect } = React; -const {Link, useParams, useHistory} = window.ReactRouterDOM; - -const SectionList = () => { - const [sections, setSections] = useState([]) - const [newSection, setNewSection] = useState({}) - const {courseId} = useParams() - useEffect(() => { - findSectionsForCourse(courseId) - }, []) - const createSectionForCourse = (section) => - sectionService.createSectionForCourse(courseId, section) - .then(section => { - setNewSection({name:''}) - setSections(sections => ([...sections, section])) - }) - const updateSection = (id, newSection) => - sectionService.updateSection(id, newSection) - .then(section => setSections(sections => (sections.map(section => section.id === id ? newSection : section)))) - const findSectionsForCourse = (courseId) => - sectionService.findSectionsForCourse(courseId) - .then(sections => setSections(sections)) - const deleteSection = (id) => - sectionService.deleteSection(id) - .then(sections => setSections(sections => sections.filter(section => section.id !== id))) - return( -
-

- history.back()}> - - - Sections -

-
    -
  • -
    -
    - setNewSection(newSection => ({...newSection, name: e.target.value}))}/> -
    -
    - createSectionForCourse(newSection)}> -
    -
    -
  • - { - sections.map(section => -
  • - -
  • ) - } -
-
- ) -} - -export default SectionList; \ No newline at end of file diff --git a/src/main/webapp/react/university/sections/section-service.js b/src/main/webapp/react/university/sections/section-service.js deleted file mode 100644 index 195cb5c..0000000 --- a/src/main/webapp/react/university/sections/section-service.js +++ /dev/null @@ -1,39 +0,0 @@ -const COURSE_URL = "http://localhost:8080/api/courses" -const SECTION_URL = "http://localhost:8080/api/sections" - -export const createSectionForCourse = (courseId, section) => - fetch(`${COURSE_URL}/${courseId}/sections`, { - method: 'POST', - body: JSON.stringify(section), - headers: {'content-type': 'application/json'} - }) - .then(response => response.json()) - -export const findSectionsForCourse = (courseId) => - fetch(`${COURSE_URL}/${courseId}/sections`) - .then(response => response.json()) - -export const findSectionById = (id) => - fetch(`${SECTION_URL}/${id}`) - .then(response => response.json()) - -export const updateSection = (id, section) => - fetch(`${SECTION_URL}/${id}`, { - method: 'PUT', - body: JSON.stringify(section), - headers: {'content-type': 'application/json'} - }) - .then(response => response.json()) - -const deleteSection = (id) => - fetch(`${SECTION_URL}/${id}`, { - method: "DELETE" - }) - -export default { - createSectionForCourse, - findSectionsForCourse, - findSectionById, - updateSection, - deleteSection -} \ No newline at end of file diff --git a/src/main/webapp/react/users/app.js b/src/main/webapp/react/users/app.js deleted file mode 100644 index 73a67c7..0000000 --- a/src/main/webapp/react/users/app.js +++ /dev/null @@ -1,17 +0,0 @@ -import Users from "./users"; - -const {HashRouter, Route} = window.ReactRouterDOM; - -const App = () => { - return ( -
- - - - - -
- ); -} - -export default App; diff --git a/src/main/webapp/react/users/user.js b/src/main/webapp/react/users/user.js deleted file mode 100644 index b94bbb7..0000000 --- a/src/main/webapp/react/users/user.js +++ /dev/null @@ -1,32 +0,0 @@ -const { useState, useEffect } = React; - -const User = ({user, deleteUser, updateUser}) => { - const [userCopy, setUserCopy] = useState(user) - const [editing, setEditing] = useState(false) - return( -
- { - editing && -
- setUserCopy(userCopy => ({...userCopy, firstName: e.target.value}))}/> - setUserCopy(userCopy => ({...userCopy, lastName: e.target.value}))}/> - - -
- } - { - !editing && -
- {userCopy.firstName} - {userCopy.lastName} - -
- } -
- ) -} - -export default User; \ No newline at end of file diff --git a/src/main/webapp/react/users/users.html b/src/main/webapp/react/users/users.html deleted file mode 100644 index dbb1b6f..0000000 --- a/src/main/webapp/react/users/users.html +++ /dev/null @@ -1,25 +0,0 @@ - - - React Hello World - - - -
- - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/webapp/react/users/users.js b/src/main/webapp/react/users/users.js deleted file mode 100644 index c881cd5..0000000 --- a/src/main/webapp/react/users/users.js +++ /dev/null @@ -1,54 +0,0 @@ -import User from "./user"; - -const { useState, useEffect } = React; - -const Users = () => { - const [users, setUsers] = useState([]) - const [newUser, setNewUser] = useState({}) - const createUser = (user) => - fetch(`https://wbdv-generic-server.herokuapp.com/api/jannunzi/users`, { - method: 'POST', - body: JSON.stringify(user), - headers: {'content-type': 'application/json'} - }) - .then(response => response.json()) - .then(user => setUsers(users => ([...users, user]))) - const updateUser = (id, newUser) => - fetch(`http://localhost:8080/orm/update/user/${id}/${newUser.password}`) - .then(response => response.json()) - .then(user => setUsers(users => (users.map(user => user._id === id ? newUser : user)))) - const findAllUsers = () => - fetch(`http://localhost:8080/orm/find/users`) - .then(response => response.json()) - .then(users => setUsers(users)) - const deleteUser = (id) => - fetch(`https://wbdv-generic-server.herokuapp.com/api/jannunzi/users/${id}`, { - method: "DELETE" - }) - .then(response => response.json()) - .then(users => setUsers(users => users.filter(user => user._id !== id))) - useEffect(() => { - findAllUsers() - }, []) - return( -
-

Users {users.length}

- setNewUser(newUser => ({...newUser, title: e.target.value}))}/> - setNewUser(newUser => ({...newUser, owner: e.target.value}))}/> - - { - users.map(user => - ) - } -
- ) -} - -export default Users; - -