Puja controller, puja repository , puja service. todo eso se ajusto para mostrar las n ultimas pujas
Some checks failed
Deploy Spring Boot App / build-and-deploy (push) Has been cancelled
Some checks failed
Deploy Spring Boot App / build-and-deploy (push) Has been cancelled
This commit is contained in:
@@ -32,6 +32,21 @@ public class PujaController {
|
||||
public List<Puja> getForInforme(@PathVariable Long remateId){
|
||||
return pujaService.fingForReporte(remateId);
|
||||
}
|
||||
|
||||
@GetMapping("/informe/npujas/{remateId}")
|
||||
public ResponseEntity<List<Puja>> getReporteTopPujas(
|
||||
@PathVariable Long remateId,
|
||||
@RequestParam(defaultValue = "3") int limite) {
|
||||
|
||||
List<Puja> reporte = pujaService.findForNPujasReporte(remateId, limite);
|
||||
|
||||
if (reporte.isEmpty()) {
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
|
||||
return ResponseEntity.ok(reporte);
|
||||
}
|
||||
|
||||
@GetMapping("/remate/{id}")
|
||||
public List<Puja> getForRemate(@PathVariable Long id){
|
||||
return pujaService.findForRemtae(id);
|
||||
|
||||
@@ -35,4 +35,16 @@ public interface PujaRepository extends JpaRepository<Puja, Long> {
|
||||
""", nativeQuery = true)
|
||||
List<Puja> findMayorPujaPorLotePorRemateNative(Long remateId);
|
||||
|
||||
@Query(value = """
|
||||
SELECT p.* FROM (
|
||||
SELECT *,
|
||||
ROW_NUMBER() OVER (PARTITION BY lote_id ORDER BY monto DESC) as posicion
|
||||
FROM pujas
|
||||
WHERE lote_id IN (SELECT id FROM lotes WHERE remate_id = :remateId)
|
||||
) p
|
||||
WHERE p.posicion <= :limite
|
||||
ORDER BY p.lote_id, p.posicion
|
||||
""", nativeQuery = true)
|
||||
List<Puja> findTopNPujasPorLotePorRemateNative(Long remateId, int limite);
|
||||
|
||||
}
|
||||
|
||||
@@ -54,6 +54,10 @@ public class PujaService {
|
||||
public List<Puja> fingForReporte(Long id){
|
||||
return pujaRepository.findMayorPujaPorLotePorRemateNative(id);
|
||||
}
|
||||
|
||||
public List<Puja> findForNPujasReporte(Long id, int limite){
|
||||
return pujaRepository.findTopNPujasPorLotePorRemateNative(id,limite);
|
||||
}
|
||||
public Optional<Puja> findById(Long id) {
|
||||
return pujaRepository.findById(id);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
spring.application.name=fercoganbackend
|
||||
spring.profiles.active=prod
|
||||
spring.profiles.active=dev
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
|
||||
Reference in New Issue
Block a user