Skip to content
Snippets Groups Projects
Commit c8298047 authored by Haoyu Sun's avatar Haoyu Sun
Browse files

try to use session

parent ae7b1fcb
Branches
No related tags found
1 merge request!54Resolve "As an administrator, I want to generate the matches automatically so that players are divided by the program"
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");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment