parent
2325711738
commit
1d3c48413b
@ -1,6 +1,28 @@
|
|||||||
package com.mashibing.passenger.controller;/**
|
package com.mashibing.passenger.controller;
|
||||||
|
|
||||||
|
import com.mashibing.passenger.request.VerificationCodeDTO;
|
||||||
|
import com.mashibing.passenger.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;
|
||||||
|
|
||||||
|
/**
|
||||||
* @author fangyu
|
* @author fangyu
|
||||||
* @version v1.0.0
|
* @version v1.0.0
|
||||||
* @date 2022/7/24 01:20
|
* @date 2022/7/24 01:20
|
||||||
*/public class VerificationCodeController {
|
*/
|
||||||
|
@RestController
|
||||||
|
public class VerificationCodeController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private VerificationCodeService verificationCodeService;
|
||||||
|
|
||||||
|
@GetMapping("/verification-code")
|
||||||
|
public String verificationCode(@RequestBody VerificationCodeDTO verificationCodeDTO) {
|
||||||
|
String passengerPhone = verificationCodeDTO.getPassengerPhone();
|
||||||
|
System.out.println("接受到的手机号参数: " + passengerPhone);
|
||||||
|
|
||||||
|
return verificationCodeService.generateCode(passengerPhone);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,26 @@
|
|||||||
package com.mashibing.passenger.request;/**
|
package com.mashibing.passenger.request;
|
||||||
|
|
||||||
|
/**
|
||||||
* @author fangyu
|
* @author fangyu
|
||||||
* @version v1.0.0
|
* @version v1.0.0
|
||||||
* @date 2022/7/24 01:21
|
* @date 2022/7/24 01:21
|
||||||
*/public class VerificationCodeDTO {
|
*/
|
||||||
|
public class VerificationCodeDTO {
|
||||||
|
|
||||||
|
private String passengerPhone;
|
||||||
|
|
||||||
|
public String getPassengerPhone() {
|
||||||
|
return passengerPhone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassengerPhone(String passengerPhone) {
|
||||||
|
this.passengerPhone = passengerPhone;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "{\"VerificationCodeDTO\":{"
|
||||||
|
+ " \"passengerPhone\":\"" + passengerPhone + "\""
|
||||||
|
+ "}}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,26 @@
|
|||||||
package com.mashibing.passenger.service;/**
|
package com.mashibing.passenger.service;
|
||||||
|
|
||||||
|
import net.sf.json.JSONObject;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
* @author fangyu
|
* @author fangyu
|
||||||
* @version v1.0.0
|
* @version v1.0.0
|
||||||
* @date 2022/7/24 01:26
|
* @date 2022/7/24 01:26
|
||||||
*/public class VerificationCodeService {
|
*/
|
||||||
|
@Service
|
||||||
|
public class VerificationCodeService {
|
||||||
|
|
||||||
|
public String generateCode(String passengerPhone) {
|
||||||
|
// 调用验证码服务,获取验证码
|
||||||
|
System.out.println("调用验证码服务,获取验证码");
|
||||||
|
|
||||||
|
// 存入redis
|
||||||
|
System.out.println("存入redis");
|
||||||
|
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
result.put("code", 1);
|
||||||
|
result.put("message", "success");
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in new issue