-
Notifications
You must be signed in to change notification settings - Fork 0
Develop #125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Develop #125
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -45,6 +45,7 @@ public class StoreService { | |||||
| private final StoreRemainRepository storeRemainRepository; | ||||||
|
|
||||||
| // ๋งค์ฅ ๋ฑ๋ก | ||||||
| @CacheEvict(value = "storeList", allEntries = true) | ||||||
| @Transactional | ||||||
| public StoreCreateResponse createStore(Long userId, StoreCreateRequest request) { | ||||||
| userRepository.getAdminOrThrow(userId, ErrorCode.ADMIN_ONLY_STORE_CREATE); | ||||||
|
|
@@ -57,6 +58,7 @@ public StoreCreateResponse createStore(Long userId, StoreCreateRequest request) | |||||
| * ๋งค์ฅ ๋ชฉ๋ก ํตํฉ ์กฐํ (์ด๋ฆยท์นดํ ๊ณ ๋ฆฌยท์ง์ญ ์ต์ ๋ ํํฐ + DB ํ์ด์ง๋ค์ด์ + ์ธ๊ธฐ ์ ๋ ฌ) | ||||||
| * Specification ์ฌ์ฉ์ผ๋ก PostgreSQL+enum ์กฐํฉ์์ :param IS NULL ํํผ. | ||||||
| */ | ||||||
| @Cacheable(value = "storeList", key = "T(String).valueOf(#category) + ':' + T(String).valueOf(#district) + ':' + #page + ':' + #size", condition = "#name == null") | ||||||
| @Transactional(readOnly = true) | ||||||
| public List<StoreListResponse> getStores(String name, Category category, District district, int page, int size) { | ||||||
| int limitedSize = Math.min(size, 100); | ||||||
|
|
@@ -79,10 +81,9 @@ public List<StoreListResponse> getPopularStores(int limit) { | |||||
| .toList(); | ||||||
| } | ||||||
|
|
||||||
| @CacheEvict(value = "popularStores", allEntries = true) | ||||||
| @CacheEvict(value = {"popularStores", "storeList"}, allEntries = true) | ||||||
| @Transactional | ||||||
| public void evictPopularStoresCache() { | ||||||
| // ๋งค์ฅ ๋ฑ๋ก/์์ /๋ฆฌ๋ทฐ ์์ฑ ๋ฑ ์ธ๊ธฐ๋ ๋ณ๋ ์ ํธ์ถ | ||||||
| } | ||||||
|
|
||||||
| @Tool(description = "์ฌ์ฉ์ ์ฃผ๋ณ์ ์ธ๊ธฐ ๋งค์ฅ์ ์กฐํํฉ๋๋ค. '๋ด ์ฃผ๋ณ ๋ง์ง', '๊ทผ์ฒ ์ธ๊ธฐ ๋งค์ฅ', '์ฃผ๋ณ ๋ง์ง ์ถ์ฒ' ๋ฑ์ ์์ฒญ์ ์ฌ์ฉํ์ธ์. ์์น ์ ๋ณด๊ฐ ์์ผ๋ฉด ์ฌ์ฉํ ์ ์์ต๋๋ค.") | ||||||
|
|
@@ -196,6 +197,7 @@ public StoreDetailResponse getStore(Long storeId) { | |||||
| } | ||||||
|
|
||||||
| // ๋งค์ฅ ์ ๋ณด ์์ | ||||||
| @CacheEvict(value = "storeList", allEntries = true) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๋งค์ฅ ์ ๋ณด๊ฐ ์์ ๋๋ฉด ์ธ๊ธฐ ๋งค์ฅ ๋ชฉ๋ก(
Suggested change
|
||||||
| @Transactional | ||||||
| public StoreUpdateResponse updateStore(Long userId, Long storeId, StoreUpdateRequest request) { | ||||||
| userRepository.getAdminOrThrow(userId, ErrorCode.ADMIN_ONLY_STORE_UPDATE); | ||||||
|
|
@@ -210,6 +212,7 @@ public StoreUpdateResponse updateStore(Long userId, Long storeId, StoreUpdateReq | |||||
| } | ||||||
|
|
||||||
| // ๋งค์ฅ ์ํ ๋ณ๊ฒฝ | ||||||
| @CacheEvict(value = "storeList", allEntries = true) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๋งค์ฅ์ ์ํ๊ฐ ๋ณ๊ฒฝ๋์ด ๋นํ์ฑํ(
Suggested change
|
||||||
| @Transactional | ||||||
| public StoreStatusUpdateResponse updateStoreStatus(Long userId, Long storeId, StoreStatusUpdateRequest request) { | ||||||
| userRepository.getAdminOrThrow(userId, ErrorCode.ADMIN_ONLY_STORE_STATUS); | ||||||
|
|
@@ -223,20 +226,23 @@ public StoreStatusUpdateResponse updateStoreStatus(Long userId, Long storeId, St | |||||
| * ์์ฒด ๋ฆฌ๋ทฐ ์์ฑ ์ ํธ์ถ โ ์ธ๋ถ ์๋๋ ๋ณ์ /๋ฆฌ๋ทฐ์๋ฅผ base๋ก ํ๊ท ์ ํฉ์ฐ. | ||||||
| * ๋ฆฌ์ค๋์์ ๋น๋๊ธฐ๋ก ํธ์ถ๋๋ฏ๋ก ๋ฆฌ๋ทฐ ์์ฑ ์์ฒด์ ์ํฅ์ ์ฃผ์ง ์๋๋ค. | ||||||
| */ | ||||||
| @CacheEvict(value = {"popularStores", "storeList"}, allEntries = true) | ||||||
| @Transactional | ||||||
| public void applyReviewCreated(Long storeId, int newStar) { | ||||||
| Store store = storeRepository.findByIdAndIsDeletedFalse(storeId) | ||||||
| .orElseThrow(() -> new CustomException(ErrorCode.STORE_NOT_FOUND)); | ||||||
| store.applyReviewCreated(newStar); | ||||||
| } | ||||||
|
|
||||||
| @CacheEvict(value = {"popularStores", "storeList"}, allEntries = true) | ||||||
| @Transactional | ||||||
| public void applyReviewDeleted(Long storeId, int deletedStar) { | ||||||
| Store store = storeRepository.findByIdAndIsDeletedFalse(storeId) | ||||||
| .orElseThrow(() -> new CustomException(ErrorCode.STORE_NOT_FOUND)); | ||||||
| store.applyReviewDeleted(deletedStar); | ||||||
| } | ||||||
|
|
||||||
| @CacheEvict(value = {"popularStores", "storeList"}, allEntries = true) | ||||||
| @Transactional | ||||||
| public void applyReviewUpdated(Long storeId, int oldStar, int newStar) { | ||||||
| Store store = storeRepository.findByIdAndIsDeletedFalse(storeId) | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SpEL(Spring Expression Language)์์
null๊ฐ์ฒด๋ฅผ ๋ฌธ์์ด๊ณผ ์ฐ๊ฒฐ(+)ํ ๋ ์๋์ผ๋ก"null"๋ฌธ์์ด๋ก ๋ณํ๋๋ฏ๋ก,T(String).valueOf(...)๋ฅผ ์๋ตํ์ฌ ์ฝ๋๋ฅผ ๋ ๊ฐ๊ฒฐํ๊ฒ ์์ฑํ ์ ์์ต๋๋ค.\n\n๋ํ, ํ์ฌcondition = "#name == null"์กฐ๊ฑด์ ๊ฒ์์ด(name)๊ฐ ๋น ๋ฌธ์์ด("")์ด๋ ๊ณต๋ฐฑ(" ")์ผ๋ก ๋ค์ด์ค๋ ๊ฒฝ์ฐ ์บ์๋ฅผ ํ์ง ์๊ณ ํญ์ DB๋ฅผ ์กฐํํ๊ฒ ๋ง๋ญ๋๋ค. ๋ฉ์๋ ๋ด๋ถ์์๋name.isBlank()์ผ ๋trimmedName์null๋ก ์ฒ๋ฆฌํ์ฌ ์ ์ฒด ๋ชฉ๋ก์ ์กฐํํ๋ฏ๋ก, ๊ฒฐ๊ณผ์ ์ผ๋ก ๋์ผํ ์ ์ฒด ๋ชฉ๋ก ์กฐํ ์ฟผ๋ฆฌ๊ฐ ์บ์ ์์ด ๋ฐ๋ณต ์คํ๋ ์ ์์ต๋๋ค. ๋น ๋ฌธ์์ด์ด๋ ๊ณต๋ฐฑ์ธ ๊ฒฝ์ฐ์๋ ์บ์๊ฐ ์ ์ฉ๋๋๋ก ์กฐ๊ฑด์ ๊ฐ์ ํ๋ ๊ฒ์ ์ถ์ฒํฉ๋๋ค.