Skip to content
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

feat/message #52

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/main/java/cat/udl/eps/softarch/tfgfinder/domain/Chat.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
package cat.udl.eps.softarch.tfgfinder.domain;

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;

Expand All @@ -19,4 +14,6 @@ public class Chat extends UriEntity<Long>{
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@OneToOne
private Proposal proposal;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class Message extends UriEntity<Long> {
@NotBlank
private String text;

@NotNull
@ManyToOne
private User from;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package cat.udl.eps.softarch.tfgfinder.repository;

import cat.udl.eps.softarch.tfgfinder.domain.Message;
import cat.udl.eps.softarch.tfgfinder.domain.Chat;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;

import java.util.List;


@RepositoryRestResource
public interface ChatRepository extends CrudRepository<Message, Long>, PagingAndSortingRepository<Message, Long> {
public interface ChatRepository extends CrudRepository<Chat, Long>, PagingAndSortingRepository<Chat, Long> {

List<Chat> findByProposalId(Long proposal_id);


}
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,10 @@
@RepositoryRestResource
public interface MessageRepository extends CrudRepository<Message, Long>, PagingAndSortingRepository<Message, Long> {

/* Interface provides automatically, as defined in
* https://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/repository/CrudRepository.html
* and
* https://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/repository/PagingAndSortingRepository.html
* the methods: count, delete, deleteAll, deleteById, existsById, findAll, findAllById, findById, save, saveAll,...
*
* Additional methods like findByUsernameContaining can be defined following:
* https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#jpa.query-methods.query-creation
*/

List<Message> findByWhen(@Param("when")ZonedDateTime when);

List<Message> findByFrom(@Param("user") User from);

List<Message> findByChatId(@Param("chatId") Long chatId);

}