首页 > 解决方案 > 在spring boot中过滤数据

问题描述

不知道这是否可能,但我想调用我的数据并对其进行过滤,因此例如通知类型将是 1 或 2,然后给我所有的 1 和 2 My Model

public class Notifications {
        @Id
        private String id;
        private String notificationMsg;
        private String notificationType;
        private Date createdDate = new Date();


   //Get all Notification by type
    @RequestMapping(value = "/all/{notificationType}", method = RequestMethod.GET)
    public List<Notifications> getAllByNotificationType(@PathVariable("notificationType") String notificationType) {
        List<Notifications> notifications= this.notificationRepository.findByNotificationType(notificationType);
        return user;
    }

或者我应该添加到模型中并创建一个这样的界面

  List<Notifications> findByNumber1ORNumber2ORNumber3(String Number1,String Number2,String Number3);

标签: springspring-bootfilter

解决方案


您可以使用in子句:

https://javadeveloperzone.com/spring/spring-jpa-query-in-clause-example/

List<Employee> findByEmployeeNameIn(List<String> names);


推荐阅读