|
|
@ -3,7 +3,9 @@ package org.example.repositories; |
|
|
|
import org.example.controllers.UserController; |
|
|
|
import org.example.controllers.UserController; |
|
|
|
import org.example.models.Image; |
|
|
|
import org.example.models.Image; |
|
|
|
import org.example.models.Post; |
|
|
|
import org.example.models.Post; |
|
|
|
|
|
|
|
import org.example.objects.SearchDTO; |
|
|
|
import org.example.queryresults.PostQueryResult; |
|
|
|
import org.example.queryresults.PostQueryResult; |
|
|
|
|
|
|
|
import org.example.queryresults.SearchQueryResult; |
|
|
|
import org.springframework.data.neo4j.repository.Neo4jRepository; |
|
|
|
import org.springframework.data.neo4j.repository.Neo4jRepository; |
|
|
|
import org.springframework.data.neo4j.repository.query.Query; |
|
|
|
import org.springframework.data.neo4j.repository.query.Query; |
|
|
|
import org.springframework.data.repository.query.Param; |
|
|
|
import org.springframework.data.repository.query.Param; |
|
|
@ -48,6 +50,7 @@ public interface PostRepository extends Neo4jRepository<Post,Long> { |
|
|
|
")\n" + |
|
|
|
")\n" + |
|
|
|
"RETURN p") |
|
|
|
"RETURN p") |
|
|
|
Post updatePost(@Param("postId") Long postId, @Param("title") String title, @Param("content") String content, @Param("imageFile")MultipartFile imageFile, @Param("videoFile") MultipartFile videoFile); |
|
|
|
Post updatePost(@Param("postId") Long postId, @Param("title") String title, @Param("content") String content, @Param("imageFile")MultipartFile imageFile, @Param("videoFile") MultipartFile videoFile); |
|
|
|
|
|
|
|
|
|
|
|
@Query("MATCH (u:User {username: $username}), (p:Post) WHERE ID(p)=$postId CREATE (u)-[:LIKES]->(p)") |
|
|
|
@Query("MATCH (u:User {username: $username}), (p:Post) WHERE ID(p)=$postId CREATE (u)-[:LIKES]->(p)") |
|
|
|
void createLike(@Param("username") String username,@Param("postId") Long postId); |
|
|
|
void createLike(@Param("username") String username,@Param("postId") Long postId); |
|
|
|
|
|
|
|
|
|
|
@ -57,4 +60,9 @@ public interface PostRepository extends Neo4jRepository<Post,Long> { |
|
|
|
@Query("MATCH (user:User {username: $username}),(post:Post )"+"where ID(post)=$postId"+ " CREATE (user)-[:createPost ]->(post)"+ |
|
|
|
@Query("MATCH (user:User {username: $username}),(post:Post )"+"where ID(post)=$postId"+ " CREATE (user)-[:createPost ]->(post)"+ |
|
|
|
"RETURN user, post") |
|
|
|
"RETURN user, post") |
|
|
|
PostQueryResult createPostRelationship(@Param("username") String username,@Param("postId") Long postId); |
|
|
|
PostQueryResult createPostRelationship(@Param("username") String username,@Param("postId") Long postId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Query("OPTIONAL MATCH (p:Post), (u:User) " + |
|
|
|
|
|
|
|
"WHERE toLower(p.title) CONTAINS toLower($input) OR toLower(u.username) CONTAINS toLower($input) " + |
|
|
|
|
|
|
|
"RETURN p, u;") |
|
|
|
|
|
|
|
List<SearchQueryResult> search(@Param("input") String input); |
|
|
|
} |
|
|
|
} |
|
|
|