Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JavaDTO对象搜索机制?_Java_Spring_Hibernate_Microservices_Dto - Fatal编程技术网

JavaDTO对象搜索机制?

JavaDTO对象搜索机制?,java,spring,hibernate,microservices,dto,Java,Spring,Hibernate,Microservices,Dto,我已经从2个微服务生成了一个DTO对象。Profile和ProfileCredit。我能够成功地检索到包含相关数据的填充DTO对象。然而,我更好奇的是,是否可以对生成的DTO对象进行查询或条件过滤?如果是的话,实现这一目标的方法是什么? 例如,使用“招摇过市”,这就是返回的结果 是否可以按dto中的profileCredit字段进行过滤,但数据是在单独的微服务中检索的? 任何帮助、建议或对任何其他帖子或页面的引用都会非常有用 控制器 @GetMapping(path="/pr

我已经从2个微服务生成了一个DTO对象。Profile和ProfileCredit。
我能够成功地检索到包含相关数据的填充DTO对象。然而,我更好奇的是,是否可以对生成的DTO对象进行查询或条件过滤?如果是的话,实现这一目标的方法是什么?

例如,使用“招摇过市”,这就是返回的结果


是否可以按dto中的profileCredit字段进行过滤,但数据是在单独的微服务中检索的?



任何帮助、建议或对任何其他帖子或页面的引用都会非常有用



控制器

    @GetMapping(path="/profile/search/username/{username}", produces =  MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<Page<ProfileCreditDTO>> findProfileByUsername(@PathVariable String username, Pageable pageable) {
    Page<ProfileCreditDTO> results= profileCreditService.findProfileBySelectedParameters(username,pageable);
    if(results== null){
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    } else
        return new ResponseEntity<>(results,HttpStatus.OK);
}
配置文件域

    @Entity(name = "PROFILES")
@Data @NoArgsConstructor @AllArgsConstructor
@ToString
public class Profile implements Serializable {

@Id
@GeneratedValue(strategy= GenerationType.AUTO)
private Long id;
@Size(min = 2, max = 20)
private String username;
private Integer profileType;
private Integer gender;
private Integer orientation;
private boolean online;
@JsonFormat(pattern="uuuu-MM-dd'T'HH:mm:ss.SSS")
private LocalDateTime created;
@JsonFormat(pattern="uuuu-MM-dd'T'HH:mm:ss.SSS")
private LocalDateTime lastEdited;
     @Component
        @FeignClient(name = "profileCreditService")

    public interface ProfileCreditClient {


        @GetMapping("/api/credit/profile/{profileId}")
         CreditDTO findClientByProfileId(@PathVariable("profileId") Long clientId);

}
配置信用数据传输到

    @Data
@AllArgsConstructor
@NoArgsConstructor
@ToString

public class ProfileCreditDTO {
  //profile fields
    private Long profileId;
@Size(min = 2, max = 50)
private String username;

private Integer gender;
private Integer profileType;

private Integer orientation;

private boolean online;

// Credit fields

private Long creditId;
@Column(unique = true)
private double profileCredit;




public void setProfile(final Profile profile) {
    this.setProfileId(profile.getId());
    this.setUsername(profile.getUsername());
    this.setGender(profile.getGender());
    this.setProfileType(profile.getProfileType());
    this.setOrientation(profile.getOrientation());
    this.setOnline(profile.isOnline());
}

public void setCredit(final CreditDTO credit){
    this.setCreditId(credit.getId());
    this.setProfileCredit(credit.getProfileCredit());
}
ProfileCreditClient(外国)

配置文件存储库查询

    @Query("SELECT p from PROFILES p where lower(p.username) LIKE :username%")
Page<Profile> findByAllParameters(@Param("username") String username, Pageable pageable);
@Query(“从配置文件p中选择p,其中较低的(p.username)如:username%”)
PageFindByallParameters(@Param(“username”)字符串用户名,可分页;
     @Component
        @FeignClient(name = "profileCreditService")

    public interface ProfileCreditClient {


        @GetMapping("/api/credit/profile/{profileId}")
         CreditDTO findClientByProfileId(@PathVariable("profileId") Long clientId);

}
    @Query("SELECT p from PROFILES p where lower(p.username) LIKE :username%")
Page<Profile> findByAllParameters(@Param("username") String username, Pageable pageable);