/voll.med-api

Voll Med API Rest

Primary LanguageJava

Voll.Med API Rest

⚙ Features

  • Authenticate user
  • Doctors CRUD;
  • Patient CRUD;
  • Appointments booking;
  • Appointment Cancellation;

🔮 Technologies

💼 Business Rules

Appointmets

  • O horário de funcionamento da clínica é de segunda a sábado, das 07:00 às 19:00;
  • As consultas tem duração fixa de 1 hora;
  • As consultas devem ser agendadas com antecedência mínima de 30 minutos;
  • Não permitir o agendamento de consultas com pacientes inativos no sistema;
  • Não permitir o agendamento de consultas com médicos inativos no sistema;
  • Não permitir o agendamento de mais de uma consulta no mesmo dia para um mesmo paciente;
  • Não permitir o agendamento de uma consulta com um médico que já possui outra consulta agendada na mesma data/hora;
  • A escolha do médico é opcional, sendo que nesse caso o sistema deve escolher aleatoriamente algum médico disponível na data/hora preenchida.

📝 Notes

  • @RestController annotation - tells spring that the class is a rest controller and load during the project initialization
  • @RequestMapping annotation - tells spring which url the controller will be called
  • @MethodMapping annotation - tells which class method will be called for HTTP request
    • @GetMapping - HTTP Get method
    • @PostMapping - HTTP Post method
    • @PutMapping - HTTP Put method
    • @DeleteMapping - HTTP Delete method
    • @PatchMapping - HTTP Patch method
  • @Transactional annotation - tells spring that the method can write on the DB

Filter


Enable different origins on Spring Boot

Create a CrosConfiguration class implementing the WebMvcConfigurerpassing the addMapping (url), allowedOrigins and allowedMethods.@

@Configuration
public class CorsConfiguration implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
            .allowedOrigins("http://localhost:3000")
            .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS", "HEAD", "TRACE", "CONNECT");
    }
}

Can use application.yml to configure the spring

  spring:
    datasource:
      driver-class-name: com.mysql.cj.jdbc.Driver
      url: jdbc:mysql://localhost:3306/databaseName
      username: root
      password: root

Change the default parameters names

spring.data.web.pageable.page-parameter=pagina
spring.data.web.pageable.size-parameter=tamanho
spring.data.web.sort.sort-parameter=ordem