package com.tax.file.service.impl;


import com.tax.file.mapper.FileClearLogMapper;
import com.tax.file.model.FileClearLog;
import com.tax.file.model.FileClearLogExample;
import com.tax.file.model.TkFile;
import com.tax.file.service.api.FileClearLogService;
import com.yxcheng.token.common.service.AbstractService;
import com.yxcheng.token.utils.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;


@Transactional
@Component
@ComponentScan(basePackages = {"com.tax.file.dao", "com.tax.file.integration"})
public class FileClearLogServiceImpl extends AbstractService<FileClearLogMapper,FileClearLogExample,FileClearLog> implements FileClearLogService {

    private static final Logger logger = LoggerFactory.getLogger(FileClearLogServiceImpl.class);

    @Override
    public void saveLog(String uuidFlag, TkFile tkFile, String userStatus) {
        try{
            FileClearLog fileLog = new FileClearLog();
            BeanUtils.copyProperties(tkFile,fileLog);
            fileLog.setDeleteDate(DateUtils.getDate());
            fileLog.setFileId(tkFile.getId());
            fileLog.setUserStatus(userStatus);
            this.baseMapper.insert(fileLog);
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(uuidFlag + " taxno is " + tkFile.getTaxno() + ", save clear log is error!" + e.getMessage());
        }

    }
}
