Esta dando erro 403 na hora de fazer a consulta, na hora de cadastrar ou listar o token funciona mas no, metode de consulta nao esta funcionando assim estao o crontroller, DTOs e JPA`package med.absolut.api.controller;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;
import jakarta.transaction.Transactional; import jakarta.validation.Valid; import med.absolut.api.consulta.ConsultaRepository; import med.absolut.api.consulta.DadosAgendamento; import med.absolut.api.consulta.DadosDetalhamentoConsulta;
@RestController @RequestMapping("/consultas") public class ConsultaController {
@Autowired
private ConsultaRepository repository;
@PostMapping
@Transactional
public ResponseEntity agendar(@RequestBody @Valid DadosAgendamento dados) {
return ResponseEntity.ok(new DadosDetalhamentoConsulta(null, null, null, null));
}
} `
package med.absolut.api.consulta;
import java.time.LocalDateTime;
public record DadosDetalhamentoConsulta(Long id, Long idMedico, Long idPaciente, LocalDateTime data) {
}
package med.absolut.api.consulta;
import java.time.LocalDateTime;
import jakarta.validation.constraints.Future;
import jakarta.validation.constraints.NotNull;
public record DadosAgendamento(
Long idMedicos,
@NotNull
Long idPacientes,
@NotNull
@Future
LocalDateTime data
) {
}
package med.absolut.api.consulta;
import java.time.LocalDateTime;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import med.absolut.api.medico.Medico;
import med.absolut.api.paciente.Paciente;
@Table(name = "consultas")
@Entity(name = "Consulta")
@Getter
@NoArgsConstructor
@EqualsAndHashCode(of = "id")
public class Consulta {
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "medicos_id")
private Medico medico;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "pacientes_id")
private Paciente paciente;
private LocalDateTime data;
}
package med.absolut.api.consulta;
import org.springframework.data.jpa.repository.JpaRepository;
public interface ConsultaRepository extends JpaRepository<Consulta, Long>{
}