parent
7db94512a7
commit
a836e4308f
@ -0,0 +1,25 @@ |
||||
package org.example.controllers; |
||||
|
||||
|
||||
import org.example.models.Category; |
||||
import org.example.services.CategoryService; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.List; |
||||
|
||||
@RestController |
||||
@RequestMapping("/category") |
||||
public class CategoryController { |
||||
private final CategoryService categoryService; |
||||
|
||||
public CategoryController(CategoryService categoryService) { |
||||
this.categoryService = categoryService; |
||||
} |
||||
|
||||
@GetMapping("/getAllCategories") |
||||
public List<Category> getAllCategories(){ |
||||
return categoryService.getAllCategories(); |
||||
} |
||||
} |
@ -0,0 +1,21 @@ |
||||
package org.example.objects; |
||||
|
||||
public class FriendDTO { |
||||
private String username1,username2; |
||||
|
||||
public String getUsername1() { |
||||
return username1; |
||||
} |
||||
|
||||
public void setUsername1(String username1) { |
||||
this.username1 = username1; |
||||
} |
||||
|
||||
public String getUsername2() { |
||||
return username2; |
||||
} |
||||
|
||||
public void setUsername2(String username2) { |
||||
this.username2 = username2; |
||||
} |
||||
} |
@ -0,0 +1,39 @@ |
||||
package org.example.objects; |
||||
|
||||
import org.example.models.Image; |
||||
import org.example.models.Post; |
||||
import org.example.models.Video; |
||||
import org.springframework.data.neo4j.core.schema.Node; |
||||
import java.util.List; |
||||
|
||||
public class PostWithMedia { |
||||
private Post post; |
||||
private List<Image> images; |
||||
private List<Video> videos; |
||||
|
||||
// Getters and setters
|
||||
public Post getPost() { |
||||
return post; |
||||
} |
||||
|
||||
public void setPost(Post post) { |
||||
this.post = post; |
||||
} |
||||
|
||||
public List<Image> getImages() { |
||||
return images; |
||||
} |
||||
|
||||
public void setImages(List<Image> images) { |
||||
this.images = images; |
||||
} |
||||
|
||||
public List<Video> getVideos() { |
||||
return videos; |
||||
} |
||||
|
||||
public void setVideos(List<Video> videos) { |
||||
this.videos = videos; |
||||
} |
||||
} |
||||
|
@ -0,0 +1,23 @@ |
||||
package org.example.services; |
||||
|
||||
|
||||
import org.example.models.Category; |
||||
import org.example.repositories.CategoryRepository; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
@Service |
||||
public class CategoryService { |
||||
private final CategoryRepository categoryRepository; |
||||
|
||||
public CategoryService(CategoryRepository categoryRepository) { |
||||
this.categoryRepository = categoryRepository; |
||||
} |
||||
|
||||
public List<Category> getAllCategories() { |
||||
List<Category> categories = categoryRepository.findAll(); |
||||
return categories; |
||||
} |
||||
} |
Loading…
Reference in new issue