세이브용 보강 (동작안함)

This commit is contained in:
pandoli365 2026-04-20 22:58:00 +09:00
parent 4285da6ba9
commit dd1407d8ca
4 changed files with 88 additions and 40 deletions

View File

@ -4,10 +4,10 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="96b9b4a5-b1bc-45b3-baf2-17942ad056f6" name="변경" comment="웹사이트 1차 제작">
<list default="true" id="96b9b4a5-b1bc-45b3-baf2-17942ad056f6" name="변경" comment="추상화 추가">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/dev/application.properties" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/dev/application.properties" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/live/application.properties" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/live/application.properties" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/pandoli365/bibimbap/config/WebMvcConfig.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/pandoli365/bibimbap/controller/WebMvcController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/pandoli365/bibimbap/web/GameController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/pandoli365/bibimbap/web/GameController.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -148,12 +148,21 @@
<option name="project" value="LOCAL" />
<updated>1776260511168</updated>
</task>
<option name="localTasksCounter" value="3" />
<task id="LOCAL-00003" summary="추상화 추가">
<option name="closed" value="true" />
<created>1776692795089</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1776692795089</updated>
</task>
<option name="localTasksCounter" value="4" />
<servers />
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="3차 초기화" />
<MESSAGE value="웹사이트 1차 제작" />
<option name="LAST_COMMIT_MESSAGE" value="웹사이트 1차 제작" />
<MESSAGE value="추상화 추가" />
<option name="LAST_COMMIT_MESSAGE" value="추상화 추가" />
</component>
</project>

View File

@ -1,14 +0,0 @@
package com.pandoli365.bibimbap.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("index");
}
}

View File

@ -0,0 +1,74 @@
package com.pandoli365.bibimbap.controller;
import com.pandoli365.bibimbap.game.GameCatalog;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
import org.springframework.context.annotation.Configuration;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.util.Arrays;
@Configuration
public class WebMvcController implements WebMvcConfigurer {
@RequestMapping("/{pageName}")
public ModelAndView mainView(@PathVariable("pageName") String pageName,
@RequestParam(required = false) String id,
HttpSession session,
HttpServletRequest request) {
ModelAndView mv = new ModelAndView();
// if (!ALLOWED_PAGES.contains(keyword)) {
// return new ModelAndView("redirect:/main");
// }
switch (pageName) {
default:
mv.setViewName("/index");
break;
}
return mv;
}
public static String webglUrlForGame(int gameId) {
return "/webgl/game-" + gameId + "/index.html";
}
@GetMapping("/game/{id}")
public String gameDetail(@PathVariable("id") int id, Model model) {
if (!GameCatalog.isValidId(id)) {
return "redirect:/";
}
int idx = GameCatalog.toIndex(id);
model.addAttribute("gameId", id);
model.addAttribute("gameName", GameCatalog.NAMES[idx]);
model.addAttribute("creator", GameCatalog.CREATORS[idx]);
model.addAttribute("likeCount", GameCatalog.LIKE_COUNTS[idx]);
model.addAttribute("likeCountFormatted", String.format("%,d", GameCatalog.LIKE_COUNTS[idx]));
model.addAttribute("creatorNote", GameCatalog.CREATOR_NOTES[idx]);
model.addAttribute("gitUrl", GameCatalog.GIT_URLS[idx]);
/* 데모: 공통 플레이스홀더. 실제 빌드는 static/webgl/game-{id}/ 에 두고 아래 한 줄을 webglUrlForGame(id) 로 바꾸면 됩니다. */
model.addAttribute("webglUrl", "/webgl/placeholder/index.html");
model.addAttribute("webglDeployPath", webglUrlForGame(id));
return "game-detail";
}
private boolean isMobileDevice(HttpServletRequest request) {
String userAgent = request.getHeader("User-Agent");
if (userAgent == null) {
return false; // User-Agent가 없는 경우 기본값은 false
}
// 모바일 User-Agent 리스트 (대표적인 기기들)
String[] mobileKeywords = {"Android", "iPhone", "iPad", "iPod", "Windows Phone", "Mobile", "Opera Mini", "BlackBerry"};
// User-Agent 문자열이 모바일 기기를 포함하는지 검사
return Arrays.stream(mobileKeywords).anyMatch(userAgent::contains);
}
}

View File

@ -9,26 +9,5 @@ import org.springframework.web.bind.annotation.PathVariable;
@Controller
public class GameController {
public static String webglUrlForGame(int gameId) {
return "/webgl/game-" + gameId + "/index.html";
}
@GetMapping("/game/{id}")
public String gameDetail(@PathVariable("id") int id, Model model) {
if (!GameCatalog.isValidId(id)) {
return "redirect:/";
}
int idx = GameCatalog.toIndex(id);
model.addAttribute("gameId", id);
model.addAttribute("gameName", GameCatalog.NAMES[idx]);
model.addAttribute("creator", GameCatalog.CREATORS[idx]);
model.addAttribute("likeCount", GameCatalog.LIKE_COUNTS[idx]);
model.addAttribute("likeCountFormatted", String.format("%,d", GameCatalog.LIKE_COUNTS[idx]));
model.addAttribute("creatorNote", GameCatalog.CREATOR_NOTES[idx]);
model.addAttribute("gitUrl", GameCatalog.GIT_URLS[idx]);
/* 데모: 공통 플레이스홀더. 실제 빌드는 static/webgl/game-{id}/ 에 두고 아래 한 줄을 webglUrlForGame(id) 로 바꾸면 됩니다. */
model.addAttribute("webglUrl", "/webgl/placeholder/index.html");
model.addAttribute("webglDeployPath", webglUrlForGame(id));
return "game-detail";
}
}