-
Notifications
You must be signed in to change notification settings - Fork 0
Fix horim #29
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
Merged
Merged
Fix horim #29
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
4b79a54
๋ก๊ทธ์ธ/ํ์ ๊ฐ์
api + jwt์ด์ฉํ api ๋ณด์
diacond 3a0c497
์ฑํ
๋ฐฉ ํ
์คํธ ๋๋ฒ๊น
diacond 804fb31
์ฑํ
๋ฐฉ ๊ฐ์ค&์ฑํ
๋ฉ์์ง ํ
์คํธ ์๋ฃ
diacond f6d97e9
์นด์นด์ค์ง๋api + ์ฑํ
๋ฐฉ
diacond b8fb0c3
์ฑํ
๋ฐฉ+์ฑํ
๊ธฐ๋ฅ ์์ฑ
diacond bba4196
PR ๋ฆฌ๋ทฐ ๋ฐ์ - ๋ณด์ ๊ฐํ, username ๋ณต๊ตฌ
diacond 22c1cf8
testdb.mv.db ๋ฌด์
diacond bb68d4c
main๋ธ๋์น&pr๋ฆฌ๋ทฐ ๋ฐ์
diacond cc716f3
๋ฉ์ธ ๋ธ๋์น๋ ์ถฉ๋ ํด๊ฒฐ ํ ํฉ๋ณ
diacond 1c52e17
fix-horim ์ถฉ๋ ์์
ํด๊ฒฐ ์ค
diacond a85d765
Merge remote-tracking branch 'origin/main' into fix-horim
diacond 3c210c8
~
diacond b63d638
๋ชจ๋ ํ
์คํธ ์ค๋ฅ ํด๊ฒฐ
diacond f25b15a
PR ์ค java/CI ์ค๋ฅ ํด๊ฒฐ - MemberSignupTest
diacond efecb49
Role ์ญ์
yuuuyeonho 7c98787
์ํ๋ฆฌํฐ permitAll
yuuuyeonho 982e538
renew
diacond 457bf8e
Merge branch 'fix-horim' of http://github.com/Cagong-ReceiptPower/Recโฆ
diacond 25b7ce6
PR ํผ๋๋ฐฑ ๋ฐ์/์์
diacond 704ffa2
PR ํผ๋๋ฐฑ ๋ฐ์ + ์ค๋ฅ ์์
diacond 726292b
์ฑํ
๋ฐฉ ๊ฐ์ค ๋ฐฉ๋ฒ ์์
diacond 9e45231
๋ง์ผ๋ฆฌ์ง ํ
์คํธ ์ถฉ๋ ํด๊ฒฐ
diacond bacc23f
fix: ์๊ฐ์ง ์์
yuuuyeonho File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,7 @@ out/ | |
| .vscode/ | ||
|
|
||
| mydb.db | ||
| testdb.mv.db | ||
| .env | ||
| github-actions-key | ||
| github-actions-key.pub | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 13 additions & 6 deletions
19
src/main/java/com/cagong/receiptpowerserver/ReceiptPowerServerApplication.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,20 @@ | ||
| // ReceiptPowerServerApplication.java | ||
|
|
||
| package com.cagong.receiptpowerserver; | ||
|
|
||
| import io.github.cdimascio.dotenv.Dotenv; // import ์ถ๊ฐ | ||
| import org.springframework.boot.SpringApplication; | ||
| import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
| import org.springframework.data.jpa.repository.config.EnableJpaAuditing; | ||
|
|
||
| @EnableJpaAuditing | ||
| @SpringBootApplication | ||
| public class ReceiptPowerServerApplication { | ||
|
|
||
| public static void main(String[] args) { | ||
| SpringApplication.run(ReceiptPowerServerApplication.class, args); | ||
| } | ||
|
|
||
| } | ||
| public static void main(String[] args) { | ||
| Dotenv.configure() | ||
| .ignoreIfMissing() // .env ํ์ผ์ด ์์ด๋(์: ๋ฐฐํฌ ํ๊ฒฝ) ์ค๋ฅ ์์ด ํต๊ณผ | ||
| .systemProperties() // .env์ ๋ชจ๋ ๋ณ์๋ฅผ System.setProperty()๋ก ์๋ ๋ฑ๋ก | ||
| .load(); | ||
| SpringApplication.run(ReceiptPowerServerApplication.class, args); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 55 additions & 43 deletions
98
src/main/java/com/cagong/receiptpowerserver/domain/cafe/CafeService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,75 +1,87 @@ | ||
| package com.cagong.receiptpowerserver.domain.cafe; | ||
|
|
||
| import com.cagong.receiptpowerserver.domain.cafe.dto.CafeRequest; | ||
| import com.cagong.receiptpowerserver.domain.cafe.dto.CafeUpdateRequest; // [์์ ] 1. CafeUpdateRequest import | ||
| import com.cagong.receiptpowerserver.domain.cafe.dto.CafeResponse; | ||
| // [์์ ] 2. Kakao API ๋ฐ ChatRoomService ๊ด๋ จ ์์กด์ฑ *๋ชจ๋ ์ญ์ * | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import java.util.List; | ||
| import java.util.stream.Collectors; | ||
|
|
||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| @Transactional(readOnly = true) | ||
| public class CafeService { | ||
| private final CafeRepository cafeRepository; | ||
|
|
||
| public List<CafeResponse> getAllCafes(){ | ||
| return cafeRepository.findAll().stream() | ||
| .map(cafe -> new CafeResponse( | ||
| cafe.getId(), | ||
| cafe.getName(), | ||
| cafe.getAddress(), | ||
| cafe.getLatitude(), | ||
| cafe.getLongitude(), | ||
| cafe.getPhoneNumber() | ||
| )) | ||
| .collect(Collectors.toList()); | ||
| } | ||
| private final CafeRepository cafeRepository; | ||
|
|
||
| public CafeResponse getCafeById(Long cafeId){ | ||
| return cafeRepository.findById(cafeId) | ||
| .map(cafe -> new CafeResponse( | ||
| cafe.getId(), | ||
| cafe.getName(), | ||
| cafe.getAddress(), | ||
| cafe.getLatitude(), | ||
| cafe.getLongitude(), | ||
| cafe.getPhoneNumber() | ||
| )) | ||
| .orElseThrow(() -> new IllegalArgumentException("ํด๋น ID์ ์นดํ๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค: " + cafeId)); | ||
| } | ||
| // [์์ ] 3. ChatRoomService, RestTemplate, kakaoApiKey ์์กด์ฑ *๋ชจ๋ ์ญ์ * | ||
|
|
||
| /** | ||
| * 1. ์นดํ ์์ฑ (POST /api/cafes) | ||
| */ | ||
| @Transactional | ||
| public Long createCafe(CafeRequest request){ | ||
| public Long saveCafe(CafeRequest request) { | ||
| Cafe cafe = Cafe.builder() | ||
| .name(request.getCafeName()) | ||
| .address(request.getAddress()) | ||
| .latitude(request.getLatitude()) | ||
| .longitude(request.getLongitude()) | ||
| .phoneNumber(request.getPhoneNumber()) | ||
| .build(); | ||
| Cafe saved = cafeRepository.save(cafe); | ||
| return saved.getId(); | ||
| } | ||
|
|
||
| @Transactional | ||
| public void updateCafe(Long cafeId, CafeRequest request){ | ||
diacond marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Cafe cafe = cafeRepository.findById(cafeId) | ||
| .orElseThrow(() -> new IllegalArgumentException("ํด๋น ID์ ์นดํ๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค: " + cafeId)); | ||
| Cafe savedCafe = cafeRepository.save(cafe); | ||
| return savedCafe.getId(); | ||
| } | ||
|
|
||
| cafe.updateFrom(request); | ||
| /** | ||
| * 2. ์นดํ ์ ์ฒด ์กฐํ (GET /api/cafes/all) | ||
| */ | ||
| @Transactional(readOnly = true) | ||
| public List<CafeResponse> findAllCafes() { | ||
| return cafeRepository.findAll().stream() | ||
| .map(CafeResponse::new) // (CafeResponse(Cafe) ์์ฑ์ ์ฌ์ฉ) | ||
| .collect(Collectors.toList()); | ||
| } | ||
|
|
||
| cafeRepository.save(cafe); | ||
| /** | ||
| * 3. ์นดํ ID๋ก 1๊ฑด ์กฐํ (GET /api/cafes/{cafeId}) | ||
| */ | ||
| @Transactional(readOnly = true) | ||
| public CafeResponse findCafeById(Long cafeId) { | ||
| Cafe cafe = cafeRepository.findById(cafeId) | ||
| .orElseThrow(() -> new RuntimeException("ํด๋น ID์ ์นดํ๋ฅผ ์กฐํํ ์ ์์ต๋๋ค:" + cafeId)); | ||
| return new CafeResponse(cafe); // (CafeResponse(Cafe) ์์ฑ์ ์ฌ์ฉ) | ||
| } | ||
|
|
||
| /** | ||
| * 4. ์นดํ ์ญ์ (DELETE /api/cafes/{cafeId}) | ||
| */ | ||
| @Transactional | ||
| public void deleteCafe(Long cafeId){ | ||
| if(!cafeRepository.existsById(cafeId)){ | ||
| throw new IllegalArgumentException("ํด๋น ID์ ์นดํ๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค: " + cafeId); | ||
| } | ||
| cafeRepository.deleteById(cafeId); | ||
| public void deleteCafeById(Long cafeId) { | ||
| Cafe cafe = cafeRepository.findById(cafeId) | ||
| .orElseThrow(() -> new RuntimeException("ํด๋น ID์ ์นดํ๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค: " + cafeId)); | ||
| cafeRepository.delete(cafe); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * 5. ์นดํ ์์ | ||
| * */ | ||
| @Transactional | ||
| public CafeResponse updateCafe(Long cafeId, CafeUpdateRequest request) { | ||
| // [์์ ] 4. updateCafe ๋ก์ง์ ์ฌ๋ฐ๋ฅด๊ฒ ์์ | ||
|
|
||
| // 1. DB์์ ์นดํ Entity๋ฅผ ์กฐํ | ||
| Cafe cafe = cafeRepository.findById(cafeId) | ||
| .orElseThrow(() -> new RuntimeException("ํด๋น ID์ ์นดํ๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค: " + cafeId)); | ||
|
|
||
| // 2. Entity์ update ๋ฉ์๋ ํธ์ถ (JPA ๋ณ๊ฒฝ ๊ฐ์ง) | ||
| // (์ด ์ฝ๋๊ฐ ์๋ํ๋ ค๋ฉด Cafe.java์ update(CafeUpdateRequest request) ๋ฉ์๋๊ฐ ์์ด์ผ ํฉ๋๋ค) | ||
| cafe.update(request); | ||
|
|
||
| // 3. ์์ ๋ Entity๋ฅผ DTO๋ก ๋ณํํ์ฌ ๋ฐํ | ||
| return new CafeResponse(cafe); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.