package com.cf.imes.module.system.service.notify;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cf.imes.module.system.dal.dataobject.notify.NotifyMessageReadInfoDO;
import com.cf.imes.module.system.dal.mysql.notify.NotifyMessageReadInfoMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import jakarta.annotation.Resource;
import java.time.LocalDateTime;

/**
 * @author Gqr
 * @since 2024/7/15 15:29
 */
@Service
@Slf4j
public class NotifyMessageReadInfoServiceImpl implements NotifyMessageReadInfoService {

    @Resource
    private NotifyMessageReadInfoMapper notifyMessageReadInfoMapper;

    @Override
    public LocalDateTime getAny(Long messageId, Long userId) {
        NotifyMessageReadInfoDO one = notifyMessageReadInfoMapper.selectOne(new LambdaQueryWrapper<NotifyMessageReadInfoDO>()
                .eq(NotifyMessageReadInfoDO::getMessageId, messageId)
                .eq(NotifyMessageReadInfoDO::getUserId, userId)
                .select(NotifyMessageReadInfoDO::getReadTime));
        return one != null ? one.getReadTime() : null;
    }
}
