This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package com.wkrzywiec.medium.noticeboard.controller; | |
| import com.wkrzywiec.medium.noticeboard.controller.dto.BaseDTO; | |
| import com.wkrzywiec.medium.noticeboard.service.CrudService; | |
| import io.swagger.annotations.ApiOperation; | |
| import org.springframework.http.*; | |
| import org.springframework.web.bind.annotation.*; | |
| import java.util.List; | |
| import java.util.Optional; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import javax.validation.*; | |
| import org.springframework.beans.factory.annotation.Autowired; | |
| import com.wkrzywiec.spring.library.service.LibraryUserDetailService; | |
| public class UniqueEmailValidator implements ConstraintValidator<UniqueEmail, String> { | |
| @Autowired | |
| private LibraryUserDetailService userService; | |
| @Override | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import lombok.NoArgsConstructor; | |
| @NoArgsConstructor | |
| public class User { | |
| private String username; | |
| private String email; | |
| private String firstName; | |
| private String lastName; | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import lombok.ToString; | |
| @ToString(exclude="email") | |
| public class User { | |
| private String username; | |
| private String email; | |
| private String firstName; | |
| private String lastName; | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import lombok.EqualsAndHashCode; | |
| @EqualsAndHashCode | |
| public class User { | |
| private String username; | |
| private String email; | |
| private String firstName; | |
| private String lastName; | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import lombok.Getter; | |
| import lombok.Setter; | |
| @Getter | |
| @Setter | |
| public class User { | |
| private String username; | |
| private String email; | |
| private String firstName; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | @Getter | |
| @Setter | |
| @EqualsAndHashCode | |
| @ToString(exclude="password") | |
| @NoArgsConstructor | |
| public class User { | |
| private int id; | |
| private String username; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | Sort sort = builder | |
| .sort() | |
| .byField("release_date") | |
| .andByField("title").desc() | |
| .createSort(); | |
| query.setSort(sort); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | org.apache.lucene.search.Query luceneQuery = queryBuilder | |
| .keyword() | |
| .onField("id") | |
| .from(50).to(100) | |
| .createQuery(); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | org.apache.lucene.search.Query luceneQuery = queryBuilder | |
| .keyword() | |
| .wildcard() //it is necessary if we want to make use of wildcards | |
| .onFields("username", "email", "userDetail.lastName") | |
| .boostedTo(5f) | |
| .andField("userDetail.firstName") | |
| .matching(searchText + "*") | |
| .createQuery(); | 
NewerOlder