Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1-create table for medtype cihat patch 1 #3

Merged
merged 3 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@
<artifactId>jakarta.persistence-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<version>2.4.4</version> <!-- Use the latest version available -->
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.production.ehayvanbackendapi.Configurations;
import org.modelmapper.ModelMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
public class AppConfig {
@Bean
public ModelMapper modelMapper() {
return new ModelMapper();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.production.ehayvanbackendapi.Controllers;

import com.production.ehayvanbackendapi.DTO.AppointmentDTO;
import com.production.ehayvanbackendapi.Entities.Appointment;
import com.production.ehayvanbackendapi.Mappers.AppointmentMapper;
import com.production.ehayvanbackendapi.Services.AppointmentService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.stream.Collectors;

@RestController
@RequestMapping("/api/appointments")
public class AppointmentController {
private final AppointmentService appointmentService;

public AppointmentController(AppointmentService appointmentService) {
this.appointmentService = appointmentService;
}


@GetMapping("/{id}")
public ResponseEntity<AppointmentDTO> getAppointmentById(@PathVariable Integer id) {
AppointmentDTO appointmentDTO = appointmentService.getAppointmentById(id);

if (appointmentDTO != null) {
return new ResponseEntity<>(appointmentDTO, HttpStatus.OK);
} else {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
}

@PostMapping
public ResponseEntity<AppointmentDTO> createAppointment(@RequestBody AppointmentDTO appointmentDTO) {
AppointmentDTO createdAppointment = appointmentService.createAppointment(appointmentDTO);
return new ResponseEntity<>(createdAppointment, HttpStatus.CREATED);
}

// Other controller methods for creating, updating, and deleting appointments
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.production.ehayvanbackendapi.Controllers;

import com.production.ehayvanbackendapi.DTO.CustomerDTO;
import com.production.ehayvanbackendapi.Services.CustomerService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/customers")
public class CustomerController {
private final CustomerService customerService;

public CustomerController(CustomerService customerService) {
this.customerService = customerService;
}

@GetMapping("/{id}")
public ResponseEntity<CustomerDTO> getCustomerById(@PathVariable Integer id) {
CustomerDTO customerDTO = customerService.getCustomerById(id);

if (customerDTO != null) {
return new ResponseEntity<>(customerDTO, HttpStatus.OK);
} else {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
}

@PostMapping
public ResponseEntity<CustomerDTO> createCustomer(@RequestBody CustomerDTO customerDTO) {
CustomerDTO createdCustomer = customerService.createCustomer(customerDTO);
return new ResponseEntity<>(createdCustomer, HttpStatus.CREATED);
}

// Other controller methods for creating, updating, and deleting customers
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.production.ehayvanbackendapi.Controllers;

import com.production.ehayvanbackendapi.DTO.MedicationDTO;
import com.production.ehayvanbackendapi.Services.MedicationService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

public class MedicationController {
private final MedicationService medicationService;

public MedicationController(MedicationService medicationService) {
this.medicationService = medicationService;
}
@GetMapping("/{id}")
public ResponseEntity<MedicationDTO> getMedicationById(@PathVariable Integer id) {
MedicationDTO medicationDTO = medicationService.getMedicationById(id);

if (medicationDTO != null) {
return new ResponseEntity<>(medicationDTO, HttpStatus.OK);
} else {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
}
@PostMapping
public ResponseEntity<MedicationDTO> saveMedication(@RequestBody MedicationDTO medicationDTO) {
MedicationDTO savedMedication = medicationService.saveMedication(medicationDTO);
return new ResponseEntity<>(savedMedication, HttpStatus.CREATED);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.production.ehayvanbackendapi.DTO;

import java.util.Date;

public class AppointmentDTO {
private Integer appointmentID;
private Integer petOwnerID;
private Integer vetID;
private Integer petID;
private Date appointmentDate;


public AppointmentDTO(Integer appointmentID, Integer petOwnerID, Integer vetID, Integer petID, Date appointmentDate) {
this.appointmentID = appointmentID;
this.petOwnerID = petOwnerID;
this.vetID = vetID;
this.petID = petID;
this.appointmentDate = appointmentDate;
}

public Integer getAppointmentID() {
return appointmentID;
}

public void setAppointmentID(Integer appointmentID) {
this.appointmentID = appointmentID;
}

public Integer getPetOwnerID() {
return petOwnerID;
}

public void setPetOwnerID(Integer petOwnerID) {
this.petOwnerID = petOwnerID;
}

public Integer getVetID() {
return vetID;
}

public void setVetID(Integer vetID) {
this.vetID = vetID;
}

public Integer getPetID() {
return petID;
}

public void setPetID(Integer petID) {
this.petID = petID;
}

public Date getAppointmentDate() {
return appointmentDate;
}

public void setAppointmentDate(Date appointmentDate) {
this.appointmentDate = appointmentDate;
}




}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package com.production.ehayvanbackendapi.DTO;

public class CustomerDTO {
private Integer userID;
private String name;
private String surname;
private String email;
private String password;
private Integer userTypeID;
private Integer vetID;
private Integer ownerID;


public CustomerDTO(Integer userID, String name, String surname, String email,
String password, Integer userTypeID, Integer vetID, Integer ownerID) {
this.userID = userID;
this.name = name;
this.surname = surname;
this.email = email;
this.password = password;
this.userTypeID = userTypeID;
this.vetID = vetID;
this.ownerID = ownerID;
}



public Integer getUserID() {
return userID;
}

public void setUserID(Integer userID) {
this.userID = userID;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getSurname() {
return surname;
}

public void setSurname(String surname) {
this.surname = surname;
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public Integer getUserTypeID() {
return userTypeID;
}

public void setUserTypeID(Integer userTypeID) {
this.userTypeID = userTypeID;
}

public Integer getVetID() {
return vetID;
}

public void setVetID(Integer vetID) {
this.vetID = vetID;
}

public Integer getOwnerID() {
return ownerID;
}

public void setOwnerID(Integer ownerID) {
this.ownerID = ownerID;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.production.ehayvanbackendapi.DTO;

public class MedTypeDTO {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package com.production.ehayvanbackendapi.DTO;

public class MedicationDTO {
private Integer medicationID;
private String medicationName;
private Integer medTypeID;
private Integer scheduleID;
private Integer petID;


public MedicationDTO(Integer medicationID, String medicationName, Integer
medTypeID, Integer scheduleID, Integer petID) {
this.medicationID = medicationID;
this.medicationName = medicationName;
this.medTypeID = medTypeID;
this.scheduleID = scheduleID;
this.petID = petID;
}
public Integer getMedicationID() {
return medicationID;
}

public void setMedicationID(Integer medicationID) {
this.medicationID = medicationID;
}

public String getMedicationName() {
return medicationName;
}

public void setMedicationName(String medicationName) {
this.medicationName = medicationName;
}

public Integer getMedTypeID() {
return medTypeID;
}

public void setMedTypeID(Integer medTypeID) {
this.medTypeID = medTypeID;
}

public Integer getScheduleID() {
return scheduleID;
}

public void setScheduleID(Integer scheduleID) {
this.scheduleID = scheduleID;
}

public Integer getPetID() {
return petID;
}

public void setPetID(Integer petID) {
this.petID = petID;
}







}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.production.ehayvanbackendapi.DTO;

public class PetDTO {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.production.ehayvanbackendapi.DTO;

public class PetOwnerDTO {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.production.ehayvanbackendapi.DTO;

public class PetTypeDTO {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.production.ehayvanbackendapi.DTO;

public class ScheduleDTO {
}
Loading