-
Notifications
You must be signed in to change notification settings - Fork 3
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 , 지도 썸네일 수정 API #184
Conversation
) { | ||
const { comment } = updatePlaceInCourseRequest; | ||
if (updatePlaceInCourseRequest.isEmpty()) { | ||
throw new BadRequestException('수정할 정보가 없습니다.'); |
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.
q: nest 제공 에러를 쓰면 에러 코드는 어떻게 들어가나요?
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.
필터에서 999 로 들어갑니다!
여러 도메인에서 사용되는 에러인데, common exception 으로 만드는게 나을까요?
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.
그것도 괜찮을 것 같네요!
@Transactional() | ||
async setPlacesOfCourse( | ||
id: number, | ||
setPlacesOfCourseRequest: SetPlacesOfCourseRequest, | ||
) { | ||
const course = await this.courseRepository.findById(id); | ||
if (!course) throw new CourseNotFoundException(id); | ||
const course = await this.getCourseOrElseThrowNotFound(id); |
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.
👍
@IsOptional() | ||
@IsUrl() | ||
thumbnailUrl?: string; |
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.
p2: IsOptional
은 클라에서 아예 필드를 주지 않을 때 동작합니다.
클라에서 만약 thumnailUrl: ""
로 보내면 에러 납니다.
저는 그래서 아래와 같이 해결했었어요. 클라이언트에서도 없으면 빈값으로 보내기로 예전에 이야기 했었습니다!
// CreateCourseRequest 참고
@ValidateIf((object, value) => value !== '')
@IsUrl()
thumbnailUrl?: string;
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.
아래와 같이 수정하겠습니다.
thumbnailUrl
필드가 존재하지 않으면 업데이트에 반영하지 않는다.thumbnailUrl
필드가 존재하나 빈 문자열인 경우 기본 url 로 변경한다.thumbnailUrl
필드가 존재하며 유효한 url 인 경우 해당 url 로 변경한다.
backend/src/map/map.controller.ts
Outdated
if (updateMapInfoRequest.isEmpty()) { | ||
throw new BadRequestException('수정할 정보가 없습니다.'); | ||
} |
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.
q: Request
검증은 controller
의 역할이라 생각해서 service
에 넣지 않고 여기 넣으신건가요?
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.
넵 맞습니다
if (!(await this.placeRepository.existById(placeId))) { | ||
throw new InvalidPlaceToMapException(placeId); | ||
} | ||
@Transactional() |
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.
q: 트랜잭션이 필요할까요?
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.
async deletePlace(id: number, placeId: number) { | ||
const map = await this.mapRepository.findById(id); | ||
if (!map) throw new MapNotFoundException(id); | ||
const map = await this.getMapOrElseThrowNotFound(id); | ||
|
||
map.deletePlace(placeId); | ||
await this.mapRepository.save(map); | ||
|
||
return { deletedId: placeId }; |
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.
p1: 만약 위에서 필요하다면 여기도 필요할 것 같네요!
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.
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.
고수시군요
411dbe1
to
9cecdbf
Compare
9cecdbf
to
c5ea3da
Compare
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.
수고하셨습니다!!
📄 Summary
🙋🏻 More
🕰️ Actual Time of Completion
close #177