Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions BE/src/main/java/com/wepat/exception/calendar/NotExistPet.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.wepat.exception.schedule;

public class NotExistScheduleException extends RuntimeException {
public NotExistScheduleException() {
super();
}
public NotExistScheduleException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
package com.wepat.exception.calendar;
package com.wepat.exception.schedule;

import com.wepat.exception.ErrorDto;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

//@RestControllerAdvice(assignableTypes = {CalendarController.class})
public class CalendarExceptionHandler {
public class ScheduleExceptionHandler {

@ExceptionHandler(NotExistCalendarException.class)
public ResponseEntity<?> NotExistCalendarException(NotExistCalendarException e) {
ErrorDto errorDto = new ErrorDto("NotExistCalendarException", e.getMessage());
return new ResponseEntity<>(errorDto, HttpStatus.BAD_REQUEST);
}

@ExceptionHandler(NotExistPet.class)
public ResponseEntity<?> NotExistPet(NotExistPet e) {
ErrorDto errorDto = new ErrorDto("NotExistPet", e.getMessage());
@ExceptionHandler(NotExistScheduleException.class)
public ResponseEntity<?> NotExistCalendarException(NotExistScheduleException e) {
ErrorDto errorDto = new ErrorDto("NotExistScheduleException", "존재하지 않는 일정입니다.");
return new ResponseEntity<>(errorDto, HttpStatus.BAD_REQUEST);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.google.cloud.firestore.*;
import com.google.firebase.cloud.FirestoreClient;
import com.wepat.schedule.CalendarEntity;
import com.wepat.exception.calendar.AloneScheduleException;
import com.wepat.member.MemberDto;
import com.wepat.member.MemberEntity;
import com.wepat.pet.PetEntity;
Expand Down Expand Up @@ -390,7 +389,7 @@ public void deleteMember(String memberId) throws ExecutionException, Interrupted
// calendar에 연결된 펫 정보 삭제
petCollection.document(petId).delete();
}
// 사진 삭제
// 사진 삭제
List<QueryDocumentSnapshot> photoDocList = photoCollection.get().get().getDocuments();
for (QueryDocumentSnapshot photoList : photoDocList) {
String photoDtoCalendarId = photoList.toObject(PhotoEntity.class).getCalendarId();
Expand Down Expand Up @@ -549,7 +548,7 @@ public void addCalendarById(String memberId) throws ExecutionException, Interrup
}
});
if (future.get() == ReturnType.AlreadyAloneCalendarException) {
throw new AloneScheduleException();
throw new AlreadyAloneCalendarException();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public ResponseEntity<?> uploadSNSByPhotoId(@PathVariable("photoid") String phot
@ApiOperation(value = "앨범 댓글 작성")
public ResponseEntity<?> addCommentByPhotoId(@PathVariable("photoid") String photoId,
@RequestBody CommentDto commentDto) {

try {
photoService.addCommentByPhotoId(photoId, commentDto);
return new ResponseEntity<>("댓글 작성 성공", HttpStatus.OK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ public void addCommentByPhotoId(String photoId, CommentDto commentDto) throws Ex
CollectionReference photoCollection = FirestoreClient.getFirestore().collection(PHOTO_COLLECTION);
DocumentReference photoDocRef = photoCollection.document(photoId);
DocumentReference randomDocRef = photoCollection.document();

ApiFuture<?> future = FirestoreClient.getFirestore().runTransaction(transaction -> {
DocumentSnapshot photoSnapshot = transaction.get(photoDocRef).get();
if (photoSnapshot.exists()) {
Expand Down
4 changes: 2 additions & 2 deletions BE/src/main/java/com/wepat/schedule/ScheduleDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public class ScheduleDto {
private int repeatAmount;
@ApiParam(value = "일정에 관한 메모")
private String memo;
@ApiParam(value = "사진ID 리스트", hidden = true)
private List<String> photoList;
@ApiParam(value = "사진ID", hidden = true)
private String photoUrl;
@ApiParam(value = "댓글Dto 리스트", hidden = true)
private List<CommentDto> reviewList;
}
4 changes: 2 additions & 2 deletions BE/src/main/java/com/wepat/schedule/ScheduleEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public class ScheduleEntity {
private int repeatAmount;
@ApiParam(value = "일정에 관한 메모")
private String memo;
@ApiParam(value = "사진ID 리스트", hidden = true)
private List<String> photoList;
@ApiParam(value = "사진ID", hidden = true)
private String photoUrl;
@ApiParam(value = "댓글Dto 리스트", hidden = true)
private List<CommentDto> reviewList;
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package com.wepat.schedule.controller;

import com.wepat.exception.schedule.NotExistScheduleException;
import com.wepat.notification.NotifiacationType;
import com.wepat.notification.service.NotificationService;
import com.wepat.photo.CommentDto;
import com.wepat.schedule.ScheduleDto;
import com.wepat.schedule.service.ScheduleService;
import com.wepat.util.JwtUtil;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.parameters.P;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -68,14 +71,14 @@ public ResponseEntity<?> getAllScheduleByDate(@PathVariable("calendarid") String
public ResponseEntity<?> getScheduleDateByDate(@PathVariable("calendarid") String calendarId,
@PathVariable("scheduleid") String scheduleId) {
try {
scheduleService.getScheduleDetailByDate(calendarId, scheduleId);
return new ResponseEntity<>(scheduleService.getScheduleDetailByDate(calendarId, scheduleId), HttpStatus.OK);
} catch (ExecutionException e) {
throw new RuntimeException(e);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
return ResponseEntity.ok().build();
}

// 스케쥴의 정보 변경
@PutMapping("/modify/{calendarid}/{scheduleid}")
@ApiOperation(value = "일정 변경", response = HttpStatus.class)
Expand Down Expand Up @@ -121,4 +124,68 @@ public ResponseEntity<?> completeSchedule(@PathVariable("calendarid") String cal
notificationService.addNotification(calendarId, memberId, scheduleId, nowDate, NotifiacationType.INCOMPLETE.ordinal());
return ResponseEntity.ok().build();
}

@PostMapping("/comment/{calendarid}/{scheduleid}")
@ApiOperation(value = "일정에 대한 댓글 작성")
public ResponseEntity<?> addCommentByScheduleId(@PathVariable("calendarid") String calendarId,
@PathVariable("scheduleid") String scheduleId,
@RequestBody CommentDto commentDto) {

try {
scheduleService.addCommentByScheduleId(calendarId, scheduleId, commentDto);
return new ResponseEntity<>("일정 댓글 작성 성공", HttpStatus.OK);
} catch (NotExistScheduleException e) {
throw new NotExistScheduleException();
} catch (Exception e) {
throw new RuntimeException(e);
}
}

@PutMapping("/comment/{calendarid}/{scheduleid}/{commentid}")
@ApiOperation(value = "일정에 대한 댓글 수정")
public ResponseEntity<?> modifyCommentByScheduleId(@PathVariable("calendarid") String calendarId,
@PathVariable("scheduleid") String scheduleId,
@PathVariable("commentid") String commentId,
@RequestBody CommentDto commentDto) {
try {
scheduleService.modifyCommentByScheduleId(calendarId, scheduleId, commentId, commentDto);
return new ResponseEntity<>("일정 댓글 수정 완료", HttpStatus.ACCEPTED);
} catch (NotExistScheduleException e) {
throw new NotExistScheduleException();
} catch (Exception e) {
throw new RuntimeException(e);
}
}

@DeleteMapping("/comment/{calendarid}/{scheduleid}/{commentid}")
@ApiOperation(value = "일정에 대한 댓글 삭제")
public ResponseEntity<?> deleteCommentByScheduleId(@PathVariable("calendarid") String calendarId,
@PathVariable("scheduleid") String scheduleId,
@PathVariable("commentid") String commentId) {

try {
scheduleService.deleteCommentByScheduleId(calendarId, scheduleId, commentId);
return new ResponseEntity<>("일정 댓글 삭제 성공", HttpStatus.OK);
} catch (NotExistScheduleException e) {
throw new NotExistScheduleException();
} catch (Exception e) {
throw new RuntimeException(e);
}
}

@PutMapping("/photo/{calendarid}/{scheduleid}")
@ApiOperation(value = "일정에 대한 사진 추가 및 변경")
public ResponseEntity<?> modifyPhotoUrlByScheduleId(@PathVariable("calendarid") String calendarId,
@PathVariable("scheduleid") String scheduleId,
String photoUrl) {
try {
scheduleService.modifyPhotoUrlByScheduleId(calendarId, scheduleId, photoUrl);
return new ResponseEntity<>("일정 사진 추가 및 변경 성공", HttpStatus.ACCEPTED);
} catch (NotExistScheduleException e) {
throw new NotExistScheduleException();
} catch (Exception e) {
throw new RuntimeException(e);
}
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.wepat.schedule.repository;

import com.wepat.photo.CommentDto;
import com.wepat.schedule.ScheduleDto;

import java.util.HashMap;
Expand All @@ -22,4 +23,11 @@ public interface ScheduleRepository {
// 캘린더 그룹 멤버 확인
HashMap<String, String> getMemberListByCalendarId(String calendarId) throws ExecutionException, InterruptedException;

void addCommentByScheduleId(String calendarId, String scheduleId, CommentDto commentDto) throws ExecutionException, InterruptedException;

void modifyCommentByScheduleId(String calendarId, String scheduleId, String commentId, CommentDto commentDto) throws ExecutionException, InterruptedException;

void deleteCommentByScheduleId(String calendarId, String scheduleId, String commentId) throws ExecutionException, InterruptedException;

void modifyPhotoUrlByScheduleId(String calendarId, String scheduleId, String photoUrl) throws ExecutionException, InterruptedException;
}
Loading