-
Notifications
You must be signed in to change notification settings - Fork 6
Feature/communities tinder #1005
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
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4a4b40b
Tinder backend pt1
SzBeni2003 929dc71
Tinder backend pt2
SzBeni2003 fa93582
Merge branch 'staging' into feature/communities-tinder
SzBeni2003 541b2a6
SonarQube recommendations fixed
SzBeni2003 abf94a4
objectMapper.reader; API endpoint for tinder interactions
SzBeni2003 c0e6649
relocated the logic of editTinderAnswers to TinderService
SzBeni2003 dfe8030
Transactional annotations
SzBeni2003 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
65 changes: 65 additions & 0 deletions
65
.../src/main/kotlin/hu/bme/sch/cmsch/component/communities/CommunitiesTinderApiController.kt
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 |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| package hu.bme.sch.cmsch.component.communities | ||
|
|
||
| import hu.bme.sch.cmsch.service.UserService | ||
| import hu.bme.sch.cmsch.util.getUserEntityFromDatabaseOrNull | ||
| import io.swagger.v3.oas.annotations.parameters.RequestBody | ||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnBean | ||
| import org.springframework.http.ResponseEntity | ||
| import org.springframework.security.core.Authentication | ||
| import org.springframework.web.bind.annotation.GetMapping | ||
| import org.springframework.web.bind.annotation.PostMapping | ||
| import org.springframework.web.bind.annotation.PutMapping | ||
| import org.springframework.web.bind.annotation.RequestMapping | ||
| import org.springframework.web.bind.annotation.RestController | ||
|
|
||
| @RestController | ||
| @RequestMapping("/api") | ||
| @ConditionalOnBean(CommunitiesComponent::class) | ||
| class CommunitiesTinderApiController( | ||
| private val tinderService: TinderService, | ||
| private val userService: UserService | ||
| ) { | ||
|
|
||
| @RequestMapping("/tinder/question") | ||
| fun allQuestions(): List<TinderQuestionDto> { | ||
| return tinderService.getAllQuestions().map{ TinderQuestionDto(it) } | ||
| } | ||
|
|
||
| @PostMapping("/tinder/question") | ||
| fun submitAnswers( | ||
| auth: Authentication?, | ||
| @RequestBody answers: TinderAnswerDto | ||
| ): ResponseEntity<Unit> { | ||
| val user = auth?.getUserEntityFromDatabaseOrNull(userService) ?: return ResponseEntity.status(401).build() | ||
| tinderService.submitAnswers(false, user, answers) | ||
| return ResponseEntity.ok().build() | ||
| } | ||
|
|
||
| @PutMapping("/tinder/question") | ||
| fun updateAnswers( | ||
| auth: Authentication?, | ||
| @RequestBody answers: TinderAnswerDto | ||
| ): ResponseEntity<Unit> { | ||
| val user = auth?.getUserEntityFromDatabaseOrNull(userService) ?: return ResponseEntity.status(401).build() | ||
| tinderService.submitAnswers(true, user, answers) | ||
| return ResponseEntity.ok().build() | ||
| } | ||
|
|
||
| @GetMapping("tinder/communities") | ||
| fun getTinderCommunities(auth: Authentication?): ResponseEntity<List<CommunitiesTinderDto>> { | ||
| val user = auth?.getUserEntityFromDatabaseOrNull(userService) ?: return ResponseEntity.status(401).build() | ||
| val res = tinderService.getTinderCommunities(user) | ||
| return ResponseEntity.ok(res) | ||
| } | ||
|
|
||
| @PostMapping("tinder/communities/interact") | ||
| fun interactWithCommunity( | ||
| auth: Authentication?, | ||
| @RequestBody interaction: TinderInteractionDto | ||
| ): ResponseEntity<Unit> { | ||
| val user = auth?.getUserEntityFromDatabaseOrNull(userService) ?: return ResponseEntity.status(401).build() | ||
| tinderService.interactWithCommunity(user, interaction) | ||
| return ResponseEntity.ok().build() | ||
| } | ||
|
|
||
| } |
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.