package com.xtd.project.assets.event.listener;

import com.xtd.common.utils.SpringUtil;
import com.xtd.project.assets.domain.DbAssetsStockLocked;
import com.xtd.project.assets.event.DbAssetsStockLockEvent;
import com.xtd.project.assets.mapper.DbAssetsStockLockedMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Component
public class DbAssetsStockEventListeners {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    /**
     * 新增用户和
     *
     * @param dbAssetsStockLockEvent 物资加锁解锁 异步执行
     */
    @Async
    @EventListener
    public void addUser(DbAssetsStockLockEvent dbAssetsStockLockEvent) {
        DbAssetsStockLockedMapper dbAssetsStockLockedMapper = SpringUtil.getBean(DbAssetsStockLockedMapper.class);
        Long dbAsStId = dbAssetsStockLockEvent.getDbAsStId();
        Long dbAsStTableId = dbAssetsStockLockEvent.getDbAsStTableId();
        String dbAsStTableName = dbAssetsStockLockEvent.getDbAsStTableName();
        DbAssetsStockLocked dbAssetsStockLocked=new DbAssetsStockLocked();
        dbAssetsStockLocked.setDbAsStId(dbAsStId);
        dbAssetsStockLocked.setDbAsStTableId(dbAsStTableId);
        dbAssetsStockLocked.setDbAsStTableName(dbAsStTableName);
        dbAssetsStockLockedMapper.insertDbAssetsStockLocked(dbAssetsStockLocked);
    }
}
