Skip to content

Commit

Permalink
Merge pull request #31 from KONKUK-MAP-Service/feat-spot
Browse files Browse the repository at this point in the history
✔️ [Fix] : 사진 삭제 방식 변경 #31
  • Loading branch information
evergreenn authored Apr 6, 2024
2 parents 12f1cfc + cbff7e9 commit 36c7979
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
public record CommentListResponseDto(
String spotName,
Long spotId,
Long commentId,

String usersComment,
String review,
LocalDateTime CommentcreateDate,
Expand All @@ -29,6 +31,7 @@ public static CommentListResponseDto of (Comment comment, PageInfo pageInfo){
return CommentListResponseDto.builder()
.spotName(comment.getSpot().getSpotName())
.spotImageurl(comment.getSpot().getImageUrls().get(0))
.commentId(comment.getId())
.CommentcreateDate(comment.getCreatedDate())
.spotId(comment.getId())
.review(comment.getSpot().getReview())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public enum HttpExceptionCode {
IMAGE_UPLOAD_FAILED(HttpStatus.NOT_FOUND, "이미지 업로드에 실패하였습니다."),
SPOT_NOT_FOUND(HttpStatus.NOT_FOUND,"해당 spot ID가 DB에 존재하지 않습니다."),
USER_LOGIN_PERMIT_FAIL(HttpStatus.FORBIDDEN,"로그인한 사용자만 이용할 수 있습니다. "),
USER_NOT_MATCH(HttpStatus.BAD_REQUEST, "해당 사용자가 작성한 글이 아닙니다."),
USER_NOT_MATCH(HttpStatus.BAD_REQUEST, "해당 사용자가 작성한 장소가 아닙니다."),
BOOK_MARK_ERR(HttpStatus.BAD_REQUEST, "북마크 조회에 실패하였습니다."),
BOOK_MARK_NOT_EXIST(HttpStatus.NOT_FOUND, "등록된 북마크가 존재하지 않습니다."),
LIKE_ERR(HttpStatus.BAD_REQUEST, "좋아요 조회에 실피하였습니다."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public record SpotUpdateRequest (

String review,

int deleteImageindex
String[] deleteImageUrls
){

}
17 changes: 9 additions & 8 deletions src/main/java/com/cona/KUsukKusuk/spot/service/SpotService.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,18 @@ public Spot updateSpot(Long spotId,List<MultipartFile> images, SpotUpdateRequest
if (!spot.getUser().equals(user)) {
throw new UserNotFoundException(HttpExceptionCode.USER_NOT_MATCH);
}
int deleteImageindex = spotUpdateRequest.deleteImageindex();

String[] deleteImageUrls = spotUpdateRequest.deleteImageUrls();

List<String> imageUrls = spot.getImageUrls();

if (deleteImageindex>=1 && deleteImageindex<=imageUrls.size()) {
String deleteimageurl = imageUrls.get(deleteImageindex-1);
imageUrls.remove(deleteImageindex-1);
//해당 인덱스에 대응하는 이미지 삭제후 다시 저장(영속).
spot.setImageUrls(imageUrls);
s3Service.deleteImagebyUrl(user,deleteimageurl);
for (String deleteImageUrl : deleteImageUrls) {
if (imageUrls.contains(deleteImageUrl)) {
imageUrls.remove(deleteImageUrl);

spot.setImageUrls(imageUrls);
// S3에서 이미지 삭제
s3Service.deleteImagebyUrl(user, deleteImageUrl);
}
}

if (!images.get(0).isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public String findPassword(String userId, String email) {

String newPassword = generateNewPassword();
member.setPassword(bCryptPasswordEncoder.encode(newPassword));

member.setNoCryptpassword(newPassword);
userRepository.save(member);

Expand Down Expand Up @@ -178,6 +179,7 @@ public void checkPassword(String enteredPassword) {
.map(User::getPassword)
.orElseThrow(() -> new UserNotFoundException(HttpExceptionCode.USER_NOT_FOUND));


if( ! bCryptPasswordEncoder.matches(enteredPassword, storedPassword)){
throw new PasswordNotMatchException();
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ spring:
show_sql: true
format_sql: true
database: mysql
show-sql: true
show-sql: false
hibernate:
ddl-auto: update
jwt:
Expand Down Expand Up @@ -47,11 +47,11 @@ spring:
decorator:
datasource:
p6spy:
enable-logging: true
enable-logging: false

logging:
level:
org.hibernate.SQL: info
org.hibernate.SQL: error

cloud:
aws:
Expand Down

0 comments on commit 36c7979

Please sign in to comment.