-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Feature/#57
- Loading branch information
Showing
4 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
23 changes: 23 additions & 0 deletions
23
...va/com/umc/DongnaeFriend/domain/account/sharing/controller/SharingSympathyController.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.umc.DongnaeFriend.domain.account.sharing.controller; | ||
|
||
|
||
import com.umc.DongnaeFriend.domain.account.sharing.service.SharingSympathyService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RequiredArgsConstructor | ||
@RestController | ||
@RequestMapping("/account-books/sharing/likes") | ||
public class SharingSympathyController { | ||
private final SharingSympathyService sharingSympathyService; | ||
|
||
// 게시글 공감하기 | ||
@PostMapping("/{accountBookId}") | ||
public String postSympathy(@PathVariable("accountBookId") Long accountBookId) { | ||
sharingSympathyService.newSympathy(accountBookId); | ||
return ""; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...va/com/umc/DongnaeFriend/domain/account/sharing/repository/SharingSympathyRepository.java
This file contains 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
33 changes: 33 additions & 0 deletions
33
...ain/java/com/umc/DongnaeFriend/domain/account/sharing/service/SharingSympathyService.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.umc.DongnaeFriend.domain.account.sharing.service; | ||
|
||
import com.umc.DongnaeFriend.domain.account.sharing.entity.SharingBoard; | ||
import com.umc.DongnaeFriend.domain.account.sharing.entity.SharingSympathy; | ||
import com.umc.DongnaeFriend.domain.account.sharing.repository.SharingSympathyRepository; | ||
import com.umc.DongnaeFriend.domain.user.entity.User; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@RequiredArgsConstructor | ||
@Service | ||
public class SharingSympathyService { | ||
private final SharingSympathyRepository sharingSympathyRepository; | ||
|
||
public String newSympathy(Long accountBookId){ | ||
// !임시! 유저 가져오기 | ||
User user = sharingSympathyRepository.findByUserId(1L); | ||
|
||
// 게시판 가져오기 | ||
SharingBoard sharingBoard = sharingSympathyRepository.findBySharingBoardId(accountBookId); | ||
|
||
// 공감 데이터 저장하기 | ||
SharingSympathy sharingSympathy = SharingSympathy.builder() | ||
.sharingBoard(sharingBoard) | ||
.user(user) | ||
.build(); | ||
|
||
sharingSympathyRepository.save(sharingSympathy); | ||
|
||
return "[가계부 공유] 공감 성공"; | ||
} | ||
|
||
} |