Skip to content

Commit

Permalink
fix:친구 삭제 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
euunrud committed Aug 23, 2023
1 parent 85bd028 commit 8b64bf8
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 4 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public UserResponse searchFriendsList(@RequestHeader(value = "Authorization", re
//친구 삭제
@DeleteMapping("/delete")
@Operation(summary = "친구 삭제", description = "친구 삭제 API")
public Map<String, Object> delete(@RequestHeader(value = "Authorization", required = false) String token, @RequestBody @Valid Long fid) {
public Map<String, Object> delete(@RequestHeader(value = "Authorization", required = false) String token, @RequestBody @Valid String name) {

if (token == null || !jwtTokenProvider.validateToken(token)) {
Map<String, Object> invalidTokenResponse = new HashMap<>();
Expand All @@ -178,7 +178,7 @@ public Map<String, Object> delete(@RequestHeader(value = "Authorization", requir
User user = userRepository.findUserByEmail(email);
Map<String, Object> response = new HashMap<>();

if (friendService.delete(user.getUserId(), fid) > 0) {
if (friendService.delete(user.getUserId(), name) > 0) {
response.put("result", "SUCCESS");
} else {
response.put("result", "FAIL");
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/flag/flag_back/service/FriendService.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ public boolean checkFriendById2(Long id, Long fid) {
}
//
@Transactional
public Integer delete(Long id, Long fid) {
Friend friend = friendJpaRepository.findUserEntityByUserIdAndUserId2(id, fid);
public Integer delete(Long id, String name) {
User user = userRepository.findUserByName(name);
Friend friend = friendJpaRepository.findUserEntityByUserIdAndUserId2(id, user.getUserId());
if(friend != null) {
friendJpaRepository.delete(friend);
return 1;
Expand Down

0 comments on commit 8b64bf8

Please sign in to comment.