parent
d7485f796f
commit
c88cfe904e
@ -0,0 +1,26 @@ |
||||
package org.example.controllers; |
||||
|
||||
import org.example.objects.SearchDTO; |
||||
import org.example.services.PostService; |
||||
import org.springframework.http.HttpStatus; |
||||
import org.springframework.http.ResponseEntity; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.List; |
||||
|
||||
@RestController |
||||
@RequestMapping("/api/search") |
||||
public class SearchController { |
||||
private final PostService postService; |
||||
|
||||
public SearchController(PostService postService) { |
||||
this.postService = postService; |
||||
} |
||||
|
||||
|
||||
@GetMapping("/search_result") |
||||
public ResponseEntity<List<SearchDTO>> searchRelatedTopics(@RequestParam String key){ |
||||
List<SearchDTO> searchResult = postService.searchRelatedTopics(key); |
||||
return new ResponseEntity<>(searchResult, HttpStatus.OK); |
||||
} |
||||
} |
@ -0,0 +1,27 @@ |
||||
package org.example.objects; |
||||
|
||||
public class SearchDTO { |
||||
private String username; |
||||
private String title; |
||||
|
||||
public SearchDTO(String username, String title) { |
||||
this.username = username; |
||||
this.title = title; |
||||
} |
||||
|
||||
public String getUsername() { |
||||
return username; |
||||
} |
||||
|
||||
public void setUsername(String username) { |
||||
this.username = username; |
||||
} |
||||
|
||||
public String getTitle() { |
||||
return title; |
||||
} |
||||
|
||||
public void setTitle(String title) { |
||||
this.title = title; |
||||
} |
||||
} |
Loading…
Reference in new issue