Skip to content

Commit

Permalink
Merge branch 'develop' into feat/#174
Browse files Browse the repository at this point in the history
  • Loading branch information
lreowy authored Sep 3, 2024
2 parents d3a517d + 55efb5d commit 76167fd
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 9 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# ❕ PICK!PLE
![픽플이미지](https://github.com/user-attachments/assets/7083d8e6-5ac2-4465-8706-b342feddb073)

![image](https://github.com/user-attachments/assets/f21646ab-53bc-4fc3-8d3a-80df8f1ff2fb)
내가 PICK!한 바로 '그 사람'과 함께하는 클래스 모임


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import jakarta.validation.Valid;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand Down Expand Up @@ -38,4 +39,12 @@ public ApiResponseDto<List<CommentGetResponse>> getCommentListByNotice(@PathVari
return ApiResponseDto.success(SuccessCode.COMMENT_LIST_BY_NOTICE_GET_SUCCESS,
commentQueryService.getCommentListByNotice(noticeId));
}

@DeleteMapping("/v2/notice/{noticeId}/comment/{commentId}")
public ApiResponseDto deleteComment(@UserId Long userId,
@PathVariable final Long noticeId,
@PathVariable final Long commentId) {
commentCommandService.deleteComment(userId, noticeId, commentId);
return ApiResponseDto.success(SuccessCode.COMMENT_DELETE_SUCCESS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,19 @@ ApiResponseDto createComment(
ApiResponseDto<List<CommentGetResponse>> getCommentListByNotice(
@PathVariable Long noticeId
);

@Operation(summary = "공지사항 댓글 삭제")
@ApiResponses(
value = {
@ApiResponse(responseCode = "20036", description = "공지사항 댓글 삭제 성공"),
@ApiResponse(responseCode = "40409", description = "존재하지 않는 공지사항입니다."),
@ApiResponse(responseCode = "40410", description = "존재하지 않는 댓글입니다.")
}
)
ApiResponseDto deleteComment(
@Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH)
@UserId Long userId,
@PathVariable final Long noticeId,
@PathVariable final Long commentId
);
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
package com.pickple.server.api.comment.repository;

import com.pickple.server.api.comment.domain.Comment;
import com.pickple.server.global.exception.CustomException;
import com.pickple.server.global.response.enums.ErrorCode;
import java.util.List;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;

public interface CommentRepository extends JpaRepository<Comment, Long> {

List<Comment> findCommentsByNoticeId(Long noticeId);

int countCommentByNoticeId(Long noticeId);

Optional<Comment> findCommentById(Long id);

default Comment findCommentByIdOrThrow(Long id) {
return findCommentById(id)
.orElseThrow(() -> new CustomException(ErrorCode.COMMENT_NOT_FOUND));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import com.pickple.server.api.notice.repository.NoticeRepository;
import com.pickple.server.api.user.domain.User;
import com.pickple.server.api.user.repository.UserRepository;
import com.pickple.server.global.exception.CustomException;
import com.pickple.server.global.response.enums.ErrorCode;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand Down Expand Up @@ -34,4 +36,15 @@ public void createComment(Long userId,

commentRepository.save(comment);
}

public void deleteComment(Long userId, Long noticeId, Long commentId) {
Notice notice = noticeRepository.findNoticeByIdOrThrow(noticeId);
Comment comment = commentRepository.findCommentByIdOrThrow(commentId);

if (comment.getCommenter().getId().equals(userId)) {
commentRepository.delete(comment);
} else {
throw new CustomException(ErrorCode.NOT_AUTHOR);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import com.pickple.server.api.moim.dto.request.MoimCreateRequest;
import com.pickple.server.api.moim.dto.response.MoimCreateResponse;
import com.pickple.server.api.moim.repository.MoimRepository;
import com.pickple.server.global.util.DateUtil;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Scheduled;
Expand Down Expand Up @@ -47,11 +47,11 @@ public MoimCreateResponse createMoim(Long hostId, MoimCreateRequest request) {
.build();
}

//1분마다 실행
@Scheduled(cron = "0 0/1 * * * *", zone = "Asia/Seoul")
//정각마다 실행
@Scheduled(cron = "0 0 0/1 * * *", zone = "Asia/Seoul")
public void changeMoimStateOfDday() {
LocalDate date = LocalDate.now();
String formattedDate = date.format(DateTimeFormatter.ofPattern("yyyy.MM.dd"));
String formattedDate = DateUtil.refineDate(date);
List<Moim> moimList = moimRepository.findByDate(formattedDate);

for (Moim moim : moimList) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.pickple.server.api.review.Service;

import com.pickple.server.api.review.domain.Review;
import com.pickple.server.api.moim.domain.Moim;
import com.pickple.server.api.moim.repository.MoimRepository;
import com.pickple.server.api.review.domain.Review;
import com.pickple.server.api.review.domain.enums.HostTag;
import com.pickple.server.api.review.domain.enums.MoimTag;
import com.pickple.server.api.review.dto.response.ReviewListGetByHostResponse;
import com.pickple.server.api.review.dto.response.ReviewListGetByMoimResponse;
import com.pickple.server.api.review.dto.response.TagListGetResponse;
import com.pickple.server.api.review.repository.ReviewRepository;
import com.pickple.server.global.util.DateTimeUtil;
Expand Down Expand Up @@ -48,7 +49,7 @@ public List<ReviewListGetByMoimResponse> getReviewListByMoim(Long moimId) {
.date(DateTimeUtil.refineDateAndTime(review.getCreatedAt()))
.build())
.collect(Collectors.toList());
}
}

public List<ReviewListGetByHostResponse> getReviewListByHost(Long hostId) {
List<Moim> moimList = moimRepository.findMoimByHostId(hostId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.pickple.server.api.review.Service.ReviewCommandService;
import com.pickple.server.api.review.Service.ReviewQueryService;
import com.pickple.server.api.review.dto.request.ReviewCreateReqeust;
import com.pickple.server.api.review.dto.response.ReviewListGetByHostResponse;
import com.pickple.server.api.review.dto.response.ReviewListGetByMoimResponse;
import com.pickple.server.api.review.dto.response.TagListGetResponse;
import com.pickple.server.global.common.annotation.GuestId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.pickple.server.api.review.controller;

import com.pickple.server.api.review.dto.request.ReviewCreateReqeust;
import com.pickple.server.api.review.dto.response.ReviewListGetByHostResponse;
import com.pickple.server.api.review.dto.response.ReviewListGetByMoimResponse;
import com.pickple.server.api.review.dto.response.TagListGetResponse;
import com.pickple.server.global.common.annotation.GuestId;
Expand Down Expand Up @@ -48,7 +49,7 @@ ApiResponseDto createReview(
@Operation(summary = "모임에 해당하는 리뷰 조회")
@ApiResponses(
value = {
@ApiResponse(responseCode = "20038", description = "모임에 해당하는 리뷰 조회 성공"),
@ApiResponse(responseCode = "20037", description = "모임에 해당하는 리뷰 조회 성공"),
@ApiResponse(responseCode = "40404", description = "존재하지 않는 모임입니다.")
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public enum ErrorCode {
MISSING_IMAGE_URL(40009, HttpStatus.BAD_REQUEST, "필수 이미지가 없습니다."),
DUPLICATION_REVIEW(40010, HttpStatus.BAD_REQUEST, "해당 사용자가 이미 작성한 리뷰가 존재합니다"),
NO_SUBMISSION_FOUND_FOR_REVIEW(40011, HttpStatus.BAD_REQUEST, "리뷰를 작성할 수 있는 신청이 없습니다"),
NOT_AUTHOR(40012, HttpStatus.BAD_REQUEST, "해당 댓글의 작성자가 아닙니다."),

// 401 Unauthorized
ACCESS_TOKEN_EXPIRED(40100, HttpStatus.UNAUTHORIZED, "액세스 토큰이 만료되었습니다."),
Expand All @@ -41,6 +42,7 @@ public enum ErrorCode {
MOIM_SUBMISSION_NOT_FOUND(40406, HttpStatus.NOT_FOUND, "해당 모임에 신청한 내역이 없습니다."),
SUBMITTER_NOT_FOUND(40408, HttpStatus.NOT_FOUND, "존재하지 않는 호스트 승인 신청입니다."),
NOTICE_NOT_FOUND(40409, HttpStatus.NOT_FOUND, "존재하지 않는 공지사항입니다."),
COMMENT_NOT_FOUND(40410, HttpStatus.NOT_FOUND, "존재하지 않는 댓글입니다."),

// 405 Method Not Allowed Error
METHOD_NOT_ALLOWED(40500, HttpStatus.METHOD_NOT_ALLOWED, "지원하지 않는 메소드입니다."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public enum SuccessCode {
MOIM_SUBMISSION_ALL_GET_SUCCESS(20033, HttpStatus.OK, "모임 참여 신청 전체 조회 성공"),
GUEST_PROFILE_UPDATE_SUCCESS(20034, HttpStatus.OK, "게스트 프로필 수정 성공"),
HOST_PROFILE_UPDATE_SUCCESS(20035, HttpStatus.OK, "호스트 프로필 수정 성공"),
COMMENT_DELETE_SUCCESS(20036, HttpStatus.OK, "공지사항 댓글 삭제 성공"),
REVIEW_LIST_BY_MOIM_GET_SUCCESS(20037, HttpStatus.OK, "모임에 해당하는 리뷰 조회 성공"),
REVIEW_LIST_BY_HOST_GET_SUCCESS(20038, HttpStatus.OK, "호스트에 해당하는 리뷰 전체 조회 성공"),

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/pickple/server/global/util/DateUtil.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.pickple.server.global.util;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;

public class DateUtil {
Expand All @@ -16,4 +17,9 @@ public static int calculateCompletedDay(LocalDate date) {
int day = (int) ChronoUnit.DAYS.between(today, date);
return day;
}

public static String refineDate(LocalDate localDate) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy.MM.dd");
return localDate.format(formatter);
}
}

0 comments on commit 76167fd

Please sign in to comment.