
package com.tmerclub.cloud.group.listener;

import com.tmerclub.cloud.common.rocketmq.config.RocketMqConstant;
import com.tmerclub.cloud.group.bo.GroupSaveNotifyBO;
import com.tmerclub.cloud.group.service.GroupTeamService;
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.Objects;

/**
 * 提交订单 保存团队信息到mongodb
 * @author TRACK
 */
@Component
@RocketMQMessageListener(topic = RocketMqConstant.GROUP_ORDER_SAVE_TOPIC, consumerGroup = RocketMqConstant.GROUP_ORDER_SAVE_TEAM_GROUP)
public class GroupOrderSaveTeamGroupConsumer implements RocketMQListener<GroupSaveNotifyBO> {

    @Autowired
    private GroupTeamService groupTeamService;

    /**
     * 团购活动订单保存mongodb
     */
    @Override
    public void onMessage(GroupSaveNotifyBO groupSaveNotifyBO) {
        if (Objects.nonNull(groupSaveNotifyBO.getMongoGroupTeamBO())) {
            groupTeamService.saveToMongodb(groupSaveNotifyBO.getMongoGroupTeamBO());
        }
    }
}
