Newer
Older
IrisServer / src / main / java / com / ntlab / irisserver / resources / AssignmentRest.java
g-akagi on 10 Jun 2022 1 KB assingmentRestが多分完成
package com.ntlab.irisserver.resources;

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

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.util.List;

@Component
@Path("/rooms")
public class AssignmentRest {
    //GETでニックネームを貰うと、いま書いてほしいdnoを返す
    @GET
    @Path("/{rid}/game/drawings/assignment/{nickname}")
    @Produces(MediaType.APPLICATION_JSON)
    public int getDno(@PathParam("rid") String rid,@PathParam("nickname") String nickname ) {

        RoomManager rm = RoomManager.getInstance();
        Room room = rm.getRoom(rid);
        Game game = room.getGame();
        DrawingController drawingController = game.getDrawingController();

        int dno = 0;
        dno = drawingController.getDno(nickname);

        return dno;
    }
}