package cn.axzo.msg.center.inside.notices.service.impl;

import cn.axzo.basics.common.BeanMapper;
import cn.axzo.msg.center.api.request.MsgBody4Guest;
import cn.axzo.msg.center.domain.dto.MsgBody4GuestDTO;
import cn.axzo.msg.center.inside.notices.service.IYouMengMessageService;
import cn.axzo.msg.center.inside.notices.service.NewImService;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Service;

/**
 * @author: wangli
 * @date: 2022/5/24 17:43
 */
@Slf4j
@Service
@RefreshScope
public class NewImServiceImpl implements NewImService {


  @Autowired
  private IYouMengMessageService youMengMessageService;

  @Override
  public void sendImMessage(MsgBody4GuestDTO msg) {
    syncSendImMessage(msg);
  }

  @Override
  public void syncSendImMessage(MsgBody4GuestDTO msg) {
    MsgBody4Guest msgBody4Guest = BeanMapper.copyBean(msg, MsgBody4Guest.class);
    log.info("syncSendImMessage sendPushMessage= [{}]", JSONUtil.toJsonStr(msgBody4Guest));
    youMengMessageService.sendPushMessage(msgBody4Guest);
  }

}
