-
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.
- Loading branch information
Showing
5 changed files
with
129 additions
and
12 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
src/main/java/com/study/realworld/domain/follow/TestAPI.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,46 @@ | ||
package com.study.realworld.domain.follow; | ||
|
||
import com.study.realworld.domain.follow.application.FollowService; | ||
import com.study.realworld.domain.follow.domain.FollowQueryDslRepository; | ||
import com.study.realworld.domain.follow.dto.FollowableDto; | ||
import com.study.realworld.domain.user.domain.persist.User; | ||
import com.study.realworld.domain.user.domain.persist.UserRepository; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@Transactional(readOnly = true) | ||
@RestController | ||
public class TestAPI { | ||
private final FollowQueryDslRepository queryDslRepository; | ||
private final UserRepository userRepository; | ||
private final FollowService followService; | ||
|
||
public TestAPI(final FollowQueryDslRepository queryDslRepository, final UserRepository userRepository, final FollowService followService) { | ||
this.queryDslRepository = queryDslRepository; | ||
this.userRepository = userRepository; | ||
this.followService = followService; | ||
} | ||
|
||
@PostMapping("follow/{targetId}") | ||
public ResponseEntity<FollowableDto> follow(@AuthenticationPrincipal Long id, @PathVariable Long targetId) { | ||
User user = userRepository.findById(id).get(); | ||
User user1 = userRepository.findById(targetId).get(); | ||
followService.following(id, targetId); | ||
FollowableDto followableDto = queryDslRepository.existMeAndFollowing(user, user1); | ||
return ResponseEntity.ok().body(followableDto); | ||
} | ||
|
||
@GetMapping("test/{targetId}") | ||
public ResponseEntity<FollowableDto> test(@AuthenticationPrincipal Long id, @PathVariable Long targetId) { | ||
User user = userRepository.findById(id).get(); | ||
User user1 = userRepository.findById(targetId).get(); | ||
FollowableDto followableDto = queryDslRepository.existMeAndFollowing(user, user1); | ||
return ResponseEntity.ok().body(followableDto); | ||
} | ||
|
||
} |
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
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
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
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,55 @@ | ||
### JOIN | ||
POST localhost:8080/api/users | ||
Content-Type: application/json | ||
|
||
{ | ||
"user":{ | ||
"username": "Jacob", | ||
"email": "jake@jake.jake", | ||
"password": "jakejake" | ||
} | ||
} | ||
|
||
### JOIN2 | ||
POST localhost:8080/api/users | ||
Content-Type: application/json | ||
|
||
{ | ||
"user":{ | ||
"username": "Jacob2", | ||
"email": "jake2@jake.jake", | ||
"password": "jakejake2" | ||
} | ||
} | ||
|
||
### LOGIN | ||
POST localhost:8080/api/users/login | ||
Content-Type: application/json | ||
|
||
{ | ||
"user":{ | ||
"email": "jake@jake.jake", | ||
"password": "jakejake" | ||
} | ||
} | ||
|
||
> {% | ||
client.global.set("Authorization", response.body.user.token.accessToken); | ||
client.log("생성된 Authorization : " + client.global.get("Authorization")); | ||
%} | ||
|
||
### Followable | ||
GET localhost:8080/test/2 | ||
Content-Type: application/json | ||
Authorization: {{Authorization}} | ||
|
||
### follow | ||
POST localhost:8080/follow/2 | ||
Content-Type: application/json | ||
Authorization: {{Authorization}} | ||
|
||
### Followable | ||
GET localhost:8080/test/2 | ||
Content-Type: application/json | ||
Authorization: {{Authorization}} | ||
|