win.doyto.query.entity.UserIdProvider Maven / Gradle / Ivy
package win.doyto.query.entity;
import java.io.Serializable;
import java.util.Date;
/**
* UserIdProvider
*
* @author f0rb
*/
public interface UserIdProvider {
I getUserId();
@SuppressWarnings("unchecked")
default void setupUserId(Object e) {
I userId = getUserId();
if (userId != null) {
if (e instanceof Persistable && ((Persistable) e).isNew()) {
if( e instanceof CreateUserAware) {
((CreateUserAware) e).setCreateUserId(userId);
((CreateUserAware) e).setCreateTime(new Date());
}
} else {
if (e instanceof UpdateUserAware) {
((UpdateUserAware) e).setUpdateUserId(userId);
((UpdateUserAware) e).setUpdateTime(new Date());
}
}
}
}
}