
package com.tmerclub.cloud.user.listener;

import cn.hutool.core.collection.CollUtil;
import com.tmerclub.cloud.common.rocketmq.config.RocketMqConstant;
import com.tmerclub.cloud.user.bo.mongo.MongoUserBalanceLogBO;
import com.tmerclub.cloud.user.service.UserBalanceLogService;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author TRACK
 */
@Component
@RocketMQMessageListener(topic = RocketMqConstant.ADD_USER_BALANCE_LOG_TOPIC, consumerGroup = RocketMqConstant.ADD_USER_BALANCE_LOG_TOPIC)
public class AddUserBalanceLogConsumer implements RocketMQListener<List<MongoUserBalanceLogBO>> {

    @Autowired
    private UserBalanceLogService userBalanceLogService;
    @Override
    public void onMessage(List<MongoUserBalanceLogBO> list) {
        if (CollUtil.isEmpty(list)) {
            return;
        }
        userBalanceLogService.saveBatchToMongodb(list);
    }

}
