feat(frontend,backend): Create and load comments
This commit is contained in:
@@ -8,17 +8,20 @@ import jakarta.persistence.AttributeOverrides
|
||||
import jakarta.persistence.Column
|
||||
import jakarta.persistence.Embedded
|
||||
import jakarta.persistence.Entity
|
||||
import jakarta.persistence.EntityListeners
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn
|
||||
import jakarta.persistence.ManyToOne
|
||||
import org.springframework.data.annotation.CreatedDate
|
||||
import org.springframework.data.annotation.LastModifiedDate
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener
|
||||
import java.time.LocalDateTime
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@EntityListeners(AuditingEntityListener::class)
|
||||
class Comment(
|
||||
@Id
|
||||
@GeneratedValue
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.betriebsratkanzlei.legalconsenthub.comment
|
||||
|
||||
import com.betriebsratkanzlei.legalconsenthub.form_element.FormElement
|
||||
import com.betriebsratkanzlei.legalconsenthub.application_form.ApplicationForm
|
||||
import org.springframework.data.domain.Page
|
||||
import org.springframework.data.domain.Pageable
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
@@ -9,5 +9,5 @@ import java.util.UUID
|
||||
|
||||
@Repository
|
||||
interface CommentRepository : JpaRepository<Comment, UUID> {
|
||||
fun findAllByFormElement(formElement: FormElement, pageable: Pageable): Page<Comment>
|
||||
fun findAllByApplicationForm(applicationForm: ApplicationForm, pageable: Pageable): Page<Comment>
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.betriebsratkanzlei.legalconsenthub.comment
|
||||
|
||||
import com.betriebsratkanzlei.legalconsenthub.application_form.ApplicationFormRepository
|
||||
import com.betriebsratkanzlei.legalconsenthub.error.CommentNotCreatedException
|
||||
import com.betriebsratkanzlei.legalconsenthub.error.CommentNotDeletedException
|
||||
import com.betriebsratkanzlei.legalconsenthub.error.CommentNotFoundException
|
||||
@@ -16,7 +17,7 @@ import java.util.UUID
|
||||
@Service
|
||||
class CommentService(
|
||||
private val commentRepository: CommentRepository,
|
||||
private val formElementRepository: FormElementRepository,
|
||||
private val applicationFormRepository: ApplicationFormRepository,
|
||||
private val commentMapper: CommentMapper
|
||||
) {
|
||||
|
||||
@@ -36,11 +37,11 @@ class CommentService(
|
||||
return commentRepository.findById(id).orElseThrow { CommentNotFoundException(id) }
|
||||
}
|
||||
|
||||
fun getComments(formElementId: UUID): Page<Comment> {
|
||||
val formElement =
|
||||
formElementRepository.findById(formElementId).orElseThrow { FormElementNotFoundException(formElementId) }
|
||||
fun getComments(applicationFormId: UUID): Page<Comment> {
|
||||
val applicationForm =
|
||||
applicationFormRepository.findById(applicationFormId).orElse(null)
|
||||
val pageable = PageRequest.of(0, 10)
|
||||
return commentRepository.findAllByFormElement(formElement, pageable)
|
||||
return commentRepository.findAllByApplicationForm(applicationForm, pageable)
|
||||
}
|
||||
|
||||
fun updateComment(commentDto: CommentDto): Comment {
|
||||
|
||||
Reference in New Issue
Block a user