Skip to content

Commit

Permalink
Merge pull request #37 from LikeLion-12th-SKHU/develop
Browse files Browse the repository at this point in the history
Develop -> main push
  • Loading branch information
ttttkii913 authored Jul 25, 2024
2 parents 1827d63 + b8459fc commit 19e1ea3
Show file tree
Hide file tree
Showing 11 changed files with 140 additions and 66 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.likelion.likelion_12th_team05.common;

import org.likelion.likelion_12th_team05.common.error.ErrorCode;
import org.likelion.likelion_12th_team05.common.exception.NotFoundException;

import java.util.Optional;

public class EntityFinder {

// ์—”ํ‹ฐํ‹ฐ not found ์ฒ˜๋ฆฌ
public static <T> T findByIdOrThrow(Optional<T> optionalEntity, ErrorCode errorCode) {
return optionalEntity.orElseThrow(() ->
new NotFoundException(errorCode, errorCode.getMessage()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.likelion.likelion_12th_team05.common.advice;

import org.likelion.likelion_12th_team05.common.exception.NotFoundException;
import org.likelion.likelion_12th_team05.config.ApiResponseTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice
public class CustomExceptionAdvice {

// ์—”ํ‹ฐํ‹ฐ not found ์—๋Ÿฌ ์ฒ˜๋ฆฌ ํ•ธ๋“ค๋Ÿฌ
@ExceptionHandler(NotFoundException.class)
public ResponseEntity<ApiResponseTemplate<Void>> handleNotFoundException(NotFoundException ex) {
ApiResponseTemplate<Void> errorResponse = ApiResponseTemplate.errorResponse(ex.getErrorCode());
return new ResponseEntity<>(errorResponse, HttpStatus.NOT_FOUND);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class CurationController {
private final LocationService locationService;
private final UserService userService;

@Operation(summary = "๋ชจ๋“  ์‚ฌ์šฉ์ž๊ฐ€ ํ๋ ˆ์ด์…˜ 6๊ฐœ์”ฉ ์กฐํšŒ", description = "๋ชจ๋“  ์‚ฌ์šฉ์ž๊ฐ€ ํ๋ ˆ์ด์…˜์„ 6๊ฐœ์”ฉ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค.")
@Operation(summary = "๋ชจ๋“  ์‚ฌ์šฉ์ž๊ฐ€ ํ๋ ˆ์ด์…˜ 6๊ฐœ์”ฉ ์กฐํšŒ", description = "๋ชจ๋“  ์‚ฌ์šฉ์ž๊ฐ€ ์‚ฐ์ฑ…๋กœ ์ง€๋„ ํŽ˜์ด์ง€์—์„œ ํ๋ ˆ์ด์…˜์„ ํ•œ ํŽ˜์ด์ง€ ๋‹น 6๊ฐœ์”ฉ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "์‘๋‹ต ์ƒ์„ฑ์— ์„ฑ๊ณตํ•˜์˜€์Šต๋‹ˆ๋‹ค."),
@ApiResponse(responseCode = "400", description = "์ž˜๋ชป๋œ ์š”์ฒญ์ž…๋‹ˆ๋‹ค."),
Expand All @@ -57,7 +57,7 @@ public ApiResponseTemplate<CurationListResDto> curationFindAll (
return ApiResponseTemplate.successResponse(curationListResDto, SuccessCode.GET_SUCCESS);
}

@Operation(summary = "์ธ์ฆ๋œ ์‚ฌ์šฉ์ž๊ฐ€ ํ๋ ˆ์ด์…˜ ์ƒ์„ฑ", description = "์ธ์ฆ๋œ ์‚ฌ์šฉ์ž๊ฐ€ ํ๋ ˆ์ด์…˜์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.")
@Operation(summary = "์ธ์ฆ๋œ ์‚ฌ์šฉ์ž๊ฐ€ ํ๋ ˆ์ด์…˜ ์ƒ์„ฑ", description = "์ธ์ฆ๋œ ์‚ฌ์šฉ์ž๊ฐ€ ์‚ฐ์ฑ…๋กœ ์ƒ์„ฑ ํŽ˜์ด์ง€์—์„œ ํ๋ ˆ์ด์…˜์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "์‘๋‹ต ์ƒ์„ฑ์— ์„ฑ๊ณตํ•˜์˜€์Šต๋‹ˆ๋‹ค."),
@ApiResponse(responseCode = "400", description = "์ž˜๋ชป๋œ ์š”์ฒญ์ž…๋‹ˆ๋‹ค."),
Expand All @@ -71,7 +71,7 @@ public ApiResponseTemplate<CurationInfoResDto> curationSave(@RequestBody Curatio
return ApiResponseTemplate.successResponse(curationInfoResDto, SuccessCode.CURATION_SAVE_SUCCESS);
}

@Operation(summary = "์ธ์ฆ๋œ ์‚ฌ์šฉ์ž๊ฐ€ ํ๋ ˆ์ด์…˜ ์ˆ˜์ •", description = "์ธ์ฆ๋œ ์‚ฌ์šฉ์ž๊ฐ€ ํ๋ ˆ์ด์…˜์„ ์ˆ˜์ •(ํ๋ ˆ์ด์…˜ ์ œ๋ชฉ, ์„ค๋ช…)ํ•ฉ๋‹ˆ๋‹ค.")
@Operation(summary = "์ธ์ฆ๋œ ์‚ฌ์šฉ์ž๊ฐ€ ํ๋ ˆ์ด์…˜ ์ˆ˜์ •", description = "์ธ์ฆ๋œ ์‚ฌ์šฉ์ž๊ฐ€ ์‚ฐ์ฑ…๋กœ ์ง€๋„ ํŽ˜์ด์ง€์—์„œ ํ๋ ˆ์ด์…˜์„ ์ˆ˜์ •(ํ๋ ˆ์ด์…˜ ์ œ๋ชฉ, ์„ค๋ช…)ํ•ฉ๋‹ˆ๋‹ค.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "์‘๋‹ต ์ƒ์„ฑ์— ์„ฑ๊ณตํ•˜์˜€์Šต๋‹ˆ๋‹ค."),
@ApiResponse(responseCode = "400", description = "์ž˜๋ชป๋œ ์š”์ฒญ์ž…๋‹ˆ๋‹ค."),
Expand Down Expand Up @@ -100,7 +100,7 @@ public ApiResponseTemplate<SuccessCode> curationDelete(@PathVariable("curationId
return ApiResponseTemplate.successWithNoContent(SuccessCode.GET_SUCCESS);
}

@Operation(summary = "๋ชจ๋“  ์‚ฌ์šฉ์ž๊ฐ€ ํ๋ ˆ์ด์…˜ ๊ฒ€์ƒ‰", description = "๋ชจ๋“  ์‚ฌ์šฉ์ž๊ฐ€ ํ๋ ˆ์ด์…˜์„ ๊ฒ€์ƒ‰ํ•ฉ๋‹ˆ๋‹ค.")
@Operation(summary = "๋ชจ๋“  ์‚ฌ์šฉ์ž๊ฐ€ ํ๋ ˆ์ด์…˜ ๊ฒ€์ƒ‰", description = "๋ชจ๋“  ์‚ฌ์šฉ์ž๊ฐ€ ์‚ฐ์ฑ…๋กœ ์ง€๋„ ํŽ˜์ด์ง€์—์„œ ํ๋ ˆ์ด์…˜์„ ๊ฒ€์ƒ‰ํ•ฉ๋‹ˆ๋‹ค.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "์‘๋‹ต ์ƒ์„ฑ์— ์„ฑ๊ณตํ•˜์˜€์Šต๋‹ˆ๋‹ค."),
@ApiResponse(responseCode = "400", description = "์ž˜๋ชป๋œ ์š”์ฒญ์ž…๋‹ˆ๋‹ค."),
Expand All @@ -113,10 +113,7 @@ public ApiResponseTemplate<CurationListResDto> searchCurations(@RequestParam Str
return ApiResponseTemplate.successResponse(searchResults, SuccessCode.GET_SUCCESS);
}

// - ์ค‘, ์กฐํšŒ-
// ๋žœ๋”ฉ ํŽ˜์ด์ง€ - ๊ฒŒ์‹œ๊ธ€์„ ๋งŽ์ด ์ž‘์„ฑํ•œ 5๋ช…์˜ ํ๋ ˆ์ดํ„ฐ ์กฐํšŒ ๊ฐ€๋Šฅ

@Operation(summary = "๋ชจ๋“  ์‚ฌ์šฉ์ž๊ฐ€ ์ข‹์•„์š” ์ˆœ์œผ๋กœ ์ •๋ ฌ๋œ ํ๋ ˆ์ด์…˜ 6๊ฐœ ์กฐํšŒ", description = "๋ชจ๋“  ์‚ฌ์šฉ์ž๊ฐ€ ์ข‹์•„์š” ์ˆœ์œผ๋กœ ์ •๋ ฌ๋œ ํ๋ ˆ์ด์…˜์„ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค.")
@Operation(summary = "๋ชจ๋“  ์‚ฌ์šฉ์ž๊ฐ€ ์ข‹์•„์š” ์ˆœ์œผ๋กœ ์ •๋ ฌ๋œ ํ๋ ˆ์ด์…˜ 6๊ฐœ ์กฐํšŒ", description = "๋ชจ๋“  ์‚ฌ์šฉ์ž๊ฐ€ ๋žœ๋”ฉํŽ˜์ด์ง€์—์„œ ์ข‹์•„์š” ์ˆœ์œผ๋กœ ์ •๋ ฌ๋œ 6๊ฐœ์˜ ํ๋ ˆ์ด์…˜์„ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "์‘๋‹ต ์ƒ์„ฑ์— ์„ฑ๊ณตํ•˜์˜€์Šต๋‹ˆ๋‹ค."),
@ApiResponse(responseCode = "400", description = "์ž˜๋ชป๋œ ์š”์ฒญ์ž…๋‹ˆ๋‹ค."),
Expand All @@ -128,4 +125,17 @@ public ApiResponseTemplate<CurationListResDto> findTop6ByOrderByLikeCountDesc()
CurationListResDto curationListResDto = curationService.findTop6ByOrderByLikeCountDesc();
return ApiResponseTemplate.successResponse(curationListResDto, SuccessCode.GET_SUCCESS);
}

@Operation(summary = "๋ชจ๋“  ์‚ฌ์šฉ์ž๊ฐ€ ์ตœ์‹ ์ˆœ์œผ๋กœ ์ •๋ ฌ๋œ ํ๋ ˆ์ด์…˜ 6๊ฐœ ์กฐํšŒ", description = "๋ชจ๋“  ์‚ฌ์šฉ์ž๊ฐ€ ๋žœ๋”ฉํŽ˜์ด์ง€์—์„œ ์ตœ์‹ ์ˆœ์œผ๋กœ ์ •๋ ฌ๋œ 6๊ฐœ์˜ ํ๋ ˆ์ด์…˜์„ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "์‘๋‹ต ์ƒ์„ฑ์— ์„ฑ๊ณตํ•˜์˜€์Šต๋‹ˆ๋‹ค."),
@ApiResponse(responseCode = "400", description = "์ž˜๋ชป๋œ ์š”์ฒญ์ž…๋‹ˆ๋‹ค."),
@ApiResponse(responseCode = "500", description = "์„œ๋ฒ„ ๋‚ด๋ถ€ ์˜ค๋ฅ˜์ž…๋‹ˆ๋‹ค.")
})
@GetMapping("/recent")
public ApiResponseTemplate<CurationListResDto> findTop6byOrderByCreateDateDesc() {
CurationListResDto curationListResDto = curationService.findTop6byOrderByCreateDateDesc();
return ApiResponseTemplate.successResponse(curationListResDto, SuccessCode.GET_SUCCESS);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@
import org.likelion.likelion_12th_team05.curation.domain.Curation;

import java.time.LocalDate;
import java.time.LocalDateTime;

@Builder
public record CurationInfoResDto(
Long id,
String name,
String content,
LocalDateTime createDate,
Integer likeCount
) {
public static CurationInfoResDto from(Curation curation) {
return CurationInfoResDto.builder()
.id(curation.getId())
.name(curation.getName())
.content(curation.getContent())
.createDate(curation.getCreateDate())
.likeCount(curation.getLikeCount())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.likelion.likelion_12th_team05.curation.application;

import lombok.RequiredArgsConstructor;
import org.likelion.likelion_12th_team05.common.EntityFinder;
import org.likelion.likelion_12th_team05.common.error.ErrorCode;
import org.likelion.likelion_12th_team05.common.exception.NotFoundException;
import org.likelion.likelion_12th_team05.curation.api.dto.request.CurationUpdateReqDto;
Expand Down Expand Up @@ -29,10 +30,9 @@ public class CurationService {
// ์ธ์ฆ๋œ ์‚ฌ์šฉ์ž - ํ๋ ˆ์ด์…˜ ์ƒ์„ฑ
@Transactional
public CurationInfoResDto curationSave(CurationSaveReqDto curationSaveReqDto, Principal principal) {
String email = principal.getName();
User user = userRepository.findByEmail(email).orElseThrow(
() -> new NotFoundException(ErrorCode.USER_NOT_FOUND_EXCEPTION
, ErrorCode.USER_NOT_FOUND_EXCEPTION.getMessage()));
Long id = Long.parseLong(principal.getName()); // user repo์—์„œ userId๋กœ ๋ฐ”๊ฟ”์•ผ ํ•จ
User user = getUserById(id);

Curation curation = curationSaveReqDto.toEntity(user);
curationRepository.save(curation);

Expand All @@ -42,19 +42,15 @@ public CurationInfoResDto curationSave(CurationSaveReqDto curationSaveReqDto, Pr
// ์ธ์ฆ๋œ ์‚ฌ์šฉ์ž - ํ๋ ˆ์ด์…˜ ์ˆ˜์ •
@Transactional
public CurationInfoResDto curationUpdate(Long curationId, CurationUpdateReqDto curationUpdateReqDto, Principal principal) {
String email = principal.getName();
User user = userRepository.findByEmail(email).orElseThrow(
() -> new NotFoundException(ErrorCode.USER_NOT_FOUND_EXCEPTION
, ErrorCode.USER_NOT_FOUND_EXCEPTION.getMessage()));
Long id = Long.parseLong(principal.getName()); // user repo์—์„œ userId๋กœ ๋ฐ”๊ฟ”์•ผ ํ•จ
User user = getUserById(id);

Curation curation = curationRepository.findById(curationId).orElseThrow(
() -> new NotFoundException(ErrorCode.CURATIONS_NOT_FOUND_EXCEPTION
, ErrorCode.CURATIONS_NOT_FOUND_EXCEPTION.getMessage()));
Curation curation = getCurationById(curationId);

// ์ˆ˜์ • ๊ถŒํ•œ ํ™•์ธ -- ํ† ํฐ ๋ฐœ๊ธ‰์˜ ์ฃผ์ฒด๊ฐ€ email์ด๊ธฐ์— email๋กœ ์‚ฌ์šฉ์ž ํ™•์ธ์„ ํ•˜์˜€์œผ๋‚˜
// userid๋กœ ํŒ๋‹จ ํ•˜๋Š” ๊ฒƒ์ด ๋” ์ข‹์ง€ ์•Š์„๊นŒ ์ƒ๊ฐํ•จ. ์ผ๋‹จ crud์™€ ๋กœ๊ทธ์ธ ์—ฐ๊ฒฐ ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•ด email๋กœ ํ…Œ์ŠคํŠธ ํ•จ -- ์ƒ์˜ ํ•„์š”
String LoginEmail = principal.getName();
if (!email.equals(LoginEmail)) {
// userid๋กœ ํŒ๋‹จ ํ•˜๋Š” ๊ฒƒ์ด ๋” ์ข‹์ง€ ์•Š์„๊นŒ ์ƒ๊ฐํ•จ. ์ผ๋‹จ crud์™€ ๋กœ๊ทธ์ธ ์—ฐ๊ฒฐ ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•ด email๋กœ ํ…Œ์ŠคํŠธ ํ•จ -> ํ…Œ์ŠคํŠธ ์„ฑ๊ณต -> userId๋กœ ๋ฐ”๊พธ๊ธฐ๋กœ ํ•จ
String LoginId = principal.getName();
if (!id.equals(LoginId)) {
throw new NotFoundException(ErrorCode.NO_AUTHORIZATION_EXCEPTION
, ErrorCode.NO_AUTHORIZATION_EXCEPTION.getMessage());
}
Expand All @@ -67,8 +63,7 @@ public CurationInfoResDto curationUpdate(Long curationId, CurationUpdateReqDto c
// ์ธ์ฆ๋œ ์‚ฌ์šฉ์ž - ํ๋ ˆ์ด์…˜ ์‚ญ์ œ
@Transactional
public void curationDelete(Long curationId, Principal principal) {
Curation curation = curationRepository.findById(curationId)
.orElseThrow(() -> new IllegalArgumentException("ํ•ด๋‹น ํ๋ ˆ์ด์…˜์ด ์—†์Šต๋‹ˆ๋‹ค. id=" + curationId));
Curation curation = getCurationById(curationId);

// ์‚ญ์ œ ๊ถŒํ•œ ํ™•์ธ
Long id = Long.parseLong(principal.getName());
Expand Down Expand Up @@ -102,7 +97,7 @@ public CurationListResDto curationFindAll(Pageable pageable) {
return CurationListResDto.from(curationInfoResDtoList);
}

// ๋ชจ๋“  ์‚ฌ์šฉ์ž - ํ๋ ˆ์ด์…˜ ์ข‹์•„์š” ๋งŽ์€ ์ˆœ์œผ๋กœ 6๊ฐœ๋งŒ ์กฐํšŒ
// ๋ชจ๋“  ์‚ฌ์šฉ์ž - ๋žœ๋”ฉ ํŽ˜์ด์ง€ - ํ๋ ˆ์ด์…˜ ์ข‹์•„์š” ๋งŽ์€ ์ˆœ์œผ๋กœ 6๊ฐœ๋งŒ ์กฐํšŒ
@Transactional
public CurationListResDto findTop6ByOrderByLikeCountDesc() {
List<Curation> curations = curationRepository.findTop6ByOrderByLikeCountDesc();
Expand All @@ -112,4 +107,24 @@ public CurationListResDto findTop6ByOrderByLikeCountDesc() {
return CurationListResDto.from(curationInfoResDtoList);
}

// ๋ชจ๋“  ์‚ฌ์šฉ์ž - ๋žœ๋”ฉํŽ˜์ด์ง€ - ํ๋ ˆ์ด์…˜ ์ตœ์‹ (createDate desc) ์ˆœ์œผ๋กœ 6๊ฐœ๋งŒ ์กฐํšŒ
@Transactional
public CurationListResDto findTop6byOrderByCreateDateDesc() {
List<Curation> curations = curationRepository.findTop6byOrderByCreateDateDesc();
List<CurationInfoResDto> curationInfoResDtoList = curations.stream()
.map(CurationInfoResDto::from)
.toList();
return CurationListResDto.from(curationInfoResDtoList);
}

// ๋ฐ˜๋ณต๋˜๋Š” ์˜ˆ์™ธ ๋ฐ˜ํ™˜ ๋ฉ”์„œ๋“œ ์ถ”์ถœ => ๊ณตํ†ต ์˜ˆ์™ธ ์ฒ˜๋ฆฌ๋กœ ์ผ๊ด€์„ฑ ๋†’์ด๊ธฐ ์œ„ํ•จ => entityfinder๋กœ ์ค‘์•™ ๊ด€๋ฆฌ
private Curation getCurationById(Long curationId) {
return EntityFinder.findByIdOrThrow(curationRepository.findById(curationId)
, ErrorCode.CURATIONS_NOT_FOUND_EXCEPTION);
}

private User getUserById(Long userId) {
return EntityFinder.findByIdOrThrow(userRepository.findById(userId)
, ErrorCode.USER_NOT_FOUND_EXCEPTION);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ public interface CurationRepository extends JpaRepository<Curation, Long> {
List<Curation> findTop6ByOrderByLikeCountDesc();

// ์ตœ์‹ ์ˆœ ์กฐํšŒ
@Query(value = "SELECT * FROM curation ORDER BY create_date DESC limit 6", nativeQuery = true)
List<Curation> findTop6byOrderByCreateDateDesc();
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.likelion.likelion_12th_team05.like.application;

import lombok.RequiredArgsConstructor;
import org.likelion.likelion_12th_team05.common.EntityFinder;
import org.likelion.likelion_12th_team05.common.error.ErrorCode;
import org.likelion.likelion_12th_team05.common.exception.NotFoundException;
import org.likelion.likelion_12th_team05.curation.domain.Curation;
Expand All @@ -13,7 +14,6 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;

import java.io.IOException;
import java.security.Principal;
import java.util.List;

Expand All @@ -27,14 +27,10 @@ public class LikeService {

@Transactional
public void likeSave(@PathVariable("curationId") Long curationId, Principal principal) {
Curation curation = curationRepository.findById(curationId).orElseThrow(
() -> new NotFoundException(ErrorCode.CURATIONS_NOT_FOUND_EXCEPTION,
ErrorCode.CURATIONS_NOT_FOUND_EXCEPTION.getMessage()));
Curation curation = getCurationById(curationId);

String email = principal.getName();
User user = userRepository.findByEmail(email).orElseThrow(
() -> new NotFoundException(ErrorCode.USER_NOT_FOUND_EXCEPTION,
ErrorCode.USER_NOT_FOUND_EXCEPTION.getMessage()));
Long id = Long.parseLong(principal.getName());
User user = getUserById(id);

Like like = Like.of(curation, user);
likeRepository.save(like);
Expand All @@ -46,14 +42,11 @@ public void likeSave(@PathVariable("curationId") Long curationId, Principal prin
}

@Transactional
public void likeDelete(@PathVariable("curationId") Long curationId, Principal principal) throws IOException {
Curation curation = curationRepository.findById(curationId).orElseThrow(
() -> new NotFoundException(ErrorCode.CURATIONS_NOT_FOUND_EXCEPTION,
ErrorCode.CURATIONS_NOT_FOUND_EXCEPTION.getMessage()));
String email = principal.getName();
User user = userRepository.findByEmail(email).orElseThrow(
() -> new NotFoundException(ErrorCode.USER_NOT_FOUND_EXCEPTION,
ErrorCode.USER_NOT_FOUND_EXCEPTION.getMessage()));
public void likeDelete(@PathVariable("curationId") Long curationId, Principal principal) {
Curation curation = getCurationById(curationId);

Long id = Long.parseLong(principal.getName());
User user = getUserById(id);

// ํ๋ ˆ์ด์…˜์— ์ข‹์•„์š”๊ฐ€ ์กด์žฌํ•˜๋Š”์ง€ ํ™•์ธ
List<Like> existingLikes = likeRepository.findByCurationAndUser(curation, user);
Expand All @@ -68,4 +61,15 @@ public void likeDelete(@PathVariable("curationId") Long curationId, Principal pr
curation.deleteLikeCount();
curationRepository.save(curation);
}

// ๋ฐ˜๋ณต๋˜๋Š” ์˜ˆ์™ธ ๋ฐ˜ํ™˜ ๋ฉ”์„œ๋“œ ์ถ”์ถœ => ๊ณตํ†ต ์˜ˆ์™ธ ์ฒ˜๋ฆฌ๋กœ ์ผ๊ด€์„ฑ ๋†’์ด๊ธฐ ์œ„ํ•จ => entityfinder๋กœ ์ค‘์•™ ๊ด€๋ฆฌ
private Curation getCurationById(Long curationId) {
return EntityFinder.findByIdOrThrow(curationRepository.findById(curationId)
, ErrorCode.CURATIONS_NOT_FOUND_EXCEPTION);
}

private User getUserById(Long userId) {
return EntityFinder.findByIdOrThrow(userRepository.findById(userId)
, ErrorCode.USER_NOT_FOUND_EXCEPTION);
}
}
Loading

0 comments on commit 19e1ea3

Please sign in to comment.