package org.xcolab.service.members.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import org.xcolab.model.tables.pojos.PlatformTeam;
import org.xcolab.service.members.domain.platformteam.PlatformTeamDao;

import java.util.List;

@RestController
@RequestMapping("/platformteams")
public class PlatformTeamsController {
    private final PlatformTeamDao platformTeamDao;

    @Autowired
    public PlatformTeamsController(PlatformTeamDao platformTeamDao) {
        this.platformTeamDao = platformTeamDao;
    }

    @GetMapping
    public List<PlatformTeam> listPlatformTeams() {
        return platformTeamDao.getPlatformTeams();
    }
}

@@ -128,38 +128,506 @@
 ork.
-web.bind.annotation.GetMapping
+boot.context.config.ResourceNotFoundException;%0Aimport org.springframework.http.HttpStatus;%0Aimport org.springframework.http.ResponseEntity;%0Aimport org.springframework.web.bind.annotation.DeleteMapping;%0Aimport org.springframework.web.bind.annotation.GetMapping;%0Aimport org.springframework.web.bind.annotation.PathVariable;%0Aimport org.springframework.web.bind.annotation.PostMapping;%0Aimport org.springframework.web.bind.annotation.PutMapping;%0Aimport org.springframework.web.bind.annotation.RequestBody
 ;%0Aim
@@ -679,32 +679,93 @@
 RequestMapping;%0A
+import org.springframework.web.bind.annotation.RequestParam;%0A
 import org.sprin
@@ -812,16 +812,61 @@
 oller;%0A%0A
+import org.xcolab.model.tables.pojos.Member;%0A
 import o
@@ -1002,16 +1002,43 @@
 il.List;
+%0Aimport java.util.Optional;
 %0A%0A@RestC
@@ -1376,24 +1376,24 @@
 rmTeams() %7B%0A
-
         retu
@@ -1436,11 +1436,1746 @@
 );%0A    %7D
+%0A%0A    @PostMapping%0A    public PlatformTeam createPlatformTeam(@RequestBody PlatformTeam platformTeam) %7B%0A        return platformTeamDao.createPlatformTeam(platformTeam.getName());%0A    %7D%0A%0A    @GetMapping(%22%7BteamId%7D%22)%0A    public ResponseEntity%3CPlatformTeam%3E getPlatformTeam(@PathVariable Long teamId) %7B%0A        Optional%3CPlatformTeam%3E team = platformTeamDao.getPlatformTeam(teamId);%0A        return team.map(platformTeam -%3E new ResponseEntity%3C%3E(platformTeam, HttpStatus.OK))%0A                .orElseGet(() -%3E new ResponseEntity%3C%3E(HttpStatus.NOT_FOUND));%0A    %7D%0A%0A    @DeleteMapping(%22%7BteamId%7D%22)%0A    public boolean deletePlatformTeam(@PathVariable Long teamId)%0A    %7B%0A        return platformTeamDao.delete(teamId) %3E 0;%0A    %7D%0A%0A    @PutMapping(%22%7BteamId%7D%22)%0A    public PlatformTeam updatePlatformTeam(@RequestBody PlatformTeam platformTeam, @PathVariable%0A            Long teamId) %7B%0A        assert (platformTeam.getId_().equals(teamId));%0A        return platformTeamDao.updatePlatformTeam(platformTeam);%0A    %7D%0A%0A    @GetMapping(%22%7BteamId%7D/members%22)%0A    public List%3CMember%3E listTeamMembers(@PathVariable Long teamId) %7B%0A        return platformTeamDao.getTeamMembers(teamId);%0A    %7D%0A%0A    @GetMapping(%22teams/%7BuserId%7D%22)%0A    public List%3CPlatformTeam%3E listTeamsForUser(@PathVariable Long userId) %7B%0A        return platformTeamDao.getUserTeams(userId);%0A    %7D%0A%0A    @PutMapping(%22%7BteamId%7D/members/%7BuserId%7D%22)%0A    public boolean addMember(@PathVariable Long teamId, @PathVariable Long userId) %7B%0A        return platformTeamDao.addMember(teamId, userId) %3E 0;%0A    %7D%0A%0A    @DeleteMapping(%22%7BteamId%7D/members/%7BuserId%7D%22)%0A    public boolean removeMember(@PathVariable Long teamId, @PathVariable Long userId) %7B%0A        return platformTeamDao.removeMember(teamId, userId) %3E 0;%0A    %7D
 %0A%7D%0A

implement backend teams controller