/*
 * Author: wangjian
 * 生成ServiceImpl
 */
package com.tofly.base.service.messge.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tofly.base.em.Constant;
import com.tofly.pojo.message.Messagerecipient;
import com.tofly.base.mapper.MessagerecipientMapper;
import com.tofly.base.service.messge.MessagerecipientService;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 接收人接收消息数据表：TF_YW_MESSAGERECIPIENT_W
 *
 * @author admin
 * @date Wed Mar 31 00:00:00 CST 2021
 */
@Service("messagerecipientService")
public class MessagerecipientServiceImpl extends ServiceImpl<MessagerecipientMapper, Messagerecipient> implements MessagerecipientService {

    @Override
    public Boolean updateBatchMessageFlag(String messageIds) {
        List<Long> updateMessageFlagList = Arrays.stream(messageIds.split(Constant.CSV)).map(s -> Long.parseLong(s.trim()))
                .collect(Collectors.toList());
        List<Messagerecipient> list = this.list(new QueryWrapper<Messagerecipient>().lambda().in(Messagerecipient::getMessageId, updateMessageFlagList));
        list.forEach(info ->info.setFlag("1"));
        return this.updateBatchById(list);
    }
}
