Skip to content
Snippets Groups Projects

Resolve "As an administrator, I want to generate the matches automatically so that players are divided by the program"

10 files
+ 433
38
Compare changes
  • Side-by-side
  • Inline
Files
10
package uk.ac.cf.spring.demo.sports.match;
import jakarta.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Controller;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
//import org.springframework.web.servlet.ModelAndView;
@@ -17,12 +20,12 @@ public class MatchController {
}
// get all Match List
@GetMapping
public List<MatchItem> getAllMenuItems() {
public List<MatchItem> getAllMatchItems() {
return matchService.getMatchItems();
}
// get Match by id
@GetMapping("/{id}")
public MatchItem getMenuItem(@PathVariable Long id) {
public MatchItem getMatchItem(@PathVariable Long id) {
return matchService.getMatchItemById(id);
}
@@ -44,8 +47,23 @@ public class MatchController {
public void deleteMatchItem(@PathVariable Long id) {
matchService.deleteMatchItem(id);
}
//fail to come true
// @PutMapping("/{id}")
// public ResponseEntity<String> updateMatchItem(@PathVariable Long id, @RequestBody MatchItem matchItem, HttpSession session) {
// Long userId = (Long) session.getAttribute("userId");
// if (userId == null) {
// return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body("{\"message\": \"User not logged in\"}");
// }
// if(matchItem.getPlayerAId() == 0) {
// matchItem.setPlayerAId(userId);
// }else {
// matchItem.setPlayerBId(userId);
// }
//
// matchItem.setId(id);
// matchService.updateMatchItem(matchItem);
// return ResponseEntity.ok("{\"message\": \"Match added successfully\"}");
// }
// @GetMapping("/match")
// public ModelAndView getMatch() {
// ModelAndView modelAndView = new ModelAndView("match/allMatchList");
Loading