IClearApiHsCodeLogService.java 1.43 KB
package com.erry.iclear.dateInterface.service;

import com.erry.iclear.dateInterface.entity.IClearApiHsCodeLog;
import com.erry.iclear.dateInterface.repository.IClearApiHsCodeLogRepository;
import com.erry.iclear.dateInterface.util.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 *
 * hscode请求日志
 * mt
 * 2022年2月15日15:46:18
 */
@Service
@Slf4j
public class IClearApiHsCodeLogService {
    @Autowired
    private IClearApiHsCodeLogRepository iClearApiHsCodeLogRepository;

    /**
     * 保存日志
     * @param iClearApiHsCodeLog
     */
    public IClearApiHsCodeLog saveIClearApiHsCodeLog(IClearApiHsCodeLog iClearApiHsCodeLog){
        try{
            return iClearApiHsCodeLogRepository.save(iClearApiHsCodeLog);
        }catch (Exception e){
            log.error("IClearApiHsCodeLog() error:"+ e.getMessage());
        }
        return null;
    }

    /**
     * 查询日志,最近10分钟如果有查询过全量hscode则返回true
     * @return
     */
    public boolean findIClearApiHsCodeLog(){
        boolean rs = false;
        try{
            Long count = iClearApiHsCodeLogRepository.findIClearApiHsCodeLog(DateUtils.getAfter10());
            if(count > 0){
                rs = true;
            }
        }catch(Exception ex){
            log.error(ex.getMessage(),ex);
        }
        return rs;
    }
}