package com.tax.file.service.impl;


import com.tax.file.mapper.FileUserLogMapper;
import com.tax.file.model.FileUserLog;
import com.tax.file.model.FileUserLogExample;
import com.tax.file.service.api.FileUserLogService;
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 FileUserLogServiceImpl extends AbstractService<FileUserLogMapper,FileUserLogExample,FileUserLog> implements FileUserLogService {

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

    }
}
