Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵增煜
/
tzt-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
6303c69f
authored
Nov 20, 2024
by
赵增煜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
问诊人短信
parent
59413f0f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
8 deletions
+17
-8
app/Api/Controllers/PatientController.php
+15
-3
app/Api/Controllers/UserController.php
+2
-5
No files found.
app/Api/Controllers/PatientController.php
View file @
6303c69f
...
...
@@ -60,11 +60,16 @@ public function add(Request $request)
if
(
!
validateIdCard
(
$data
[
'id_card'
]))
{
return
$this
->
failed
(
'身份证格式错误'
);
}
$mobile
=
$data
[
'mobile'
];
$verificationCode
=
cache
()
->
get
(
"sms_verification_code_
{
$mobile
}
"
);
$code
=
$data
[
'code'
];
if
(
$verificationCode
!=
$code
)
{
return
$this
->
failed
(
'验证码错误'
);
}
$idCardInfo
=
Util
::
getIdCardInfo
(
$data
[
'id_card'
]);
$patient
->
name
=
$data
[
'name'
];
$patient
->
id_card
=
$data
[
'id_card'
];
$patient
->
mobile
=
$
data
[
'mobile'
]
;
$patient
->
mobile
=
$
mobile
;
$patient
->
gender
=
$idCardInfo
[
'gender'
];
$patient
->
is_default
=
0
;
// $res = PatientModel::create($data);
...
...
@@ -91,10 +96,17 @@ public function update(Request $request)
if
(
!
$data
)
{
return
$this
->
failed
(
'该问诊人不存在'
);
}
$mobile
=
$request
->
input
(
'mobile'
);
$verificationCode
=
cache
()
->
get
(
"sms_verification_code_
{
$mobile
}
"
);
$code
=
$request
->
input
(
'code'
);
if
(
$verificationCode
!=
$code
)
{
return
$this
->
failed
(
'验证码错误'
);
}
$data
->
name
=
$request
->
input
(
'name'
);
$data
->
id_card
=
$id_card
;
$data
->
gender
=
$idCardInfo
[
'gender'
];
$data
->
mobile
=
$
request
->
input
(
'mobile'
)
;
$data
->
mobile
=
$
mobile
;
$data
->
save
();
return
$this
->
success
(
$data
);
...
...
app/Api/Controllers/UserController.php
View file @
6303c69f
...
...
@@ -71,7 +71,6 @@ public function smsCode(Request $request)
if
(
!
preg_match
(
'/^1[3-9]\d{9}$/'
,
$mobile
))
{
return
response
()
->
json
([
'error'
=>
'手机号格式不正确'
]);
}
// TODO 增加手机验证码发送频率限制
// 检查手机号在医师或者药店表中是否存在
...
...
@@ -85,15 +84,13 @@ public function smsCode(Request $request)
if
(
!
$doctor
)
{
return
$this
->
failed
(
'手机号不存在'
);
}
}
else
{
return
$this
->
failed
(
'登录类型错误'
);
}
// 生成短信验证码
$verificationCode
=
rand
(
100000
,
999999
);
// 生成6位随机验证码
// 存储验证码和有效期(10分钟)
cache
()
->
put
(
"sms_verification_code_
{
$
login_type
}
_
{
$
mobile
}
"
,
$verificationCode
,
600
);
// 600秒 = 10分钟
cache
()
->
put
(
"sms_verification_code_
{
$mobile
}
"
,
$verificationCode
,
600
);
// 600秒 = 10分钟
$templateName
=
'verification_code'
;
$templateData
=
[
'code'
=>
$verificationCode
];
...
...
@@ -114,7 +111,7 @@ public function bindRole(Request $request)
return
$this
->
failed
(
'参数错误'
);
}
$verificationCode
=
cache
()
->
get
(
"sms_verification_code_
{
$
login_type
}
_
{
$
mobile
}
"
);
$verificationCode
=
cache
()
->
get
(
"sms_verification_code_
{
$mobile
}
"
);
if
(
$verificationCode
!=
$code
)
{
return
$this
->
failed
(
'验证码错误'
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment