package com.ssj.service.conch.conch.service.impl;

import com.ssj.bean.conch.conch.domain.ConchDerverUseRecord;
import com.ssj.dao.conch.conch.dao.ConchDerverUseRecordDao;
import com.ssj.framework.core.common.service.BaseServiceImpl;
import com.ssj.framework.weixin.util.DateUtil;
import com.ssj.service.conch.conch.service.ConchDerverUseRecordService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
 * @author Mount Liu
 * @date 2019/7/30
 */
@Service
@Transactional
public class ConchDerverUseRecordServiceImpl extends BaseServiceImpl<ConchDerverUseRecord, String> implements ConchDerverUseRecordService {

    protected Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private ConchDerverUseRecordDao dao;

    @Override
    public PagingAndSortingRepository<ConchDerverUseRecord, String> getDao() {
        return dao;
    }

    @Override
    public ConchDerverUseRecord findByUserIdAndDerver(String userId, String derver) {
        return dao.findByUserIdAndDerver(userId, derver);
    }

    @Override
    public List<ConchDerverUseRecord> findOneDayInvalidRecord(Date oneDay) {
        return dao.findByEndTime(DateUtil.format_yyyyMMdd(DateUtil.getDateAfter(oneDay, -1)));
    }

}
