Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
newShopBack
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
newshop
newShopBack
Commits
46326144
Commit
46326144
authored
Nov 07, 2019
by
郭勇志
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
分库
parent
b224a28d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
10 deletions
+17
-10
db.php
backend/config/db.php
+7
-0
ShopRbacUser.php
backend/models/v1/user/ShopRbacUser.php
+10
-10
No files found.
backend/config/db.php
View file @
46326144
...
...
@@ -17,5 +17,12 @@ return [
'password'
=>
''
,
'charset'
=>
'utf8'
,
],
'db-101'
=>
[
'class'
=>
'yii\db\Connection'
,
'dsn'
=>
'mysql:host=localhost;dbname=weishopdbt'
,
'username'
=>
'root'
,
'password'
=>
''
,
'charset'
=>
'utf8'
,
],
]
];
backend/models/v1/user/ShopRbacUser.php
View file @
46326144
...
...
@@ -5,6 +5,7 @@ namespace app\models\v1\user;
use
Yii
;
use
yii\web\IdentityInterface
;
use
app\models\v1\BaseModel
;
use
yii\web\HttpException
;
/**
* This is the model class for table "shop_rbac_user".
*
...
...
@@ -33,7 +34,6 @@ use app\models\v1\BaseModel;
* @property string $WX_OPENID 小程序OPENID
* @property int $AGE 年龄
* @property string $SHARE_NO 分享码
* @property string $ACCESS_TOKEN 验证TOKEN
*/
class
ShopRbacUser
extends
BaseModel
implements
IdentityInterface
{
...
...
@@ -54,7 +54,7 @@ class ShopRbacUser extends BaseModel implements IdentityInterface
[[
'GUID'
,
'CODE'
],
'required'
],
[[
'CREATE_DATE'
,
'UPDATE_DATE'
],
'safe'
],
[[
'IS_FORBID'
,
'CONTACTSEX'
,
'IS_UPLOAD_HX'
,
'IS_BELONG'
,
'AGE'
],
'integer'
],
[[
'GUID'
,
'CODE'
,
'PASSWORD'
,
'ORG_GUID'
,
'EMPLOYEE_GUID'
,
'CREATE_GUID'
,
'UPDATE_GUID'
,
'MOBILEPHONE'
,
'USER_GUID'
,
'REMARK'
,
'ALIPAY_UID'
,
'WX_UNIONID'
,
'WX_OPENID'
,
'SHARE_NO'
,
'ACCESS_TOKEN'
],
'string'
,
'max'
=>
50
],
[[
'GUID'
,
'CODE'
,
'PASSWORD'
,
'ORG_GUID'
,
'EMPLOYEE_GUID'
,
'CREATE_GUID'
,
'UPDATE_GUID'
,
'MOBILEPHONE'
,
'USER_GUID'
,
'REMARK'
,
'ALIPAY_UID'
,
'WX_UNIONID'
,
'WX_OPENID'
,
'SHARE_NO'
],
'string'
,
'max'
=>
50
],
[[
'NAME'
,
'CREATE_NAME'
,
'UPDATE_NAME'
],
'string'
,
'max'
=>
100
],
[[
'DESCRIPTION'
],
'string'
,
'max'
=>
255
],
[[
'GUID'
],
'unique'
],
...
...
@@ -92,7 +92,6 @@ class ShopRbacUser extends BaseModel implements IdentityInterface
'WX_OPENID'
=>
'Wx Openid'
,
'AGE'
=>
'Age'
,
'SHARE_NO'
=>
'Share No'
,
'ACCESS_TOKEN'
=>
'Access Token'
,
];
}
/**
...
...
@@ -112,8 +111,8 @@ class ShopRbacUser extends BaseModel implements IdentityInterface
*/
public
function
generateAccessToken
()
{
$
this
->
ACCESS_TOKEN
=
Yii
::
$app
->
security
->
generateRandomString
();
return
$
this
->
ACCESS_TOKEN
;
$
accessToken
=
Yii
::
$app
->
security
->
generateRandomString
();
return
$
accessToken
;
}
/**
* 根据给到的ID查询身份。
...
...
@@ -133,7 +132,6 @@ class ShopRbacUser extends BaseModel implements IdentityInterface
*/
public
static
function
findIdentityByAccessToken
(
$token
,
$type
=
null
)
{
// return static::findOne(['ACCESS_TOKEN' => $token]);
// 取得reids中用户信息
$redis
=
Yii
::
$app
->
redis
;
$model
=
new
ShopRbacUser
;
...
...
@@ -141,13 +139,15 @@ class ShopRbacUser extends BaseModel implements IdentityInterface
if
(
$rtnGet
)
{
$userInfo
=
json_decode
(
$rtnGet
,
true
);
$db
=
DB_PREFIX
.
$userInfo
[
'ORG_GUID'
];
$dbObj
=
\Yii
::
$app
->
$db
;
$query
=
new
\yii\db\Query
();
$temp
=
$query
->
where
(
array
(
'GUID'
=>
$userInfo
[
'USER_GUID'
]))
->
from
(
'shop_rbac_user'
)
->
limit
(
1
)
->
one
(
$dbObj
);
if
(
!
empty
(
$temp
))
{
$model
->
attributes
=
$temp
;
return
$model
;
}
throw
new
HttpException
(
'404'
,
'用户存在'
);
}
return
false
;
}
...
...
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