package com.ag.log.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ag.log.TopicUserCol;
import com.ag.log.service.TopicUserColService;
import com.ag.log.mapper.TopicUserColMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 */
@Service
public class TopicUserColServiceImpl extends ServiceImpl<TopicUserColMapper, TopicUserCol>
    implements TopicUserColService{

    @Autowired
    private TopicUserColMapper mapper;

    @Override
    public int deleteByUserId(String userId) {
        QueryWrapper<TopicUserCol> wrapper = Wrappers.query();
        wrapper.eq("USER_ID",userId);
        return mapper.delete(wrapper);
    }

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


}




