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.dto.request.BaseSmsRequest;
import cn.axzo.msg.center.notices.integration.dto.request.MessageRequest;
import cn.axzo.msg.center.notices.integration.support.AbstractChuangLanMessageRequestResolver;
import cn.axzo.msg.center.notices.integration.support.ChuangLanAccountProperties;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 创蓝通知短信请求类
 *
 * @author zhaoyong
 * @see ChuangLanNoticeMessageRequestResolver
 * @since 2021-08-07 17:53
 */
@Component
public class ChuangLanNoticeMessageRequestResolver extends AbstractChuangLanMessageRequestResolver {

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

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

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