package com.njcn.msgpush.module.push.checker.impl;

import com.njcn.msgpush.module.push.checker.IChecker;
import com.njcn.msgpush.module.push.constant.MsgStatusConstant;
import com.njcn.msgpush.module.push.dal.dataobject.message.MessageRecordDO;
import com.njcn.msgpush.module.push.service.blacklist.BlacklistService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author caozehui
 * @data 2026-02-27
 * @description 黑名单检查器
 */
@Component
public class BlacklistChecker implements IChecker {
    @Autowired
    private BlacklistService blacklistService;

    @Override
    public void check(List<MessageRecordDO> messageRecordList) {
        for (int i = 0; i < messageRecordList.size(); i++) {
            MessageRecordDO messageRecordDO = messageRecordList.get(i);
            boolean check = blacklistService.check(messageRecordDO);
            if (!check) {
                messageRecordDO.setStatus(MsgStatusConstant.BLACKLISTED);
            }
        }
    }
}
