package cn.axzo.msg.center.notices.integration.support.impl;

import cn.axzo.msg.center.notices.common.enums.MessageTemplateTypeEnum;
import cn.axzo.msg.center.notices.integration.support.AbstractChuangLanMessageRequestResolver;
import cn.axzo.msg.center.notices.integration.support.ChuangLanAccountProperties;
import cn.axzo.msg.center.notices.integration.dto.request.BaseSmsRequest;
import cn.axzo.msg.center.notices.integration.dto.request.MessageRequest;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 创蓝会员营销短信请求类
 *
 * @author zhaoyong
 * @see ChuangLanMemberMessageRequestResolver
 * @since 2021-08-07 17:53
 */
@Component
public class ChuangLanMemberMessageRequestResolver extends AbstractChuangLanMessageRequestResolver {

  @Resource(name = "chuangLanAccountProperties")
  private ChuangLanAccountProperties chuangLanAccountProperties;

  @Override
  public BaseSmsRequest resolve(MessageRequest request) {
    BaseSmsRequest result = getBaseSmsRequest(request);
    result.setAccount(chuangLanAccountProperties.getMemberAccount());
    result.setPassword(chuangLanAccountProperties.getMemberPassword());
    result.setReport("true");
    result.setMsg(request.getTemplateContent());
    return result;
  }

  @Override
  public MessageTemplateTypeEnum getRouteKey() {
    return MessageTemplateTypeEnum.PROMOTIONAL;
  }
}
