| | |
| | | package com.xiaopeng.automaticPilot.service.impl; |
| | | |
| | | import com.xiaopeng.api.feignClient.operation.SmsClient; |
| | | import com.xiaopeng.api.vo.operation.SmsVo; |
| | | import com.xiaopeng.automaticPilot.dto.XpCommonResponse; |
| | | import com.xiaopeng.automaticPilot.dto.RobotaxiSmsCodeRequest; |
| | | import com.xiaopeng.automaticPilot.dto.RobotaxiSmsValidateRequest; |
| | |
| | | import com.xiaopeng.common.core.utils.StringUtils; |
| | | import com.xiaopeng.common.redis.service.RedisService; |
| | | import com.xiaopeng.automaticPilot.enums.RobotaxiErrorEnum; |
| | | import com.xiaopeng.automaticPilot.enums.SmsPushType; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import javax.annotation.Resource; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | @Slf4j |
| | |
| | | public class VehicleRtInfoServiceImpl implements VehicleRtInfoService { |
| | | |
| | | private static final long CODE_TTL_MINUTES = 5L; |
| | | public static final String ROBOTAXI_VERIFY_CODE_SMS_TPL = "RobotaxiVerifyCodeSmsTpl"; |
| | | |
| | | @Resource |
| | | private RedisService redisService; |
| | | |
| | | @Resource |
| | | private XpVehicleClient xpVehicleClient; |
| | | |
| | | @Resource |
| | | private SmsClient smsClient; |
| | | |
| | | @Value("${robotaxi.sms.app-id:1476153389173952512}") |
| | | private String smsAppId; |
| | | |
| | | @Value("#{'${robotaxi.sms.whitelist.mobiles:}'.split(',')}") |
| | | private List<String> whitelistMobiles; |
| | |
| | | |
| | | // TODO: Call SMS interface to send code when available |
| | | // sendSms(request.getMobile(), code); |
| | | Map<String, String> param = Collections.singletonMap("code", code); |
| | | SmsVo smsVo = new SmsVo(); |
| | | smsVo.setAppId(smsAppId); |
| | | smsVo.setParams(param); |
| | | smsVo.setTemplateCode(ROBOTAXI_VERIFY_CODE_SMS_TPL); |
| | | smsVo.setReceivers(request.getMobile()); |
| | | smsVo.setPushType(SmsPushType.SMS.getCode()); |
| | | smsClient.pushSms(smsVo); |
| | | |
| | | String key = buildSmsCodeKey(request.getSmsType(), request.getVin(), request.getMobile()); |
| | | redisService.setCacheObject(key, code, CODE_TTL_MINUTES, TimeUnit.MINUTES); |