package com.ruoyi.common.orm.listener;

import com.mybatisflex.annotation.UpdateListener;
import com.ruoyi.common.orm.core.domain.BaseEntity;
import com.ruoyi.common.security.utils.LoginHelper;

import java.util.Date;

/**
 * Entity实体类更新数据监听器
 *
 * @author dataprince数据小王子
 */
public class EntityUpdateListener implements UpdateListener {
    @Override
    public void onUpdate(Object entity) {
        BaseEntity baseEntity = (BaseEntity) entity;
        baseEntity.setUpdateBy(LoginHelper.getUserId());
        baseEntity.setUpdateTime(new Date());
    }
}
