past image issue resolve

This commit is contained in:
2025-11-21 09:39:27 +05:30
parent fdab880de2
commit 96f56fd1ca
4 changed files with 25 additions and 6 deletions

View File

@ -33,6 +33,17 @@ public class CourseController {
} }
} }
// Get all past/inactive courses (for public display)
@GetMapping("/past")
public ResponseEntity<List<Course>> getPastCourses() {
try {
List<Course> courses = courseRepository.findAllByIsActiveFalse();
return ResponseEntity.ok(courses);
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
}
// Get all courses (for admin) // Get all courses (for admin)
@GetMapping @GetMapping
public List<Course> getAllCourses() { public List<Course> getAllCourses() {

View File

@ -1,3 +1,4 @@
// EventController.java - FIXED
package net.shyshkin.study.fullstack.supportportal.backend.controller; package net.shyshkin.study.fullstack.supportportal.backend.controller;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -69,17 +70,17 @@ public class EventController {
} }
} }
// Additional endpoint to get upcoming events // Upcoming events - ACTIVE events ordered by date ASC
@GetMapping("/upcoming") @GetMapping("/upcoming")
public ResponseEntity<List<Event>> getUpcomingEvents() { public ResponseEntity<List<Event>> getUpcomingEvents() {
List<Event> events = eventRepository.findByIsActiveTrueOrderByDateAsc(); List<Event> events = eventRepository.findByIsActiveTrueOrderByDateAsc();
return new ResponseEntity<>(events, HttpStatus.OK); return new ResponseEntity<>(events, HttpStatus.OK);
} }
// Additional endpoint to get past events // FIXED: Past events - INACTIVE events ordered by date DESC
@GetMapping("/past") @GetMapping("/past")
public ResponseEntity<List<Event>> getPastEvents() { public ResponseEntity<List<Event>> getPastEvents() {
List<Event> events = eventRepository.findByIsActiveTrueOrderByDateDesc(); List<Event> events = eventRepository.findByIsActiveFalseOrderByDateDesc();
return new ResponseEntity<>(events, HttpStatus.OK); return new ResponseEntity<>(events, HttpStatus.OK);
} }
} }

View File

@ -1,4 +1,4 @@
// CourseRepository.java // CourseRepository.java - Add this method to your existing repository
package net.shyshkin.study.fullstack.supportportal.backend.repository; package net.shyshkin.study.fullstack.supportportal.backend.repository;
import net.shyshkin.study.fullstack.supportportal.backend.domain.Course; import net.shyshkin.study.fullstack.supportportal.backend.domain.Course;
@ -9,7 +9,13 @@ import java.util.List;
@Repository @Repository
public interface CourseRepository extends JpaRepository<Course, Long> { public interface CourseRepository extends JpaRepository<Course, Long> {
// Get all active courses
List<Course> findAllByIsActiveTrue(); List<Course> findAllByIsActiveTrue();
// Get all past/inactive courses - ADD THIS METHOD
List<Course> findAllByIsActiveFalse();
List<Course> findAllByCategory(String category); List<Course> findAllByCategory(String category);
List<Course> findAllByLevel(String level); List<Course> findAllByLevel(String level);
} }

View File

@ -1,3 +1,4 @@
// EventRepository.java - FIXED
package net.shyshkin.study.fullstack.supportportal.backend.repository; package net.shyshkin.study.fullstack.supportportal.backend.repository;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
@ -14,8 +15,8 @@ public interface EventRepository extends JpaRepository<Event, Long> {
// Find active events ordered by date ascending (for upcoming events) // Find active events ordered by date ascending (for upcoming events)
List<Event> findByIsActiveTrueOrderByDateAsc(); List<Event> findByIsActiveTrueOrderByDateAsc();
// Find active events ordered by date descending (for past events) // FIXED: Find INACTIVE events ordered by date descending (for past events)
List<Event> findByIsActiveTrueOrderByDateDesc(); List<Event> findByIsActiveFalseOrderByDateDesc();
// Find events by year // Find events by year
List<Event> findByYearAndIsActiveTrue(String year); List<Event> findByYearAndIsActiveTrue(String year);