Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/org/sophy/sophy/service/BooktalkService.java
  • Loading branch information
dong2ast committed Jul 20, 2023
2 parents 97f2701 + 8ede17b commit bc7983f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ protected ApiResponseDto handleExpiredRefreshTokenException(final ExpiredJwtExce
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(InvalidFormatException.class)
protected ApiResponseDto handleInvalidFormatException(final InvalidFormatException e) {
return ApiResponseDto.error(ErrorStatus.INVALID_FORMAT_EXCEPTION);
}

@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(IllegalArgumentException.class)
protected ApiResponseDto handleIllegalArgumentException(final IllegalArgumentException e) {
return ApiResponseDto.error(ErrorStatus.NOT_FOUND_CITY_EXCEPTION);
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/sophy/sophy/exception/ErrorStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ public enum ErrorStatus {
VALIDATION_EXCEPTION(HttpStatus.BAD_REQUEST, "잘못된 요청입니다."),
VALIDATION_REQUEST_MISSING_EXCEPTION(HttpStatus.BAD_REQUEST, "올바른 요청값이 입력되지 않았습니다."),
INVALID_PASSWORD_EXCEPTION(HttpStatus.BAD_REQUEST, "잘못된 비밀번호가 입력됐습니다."),
INVALID_MULTIPART_EXTENSION_EXCEPTION(HttpStatus.BAD_REQUEST, "허용되지 않은 타입의 파일입니다"),
INVALID_MULTIPART_EXTENSION_EXCEPTION(HttpStatus.BAD_REQUEST, "허용되지 않은 타입의 파일입니다."),
INVALID_TOKEN_INFO_EXCEPTION(HttpStatus.BAD_REQUEST, "토큰 혹은 만료시간 설정이 잘못되었습니다."),
INVALID_FORMAT_EXCEPTION(HttpStatus.BAD_REQUEST, "잘못된 형식입니다."),

/**
* 401 UNAUTHORIZED
Expand Down
19 changes: 13 additions & 6 deletions src/main/java/org/sophy/sophy/service/BooktalkService.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ public class BooktalkService {
private final MemberBooktalkRepository memberBooktalkRepository;
private final CompletedBooktalkRepository completedBooktalkRepository;

// 북토크 생성
@Transactional
public BooktalkCreateResponseDto createBooktalk(BooktalkRequestDto booktalkRequestDto) { // 북토크 생성
public BooktalkCreateResponseDto createBooktalk(BooktalkRequestDto booktalkRequestDto) {
Place place = placeRepository.getPlaceById(booktalkRequestDto.getPlaceId());
Member member = memberRepository.getMemberById(booktalkRequestDto.getMemberId());
if (!member.getIsAuthor()) {
Expand All @@ -38,15 +39,17 @@ public BooktalkCreateResponseDto createBooktalk(BooktalkRequestDto booktalkReque
return BooktalkCreateResponseDto.of(booktalkRepository.save(booktalk));
}

// 북토크 수정
@Transactional
public BooktalkUpdateDto updateBooktalk(Long booktalkId, BooktalkUpdateDto booktalkUpdateDto) { //북토크 상태 업뎃
public BooktalkUpdateDto updateBooktalk(Long booktalkId, BooktalkUpdateDto booktalkUpdateDto) {
Booktalk booktalk = booktalkRepository.getBooktalkById(booktalkId);
booktalk.patchBooktalk(booktalkUpdateDto, placeRepository.getPlaceById(booktalkUpdateDto.getPlaceId()));
return booktalkUpdateDto;
}

// 북토크 삭제
@Transactional
public BooktalkDeleteResponseDto deleteBooktalk(Long booktalkId) { // 수정필요 -> 테이블 외래키 고려하여 관련된 엔티티 전부 삭제해야 함 (소프트 삭제로 변경)
public BooktalkDeleteResponseDto deleteBooktalk(Long booktalkId) { // 수정필요 -> 테이블 외래키 고려하여 관련된 엔티티 전부 삭제해야 함
Booktalk booktalk = booktalkRepository.getBooktalkById(booktalkId);
//TODO soft delete?
//공간이 거절 됐거나 공간 매칭중일 때만 삭제가능
Expand All @@ -56,20 +59,23 @@ public BooktalkDeleteResponseDto deleteBooktalk(Long booktalkId) { // 수정필
return BooktalkDeleteResponseDto.of(booktalkId);
}

public BooktalkDetailResponseDto getBooktalkDetail(Long booktalkId) { //북토크 상세 조회
// 북토크 상세 조회
public BooktalkDetailResponseDto getBooktalkDetail(Long booktalkId) {
Booktalk booktalk = booktalkRepository.getBooktalkById(booktalkId);
return BooktalkDetailResponseDto.of(booktalk);
}

// 북토크 참여 신청
@Transactional
public void postBooktalkParticipation(BooktalkParticipationRequestDto booktalkParticipationRequestDto) { //북토크 참가신청
public void postBooktalkParticipation(BooktalkParticipationRequestDto booktalkParticipationRequestDto) {
Member member = memberRepository.getMemberById(booktalkParticipationRequestDto.getMemberId());
Booktalk booktalk = booktalkRepository.getBooktalkById(booktalkParticipationRequestDto.getBooktalkId());
// 복합키?
MemberBooktalk memberBooktalk = booktalkParticipationRequestDto.toMemberBooktalk(booktalk, member);
memberBooktalkRepository.save(memberBooktalk);
}

// 마감임박 북토크 조회
public List<BooktalkDeadlineUpcomingDto> getBooktalkDeadlineUpcoming() {
List<Place> placeList = placeRepository.findAll();

Expand All @@ -91,8 +97,9 @@ public List<BooktalkDeadlineUpcomingDto> getBooktalkDeadlineUpcoming() {

}

//지역으로 북토크 조회
@Transactional
public List<BooktalkResponseDto> getBooktalksByCity(City city) { //지역으로 북토크 조회
public List<BooktalkResponseDto> getBooktalksByCity(City city) {

List<Booktalk> booktalks;

Expand Down

0 comments on commit bc7983f

Please sign in to comment.