package cn.com.ty.lift.ud.common;

import java.time.Clock;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;

import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;

@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
	/**
     * 新增数据执行
     * @param metaObject
     */
    @Override
    public void insertFill(MetaObject metaObject) {
//        SysUserEntity userEntity = ShiroUtil.getUser();
        this.setFieldValByName("createTime", LocalDateTime.now(Clock.system(ZoneId.of("Asia/Shanghai"))), metaObject);
//        this.setFieldValByName("createBy", userEntity.getLoginName(), metaObject);
        this.setFieldValByName("updateTime", LocalDateTime.now(), metaObject);
//        this.setFieldValByName("updateBy", userEntity.getLoginName(), metaObject);
    }

    /**
     * 更新数据执行
     * @param metaObject
     */
    @Override
    public void updateFill(MetaObject metaObject) {
//        SysUserEntity userEntity = ShiroUtil.getUser();
        this.setFieldValByName("updateTime", LocalDateTime.now(Clock.system(ZoneId.of("Asia/Shanghai"))), metaObject);
//        this.setFieldValByName("updateBy", userEntity.getLoginName(), metaObject);
    }
}
