Skip to content
Snippets Groups Projects
Commit 1aaca182 authored by Xiemuqing Xiao's avatar Xiemuqing Xiao
Browse files

Merge remote-tracking branch 'origin/28-registration-feature' into 28-registration-feature

parent 2e952015
No related branches found
No related tags found
4 merge requests!51Resolves 64,!49Resolve issue 70,!48Resolve issue 70,!47Revert "Merge branch '26-as-a-user-i-want-to-see-the-rankings-of-each-member' into 'main'"
package uk.ac.cf.spring.demo.sports.match;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/admin/matchitems")
public class MatchItemController {
@Autowired
private MatchItemService matchItemService;
@GetMapping
public List<Map<String, Object>> getAllMatchItems() {
return matchItemService.getAllMatchItems();
}
@PutMapping("/{id}")
public void updateMatchItemScore(@PathVariable long id, @RequestBody MatchItemUpdateRequest request) {
matchItemService.updateMatchItemScore(id, request.getScoreA(), request.getScoreB(), request.getWinnerId());
}
@DeleteMapping("/{id}")
public void deleteMatchItem(@PathVariable long id) {
matchItemService.deleteMatchItem(id);
}
}
class MatchItemUpdateRequest {
private int scoreA;
private int scoreB;
private long winnerId;
// Getters and setters
public int getScoreA() {
return scoreA;
}
public void setScoreA(int scoreA) {
this.scoreA = scoreA;
}
public int getScoreB() {
return scoreB;
}
public void setScoreB(int scoreB) {
this.scoreB = scoreB;
}
public long getWinnerId() {
return winnerId;
}
public void setWinnerId(long winnerId) {
this.winnerId = winnerId;
}
}
package uk.ac.cf.spring.demo.sports.match;
import java.util.List;
public interface MatchItemRepository {
// get match items
List<MatchItem> getMatchItems();
// get Match Item by id
MatchItem getMatchItemById(Long id);
// get MatchItem by sport
List<MatchItem> getMatchItemBySport(String sport);
// add MatchItem
void addMatchItem(MatchItem matchItem);
// update MatchItem
void updateMatchItem(MatchItem matchItem);
// delete MatchItem
void deleteMatchItem(Long id);
}
\ No newline at end of file
package uk.ac.cf.spring.demo.sports.match;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
@Service
public class MatchItemService {
@Autowired
private MatchItemRepository matchItemRepository;
public List<Map<String, Object>> getAllMatchItems() {
return matchItemRepository.getAllMatchItems();
}
public void updateMatchItemScore(long matchId, int scoreA, int scoreB, long winnerId) {
matchItemRepository.updateMatchItemScore(matchId, scoreA, scoreB, winnerId);
}
public void deleteMatchItem(long matchId) {
matchItemRepository.deleteMatchItem(matchId);
}
}
......@@ -19,8 +19,8 @@
<!-- <button class="subscribe-btn">Subscribe</button>-->
<!-- </div>-->
<div class="auth-buttons">
<a href="html/login.html" class="login-btn">Login</a>
<a href="html/signup.html" class="signup-btn">Sign Up</a>
<a href="http://localhost:8080/html/login.html" class="login-btn">Login</a>
<a href="http://localhost:8080/html/register.html" class="signup-btn">Sign Up</a>
<a href="html/subscribe.html" class="subscribe-btn">Subscribe</a>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment