-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
63f9a14
commit 41d385e
Showing
22 changed files
with
338 additions
and
174 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,5 +26,6 @@ | |
/nbdist/ | ||
/.nb-gradle/ | ||
|
||
*.log | ||
/logs/ | ||
/db/ |
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
29 changes: 0 additions & 29 deletions
29
src/main/java/com/yevhenii/kpi/readmore/controller/ErrorController.java
This file was deleted.
Oops, something went wrong.
25 changes: 2 additions & 23 deletions
25
src/main/java/com/yevhenii/kpi/readmore/controller/OAuthSignUpController.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 |
---|---|---|
@@ -1,30 +1,9 @@ | ||
package com.yevhenii.kpi.readmore.controller; | ||
|
||
import com.yevhenii.kpi.readmore.service.OAuthSignUpService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.context.request.WebRequest; | ||
import org.springframework.web.servlet.ModelAndView; | ||
|
||
@Controller | ||
public class OAuthSignUpController { | ||
public interface OAuthSignUpController { | ||
|
||
private final OAuthSignUpService signUpService; | ||
|
||
@Autowired | ||
public OAuthSignUpController(OAuthSignUpService signUpService) { | ||
this.signUpService = signUpService; | ||
} | ||
|
||
// todo add dao | ||
@RequestMapping("/signup") | ||
public ModelAndView signup(WebRequest request) { | ||
|
||
if (signUpService.signup(request)) { | ||
return new ModelAndView("redirect:/"); | ||
} else { | ||
return new ModelAndView("redirect:/error"); | ||
} | ||
} | ||
ModelAndView signup(WebRequest request); | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/com/yevhenii/kpi/readmore/controller/OAuthSignUpControllerImpl.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,27 @@ | ||
package com.yevhenii.kpi.readmore.controller; | ||
|
||
import com.yevhenii.kpi.readmore.service.OAuthSignUpService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.context.request.WebRequest; | ||
import org.springframework.web.servlet.ModelAndView; | ||
|
||
@Controller | ||
public class OAuthSignUpControllerImpl implements OAuthSignUpController { | ||
|
||
private final OAuthSignUpService signUpService; | ||
|
||
@Autowired | ||
public OAuthSignUpControllerImpl(OAuthSignUpService signUpService) { | ||
this.signUpService = signUpService; | ||
} | ||
|
||
@Autowired | ||
@RequestMapping("/signup") | ||
public ModelAndView signup(WebRequest request) { | ||
|
||
return signUpService.signup(request) ? | ||
new ModelAndView("redirect:/") : new ModelAndView("redirect:/error"); | ||
} | ||
} |
66 changes: 0 additions & 66 deletions
66
src/main/java/com/yevhenii/kpi/readmore/controller/TweetAfterConnectInterceptor.java
This file was deleted.
Oops, something went wrong.
50 changes: 4 additions & 46 deletions
50
src/main/java/com/yevhenii/kpi/readmore/controller/TwitterController.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 |
---|---|---|
@@ -1,53 +1,11 @@ | ||
package com.yevhenii.kpi.readmore.controller; | ||
|
||
import com.yevhenii.kpi.readmore.utils.TwitterUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.http.HttpStatus; | ||
import com.yevhenii.kpi.readmore.model.State; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.social.connect.ConnectionRepository; | ||
import org.springframework.social.twitter.api.Twitter; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
public interface TwitterController { | ||
|
||
@RestController | ||
@RequestMapping("/twitter") | ||
public class TwitterController { | ||
ResponseEntity<Void> tweetList(State state); | ||
|
||
private final Twitter twitter; | ||
|
||
private final ConnectionRepository connectionRepository; | ||
|
||
@Value("${spring.social.twitter.appId}") | ||
String consumerKey; | ||
@Value("${spring.social.twitter.appSecret}") | ||
String consumerSecret; | ||
|
||
private final TwitterUtils twitterUtils; | ||
|
||
@Autowired | ||
public TwitterController(Twitter twitter, ConnectionRepository connectionRepository, TwitterUtils twitterUtils) { | ||
this.twitter = twitter; | ||
this.connectionRepository = connectionRepository; | ||
this.twitterUtils = twitterUtils; | ||
} | ||
|
||
@RequestMapping(method = RequestMethod.GET, value = "/friends") | ||
public ResponseEntity<List<String>> friends() { | ||
|
||
return ResponseEntity.ok(twitterUtils.getFriendNames()); | ||
} | ||
|
||
// todo refactor | ||
@RequestMapping(method = RequestMethod.GET, value = "/tweet") | ||
public ResponseEntity<Void> tweet() { | ||
|
||
return new ResponseEntity<>( | ||
twitterUtils.tweet("Read More!").getText().equals("Read More!") ? | ||
HttpStatus.OK : HttpStatus.INTERNAL_SERVER_ERROR | ||
); | ||
} | ||
ResponseEntity<Void> tweetBook(State state, Long bookId); | ||
} |
72 changes: 72 additions & 0 deletions
72
src/main/java/com/yevhenii/kpi/readmore/controller/TwitterControllerImpl.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,72 @@ | ||
package com.yevhenii.kpi.readmore.controller; | ||
|
||
import com.yevhenii.kpi.readmore.model.State; | ||
import com.yevhenii.kpi.readmore.service.TwitterService; | ||
import com.yevhenii.kpi.readmore.utils.ControllerUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.social.connect.ConnectionRepository; | ||
import org.springframework.social.twitter.api.Twitter; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/twitter") | ||
public class TwitterControllerImpl implements TwitterController { | ||
|
||
private final Twitter twitter; | ||
|
||
private final ConnectionRepository connectionRepository; | ||
|
||
@Value("${spring.social.twitter.appId}") | ||
String consumerKey; | ||
@Value("${spring.social.twitter.appSecret}") | ||
String consumerSecret; | ||
|
||
private final TwitterService twitterService; | ||
|
||
@Autowired | ||
public TwitterControllerImpl(Twitter twitter, | ||
ConnectionRepository connectionRepository, | ||
TwitterService twitterService) { | ||
this.twitter = twitter; | ||
this.connectionRepository = connectionRepository; | ||
this.twitterService = twitterService; | ||
} | ||
|
||
@RequestMapping(method = RequestMethod.GET, value = "/friends") | ||
public ResponseEntity<List<String>> friends() { | ||
|
||
return ResponseEntity.ok(twitterService.getFriendNames()); | ||
} | ||
|
||
// todo refactor | ||
@RequestMapping(method = RequestMethod.GET, value = "/tweet") | ||
public ResponseEntity<Void> tweet() { | ||
|
||
return new ResponseEntity<>( | ||
twitterService.tweet("Read More!").getText().equals("Read More!") ? | ||
HttpStatus.OK : HttpStatus.INTERNAL_SERVER_ERROR | ||
); | ||
} | ||
|
||
@Override | ||
@RequestMapping(method = RequestMethod.POST, value = "/tweet/list") | ||
public ResponseEntity<Void> tweetList(@RequestParam State state) { | ||
|
||
return ControllerUtils.okOrBadRequest(twitterService.tweetList(state)); | ||
} | ||
|
||
@Override | ||
@RequestMapping(method = RequestMethod.POST, value = "/tweet/book") | ||
public ResponseEntity<Void> tweetBook(@RequestParam State state, @RequestParam Long bookId) { | ||
|
||
return ControllerUtils.okOrBadRequest(twitterService.tweetBook(state, bookId)); | ||
} | ||
} |
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
Oops, something went wrong.