From 7d2e34587632429ad47160f86a5350f527cf8ac7 Mon Sep 17 00:00:00 2001 From: chuyan <1047381936@qq.com> Date: Tue, 8 Sep 2020 21:56:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E3=80=81=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=9B=B8=E5=85=B3repository=E7=BC=96=E5=86=99=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ase/model/activity/Activity.java | 3 +++ .../codesdream/ase/model/activity/Report.java | 2 ++ .../activity/ActivityRepository.java | 23 ++++++++++++++++ .../repository/activity/ReportRepository.java | 26 +++++++++++++++++++ .../ase/repository/file/FileRepository.java | 12 +++++++++ .../ase/repository/file/ImageRepository.java | 9 +++++++ .../ase/repository/mark/TagRepository.java | 12 +++++++++ 7 files changed, 87 insertions(+) create mode 100644 src/main/java/com/codesdream/ase/repository/activity/ActivityRepository.java create mode 100644 src/main/java/com/codesdream/ase/repository/activity/ReportRepository.java create mode 100644 src/main/java/com/codesdream/ase/repository/file/FileRepository.java create mode 100644 src/main/java/com/codesdream/ase/repository/file/ImageRepository.java create mode 100644 src/main/java/com/codesdream/ase/repository/mark/TagRepository.java diff --git a/src/main/java/com/codesdream/ase/model/activity/Activity.java b/src/main/java/com/codesdream/ase/model/activity/Activity.java index e63bf92..654ff8b 100644 --- a/src/main/java/com/codesdream/ase/model/activity/Activity.java +++ b/src/main/java/com/codesdream/ase/model/activity/Activity.java @@ -41,4 +41,7 @@ public class Activity { @ManyToMany(cascade = CascadeType.MERGE) List tags = new ArrayList<>(); + + @OneToOne(cascade = CascadeType.MERGE) + Report report; } diff --git a/src/main/java/com/codesdream/ase/model/activity/Report.java b/src/main/java/com/codesdream/ase/model/activity/Report.java index 976011f..1b28023 100644 --- a/src/main/java/com/codesdream/ase/model/activity/Report.java +++ b/src/main/java/com/codesdream/ase/model/activity/Report.java @@ -15,6 +15,8 @@ public class Report { @Id int id; + int activityId; + String title; @ManyToOne(cascade = CascadeType.MERGE) diff --git a/src/main/java/com/codesdream/ase/repository/activity/ActivityRepository.java b/src/main/java/com/codesdream/ase/repository/activity/ActivityRepository.java new file mode 100644 index 0000000..c8d7d90 --- /dev/null +++ b/src/main/java/com/codesdream/ase/repository/activity/ActivityRepository.java @@ -0,0 +1,23 @@ +package com.codesdream.ase.repository.activity; + +import com.codesdream.ase.model.activity.Activity; +import com.codesdream.ase.model.permission.User; +import org.springframework.data.domain.Sort; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface ActivityRepository extends JpaRepository { + + List findByTitle(String title); + List findByTitle(String title, Sort sort); + + List findByCreator(User creator); + List findByCreator(User creator, Sort sort); + + List findByManager(User manager); + List findByManager(User manager, Sort sort); + +} diff --git a/src/main/java/com/codesdream/ase/repository/activity/ReportRepository.java b/src/main/java/com/codesdream/ase/repository/activity/ReportRepository.java new file mode 100644 index 0000000..ac6ce9f --- /dev/null +++ b/src/main/java/com/codesdream/ase/repository/activity/ReportRepository.java @@ -0,0 +1,26 @@ +package com.codesdream.ase.repository.activity; + +import com.codesdream.ase.model.activity.Report; +import com.codesdream.ase.model.permission.User; +import org.springframework.data.domain.Sort; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Optional; + +@Repository +public interface ReportRepository extends JpaRepository { + + Optional findByActivityId(int activityId); + + List findByTitle(String title); + List findByTitle(String title, Sort sort); + + List findByCreator(User creator); + List findByCreator(User creator, Sort sort); + + List findByManager(User manager); + List findByManager(User manager, Sort sort); + +} diff --git a/src/main/java/com/codesdream/ase/repository/file/FileRepository.java b/src/main/java/com/codesdream/ase/repository/file/FileRepository.java new file mode 100644 index 0000000..b8b5ce6 --- /dev/null +++ b/src/main/java/com/codesdream/ase/repository/file/FileRepository.java @@ -0,0 +1,12 @@ +package com.codesdream.ase.repository.file; + +import com.codesdream.ase.model.file.File; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +@Repository +public interface FileRepository extends JpaRepository { + Optional findByTitle(String title); +} diff --git a/src/main/java/com/codesdream/ase/repository/file/ImageRepository.java b/src/main/java/com/codesdream/ase/repository/file/ImageRepository.java new file mode 100644 index 0000000..dd3d276 --- /dev/null +++ b/src/main/java/com/codesdream/ase/repository/file/ImageRepository.java @@ -0,0 +1,9 @@ +package com.codesdream.ase.repository.file; + +import com.codesdream.ase.model.file.Image; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface ImageRepository extends JpaRepository { +} diff --git a/src/main/java/com/codesdream/ase/repository/mark/TagRepository.java b/src/main/java/com/codesdream/ase/repository/mark/TagRepository.java new file mode 100644 index 0000000..4cb4642 --- /dev/null +++ b/src/main/java/com/codesdream/ase/repository/mark/TagRepository.java @@ -0,0 +1,12 @@ +package com.codesdream.ase.repository.mark; + +import com.codesdream.ase.model.mark.Tag; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +@Repository +public interface TagRepository extends JpaRepository { + Optional findByTagName(String tagName); +}