package com.blueland.common.core.listener;

import com.mybatisflex.annotation.InsertListener;
import com.mybatisflex.annotation.UpdateListener;
import com.blueland.common.core.domain.BaseEntity;
import com.blueland.common.core.utils.UserUtils;


import java.util.Date;

public class FlexCommonListener implements InsertListener, UpdateListener {
    @Override
    public void onInsert(Object o) {
        BaseEntity base = (BaseEntity) o;
        base.setCreateBy(UserUtils.getStaffCode());
        base.setCreateTime(new Date());
        base.setUpdateBy(UserUtils.getStaffCode());
        base.setUpdateTime(new Date());
    }

    @Override
    public void onUpdate(Object o) {
        BaseEntity base = (BaseEntity) o;
        base.setUpdateBy(UserUtils.getStaffCode());
        base.setUpdateTime(new Date());
    }
}
