不要企图无所不知,否则你将一无所知。——佚名
在r2dbc中自动填充审计字段可以使用org.springframework.data.annotation.CreatedDate注解
以及org.springframework.data.annotation.LastModifiedDate
例如:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| import lombok.Data; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.LastModifiedDate;
import java.time.LocalDateTime;
@Data public class RtcInspectLog { private Long id; @CreatedDate private LocalDateTime createdAt; @LastModifiedDate private LocalDateTime updatedAt; }
|
然后需要配置org.springframework.data.r2dbc.config.EnableR2dbcAuditing
例如
1 2 3
| @Configuration @EnableR2dbcAuditing class Config {}
|
即可自动填充