/**
* 设置创建时间
* @param source
* @return
*/
public static Object setCreateTime (Object source) {
final BeanWrapper src = new BeanWrapperImpl(source);
java.beans.PropertyDescriptor[] pds = src.getPropertyDescriptors();
Set<String> emptyNames = new HashSet<String>();
for(java.beans.PropertyDescriptor pd : pds) {
Object srcValue = src.getPropertyValue(pd.getName());
if("createTime".equals(pd.getName()) && srcValue == null){
src.setPropertyValue(new PropertyValue("createTime",CommonUtil.getCurrTimes()));
source = src.getWrappedInstance();
}
if("updateTime".equals(pd.getName()) && srcValue == null){
src.setPropertyValue(new PropertyValue("updateTime",CommonUtil.getCurrTimes()));
source = src.getWrappedInstance();
}
}
return source;
}
获取model通用属性,并设置属性值,创建时间,修改时间等,仅供参考
最新推荐文章于 2022-02-25 22:24:13 发布