Search in sources :

Example 1 with BaseEntity

use of com.ruoyi.common.core.domain.BaseEntity in project RuoYi-Flowable-Plus by KonBAI-Q.

the class CreateAndUpdateMetaObjectHandler method insertFill.

@Override
public void insertFill(MetaObject metaObject) {
    try {
        if (ObjectUtil.isNotNull(metaObject) && metaObject.getOriginalObject() instanceof BaseEntity) {
            BaseEntity baseEntity = (BaseEntity) metaObject.getOriginalObject();
            Date current = ObjectUtil.isNotNull(baseEntity.getCreateTime()) ? baseEntity.getCreateTime() : new Date();
            baseEntity.setCreateTime(current);
            baseEntity.setUpdateTime(current);
            String username = StringUtils.isNotBlank(baseEntity.getCreateBy()) ? baseEntity.getCreateBy() : getLoginUsername();
            // 当前已登录 且 创建人为空 则填充
            baseEntity.setCreateBy(username);
            // 当前已登录 且 更新人为空 则填充
            baseEntity.setUpdateBy(username);
        }
    } catch (Exception e) {
        throw new ServiceException("自动注入异常 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);
    }
}
Also used : ServiceException(com.ruoyi.common.exception.ServiceException) BaseEntity(com.ruoyi.common.core.domain.BaseEntity) Date(java.util.Date) ServiceException(com.ruoyi.common.exception.ServiceException)

Example 2 with BaseEntity

use of com.ruoyi.common.core.domain.BaseEntity in project RuoYi-Flowable-Plus by KonBAI-Q.

the class CreateAndUpdateMetaObjectHandler method updateFill.

@Override
public void updateFill(MetaObject metaObject) {
    try {
        if (ObjectUtil.isNotNull(metaObject) && metaObject.getOriginalObject() instanceof BaseEntity) {
            BaseEntity baseEntity = (BaseEntity) metaObject.getOriginalObject();
            Date current = new Date();
            // 更新时间填充(不管为不为空)
            baseEntity.setUpdateTime(current);
            String username = getLoginUsername();
            // 当前已登录 更新人填充(不管为不为空)
            if (StringUtils.isNotBlank(username)) {
                baseEntity.setUpdateBy(username);
            }
        }
    } catch (Exception e) {
        throw new ServiceException("自动注入异常 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);
    }
}
Also used : ServiceException(com.ruoyi.common.exception.ServiceException) BaseEntity(com.ruoyi.common.core.domain.BaseEntity) Date(java.util.Date) ServiceException(com.ruoyi.common.exception.ServiceException)

Example 3 with BaseEntity

use of com.ruoyi.common.core.domain.BaseEntity in project RuoYi-Vue by yangzongzhuan.

the class DataScopeAspect method clearDataScope.

/**
 * 拼接权限sql前先清空params.dataScope参数防止注入
 */
private void clearDataScope(final JoinPoint joinPoint) {
    Object params = joinPoint.getArgs()[0];
    if (StringUtils.isNotNull(params) && params instanceof BaseEntity) {
        BaseEntity baseEntity = (BaseEntity) params;
        baseEntity.getParams().put(DATA_SCOPE, "");
    }
}
Also used : BaseEntity(com.ruoyi.common.core.domain.BaseEntity)

Example 4 with BaseEntity

use of com.ruoyi.common.core.domain.BaseEntity in project RuoYi-Vue-Plus by JavaLionLi.

the class CreateAndUpdateMetaObjectHandler method insertFill.

@Override
public void insertFill(MetaObject metaObject) {
    try {
        if (ObjectUtil.isNotNull(metaObject) && metaObject.getOriginalObject() instanceof BaseEntity) {
            BaseEntity baseEntity = (BaseEntity) metaObject.getOriginalObject();
            Date current = ObjectUtil.isNotNull(baseEntity.getCreateTime()) ? baseEntity.getCreateTime() : new Date();
            baseEntity.setCreateTime(current);
            baseEntity.setUpdateTime(current);
            String username = StringUtils.isNotBlank(baseEntity.getCreateBy()) ? baseEntity.getCreateBy() : getLoginUsername();
            // 当前已登录 且 创建人为空 则填充
            baseEntity.setCreateBy(username);
            // 当前已登录 且 更新人为空 则填充
            baseEntity.setUpdateBy(username);
        }
    } catch (Exception e) {
        throw new ServiceException("自动注入异常 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);
    }
}
Also used : ServiceException(com.ruoyi.common.exception.ServiceException) BaseEntity(com.ruoyi.common.core.domain.BaseEntity) Date(java.util.Date) ServiceException(com.ruoyi.common.exception.ServiceException)

Example 5 with BaseEntity

use of com.ruoyi.common.core.domain.BaseEntity in project RuoYi-Vue-Plus by JavaLionLi.

the class CreateAndUpdateMetaObjectHandler method updateFill.

@Override
public void updateFill(MetaObject metaObject) {
    try {
        if (ObjectUtil.isNotNull(metaObject) && metaObject.getOriginalObject() instanceof BaseEntity) {
            BaseEntity baseEntity = (BaseEntity) metaObject.getOriginalObject();
            Date current = new Date();
            // 更新时间填充(不管为不为空)
            baseEntity.setUpdateTime(current);
            String username = getLoginUsername();
            // 当前已登录 更新人填充(不管为不为空)
            if (StringUtils.isNotBlank(username)) {
                baseEntity.setUpdateBy(username);
            }
        }
    } catch (Exception e) {
        throw new ServiceException("自动注入异常 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);
    }
}
Also used : ServiceException(com.ruoyi.common.exception.ServiceException) BaseEntity(com.ruoyi.common.core.domain.BaseEntity) Date(java.util.Date) ServiceException(com.ruoyi.common.exception.ServiceException)

Aggregations

BaseEntity (com.ruoyi.common.core.domain.BaseEntity)9 ServiceException (com.ruoyi.common.exception.ServiceException)4 Date (java.util.Date)4 SysRole (com.ruoyi.common.core.domain.entity.SysRole)3