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
91695858
authored
Nov 14, 2024
by
lujunyi
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://git.imohe.com/zhaozengyu/tzt-admin
parents
d30d5d6b
223077ac
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
6 deletions
+77
-6
app/Api/Controllers/PatientController.php
+13
-6
app/helpers.php
+64
-0
No files found.
app/Api/Controllers/PatientController.php
View file @
91695858
...
@@ -55,6 +55,10 @@ public function add(Request $request)
...
@@ -55,6 +55,10 @@ public function add(Request $request)
$pharmacy
=
PharmacyModel
::
query
()
->
where
(
'user_id'
,
$authInfo
->
id
)
->
first
();
$pharmacy
=
PharmacyModel
::
query
()
->
where
(
'user_id'
,
$authInfo
->
id
)
->
first
();
$data
[
'pharmacy_id'
]
=
$pharmacy
->
id
;
$data
[
'pharmacy_id'
]
=
$pharmacy
->
id
;
}
}
// 验证身份证格式
if
(
!
validateIdCard
(
$data
[
'id_card'
]))
{
return
$this
->
failed
(
'身份证格式错误'
);
}
$idCardInfo
=
Util
::
getIdCardInfo
(
$data
[
'id_card'
]);
$idCardInfo
=
Util
::
getIdCardInfo
(
$data
[
'id_card'
]);
$data
[
'gender'
]
=
$idCardInfo
[
'gender'
];
$data
[
'gender'
]
=
$idCardInfo
[
'gender'
];
$data
[
'is_default'
]
=
0
;
$data
[
'is_default'
]
=
0
;
...
@@ -62,7 +66,7 @@ public function add(Request $request)
...
@@ -62,7 +66,7 @@ public function add(Request $request)
if
(
$res
)
{
if
(
$res
)
{
return
$this
->
success
(
$res
);
return
$this
->
success
(
$res
);
}
else
{
}
else
{
return
$this
->
error
(
401
,
'添加失败'
);
return
$this
->
failed
(
'添加失败'
);
}
}
}
}
...
@@ -71,12 +75,15 @@ public function update(Request $request)
...
@@ -71,12 +75,15 @@ public function update(Request $request)
{
{
$id
=
$request
->
input
(
'id'
);
$id
=
$request
->
input
(
'id'
);
$id_card
=
$request
->
input
(
'id_card'
);
$id_card
=
$request
->
input
(
'id_card'
);
// 验证身份证格式
if
(
!
validateIdCard
(
$id_card
))
{
return
$this
->
failed
(
'身份证格式错误'
);
}
// TODO 提取身份信息
$idCardInfo
=
Util
::
getIdCardInfo
(
$id_card
);
$idCardInfo
=
Util
::
getIdCardInfo
(
$id_card
);
$data
=
PatientModel
::
find
(
$id
);
$data
=
PatientModel
::
find
(
$id
);
if
(
!
$data
)
{
if
(
!
$data
)
{
return
$this
->
error
(
401
,
'该问诊人不存在'
);
return
$this
->
failed
(
'该问诊人不存在'
);
}
}
$data
->
name
=
$request
->
input
(
'name'
);
$data
->
name
=
$request
->
input
(
'name'
);
$data
->
id_card
=
$id_card
;
$data
->
id_card
=
$id_card
;
...
@@ -91,7 +98,7 @@ public function delete(Request $request)
...
@@ -91,7 +98,7 @@ public function delete(Request $request)
$id
=
$request
->
input
(
'id'
);
$id
=
$request
->
input
(
'id'
);
$data
=
PatientModel
::
find
(
$id
);
$data
=
PatientModel
::
find
(
$id
);
if
(
!
$data
)
{
if
(
!
$data
)
{
return
$this
->
error
(
401
,
'该问诊人不存在'
);
return
$this
->
failed
(
'该问诊人不存在'
);
}
}
$data
->
delete
();
$data
->
delete
();
...
@@ -121,7 +128,7 @@ public function setDefault(Request $request)
...
@@ -121,7 +128,7 @@ public function setDefault(Request $request)
$id
=
$request
->
input
(
'id'
);
$id
=
$request
->
input
(
'id'
);
$data
=
PatientModel
::
find
(
$id
);
$data
=
PatientModel
::
find
(
$id
);
if
(
!
$data
)
{
if
(
!
$data
)
{
return
$this
->
error
(
401
,
'该问诊人不存在'
);
return
$this
->
failed
(
'该问诊人不存在'
);
}
}
$data
->
is_default
=
1
;
$data
->
is_default
=
1
;
$data
->
save
();
$data
->
save
();
...
@@ -146,7 +153,7 @@ public function getDefault(Request $request)
...
@@ -146,7 +153,7 @@ public function getDefault(Request $request)
if
(
$data
)
{
if
(
$data
)
{
return
$this
->
success
(
$data
);
return
$this
->
success
(
$data
);
}
else
{
}
else
{
return
$this
->
error
(
401
,
'暂无默认问诊人'
);
return
$this
->
failed
(
'暂无默认问诊人'
);
}
}
}
}
}
}
app/helpers.php
View file @
91695858
...
@@ -244,3 +244,67 @@ function data_masking(string $strType, $str = '')
...
@@ -244,3 +244,67 @@ function data_masking(string $strType, $str = '')
return
$maskStr
;
return
$maskStr
;
}
}
}
}
if
(
!
function_exists
(
'validateIdCard'
))
{
/**
* 身份证号码校验
*/
function
validateIdCard
(
$value
)
{
$len
=
strlen
(
$value
);
if
(
$len
!=
15
&&
$len
!=
18
)
{
return
false
;
}
if
(
$len
===
18
)
{
$birthday
=
substr
(
$value
,
6
,
8
);
// 6-14 出生日期
if
(
!
validateBirthday
(
$birthday
))
{
return
false
;
}
$sex
=
substr
(
$value
,
-
2
,
1
);
if
(
!
validateISO7064
(
$value
))
{
return
false
;
}
return
true
;
}
else
{
$birthday
=
substr
(
$value
,
6
,
6
);
$birthday
=
'19'
.
$birthday
;
if
(
!
validateBirthday
(
$birthday
))
{
return
false
;
}
$sex
=
substr
(
$value
,
-
1
);
return
true
;
}
}
function
validateBirthday
(
$birthday
)
{
$year
=
substr
(
$birthday
,
0
,
4
);
$month
=
substr
(
$birthday
,
4
,
2
);
$day
=
substr
(
$birthday
,
6
,
2
);
$timestamp
=
mktime
(
0
,
0
,
0
,
$month
,
$day
,
$year
);
return
$timestamp
!==
false
&&
$timestamp
<
strtotime
(
'midnight'
);
}
function
validateISO7064
(
$value
)
{
$bits
=
[
7
,
9
,
10
,
5
,
8
,
4
,
2
,
1
,
6
,
3
,
7
,
9
,
10
,
5
,
8
,
4
,
2
];
$arr_ch
=
[
'1'
,
'0'
,
'X'
,
'9'
,
'8'
,
'7'
,
'6'
,
'5'
,
'4'
,
'3'
,
'2'
];
$sign
=
0
;
for
(
$i
=
0
;
$i
<
17
;
$i
++
)
{
$b
=
(
int
)
$value
[
$i
];
$w
=
$bits
[
$i
];
$sign
+=
$b
*
$w
;
}
$n
=
$sign
%
11
;
$r
=
$arr_ch
[
$n
];
$last
=
substr
(
$value
,
-
1
);
return
(
$r
==
$last
)
||
$r
==
10
&&
(
$last
==
'x'
||
$last
==
'X'
);
}
}
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