Skip to content

Commit

Permalink
add use case
Browse files Browse the repository at this point in the history
  • Loading branch information
darmi_zhang committed Nov 6, 2023
1 parent 2b5b4bc commit edf1ca2
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.darmi.demo.request.TaskCriteria;
import com.darmi.demo.entity.mongo.Task;
import com.darmi.plugin.core.MongoLambdaQuery;
import java.util.List;
import org.springframework.data.domain.Page;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;
Expand All @@ -12,6 +13,21 @@
*/
@Repository
public interface TaskRepository extends MongoRepository<Task, String> {

default Task one(TaskCriteria taskCriteria) {
return MongoLambdaQuery.lambdaQuery(Task.class)
.is(Task::getName, taskCriteria.getName())
.one();
}

default List<Task> list(TaskCriteria taskCriteria) {
return MongoLambdaQuery.lambdaQuery(Task.class)
.gt(Task::getCreated, taskCriteria.getBegin())
.lt(Task::getCreated, taskCriteria.getEnd())
.list();
}


default Page<Task> search(TaskCriteria taskCriteria) {
return MongoLambdaQuery.lambdaQuery(Task.class)
.is(Task::getName, taskCriteria.getName())
Expand Down

0 comments on commit edf1ca2

Please sign in to comment.