Added time logic and edited several buttons in hod panel

This commit is contained in:
2026-07-02 08:49:32 +05:30
parent 31fcc27658
commit 2f18d432e7
4 changed files with 333 additions and 11 deletions

View File

@@ -34,6 +34,17 @@ public class EventController {
List<Registration> regs = registrationRepository.findAll();
for (Event event : events) {
if (event.getStartDate() != null) {
String sd = event.getStartDate().replace(" ", "T");
if (!sd.endsWith("Z")) sd += "Z";
event.setStartDate(sd);
}
if (event.getEndDate() != null) {
String ed = event.getEndDate().replace(" ", "T");
if (!ed.endsWith("Z")) ed += "Z";
event.setEndDate(ed);
}
int count = (int) regs.stream()
.filter(r -> r.getEventId() != null && r.getEventId().equals(event.getId()))
.count();

View File

@@ -28,16 +28,25 @@ public class RegistrationController {
public List<Registration> getRegistrations(@RequestParam(required = false) Long userId,
@RequestParam(required = false) Long eventId,
@RequestParam(required = false) String teamCode) {
List<Registration> list;
if (userId != null) {
return registrationRepository.findByUserId(userId);
list = registrationRepository.findByUserId(userId);
} else if (eventId != null) {
list = registrationRepository.findByEventId(eventId);
} else if (teamCode != null) {
list = registrationRepository.findByTeamCode(teamCode);
} else {
list = registrationRepository.findAll();
}
if (eventId != null) {
return registrationRepository.findByEventId(eventId);
for (Registration reg : list) {
if (reg.getRegisteredAt() != null) {
String ra = reg.getRegisteredAt().replace(" ", "T");
if (!ra.endsWith("Z")) ra += "Z";
reg.setRegisteredAt(ra);
}
}
if (teamCode != null) {
return registrationRepository.findByTeamCode(teamCode);
}
return registrationRepository.findAll();
return list;
}
@PostMapping

View File

@@ -21,6 +21,23 @@ public class SpecialEventController {
@GetMapping
public List<SpecialEvent> getAllSpecialEvents() {
List<SpecialEvent> list = specialEventRepository.findAll();
for (SpecialEvent se : list) {
if (se.getStartDate() != null) {
String sd = se.getStartDate().replace(" ", "T");
if (!sd.endsWith("Z")) sd += "Z";
se.setStartDate(sd);
}
if (se.getEndDate() != null) {
String ed = se.getEndDate().replace(" ", "T");
if (!ed.endsWith("Z")) ed += "Z";
se.setEndDate(ed);
}
if (se.getCreatedAt() != null) {
String ca = se.getCreatedAt().replace(" ", "T");
if (!ca.endsWith("Z")) ca += "Z";
se.setCreatedAt(ca);
}
}
list.sort((a, b) -> {
String ca = a.getCreatedAt() != null ? a.getCreatedAt() : "";
String cb = b.getCreatedAt() != null ? b.getCreatedAt() : "";