package com.tax.file.service.impl;


import com.tax.file.mapper.FileLogMapper;
import com.tax.file.model.FileLog;
import com.tax.file.model.FileLogExample;
import com.tax.file.service.api.FileLogService;
import com.yxcheng.token.common.service.AbstractService;
import com.yxcheng.token.utils.DateUtils;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;


@Transactional
@Component
@ComponentScan(basePackages = {"com.tax.file.dao", "com.tax.file.integration"})
public class FileLogServiceImpl extends AbstractService<FileLogMapper,FileLogExample,FileLog> implements FileLogService {

    @Override
    public void saveLog(String uuidFlag, String userName, String taxno, Date reqDate, String reqContext, String resContext, Date resDate, String applyStatus) {
        try{
            FileLog fileLog = new FileLog();
            fileLog.setTaxno(taxno);
            fileLog.setReqDate(reqDate);
            fileLog.setReqContext(reqContext);
            fileLog.setResContext(resContext);
            fileLog.setResDate(resDate);
            fileLog.setApplyStatus(applyStatus);
            fileLog.setUuidFlag(uuidFlag);
            fileLog.setLostTime(DateUtils.getSecondsDiff(reqDate,resDate));
            fileLog.setUserName(userName);
            this.baseMapper.insert(fileLog);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
