Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ public ResponseEntity<Long> create(@RequestBody GameRequest request, HttpServlet
return ResponseEntity.ok(gameService.createGame(request, servletRequest));
}

@GetMapping("/games/search")
@Operation(summary = "게임 검색", description = "게임을 검색한다.")
public List<GameResponse> search(@RequestParam(value = "searchKeyword") String keyword) {
List<GameResponse> gameResponseList = gameService.searchGames(keyword);
return gameResponseList;
}

@GetMapping("/games")
@Operation(summary = "모든 게임 조회", description = "모든 게임을 지정한 정렬 방법으로 가져온다.")
public List<GameResponse> getGames(@Parameter(name = "sortBy", description = "정렬 방법") @RequestParam(name = "sortBy", required = false) String sortBy) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ public interface GameRepository extends JpaRepository<Game, Long> {

Game findGameById(Long id);

List<Game> findByTitleContaining(String keyword);

List<Game> findAllByActivationTrue(Sort sort);
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,20 @@ public Long createGame(GameRequest gameRequest, HttpServletRequest servletReques
return game.getId();
}

// 검색창에서 입력한 키워드가 제목에 들어있는 게임 찾기
public List<GameResponse> searchGames(String keyword) {
List<Game> gameList = gameRepository.findByTitleContaining(keyword);
List<GameResponse> gameResponseList = new ArrayList<>();

if (gameList.isEmpty()) return gameResponseList;

for(Game game : gameList) {
gameResponseList.add(GameResponse.from(game));
}

return gameResponseList;
}

public GameResponse findById(Long id) {
Game game = gameRepository.findById(id).orElseThrow();
return GameResponse.from(game);
Expand Down
23 changes: 23 additions & 0 deletions src/main/resources/application-oauth.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#원래는 .gitignore에 넣어야하는 정보들이지만 그냥 올립니다!
spring:
security:
oauth2:
client:
registration:
twitch:
client-id: <Input Your Client ID>
client-secret: <Input Your Client Secret>
client-authentication-method: POST
scope: <Want to get permission code>
authorization-grant-type: authorization_code
provider: twitch
client-name: Twitch
redirect-uri: {baseUrl}/{action}/oauth2/code/{registrationId}
provider:
twitch:
authorization-uri: https://id.twitch.tv/oauth2/authorize?response_type=code
token-uri: https://id.twitch.tv/oauth2/token
user-info-uri: https://id.twitch.tv/oauth2/userinfo
user-info-authentication-method: POST
jwk-set-uri: https://id.twitch.tv/oauth2/keys
user-name-attribute: sub
1 change: 1 addition & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
spring:
profiles:
active: prod
# include: oauth

logging:
level:
Expand Down