public boolean onSave(Object entity, Serializable id, Object[] state,
String[] propertyNames, Type[] types) {
TSUser currentUser = null;
try {
currentUser = ResourceUtil.getSessionUserName();
} catch (RuntimeException e) {
logger.warn("当前session为空,无法获取用户");
}
if(currentUser==null){
return true;
}
try {
//添加数据
for (int index=0;index<propertyNames.length;index++)
{
/*找到名为"创建时间"的属性*/
if ("createDate".equals(propertyNames[index]))
{
/*使用拦截器将对象的"创建时间"属性赋上值*/
if(oConvertUtils.isEmpty(state[index])){
state[index] = new Date();
}
continue;
}
/*找到名为"创建人"的属性*/
else if ("createBy".equals(propertyNames[index]))
{
/*使用拦截器将对象的"创建人"属性赋上值*/
if(oConvertUtils.isEmpty(state[index])){
state[index] = currentUser.getUserName();
}
continue;
}
/*找到名为"创建人名称"的属性*/
else if ("createName".equals(propertyNames[index]))
{
/*使用拦截器将对象的"创建人名称"属性赋上值*/
if(oConvertUtils.isEmpty(state[index])){
state[index] = currentUser.getRealName();
}
continue;
}
}
} catch (RuntimeException e) {