Newer
Older
IrisServer / src / main / java / com / ntlab / irisserver / resources / MemberRest.java
package com.ntlab.irisserver.resources;

import com.ntlab.irisserver.entities.Member;
import com.ntlab.irisserver.entities.Room;
import com.ntlab.irisserver.models.RoomManager;
import org.springframework.stereotype.Component;

import javax.ws.rs.*;
import java.util.List;

@Component
@Path("/rooms")
public class MemberRest {
    // チーム変更・役職変更のメソッド
    @Path("/{rid}/members/{nickname}")
    @PUT
    public String putMember(@PathParam("rid") String rid, @PathParam("nickname") String nickname,
                            @FormParam("belongs") String belongs, @FormParam("is-master") boolean is_master) {
        RoomManager rm = RoomManager.getInstance();
        Room room = rm.getRoom(rid);
        room.changeTeamAndMaster(nickname, belongs, is_master);
        return "変更しました";
    }

    // プレイヤーを退出させるメソッド
    @Path("/{rid}/members/{nickname}")
    @DELETE
    public String deleteMember(@PathParam("rid") String rid, @PathParam("nickname") String nickname) {
        RoomManager rm = RoomManager.getInstance();
        Room room = rm.getRoom(rid);
        room.deleteMember(nickname);
        return "退出しました";
    }
}