package com.xunhong.erp.turbo.facade.app.executor.cmd;

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
import com.xunhong.erp.turbo.api.facade.dto.qry.WxMaPhoneQry;
import com.xunhong.erp.turbo.api.infra.api.SettingServiceI;
import com.xunhong.erp.turbo.facade.app.executor.common.WxCmdExe;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

/**
 * @author shenyifei
 */
@Component
@RequiredArgsConstructor
public class WxPhoneBindCmdExe extends WxCmdExe {

	@DubboReference(version = "1.0.0")
	private final SettingServiceI settingService;

	@SneakyThrows
	public String execute(WxMaPhoneQry wxMaPhoneQry) {
		WxMaService wxMaService = getWxMaService(settingService);
		WxMaPhoneNumberInfo phoneNumber = wxMaService.getUserService().getPhoneNumber(wxMaPhoneQry.getCode());
		return phoneNumber.getPhoneNumber();
	}
}
