package com.njcn.product.event.transientes.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.product.event.transientes.mapper.MsgEventInfoMapper;
import com.njcn.product.event.transientes.pojo.po.MsgEventInfo;
import com.njcn.product.event.transientes.service.MsgEventInfoService;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: cdf
 * @CreateTime: 2025-06-25
 * @Description:
 */
@Service
public class MsgEventInfoServiceImpl extends ServiceImpl<MsgEventInfoMapper, MsgEventInfo> implements MsgEventInfoService {
    @Override
    public List<MsgEventInfo> getMsgByIds(List<String> ids) {
        //通知
        List<MsgEventInfo> msgEventInfoList = new ArrayList<>();
        if(!CollectionUtils.isEmpty(ids)){
            if(ids.size()>1000){
                List<List<String>> listEven = CollUtil.split(ids,1000);
                for(List<String> pList: listEven){
                    List<MsgEventInfo> temp = this.lambdaQuery().in(MsgEventInfo::getEventIndex,pList).list();
                    msgEventInfoList.addAll(temp);
                }
            }else {
                List<MsgEventInfo> temp = this.lambdaQuery().in(MsgEventInfo::getEventIndex,ids).list();
                msgEventInfoList.addAll(temp);
            }
        }
        return msgEventInfoList;
    }
}
