|
@@ -1,5 +1,6 @@
|
|
|
package com.backendsys.modules.sms.controller;
|
|
|
|
|
|
+import com.backendsys.exception.CustException;
|
|
|
import com.backendsys.modules.common.config.security.annotations.Anonymous;
|
|
|
import com.backendsys.modules.common.utils.Result;
|
|
|
import com.backendsys.modules.sms.entity.Sms;
|
|
@@ -13,6 +14,8 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.util.regex.Pattern;
|
|
|
+
|
|
|
@Validated
|
|
|
@RestController
|
|
|
public class SmsController {
|
|
@@ -29,6 +32,14 @@ public class SmsController {
|
|
|
@Anonymous
|
|
|
@PostMapping("/api/system/sms/getSMS")
|
|
|
public Result getSMS(@Validated(Sms.Send.class) @RequestBody Sms sms) throws TencentCloudSDKException {
|
|
|
+
|
|
|
+ // 当区号为86时,校验手机号码
|
|
|
+ if (sms.getPhone_area_code() == 86) {
|
|
|
+ if (!Pattern.matches("^1[3-9]\\d{9}$", sms.getPhone())) {
|
|
|
+ throw new CustException("手机号码格式不正确");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return Result.success().put("data", smsService.sendValidCode(sms));
|
|
|
}
|
|
|
|