package com.ag.log.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ag.log.RemqMsgCustom;
import com.ag.log.service.RemqMsgCustomService;
import com.ag.log.mapper.RemqMsgCustomMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

/**
 *
 */
@Service
public class RemqMsgCustomServiceImpl extends ServiceImpl<RemqMsgCustomMapper, RemqMsgCustom>
    implements RemqMsgCustomService{

    @Autowired
    private RemqMsgCustomMapper remqMsgCustomMapper;

    @Override
    public int queryNoRead(String user) {
        return remqMsgCustomMapper.queryNoRead(user);
    }

    @Override
    public int markMsg(List<String> ids) {
        if(ids.size()>999){
          Integer tempCount=0;
            List<List<String>> lists = CollUtil.split(ids,999);
            for (List<String> list : lists) {
                tempCount+=remqMsgCustomMapper.markMsg(list);
            }
            return tempCount;
        }else{
            return remqMsgCustomMapper.markMsg(ids);
        }

    }
}




