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

[과제 #4 제출 스레드] #31

Closed
LimdaeIl opened this issue Feb 21, 2024 · 0 comments · Fixed by #33
Closed

[과제 #4 제출 스레드] #31

LimdaeIl opened this issue Feb 21, 2024 · 0 comments · Fixed by #33
Assignees
Labels
Task 인프런 워밍업 스터디 클럽 과제

Comments

@LimdaeIl
Copy link
Owner

LimdaeIl commented Feb 21, 2024

진도표 4일차와 연결됩니다
우리는 GET API와 POST API를 만드는 방법을 배웠습니다. 👍 추가적인 API 들을 만들어 보며 API 개발에 익숙해져 봅시다!

Image

Image

Image

@LimdaeIl LimdaeIl self-assigned this Feb 21, 2024
@LimdaeIl LimdaeIl added the enhancement New feature or request label Feb 21, 2024
@LimdaeIl LimdaeIl added Task 인프런 워밍업 스터디 클럽 과제 and removed enhancement New feature or request labels Feb 21, 2024
LimdaeIl added a commit that referenced this issue Feb 22, 2024
지난 과제 임포트 단순 변경
LimdaeIl added a commit that referenced this issue Feb 22, 2024
`JdbcTemplate` 으로 데이터베이스와 매핑하여 문제들을 해결했다.

### 문제1
POST 방식으로 JSON 데이터인 `이름, 날짜, 가격` 을 MySQL에 저장하기 위해 `update` 쿼리문을 생성한다.
1. 포스트맨으로부터 보낸 JSON 데이터는  `@RequestBody` 에 의해 `이름, 날짜, 가격` 을 가져오고 `Task04ExRequest` dto 에 매핑한다.
2. `jdbcTemplate.update()` 메서드의 매개변수는 `update` 쿼리문 그리고 인 파라미터를 넣어준다. 인 파라미터는 매핑된 dto 클래스로부터 `이름, 날짜, 가격`을 getter 메서드로 불러오면 된다.

### 문제 2
과일이 판매되면 `salesQuantity`속성의 값이 1씩 증가하도록 변경했다. (판매된 갯수만큼 증가시키면 좋겠지만 판매 여부가 관건인 문제이다.) 판매되면 1, 판매가 안된 상황이면 0이다. 따라서`salesQuantity` 속성의 변경은 PUT 방식으로 작성하고 JSON 형식으로 `id` 를 요청하고 JSON 형식으로 `id` 를 응답 받는다 .

### 문제 3 - sum(), group by() 미적용 상태
데이터베이스에 저장된 모든 데이터를 리스트에 저장하고, 쿼리 파라미터와 동일한 과일의 판매 여부를 비교하여 판매된 과일 금액, 팔리지 않은 금액을 JSON 형식으로 응답한다.
LimdaeIl added a commit that referenced this issue Feb 22, 2024
주어진 문제 구하는 방식을 쿼리를 중심으로 구하도록 변경했다. `sum(), group by()` 쿼리문을 사용하여 요구사항 이외의 다른 문법을 배제하고 코드가 더욱 간결하고 적절하게 쿼리가 수행됐다.
LimdaeIl added a commit that referenced this issue Feb 22, 2024
@LimdaeIl LimdaeIl linked a pull request Feb 22, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Task 인프런 워밍업 스터디 클럽 과제
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant