Skip to content

Commit

Permalink
Frontend/enhancement/follow unfollow 654 (#671)
Browse files Browse the repository at this point in the history
--- Tested and works well

* homepage will show the realted objects according to recommendation

* if no recommendation show all

* add follow/unfollow and other fixes

---------

Co-authored-by: Halis Ayberk Erdem <[email protected]>
Co-authored-by: Ömer Talip Akalın <[email protected]>
Co-authored-by: Ömer Talip Akalın <[email protected]>
  • Loading branch information
4 people authored Dec 25, 2023
1 parent a42d3a8 commit 8998173
Show file tree
Hide file tree
Showing 79 changed files with 958 additions and 2,962 deletions.
Empty file removed app/annotation-service/README.md
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,9 @@ package com.group6.annotationservice

import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.context.annotation.Bean
import org.springframework.web.servlet.config.annotation.CorsRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer

@SpringBootApplication
class AnnotationServiceApplication {
@Bean
fun corsFilter(): WebMvcConfigurer {
return object : WebMvcConfigurer {
override fun addCorsMappings(registry: CorsRegistry) {
registry.addMapping("/**")
.allowedOrigins("http://localhost:3000", "http://game-lounge.com")
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
.allowCredentials(true)
.allowedHeaders("*")
.exposedHeaders("Access-Control-Allow-Origin", "Cookie", "Set-Cookie")
}
}
}
}
class AnnotationServiceApplication

fun main(args: Array<String>) {
runApplication<AnnotationServiceApplication>(*args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ class AnnotationController(
private val annotationService: AnnotationService
) {
@PostMapping("parse-selector")
@CrossOrigin(origins = ["http://localhost:3000", "http://game-lounge.com"])
fun parseSelector(@RequestBody selector: SelectorDto): ResponseEntity<String> {

return ResponseEntity.ok("test")
}
@PostMapping("/create")
@CrossOrigin(origins = ["http://localhost:3000", "http://game-lounge.com"])
fun createAnnotation(@RequestBody annotationDto: AnnotationDto): ResponseEntity<AnnotationDto> {

val responseAnnotation = DtoConverter
Expand All @@ -30,7 +28,6 @@ class AnnotationController(
}

@GetMapping("/{id}")
@CrossOrigin(origins = ["http://localhost:3000", "http://game-lounge.com"])
fun getAnnotation(@PathVariable id: String): ResponseEntity<AnnotationDto> {
val annotation = annotationService.getAnnotation(id) ?: return ResponseEntity(HttpStatus.NOT_FOUND)

Expand All @@ -40,20 +37,18 @@ class AnnotationController(
}

@PostMapping("/get-annotations-by-target")
@CrossOrigin(origins = ["http://localhost:3000", "http://game-lounge.com"])
fun getAnnotationsByTarget(@RequestBody request: GetAnnotationsByTargetIdRequest): ResponseEntity<List<AnnotationDto>> {
val annotations = annotationService.getAnnotationsByTarget(request.targetId)
val responseAnnotationList = annotations.map { DtoConverter.convertAnnotationToAnnotationDto(it) }
return ResponseEntity.ok(responseAnnotationList)
}

@DeleteMapping("/{id}")
@CrossOrigin(origins = ["http://localhost:3000", "http://game-lounge.com"])
fun deleteAnnotation(@PathVariable id: String): ResponseEntity<Void> {
return if (annotationService.deleteAnnotation(id)) {
ResponseEntity<Void>(HttpStatus.NO_CONTENT)
} else {
ResponseEntity<Void>(HttpStatus.NOT_FOUND)
}
}
}
}
1 change: 1 addition & 0 deletions app/backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ docker run --detach -p 8080:8080 -e SPRING_DATASOURCE_URL="jdbc:postgresql://<yo
```

This command runs the backend image that you previously built and allows it to accept requests on port 8080. Fill in the database details with the information you used when running the database container. Once the backend container is running, you can access your backend application via port 8080 on localhost.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class BackendApplication (val userRepository: UserRepository){
return object : WebMvcConfigurer {
override fun addCorsMappings(registry: CorsRegistry) {
registry.addMapping("/**")
.allowedOrigins("http://localhost:3000", "http://game-lounge.com", "http://167.99.242.175")
.allowedOrigins("http://localhost:3000", "http://game-lounge.com")
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
.allowCredentials(true)
.allowedHeaders("*")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class AccessController(

@PostMapping("/register", consumes = [MediaType.MULTIPART_FORM_DATA_VALUE])
@ResponseStatus(HttpStatus.CREATED)
//
fun register(
@RequestPart("request") request: RegisterationRequest,
@RequestPart("image") image: MultipartFile?
Expand All @@ -40,6 +41,7 @@ class AccessController(
cookie.path = "/"
response.addCookie(cookie)


response.setHeader("Access-Control-Allow-Credentials", "true")
}

Expand Down
2 changes: 1 addition & 1 deletion app/backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ spring.mail.properties.mail.smtp.starttls.enable=true
custom.mailUrl=${MAIL_URL}

# Flyway
spring.flyway.enabled=false
spring.flyway.enabled=false
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,33 @@ import com.gamelounge.backend.exception.UnauthorizedCommentAccessException
import com.gamelounge.backend.middleware.SessionAuth
import com.gamelounge.backend.model.request.CreateCommentRequest
import com.gamelounge.backend.model.request.UpdateCommentRequest
import com.gamelounge.backend.repository.*
import com.gamelounge.backend.repository.CommentRepository
import com.gamelounge.backend.repository.PostRepository
import com.gamelounge.backend.repository.ReportRepository
import com.gamelounge.backend.repository.UserRepository
import com.gamelounge.backend.service.CommentService
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertThrows
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.mockito.Mockito
import org.mockito.kotlin.*
import java.time.Instant
import java.util.*

class CommentServiceTest {
private val commentRepository: CommentRepository = Mockito.mock()
private val sessionAuth: SessionAuth = Mockito.mock()
private val postRepository: PostRepository = Mockito.mock()
private val userRepository: UserRepository = Mockito.mock()
private val reportRepository: ReportRepository = Mockito.mock()
private val lfgRepository: LFGRepository = Mockito.mock()
private val objectMapper: ObjectMapper = Mockito.mock()

private val commentRepository: CommentRepository = mock()
private val sessionAuth: SessionAuth = mock()
private val postRepository: PostRepository = mock()
private val userRepository: UserRepository = mock()
private val reportRepository: ReportRepository = mock()
private val objectMapper: ObjectMapper = mock()
private val commentService = CommentService(
commentRepository,
sessionAuth,
postRepository,
userRepository,
reportRepository,
lfgRepository,
objectMapper
commentRepository,
sessionAuth,
postRepository,
userRepository,
reportRepository,
objectMapper
)

@Test
Expand Down
Loading

0 comments on commit 8998173

Please sign in to comment.