package thyyxxk.webserver.dao.his.ca;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import thyyxxk.webserver.entity.ca.CaSignRedis;
import thyyxxk.webserver.utils.DateUtil;

import java.util.Date;

@Mapper
public interface CaRedisDao extends BaseMapper<CaSignRedis> {

    default CaSignRedis selectCreateById(String id) {
        Date date = new Date();
        date = DateUtil.offsetMinute(date, -30);

        LambdaQueryWrapper<CaSignRedis> qw = CaSignRedis.lambdaQueryWrapper().eq(CaSignRedis::getId, id)
                .ge(CaSignRedis::getCreateTime, date);
        return selectOne(qw);
    }

}
