Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Spring 체스 - 3단계] 춘식(안예장) 미션 제출합니다. #288

Merged
merged 24 commits into from
Apr 29, 2021

Conversation

bimppap
Copy link

@bimppap bimppap commented Apr 24, 2021

반가워요 재연링!!
3단계를 진행하면서 REST와 스프링프레임워크에 대해 공부하면서 진행하다보니 피알이 조금 늦어버렸네요 😇
그래도 1,2 단계를 진행할 때보다 프레임워크 흐름이 이해되고 있는 것 같아요!!
또한 이동욱님의 '스프링 부트와 aws로 혼자 구현하는 웹 서비스'를 참고하며 리팩토링도 해보았습니다!!
jpa 관련 annotation도 써보고 싶었는데 아직은 어렵게 느껴져서 적용을 못해본게 아쉽네요ㅠ
이번 단계도 잘 부탁드립니다!! 따끔한 피드백은 언제나 환영이에요 💘 💘

(+) 1,2 단계가 머지되고 rebase를 깜박해서 3단계 구현을 마치고 체리픽을 하다가 1,2 단계 때 한 커밋들도 들어가게 되었습니다..
3단계는 a3ac28f 커밋부터 보시면 됩니다!!

Copy link

@jaeyeonling jaeyeonling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3단계 구현과 피드백 반영해주신 내용 잘 확인하였습니다 👍
소소한 피드백 남겨두었으니 확인 후 반영해주세요!

import java.sql.SQLException;
import org.springframework.jdbc.core.RowMapper;

public class RoomRequestMapper implements RowMapper<Room> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RowMapper 분리 👍

public void deleteAll() {
String query = "delete from move";
public void deleteAllById(int id) {
String query = "delete from move where room_id=" + id;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String을 직접 더해 로 쿼리를 만드는 것은 SQL Injection에 당할 위험이 있기 때문에 지양해보아요

@@ -19,6 +20,6 @@ public Player currentPlayer(PieceColor currentColor) {
return players.stream()
.filter(player -> player.isColor(currentColor))
.findAny()
.orElseThrow(() -> new IllegalArgumentException("해당 색을 가진 플레이어가 존재하지 않습니다."));
.orElseThrow(() -> new InvalidPlayerException("해당 색을 가진 플레이어가 존재하지 않습니다."));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CustomException으로 분리하였다면 예외처리 메시지를 Exception 내부로 옮겨보면 어떨까요?


private final String name;

@ConstructorProperties({"name"})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ConstructorProperties는 어떠한 이유로 작성하셨을까요!?


private final RoomDao roomDao;

@Transactional(readOnly = true)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

readOnly 👍


private final ChessService service;

@GetMapping(value = {"/init"})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아래 restart와 어떠한 차이가 있을까요?


private final RoomService service;

@GetMapping("/")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@GetMapping("/")
@GetMapping("/rooms")

해당 Path도 변경해야하지 않을까요!?

@@ -55,7 +80,7 @@ void getNewBoard() {
void isEnd() {
Boolean response = RestAssured.given().log().all()
.accept(MediaType.APPLICATION_JSON_VALUE)
.when().get("/board/status")
.when().get("/rooms/1/board/status")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id가 1이라는 것을 하드코딩으로 보장할 수 있을지 고민해보아요

build.gradle Outdated
@@ -14,7 +14,10 @@ repositories {

dependencies {

implementation('org.springframework.boot:spring-boot-starter-data-jpa:')
implementation'org.projectlombok:lombok'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
implementation'org.projectlombok:lombok'
implementation 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'

Gradle 5.x 이후 버전부터는 annotationProcessor 사용해주셔야 합니다!

@bimppap
Copy link
Author

bimppap commented Apr 26, 2021

안녕하세요 재연링!!
주신 피드백들을 보며 많이 고민해보고 찾아보는 시간을 가지게 되었어요.
덕분에 스프링에 대해 배운 점도 많아지고 궁금한 점도 많아졌어요!
이후에 학습로그를 작성하면서 궁금한 점을 해결해볼 생각입니다ㅎㅎ

디엠으로 이것저것 많이 물어봤는데도 친절하게 답변 주셔서 감사합니다 😇
테스트 코드는 리팩토링이 덜 되었는데 차후 천천히 추가할 예정입니다!

이번에도 잘 부탁드립니다!! 감사합니다 🙇 🙇

Copy link

@jaeyeonling jaeyeonling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수 많은 피드백 반영하시느라 고생 많으셨어요 👍
해당 미션은 머지하도록 하겠습니다!
다음 단계도 화이팅입니다 😄

@kang-hyungu kang-hyungu merged commit 5be70e1 into woowacourse:rinsabbit Apr 29, 2021
@bimppap
Copy link
Author

bimppap commented May 14, 2021

학습 로그


SQL injection

  • 보안상의 취약점을 이용하여 임의의 SQL문을 주입하고 실행하게 하여 데이터베이스가 비정상적인 동작을 하도록 조작하는 행위. injection에 사용되는 기법 종류는 다음과 같다.

    • 논리적 에러
    • Union 명령어
    • Boolean based
    • Time based
    • 저장된 프로시저
    • 다량의 sql injection
  • 참고 링크

태그

  • DB

@ConstructorProperties, Jacksonzied

  • 여기에 따로 글로 정리함

태그

  • Spring, lombok

SQL auto increment

  • Auto increment column 속성에 특정한 값을 지정해놓지 않으면 mysql이 자동적으로 sequence number 를 할당한다.
  • 만약 update 또는 insert 로 인위적으로 column에 값을 주입하면 해당 컬럼의 sequence number는 자동적으로 해당 column의 최대값으로 수정된다.
  • 참고링크

태그

  • DB

Path Variable, Query Parameter

  • Path Variable

    // URL 형식
    /users/123
      
    // RestAssured Mapping
    int id = 123;
    RestAssured
     .when()
     .get("/users/{id}",id);
  • Query Parameter

    // URL 형식
    /users?id=123
      
    // RestAssured Mapping
    int id = 123;
    RestAssured
      .queryParam("id", id)
      .get("/users");

태그

  • Spring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants