-
Notifications
You must be signed in to change notification settings - Fork 0
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
경험 저장 API 요청 시 새로 추가한 데이터에 접근할 수 있도록 수정 #105
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 단순히 200 success + recordId 로 리턴하는게 아닌 201 created + location 헤더 이용으로 보다 정석적인 방법으로 리턴하는 방식에 대해 알 수 있어서 좋았습니다.
- Mybatis에서 Insert후 해당 Row의 Id값을 알 수 있는 방법에 대해 같이 알게 됐습니다. 감사합니다!
고생하셨습니다!
@@ -4,7 +4,7 @@ | |||
|
|||
<mapper namespace="sullog.backend.record.mapper.RecordMapper"> | |||
|
|||
<insert id="insertRecord" parameterType="sullog.backend.record.entity.Record"> | |||
<insert id="insertRecord" parameterType="sullog.backend.record.entity.Record" useGeneratedKeys="true" keyProperty="recordId"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
insert후 select로 id를 가져오는게 아니라 insert하면서 리턴 값으로 id를 받을 수 있는 방법 확인했습니다!
.path("/{recordId}") | ||
.buildAndExpand(savedRecordId) | ||
.toUri(); | ||
return ResponseEntity.created(location).build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HTTP 표준에 입각해서 location 헤더에 위치값을 리턴하는 구조 확인했습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 단순히 200 success + recordId 로 리턴하는게 아닌 201 created + location 헤더 이용으로 보다 정석적인 방법으로 리턴하는 방식에 대해 알 수 있어서 좋았습니다.
- Mybatis에서 Insert후 해당 Row의 Id값을 알 수 있는 방법에 대해 같이 알게 됐습니다. 감사합니다!
고생하셨습니다!
매번 자세하게 코멘트 주셔서 감사합니다 ! 의재님이 한차례 더 정리해주셔서 많이 도움됩니다 !!! |
개요
작업사항
경험 저장 시 방금 저장한 데이터에 접근할 수 있도록 관련 로직 수정
useGeneratedKeys
기능을 이용해서 record_id에 셋팅된 값 읽어옴api resonse 수정
변경 로직
경험 저장 api
POST /records
response 수정