diff --git a/src/main/java/com/ntlab/irisserver/resources/MembersRest.java b/src/main/java/com/ntlab/irisserver/resources/MembersRest.java index 1239ede..95d7e3c 100644 --- a/src/main/java/com/ntlab/irisserver/resources/MembersRest.java +++ b/src/main/java/com/ntlab/irisserver/resources/MembersRest.java @@ -35,6 +35,8 @@ //Listの0番目と1番目をチームマスターにする if(i==0 || i==1){ info.setMaster(true); + }else{ + info.setMaster(false); } //Listの偶数番目を"r"(赤)に、奇数番目を"b"(青)にする @@ -56,12 +58,12 @@ List gm = room.getMembers(); //引数で取ってきたnicknameがownerかどうか確認 -/* - if(nickname != room.ownerName) { + + if(nickname != room.getOwnerName()) { var response = Response.status(401).entity("あなたはオーナーではありません"); throw new WebApplicationException(response.build()); } -*/ + //全員の役職を変更 membershuffle(gm); @@ -72,22 +74,16 @@ //自分のnicknameを送り、Roomに追加 @POST @Path("/{rid}/members") - public void postMembers(@PathParam("rid") String rid, @FormParam("nickname") String nickname) { + @Produces(MediaType.APPLICATION_JSON) + public Room postMembers(@PathParam("rid") String rid, @FormParam("nickname") String nickname) { RoomManager rm = RoomManager.getInstance(); Room room = rm.getRoom(rid); - List m = room.getMembers(); //引数で取ってきたnicknameがListに存在しているか確認 -/* - for(int i=0; i<10; i++){ - Member info = m.get(i); - if(info.getNickname() == nickname) { - var response = Response.status(401).entity("入力したnicknameは既に存在しています"); - throw new WebApplicationException(response.build()); - } - } -*/ - room.addMember(nickname); + if(room.getMember(nickname)==null)room.addMember(nickname); + + return room; + }