活动、文件相关repository编写完成

This commit is contained in:
chuyan 2020-09-08 21:56:54 +08:00
parent 5d3b6ec02d
commit 7d2e345876
7 changed files with 87 additions and 0 deletions

View File

@ -41,4 +41,7 @@ public class Activity {
@ManyToMany(cascade = CascadeType.MERGE)
List<Tag> tags = new ArrayList<>();
@OneToOne(cascade = CascadeType.MERGE)
Report report;
}

View File

@ -15,6 +15,8 @@ public class Report {
@Id
int id;
int activityId;
String title;
@ManyToOne(cascade = CascadeType.MERGE)

View File

@ -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<Activity, Integer> {
List<Activity> findByTitle(String title);
List<Activity> findByTitle(String title, Sort sort);
List<Activity> findByCreator(User creator);
List<Activity> findByCreator(User creator, Sort sort);
List<Activity> findByManager(User manager);
List<Activity> findByManager(User manager, Sort sort);
}

View File

@ -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<Report, Integer> {
Optional<Report> findByActivityId(int activityId);
List<Report> findByTitle(String title);
List<Report> findByTitle(String title, Sort sort);
List<Report> findByCreator(User creator);
List<Report> findByCreator(User creator, Sort sort);
List<Report> findByManager(User manager);
List<Report> findByManager(User manager, Sort sort);
}

View File

@ -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<File, Integer> {
Optional<File> findByTitle(String title);
}

View File

@ -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<Image, Integer> {
}

View File

@ -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<Tag, Integer> {
Optional<Tag> findByTagName(String tagName);
}