Springboot QueryDSL @QuerydslPredicate 时间参数序列化问题请教
先上代码:
@GetMapping("/list") @ApiOperation("审核列表") public WebResult list(@QuerydslPredicate(root = Audit.class) Predicate predicate, Pageable pageable) { return WebResult.success(auditService.searchPage(predicate, pageable)); } public class Audit { @Id private Long id; private String content; private Integer type; private Integer status; private Integer sd; private String tag; private Long userId; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonSerialize(using = LocalDateTimeSerializer.class) @JsonDeserialize(using = LocalDateTimeDeserializer.class) @Convert(converter = Jsr310JpaConverters.LocalDateTimeConverter.class) private LocalDateTime auditTime; @Generated(GenerationTime.INSERT) @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonSerialize(using = LocalDateTimeSerializer.class) @JsonDeserialize(using = LocalDateTimeDeserializer.class) @Convert(converter = Jsr310JpaConverters.LocalDateTimeConverter.class) private LocalDateTime createAt; @Generated(GenerationTime.ALWAYS) @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonSerialize(using = LocalDateTimeSerializer.class) @JsonDeserialize(using = LocalDateTimeDeserializer.class) @Convert(converter = Jsr310JpaConverters.LocalDateTimeConverter.class) private LocalDateTime updateAt; public Audit() { } }
由于 springboot GET 请求处理时间(LocalDateTime) 参数序列化时,需要在参数前加上 @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
的注解,但因为使用 @QuerydslPredicate
无法对实体里面的字段进行单独标注,所以前端请求时无法序列化时间参数,尝试过使用全局方式,也不生效。
有没有朋友使用过 QuerydslPredicate
这种传参方式,如何对里面的时间参数进行序列化?