use of com.mapia.domain.User in project 2017-01-HUDI-MAC-CHAR by NHNNEXT.
the class UserRepository method findUserByNickname.
public User findUserByNickname(String nickname) {
String query = "SELECT * FROM User WHERE nickname = ?";
List<User> resultUser;
try {
resultUser = jdbcTemplate.query(query, (rs, rowNum) -> {
User user = new User();
user.setId(rs.getLong("id"));
user.setEmail(rs.getString("email"));
user.setPassword(rs.getString("password"));
user.setNickname(rs.getString("nickname"));
return user;
}, nickname);
} catch (EmptyResultDataAccessException e) {
log.error(e.getMessage());
return null;
}
return resultUser.size() > 0 ? resultUser.get(0) : null;
}
use of com.mapia.domain.User in project 2017-01-HUDI-MAC-CHAR by NHNNEXT.
the class RoomController method enter.
@GetMapping("/{id}")
public String enter(@PathVariable long id, HttpSession session, Model model) {
if (!HttpSessionUtils.isLoginUser(session)) {
return "redirect:/login";
}
User user = HttpSessionUtils.getUserFromSession(session);
if (!lobby.isExistRoom(id)) {
session.removeAttribute(HttpSessionUtils.USER_SESSION_KEY);
if (!user.isLobby()) {
exitUserFromRoom(user);
}
return "redirect:/";
}
Room room = lobby.getRoom(id);
if (!user.isAbleToEnter(id)) {
session.removeAttribute(HttpSessionUtils.USER_SESSION_KEY);
exitUserFromRoom(user);
return "redirect:/";
}
if (room.isFull()) {
return "redirect:/lobby";
}
if (room.isSecretMode()) {
//TODO Add secret mode logic
}
// room.getUsers().forEach(ser -> ser.ready()); // FOR TEST USE ONLY
room.enter(user);
model.addAttribute("room", room);
model.addAttribute("user", user);
return "room";
}
use of com.mapia.domain.User in project 2017-01-HUDI-MAC-CHAR by NHNNEXT.
the class RoomController method exit.
@DeleteMapping("")
public String exit(HttpSession session) {
User user = HttpSessionUtils.getUserFromSession(session);
exitUserFromRoom(user);
return "redirect:/lobby";
}
use of com.mapia.domain.User in project 2017-01-HUDI-MAC-CHAR by NHNNEXT.
the class GameManagerTest method assignRole.
@Test
public void assignRole() {
users.add(new User());
users.add(new User());
users.add(new User());
users.add(new User());
users.add(new User());
GameManager gm = new GameManager(users);
}
use of com.mapia.domain.User in project 2017-01-HUDI-MAC-CHAR by NHNNEXT.
the class ApiRoomController method enter.
@GetMapping("/{id}")
public RoomResult enter(@PathVariable long id, HttpSession session, Model model) {
if (!HttpSessionUtils.isLoginUser(session)) {
return RoomResult.invalidAccess(id);
}
User user = HttpSessionUtils.getUserFromSession(session);
if (!lobby.isExistRoom(id)) {
session.removeAttribute(HttpSessionUtils.USER_SESSION_KEY);
if (!user.isLobby()) {
exitUserFromRoom(user);
}
return RoomResult.invalidAccess(id);
}
Room room = lobby.getRoom(id);
if (!user.isAbleToEnter(id)) {
session.removeAttribute(HttpSessionUtils.USER_SESSION_KEY);
exitUserFromRoom(user);
return RoomResult.invalidAccess(id);
}
if (room.isFull()) {
return RoomResult.rejectToEnterRoomOfFull(id);
}
if (room.isSecretMode()) {
//TODO Add secret mode logic
}
room.enter(user);
model.addAttribute("room", room);
model.addAttribute("user", user);
return RoomResult.successToEnterRoom(id);
}
Aggregations