|
|
@ -20,12 +20,10 @@ import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.security.user.LoginUserUtil; |
|
|
|
import com.epmet.commons.tools.security.user.SecurityUser; |
|
|
|
import com.epmet.commons.tools.security.user.UserDetail; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.ibatis.reflection.MetaObject; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import javax.swing.text.html.Option; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.Optional; |
|
|
|
|
|
|
@ -52,6 +50,7 @@ public class FieldMetaObjectHandler implements MetaObjectHandler { |
|
|
|
if (metaObject.getOriginalObject() instanceof BaseEpmetEntity) { |
|
|
|
// epmet项目新增的
|
|
|
|
setFieldValByName(FieldConstant.CUSTOMER_ID_HUMP, getCustomerIdByFieldValue(metaObject), metaObject); |
|
|
|
setFieldValByName(FieldConstant.USER_ID_HUMP, getCustomerIdByFieldValue(metaObject), metaObject); |
|
|
|
setFieldValByName(FieldConstant.CREATED_TIME_HUMP, getCreatedTimeByFieldValue(metaObject), metaObject); |
|
|
|
setFieldValByName(FieldConstant.CREATED_BY_HUMP, getCreatedByFieldValue(metaObject), metaObject); |
|
|
|
setFieldValByName(FieldConstant.UPDATED_TIME_HUMP, getUpdatedTimeByFieldValue(metaObject), metaObject); |
|
|
@ -110,6 +109,27 @@ public class FieldMetaObjectHandler implements MetaObjectHandler { |
|
|
|
} |
|
|
|
return loginUserUtil.getLoginUserCustomerId(); |
|
|
|
} |
|
|
|
/** |
|
|
|
* @Description 获取用户ID |
|
|
|
* @Param metaObject |
|
|
|
* @Return {@link Object} |
|
|
|
* @Author zhaoqifeng |
|
|
|
* @Date 2021/9/16 10:04 |
|
|
|
*/ |
|
|
|
public Object getUserIdByFieldValue(MetaObject metaObject) { |
|
|
|
if (!metaObject.hasSetter(FieldConstant.USER_ID_HUMP)) { |
|
|
|
// 如果该entity对象,没有userId属性,那么返回null;
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
Object customerId; |
|
|
|
customerId = getFieldValByName(FieldConstant.USER_ID_HUMP, metaObject); |
|
|
|
if (customerId != null && !customerId.equals("")) { |
|
|
|
// 看entity是否手动设置了,设置了就用设置的
|
|
|
|
return customerId; |
|
|
|
} |
|
|
|
return loginUserUtil.getLoginUserId(); |
|
|
|
} |
|
|
|
|
|
|
|
public Object getCreatedTimeByFieldValue(MetaObject metaObject) { |
|
|
|
Object createdTime = null; |
|
|
|