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
16bd4045
authored
Nov 11, 2024
by
lujunyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改用户表
parent
723e7713
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
7 deletions
+23
-7
app/Api/Controllers/UserController.php
+1
-1
app/Models/User.php
+14
-0
database/migrations/2014_10_12_000000_create_users_table.php
+8
-3
database/migrations/2024_11_04_135741_create_patient_table.php
+0
-3
No files found.
app/Api/Controllers/UserController.php
View file @
16bd4045
...
...
@@ -23,7 +23,7 @@ public function login(Request $request)
$credentials
=
app
(
'wechat.mini_program'
)
->
auth
->
session
(
$code
);
if
(
$credentials
[
'openid'
]
??
''
)
{
$user
=
User
::
firstOrCreate
([
'miniapp_openid'
,
$credentials
[
'openid'
]]);
$token
=
auth
(
'api'
)
->
claims
([
'
role'
=>
'问诊人'
])
->
fromUser
(
$user
);
$token
=
auth
(
'api'
)
->
claims
([
'
login_type'
=>
User
::
LOGIN_TYPE_USER
])
->
fromUser
(
$user
);
// $data = $this->respondWithToken($token)->original;
$data
=
[
'token'
=>
$token
];
...
...
app/Models/User.php
View file @
16bd4045
...
...
@@ -44,6 +44,20 @@ class User extends Authenticatable implements JWTSubject
'password'
=>
'hashed'
,
];
// 登录类型[0=普通用户,1=医师,2=药师]
const
LOGIN_TYPE_USER
=
0
;
const
LOGIN_TYPE_DOCTOR
=
1
;
const
LOGIN_TYPE_PHARMACIST
=
2
;
// 登录类型-文字映射
const
LOGIN_TYPE_MAP
=
[
self
::
LOGIN_USER
=>
'普通用户'
,
self
::
LOGIN_DOCTOR
=>
'医师'
,
self
::
LOGIN_PHARMACIST
=>
'药师'
,
];
// 下面是jwt-aut必须要实现的方法
/**
* Get the identifier that will be stored in the subject claim of the JWT.
...
...
database/migrations/2014_10_12_000000_create_users_table.php
View file @
16bd4045
...
...
@@ -13,11 +13,16 @@ public function up(): void
{
Schema
::
create
(
'users'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
string
(
'name'
);
$table
->
string
(
'email'
)
->
uniqu
e
();
$table
->
string
(
'name'
)
->
nullable
()
;
$table
->
string
(
'email'
)
->
nullabl
e
();
$table
->
timestamp
(
'email_verified_at'
)
->
nullable
();
$table
->
string
(
'password'
);
$table
->
string
(
'password'
)
->
nullable
()
;
$table
->
rememberToken
();
$table
->
string
(
'openid'
,
40
)
->
nullable
()
->
unique
(
'uk_openid'
)
->
comment
(
'小程序openid'
);
$table
->
string
(
'avatar'
)
->
nullable
()
->
comment
(
'头像'
);
$table
->
string
(
'nick_name'
,
100
)
->
nullable
()
->
comment
(
'昵称'
);
$table
->
tinyInteger
(
'last_login_type'
)
->
default
(
0
)
->
comment
(
'最后一次登录类型[0=普通用户,1=医师,2=药师]'
);
$table
->
timestamps
();
});
}
...
...
database/migrations/2024_11_04_135741_create_patient_table.php
View file @
16bd4045
...
...
@@ -18,9 +18,6 @@ public function up(): void
$table
->
tinyInteger
(
'gender'
)
->
default
(
0
)
->
comment
(
'性别。[1=男性,2=女性,0=未知]'
);
$table
->
string
(
'id_card'
,
18
)
->
nullable
()
->
index
(
'idx_idcard'
)
->
comment
(
'身份证号'
);
$table
->
string
(
'mobile'
,
11
)
->
nullable
()
->
index
(
'idx_mobile'
)
->
comment
(
'手机号'
);
$table
->
string
(
'miniapp_openid'
,
40
)
->
nullable
()
->
index
(
'idx_miniappopenid'
)
->
comment
(
'小程序openid'
);
$table
->
string
(
'avatar'
)
->
nullable
()
->
comment
(
'头像'
);
$table
->
string
(
'nick_name'
,
100
)
->
nullable
()
->
comment
(
'昵称'
);
$table
->
timestamps
();
$table
->
softDeletes
();
});
...
...
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