飞滴出行网约车2022-获取验证码整体流程-模拟搭建

master
yh 3 years ago
parent 4e3e69161a
commit e757241b0b

@ -0,0 +1,26 @@
package com.mashibing.apipassenger.controller;
import com.mashibing.apipassenger.request.VerificationCodeDTO;
import com.mashibing.apipassenger.service.VerificationCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class VerificationController {
@Autowired
private VerificationCodeService service;
// 实现 乘客获取验证码 API
@GetMapping("/verification-code")
public String verificationcode(@RequestBody VerificationCodeDTO verificationCodeDTO){
String passengerPhone = verificationCodeDTO.getPassengerPhone();
System.out.println("接受到的手机验证码为"+passengerPhone);
return service.generatorCode(passengerPhone);
}
}

@ -0,0 +1,15 @@
package com.mashibing.apipassenger.request;
public class VerificationCodeDTO {
private String passengerPhone;
public String getPassengerPhone() {
return passengerPhone;
}
public void setPassengerPhone(String passengerPhone) {
this.passengerPhone = passengerPhone;
}
}

@ -0,0 +1,24 @@
package com.mashibing.apipassenger.service;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Service;
@Service
public class VerificationCodeService {
public String generatorCode(String passengerPhone){
// 调用验证码服务,获取验证码
System.out.println("调用验证码服务,获取验证码");
String code = "111111";
// 存入redis
System.out.println("存入redis");
JSONObject result = new JSONObject();
result.put("code",1);
result.put("message","success");
// 返回值
return result.toString();
}
}

@ -28,4 +28,13 @@
<!--<spring-cloud-alibaba.version>2020.0.5</spring-cloud-alibaba.version>-->
</properties>
<dependencies>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
</dependencies>
</project>
Loading…
Cancel
Save