添加发送验证码的controller逻辑。暂且写一个直接返回1234的吧。

This commit is contained in:
高子兴 2024-07-01 20:12:35 +08:00
parent c03b190aba
commit 3fdded3c9c

View File

@ -10,6 +10,9 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
@RestController @RestController
class AuthenticationController { class AuthenticationController {
@ -91,5 +94,19 @@ class AuthenticationController {
return new ResponseEntity<>(HttpStatus.BAD_REQUEST); return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
} }
@PostMapping("/sendVerificationCode")
public ResponseEntity<Map<String, Integer>> sendVerificationCode(@RequestBody Map<String, String> request) {
String contactInfo = request.get("contactInfo");
// TODO:发送验证码功能有待添加 boolean isSent = userService.sendVerificationCode(contactInfo);
boolean isSent = true;
if (isSent) {
HashMap<String, Integer> response = new HashMap<>();
response.put("code", 1234);
return new ResponseEntity<>(response, HttpStatus.OK);
} else {
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
} }