123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- /**
- * Created by PhpStorm
- * User: 林志杰
- * Email: [email protected]
- * Time: 2020/1/11 17:54
- */
- declare(strict_types=1);
- namespace app\api\controller;
- use app\common\business\Sms AS SmsBus;
- use app\api\validate\User;
- use app\BaseController;
- use think\exception\ValidateException;
- class Sms extends BaseController
- {
- public function code(): object
- {
- $phoneNumber = input('param.phone_number', '', 'trim');
- halt($phoneNumber);
- $data = [
- 'phoneNumber' => $phoneNumber
- ];
- try {
- validate(User::class)->scene('send_code')->check($data);
- } catch (ValidateException $e) {
- return show(config('status.error'), $e->getError());
- }
- // 调用business层
- if (SmsBus::sendCode($phoneNumber, 6, 'jd')) {
- return show(config('status.success'), '发送验证码成功');
- }
- return show(config('status.success'), '发送验证码失败');
- }
- }
|