Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
openApi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hj
openApi
Commits
95b68a5b
Commit
95b68a5b
authored
Aug 28, 2022
by
hangjun83
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
openapi 震坤行
parent
94d80aca
Changes
18
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
12 additions
and
951 deletions
+12
-951
server/app/Providers/Auth/AdminUsersProvider.php
server/app/Providers/Auth/AdminUsersProvider.php
+0
-133
server/app/Providers/AuthServiceProvider.php
server/app/Providers/AuthServiceProvider.php
+0
-31
server/app/Repositories/Criteria/UserCriteria.php
server/app/Repositories/Criteria/UserCriteria.php
+0
-33
server/app/Repositories/Models/AdminUsers.php
server/app/Repositories/Models/AdminUsers.php
+0
-101
server/app/Repositories/Models/Menus.php
server/app/Repositories/Models/Menus.php
+0
-36
server/app/Repositories/Transformers/PostTransformer.php
server/app/Repositories/Transformers/PostTransformer.php
+0
-46
server/app/Repositories/Transformers/UserTransformer.php
server/app/Repositories/Transformers/UserTransformer.php
+0
-39
server/app/Services/ThirdPlatform/Api/BjsApiService.php
server/app/Services/ThirdPlatform/Api/BjsApiService.php
+11
-7
server/app/Support/Traits/HttpClientHelpers.php
server/app/Support/Traits/HttpClientHelpers.php
+1
-8
server/config/auth.php
server/config/auth.php
+0
-97
server/config/broadcasting.php
server/config/broadcasting.php
+0
-64
server/config/cors.php
server/config/cors.php
+0
-61
server/config/crontabjob.php
server/config/crontabjob.php
+0
-24
server/config/permission.php
server/config/permission.php
+0
-152
server/config/view.php
server/config/view.php
+0
-40
server/routes/api/auth.php
server/routes/api/auth.php
+0
-41
server/routes/api/permissions.php
server/routes/api/permissions.php
+0
-38
server/routes/api/zhenkunhang.php
server/routes/api/zhenkunhang.php
+0
-0
No files found.
server/app/Providers/Auth/AdminUsersProvider.php
deleted
100644 → 0
View file @
94d80aca
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace
App\Providers\Auth
;
use
App\Repositories\Enums\CacheEnum
;
use
App\Support\Traits\Helpers
;
use
Illuminate\Auth\AuthenticationException
;
use
Illuminate\Contracts\Auth\Authenticatable
as
UserContract
;
use
Illuminate\Contracts\Auth\UserProvider
;
use
Illuminate\Contracts\Support\Arrayable
;
use
Illuminate\Support\Str
;
use
Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException
;
class
AdminUsersProvider
implements
UserProvider
{
use
Helpers
;
protected
$model
=
null
;
public
function
__construct
(
$app
,
$model
)
{
if
(
!
$model
instanceof
\Illuminate\Database\Eloquent\Model
){
$class
=
'\\'
.
ltrim
(
$model
,
'\\'
);
$this
->
model
=
new
$class
;
}
else
{
$this
->
model
=
$model
;
}
}
/**
* Retrieve a user by their unique identifier.
*
* @param mixed $identifier
* @return \Illuminate\Contracts\Auth\Authenticatable|null
*/
public
function
retrieveById
(
$identifier
)
{
// 只做根据identifier的值做查询用户操作
$user
=
$this
->
model
->
newQuery
()
->
where
(
$this
->
model
->
getAuthIdentifierName
(),
$identifier
)
->
first
();
if
(
$user
->
status
===
0
){
throw
new
AuthenticationException
(
'用户已被禁用,请联系管理员.'
);
}
return
$user
;
/*return Cache::remember($cacheKey, $cacheExpireTime, function () use ($identifier) {
return $this->model->newQuery()
->where($this->model->getAuthIdentifierName(), $identifier)
->first();
});*/
}
/**
* Retrieve a user by the given credentials.
*
* @param array $credentials
* @return \Illuminate\Contracts\Auth\Authenticatable|null
*/
public
function
retrieveByCredentials
(
array
$credentials
)
{
if
(
empty
(
$credentials
))
{
throw
new
UnauthorizedHttpException
(
'auth params error'
,
'参数缺少'
,
null
,
ResponseCodeEnum
::
CLIENT_PARAMETER_ERROR
);
}
$query
=
$this
->
model
->
newQuery
();
foreach
(
$credentials
as
$key
=>
$value
)
{
if
(
Str
::
contains
(
$key
,
'password'
))
{
$value
=
$this
->
model
->
encryptPassword
(
$value
);
//continue;
}
if
(
is_array
(
$value
)
||
$value
instanceof
Arrayable
)
{
$query
->
whereIn
(
$key
,
$value
);
}
else
{
$query
->
where
(
$key
,
$value
);
}
}
return
$query
->
first
();
}
/**
* Validate a user against the given credentials.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param array $credentials
* @return bool
*/
public
function
validateCredentials
(
UserContract
$user
,
array
$credentials
)
{
$encodePassword
=
$this
->
model
->
encryptPassword
(
$credentials
[
'password'
]);
if
(
$encodePassword
!==
$user
->
password
){
throw
new
AuthenticationException
(
'用户登陆密码错误,请重新输入.'
);
}
if
(
$user
->
status
===
0
){
throw
new
AuthenticationException
(
'用户已被禁用,请联系管理员.'
);
}
return
true
;
}
/**
* Retrieve a user by their unique identifier and "remember me" token.
*
* @param mixed $identifier
* @param string $token
* @return \Illuminate\Contracts\Auth\Authenticatable|null
*/
public
function
retrieveByToken
(
$identifier
,
$token
)
{
return
null
;
}
/**
* Update the "remember me" token for the given user in storage.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param string $token
* @return void
*/
public
function
updateRememberToken
(
UserContract
$user
,
$token
)
{
}
}
server/app/Providers/AuthServiceProvider.php
deleted
100644 → 0
View file @
94d80aca
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace
App\Providers
;
use
App\Repositories\Enums\PermissionEnum
;
use
Illuminate\Support\Facades\Gate
;
use
Illuminate\Support\ServiceProvider
;
use
App\Providers\Auth\AdminUsersProvider
;
class
AuthServiceProvider
extends
ServiceProvider
{
/**
* Boot the authentication services for the application.
*/
public
function
boot
()
{
//Gate::before(PermissionEnum::gateBeforeCallback());
$this
->
app
[
'auth'
]
->
provider
(
'superadmin'
,
function
(
$app
,
array
$config
)
{
return
new
AdminUsersProvider
(
$app
,
$config
[
'model'
]);
});
}
}
server/app/Repositories/Criteria/UserCriteria.php
deleted
100644 → 0
View file @
94d80aca
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace
App\Repositories\Criteria
;
use
Illuminate\Database\Eloquent\Builder
;
use
App\Repositories\Criteria\Criteria
;
class
UserCriteria
extends
Criteria
{
protected
function
condition
(
Builder
$query
)
:
void
{
if
(
$name
=
$this
->
request
->
get
(
'nickname'
))
{
$query
->
where
(
'nickname'
,
'='
,
$name
);
}
if
(
$email
=
$this
->
request
->
get
(
'email'
))
{
$query
->
where
(
'email'
,
'like'
,
"%
$email
%"
);
}
if
(
$username
=
$this
->
request
->
get
(
'username'
))
{
$query
->
where
(
'username'
,
'='
,
$username
);
}
}
}
server/app/Repositories/Models/AdminUsers.php
deleted
100644 → 0
View file @
94d80aca
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace
App\Repositories\Models
;
use
App\Repositories\Enums\RoleEnum
;
use
Database\Factories\UserFactory
;
use
Illuminate\Auth\Authenticatable
;
use
Illuminate\Contracts\Auth\Access\Authorizable
as
AuthorizableContract
;
use
Illuminate\Contracts\Auth\Authenticatable
as
AuthenticatableContract
;
use
Illuminate\Database\Eloquent\Factories\HasFactory
;
use
Laravel\Lumen\Auth\Authorizable
;
use
Spatie\Permission\Traits\HasRoles
;
use
Tymon\JWTAuth\Contracts\JWTSubject
;
class
AdminUsers
extends
Model
implements
AuthenticatableContract
,
AuthorizableContract
,
JWTSubject
{
use
Authenticatable
, Authorizable, HasFactory, HasRoles
;
protected
$table
=
'admin_users'
;
protected
$guard_name
=
'api'
;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected
$fillable
=
[
'username'
,
'nickname'
,
'password'
,
'email'
,
'token'
,
'is_admin'
,
'status'
];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected
$hidden
=
[
];
/**
* Get the identifier that will be stored in the subject claim of the JWT.
*
* @return mixed
*/
public
function
getJWTIdentifier
()
{
return
$this
->
getKey
();
}
/**
* Return a key value array, containing any custom claims to be added to the JWT.
*
* @return array
*/
public
function
getJWTCustomClaims
()
{
return
[];
}
public
function
isSuperAdmin
()
:
bool
{
return
$this
->
is_admin
===
1
?
true
:
false
;
}
/**
* 是否是非法禁止使用的用户 status == 0
* @return bool
*/
public
function
isUnusualUser
()
:
bool
{
return
$this
->
status
===
0
?
true
:
false
;
}
public
function
isOwnerOf
(
\Illuminate\Database\Eloquent\Model
$model
,
string
$key
=
'user_id'
)
:
bool
{
if
(
$model
instanceof
User
)
{
return
$this
->
id
===
$model
->
id
;
}
return
$this
->
id
===
$model
->
$key
;
}
public
function
encryptPassword
(
$hash
)
:
string
{
$str
=
base64_encode
(
$hash
);
$encodePassword
=
md5
(
md5
(
$str
));
return
$encodePassword
;
}
}
server/app/Repositories/Models/Menus.php
deleted
100644 → 0
View file @
94d80aca
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace
App\Repositories\Models
;
class
Menus
extends
Model
{
protected
$table
=
'menus'
;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected
$fillable
=
[
'menu_name'
,
'title'
,
'menu_path'
,
'menu_icon'
,
'parent_id'
,
'menu_type'
,
'component'
,
'status'
,
'sort'
,
'is_show'
,
'sys_default'
,
'created_by'
];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected
$hidden
=
[
];
}
server/app/Repositories/Transformers/PostTransformer.php
deleted
100644 → 0
View file @
94d80aca
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace
App\Repositories\Transformers
;
use
App\Repositories\Enums\PermissionEnum
;
use
App\Repositories\Models\Post
;
use
Illuminate\Support\Str
;
use
League\Fractal\TransformerAbstract
;
class
PostTransformer
extends
TransformerAbstract
{
protected
$defaultIncludes
=
[
'author'
,
];
public
function
transform
(
Post
$post
)
{
return
[
'id'
=>
$post
->
id
,
'title'
=>
$post
->
title
,
'body'
=>
$this
->
checkColumnPermission
()
?
$post
->
body
:
Str
::
limit
(
$post
->
body
,
120
),
// 没有文章详情查看权限时,返回截取的部分内容
'published'
=>
$post
->
published
,
];
}
protected
function
checkColumnPermission
()
{
return
auth
(
'api'
)
->
user
()
->
can
(
PermissionEnum
::
ROUTE_POSTS_VIEW
()
->
name
);
}
public
function
includeAuthor
(
Post
$post
)
{
$author
=
$post
->
author
;
return
$this
->
item
(
$author
,
new
UserTransformer
());
}
}
server/app/Repositories/Transformers/UserTransformer.php
deleted
100644 → 0
View file @
94d80aca
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace
App\Repositories\Transformers
;
use
App\Repositories\Enums\PermissionEnum
;
use
App\Repositories\Models\User
;
use
League\Fractal\TransformerAbstract
;
class
UserTransformer
extends
TransformerAbstract
{
public
function
transform
(
User
$user
)
{
$data
=
[
'id'
=>
$user
->
id
,
'nickname'
=>
$user
->
name
,
'email'
=>
$user
->
email
,
];
if
(
!
$this
->
checkColumnPermission
())
{
$data
[
'email'
]
=
'**** ****'
;
}
return
$data
;
}
protected
function
checkColumnPermission
()
{
return
auth
(
'api'
)
->
user
()
->
can
(
PermissionEnum
::
DATA_USERS_COLUMN_EMAIL
()
->
name
);
}
}
server/app/Services/ThirdPlatform/Api/BjsApiService.php
View file @
95b68a5b
...
@@ -36,14 +36,18 @@ class BjsApiService extends PlatformAbstractService
...
@@ -36,14 +36,18 @@ class BjsApiService extends PlatformAbstractService
{
{
try
{
try
{
if
(
$this
->
checkPlatformStatus
()){
if
(
$this
->
checkPlatformStatus
()){
$params
=
[];
/*
$params = [];
$params
[
'CASNumber'
]
=
$this
->
mergeApiMetaData
(
$product
);
$params['CASNumber'] = $this->mergeApiMetaData($product);
*/
$uri
=
$this
->
platformInfo
[
'platform_url'
]
.
'/api/BJS/GetStockPriceDataThree'
;
$uri
=
$this
->
platformInfo
[
'platform_url'
]
.
'/api/BJS/GetStockPriceDataThree?CASNumber='
.
$this
->
mergeApiMetaData
(
$product
);
$response
=
$this
->
getPostClient
(
$uri
,
$params
,
null
,[
$response
=
$this
->
clientRequest
(
'get'
,
$uri
,[
'auth'
=>
[
'Client_id'
=>
$this
->
platformInfo
[
'platform_params'
][
'Client_id'
],
'Client_id'
=>
$this
->
platformInfo
[
'platform_params'
][
'Client_id'
],
'Client_secret'
=>
$this
->
platformInfo
[
'platform_params'
][
'Client_secret'
]
'Client_secret'
=>
$this
->
platformInfo
[
'platform_params'
][
'Client_secret'
]
],
false
);
]
]);
return
$this
->
apiResponse
(
$response
);
return
$this
->
apiResponse
(
$response
);
}
}
...
...
server/app/Support/Traits/HttpClientHelpers.php
View file @
95b68a5b
...
@@ -18,7 +18,7 @@ trait HttpClientHelpers
...
@@ -18,7 +18,7 @@ trait HttpClientHelpers
return
$options
;
return
$options
;
}
}
protected
function
getPostClient
(
$uri
,
$paramsBody
=
[],
$auth
=
null
,
$header
=
null
,
$
multipart
=
null
,
$
json
=
true
)
protected
function
getPostClient
(
$uri
,
$paramsBody
=
[],
$auth
=
null
,
$header
=
null
,
$json
=
true
)
{
{
$options
=
[];
$options
=
[];
if
(
$json
)
{
if
(
$json
)
{
...
@@ -31,13 +31,6 @@ trait HttpClientHelpers
...
@@ -31,13 +31,6 @@ trait HttpClientHelpers
$options
[
'form_params'
]
=
$paramsBody
;
$options
[
'form_params'
]
=
$paramsBody
;
}
}
if
(
!
is_null
(
$multipart
)){
$options
[
'multipart'
]
=
[
'name'
=>
'file'
,
'contents'
=>
$multipart
];
}
if
(
$auth
&&
is_array
(
$auth
)){
if
(
$auth
&&
is_array
(
$auth
)){
$options
[
'auth'
]
=
$auth
;
$options
[
'auth'
]
=
$auth
;
}
}
...
...
server/config/auth.php
deleted
100644 → 0
View file @
94d80aca
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
return
[
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option controls the default authentication "guard" and password
| reset options for your application. You may change these defaults
| as required, but they're a perfect start for most applications.
|
*/
'defaults'
=>
[
'guard'
=>
env
(
'AUTH_GUARD'
,
'api'
),
],
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| here which uses session storage and the Eloquent user provider.
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| Supported: "token"
|
*/
'guards'
=>
[
'api'
=>
[
'driver'
=>
'jwt'
,
'provider'
=>
'users'
,
// 与下面的 providers 中的 users 是对应的
],
],
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/
'providers'
=>
[
'users'
=>
[
'driver'
=>
'superadmin'
,
'model'
=>
\App\Repositories\Models\AdminUsers
::
class
,
],
],
/*
|--------------------------------------------------------------------------
| Resetting Passwords
|--------------------------------------------------------------------------
|
| Here you may set the options for resetting passwords including the view
| that is your password reset e-mail. You may also set the name of the
| table that maintains all of the reset tokens for your application.
|
| You may specify multiple password reset configurations if you have more
| than one user table or model in the application and you want to have
| separate password reset settings based on the specific user types.
|
| The expire time is the number of minutes that the reset token should be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
*/
'passwords'
=>
[
],
];
server/config/broadcasting.php
deleted
100644 → 0
View file @
94d80aca
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
return
[
/*
|--------------------------------------------------------------------------
| Default Broadcaster
|--------------------------------------------------------------------------
|
| This option controls the default broadcaster that will be used by the
| framework when an event needs to be broadcast. You may set this to
| any of the connections defined in the "connections" array below.
|
| Supported: "pusher", "redis", "log", "null"
|
*/
'default'
=>
env
(
'BROADCAST_DRIVER'
,
'null'
),
/*
|--------------------------------------------------------------------------
| Broadcast Connections
|--------------------------------------------------------------------------
|
| Here you may define all of the broadcast connections that will be used
| to broadcast events to other systems or over websockets. Samples of
| each available type of connection are provided inside this array.
|
*/
'connections'
=>
[
'pusher'
=>
[
'driver'
=>
'pusher'
,
'key'
=>
env
(
'PUSHER_APP_KEY'
),
'secret'
=>
env
(
'PUSHER_APP_SECRET'
),
'app_id'
=>
env
(
'PUSHER_APP_ID'
),
'options'
=>
[
'cluster'
=>
env
(
'PUSHER_APP_CLUSTER'
),
'encrypted'
=>
true
,
],
],
'redis'
=>
[
'driver'
=>
'redis'
,
'connection'
=>
env
(
'BROADCAST_REDIS_CONNECTION'
,
'default'
),
],
'log'
=>
[
'driver'
=>
'log'
,
],
'null'
=>
[
'driver'
=>
'null'
,
],
],
];
server/config/cors.php
deleted
100644 → 0
View file @
94d80aca
<?php
return
[
/*
|--------------------------------------------------------------------------
| Laravel CORS Options
|--------------------------------------------------------------------------
|
| The allowed_methods and allowed_headers options are case-insensitive.
|
| You don't need to provide both allowed_origins and allowed_origins_patterns.
| If one of the strings passed matches, it is considered a valid origin.
|
| If ['*'] is provided to allowed_methods, allowed_origins or allowed_headers
| all methods / origins / headers are allowed.
|
*/
/*
* You can enable CORS for 1 or multiple paths.
* Example: ['api/*']
*/
'paths'
=>
[
'adminapi/*'
],
/*
* Matches the request method. `['*']` allows all methods.
*/
'allowed_methods'
=>
[
'*'
],
/*
* Matches the request origin. `['*']` allows all origins. Wildcards can be used, eg `*.mydomain.com`
*/
'allowed_origins'
=>
[
'*'
],
/*
* Patterns that can be used with `preg_match` to match the origin.
*/
'allowed_origins_patterns'
=>
[],
/*
* Sets the Access-Control-Allow-Headers response header. `['*']` allows all headers.
*/
'allowed_headers'
=>
[
'*'
],
/*
* Sets the Access-Control-Expose-Headers response header with these headers.
*/
'exposed_headers'
=>
[],
/*
* Sets the Access-Control-Max-Age response header when > 0.
*/
'max_age'
=>
0
,
/*
* Sets the Access-Control-Allow-Credentials header.
*/
'supports_credentials'
=>
false
,
];
\ No newline at end of file
server/config/crontabjob.php
deleted
100644 → 0
View file @
94d80aca
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
return
[
'command_job'
=>
[
'integle'
=>
[
'topic'
=>
''
,
'producer'
=>
''
,
'consumer'
=>
''
,
'datetime'
=>
''
],
'wuxi'
=>
[
]
],
];
server/config/permission.php
deleted
100644 → 0
View file @
94d80aca
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
return
[
'models'
=>
[
/*
* When using the "HasPermissions" trait from this package, we need to know which
* Eloquent model should be used to retrieve your permissions. Of course, it
* is often just the "Permission" model but you may use whatever you like.
*
* The model you want to use as a Permission model needs to implement the
* `Spatie\Permission\Contracts\Permission` contract.
*/
'permission'
=>
Spatie\Permission\Models\Permission
::
class
,
/*
* When using the "HasRoles" trait from this package, we need to know which
* Eloquent model should be used to retrieve your roles. Of course, it
* is often just the "Role" model but you may use whatever you like.
*
* The model you want to use as a Role model needs to implement the
* `Spatie\Permission\Contracts\Role` contract.
*/
'role'
=>
Spatie\Permission\Models\Role
::
class
,
],
'table_names'
=>
[
/*
* When using the "HasRoles" trait from this package, we need to know which
* table should be used to retrieve your roles. We have chosen a basic
* default value but you may easily change it to any table you like.
*/
'roles'
=>
'roles'
,
/*
* When using the "HasPermissions" trait from this package, we need to know which
* table should be used to retrieve your permissions. We have chosen a basic
* default value but you may easily change it to any table you like.
*/
'permissions'
=>
'permissions'
,
/*
* When using the "HasPermissions" trait from this package, we need to know which
* table should be used to retrieve your models permissions. We have chosen a
* basic default value but you may easily change it to any table you like.
*/
'model_has_permissions'
=>
'model_has_permissions'
,
/*
* When using the "HasRoles" trait from this package, we need to know which
* table should be used to retrieve your models roles. We have chosen a
* basic default value but you may easily change it to any table you like.
*/
'model_has_roles'
=>
'model_has_roles'
,
/*
* When using the "HasRoles" trait from this package, we need to know which
* table should be used to retrieve your roles permissions. We have chosen a
* basic default value but you may easily change it to any table you like.
*/
'role_has_permissions'
=>
'role_has_permissions'
,
],
'column_names'
=>
[
/*
* Change this if you want to name the related model primary key other than
* `model_id`.
*
* For example, this would be nice if your primary keys are all UUIDs. In
* that case, name this `model_uuid`.
*/
'model_morph_key'
=>
'model_id'
,
],
/*
* When set to true, the required permission names are added to the exception
* message. This could be considered an information leak in some contexts, so
* the default setting is false here for optimum safety.
*/
'display_permission_in_exception'
=>
true
,
/*
* When set to true, the required role names are added to the exception
* message. This could be considered an information leak in some contexts, so
* the default setting is false here for optimum safety.
*/
'display_role_in_exception'
=>
true
,
/*
* By default wildcard permission lookups are disabled.
*/
'enable_wildcard_permission'
=>
false
,
'cache'
=>
[
/*
* By default all permissions are cached for 24 hours to speed up performance.
* When permissions or roles are updated the cache is flushed automatically.
*/
'expiration_time'
=>
\DateInterval
::
createFromDateString
(
'24 hours'
),
/*
* The cache key used to store all permissions.
*/
'key'
=>
'spatie.permission.cache'
,
/*
* When checking for a permission against a model by passing a Permission
* instance to the check, this key determines what attribute on the
* Permissions model is used to cache against.
*
* Ideally, this should match your preferred way of checking permissions, eg:
* `$user->can('view-posts')` would be 'name'.
*/
'model_key'
=>
'name'
,
/*
* You may optionally indicate a specific cache driver to use for permission and
* role caching using any of the `store` drivers listed in the cache.php config
* file. Using 'default' here means to use the `default` set in cache.php.
*/
'store'
=>
'default'
,
],
];
server/config/view.php
deleted
100644 → 0
View file @
94d80aca
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
return
[
/*
|--------------------------------------------------------------------------
| View Storage Paths
|--------------------------------------------------------------------------
|
| Most templating systems load templates from disk. Here you may specify
| an array of paths that should be checked for your views. Of course
| the usual Laravel view path has already been registered for you.
|
*/
'paths'
=>
[
resource_path
(
'views'
),
],
/*
|--------------------------------------------------------------------------
| Compiled View Path
|--------------------------------------------------------------------------
|
| This option determines where all the compiled Blade templates will be
| stored for your application. Typically, this is within the storage
| directory. However, as usual, you are free to change this value.
|
*/
'compiled'
=>
realpath
(
storage_path
(
'framework/views'
)),
];
server/routes/api/auth.php
deleted
100644 → 0
View file @
94d80aca
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/
$api
->
version
(
'v1'
,
function
(
$api
)
{
$api
->
group
([
'namespace'
=>
'App\Http\Controllers\V1\Auth'
,
'middleware'
=>
[
'api.auth'
,
'permissions'
],
'providers'
=>
'jwt'
],
function
(
$api
)
{
//用户相关
$api
->
post
(
'/adminapi/user/add'
,
[
'permission'
=>
'user.add'
,
'uses'
=>
'AuthUserController@addUser'
]);
$api
->
post
(
'/adminapi/user/edit'
,
[
'permission'
=>
'user.edit'
,
'uses'
=>
'AuthUserController@editUser'
]);
$api
->
get
(
'/adminapi/user/info'
,
[
'uses'
=>
'AuthUserController@info'
]);
$api
->
post
(
'/adminapi/auth/resetPassword'
,
[
'permission'
=>
'user.reset_password'
,
'uses'
=>
'AuthUserController@resetPassword'
]);
$api
->
get
(
'/adminapi/user/listByPage'
,
[
'permission'
=>
'user.list.*'
,
'uses'
=>
'AuthUserController@listByPage'
]);
$api
->
post
(
'/adminapi/user/disable/{id}'
,
[
'permission'
=>
'user.edit.status'
,
'uses'
=>
'AuthUserController@changeUserStatus'
]);
$api
->
post
(
'/adminapi/user/enable/{id}'
,
[
'permission'
=>
'user.edit.status'
,
'uses'
=>
'AuthUserController@changeUserStatus'
]);
$api
->
post
(
'/adminapi/user/delByIds'
,
[
'permission'
=>
'user.del.ids'
,
'uses'
=>
'AuthUserController@delUserByIds'
]);
});
//用户登陆
$api
->
group
([
'namespace'
=>
'App\Http\Controllers\V1\Auth'
],
function
(
$api
)
{
$api
->
post
(
'/adminapi/auth/login'
,
[
'uses'
=>
'AuthUserController@login'
]);
});
//用户登出
$api
->
group
([
'namespace'
=>
'App\Http\Controllers\V1\Auth'
,
'middleware'
=>
[
'permissions'
]],
function
(
$api
)
{
$api
->
get
(
'/adminapi/auth/logout'
,
[
'uses'
=>
'AuthUserController@logout'
]);
});
});
server/routes/api/permissions.php
deleted
100644 → 0
View file @
94d80aca
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/
$api
->
version
(
'v1'
,
function
(
$api
)
{
$api
->
group
([
'namespace'
=>
'App\Http\Controllers\V1'
,
'middleware'
=>
[
'api.auth'
,
'permissions'
],
'providers'
=>
'jwt'
],
function
(
$api
)
{
//菜单相关
$api
->
get
(
'/adminapi/permission/menu/userRoleMenuList'
,
[
'uses'
=>
'PermissionsController@getUserRoleMenuList'
]);
$api
->
post
(
'/adminapi/permission/menu/edit'
,
[
'permission'
=>
'menu.permission.edit'
,
'uses'
=>
'PermissionsController@editMenus'
]);
$api
->
post
(
'/adminapi/permission/menu/subAdd'
,
[
'permission'
=>
'menu.permission.add'
,
'uses'
=>
'PermissionsController@addSubMenus'
]);
$api
->
post
(
'/adminapi/permission/menu/del'
,
[
'permission'
=>
'menu.permission.del'
,
'uses'
=>
'PermissionsController@deleteMenus'
]);
$api
->
get
(
'/adminapi/permission/menu/all'
,
[
'permission'
=>
'menu.permission.list'
,
'uses'
=>
'PermissionsController@getAllMenuList'
]);
//角色相关
$api
->
get
(
'/adminapi/permission/role/getAllByPage'
,
[
'permission'
=>
'role.permission.list.*'
,
'uses'
=>
'PermissionsController@getAllByPage'
]);
$api
->
get
(
'/adminapi/permission/role/getAllList'
,
[
'permission'
=>
'role.permission.list.view'
,
'uses'
=>
'PermissionsController@getAllList'
]);
$api
->
post
(
'/adminapi/permission/role/add'
,
[
'permission'
=>
'role.permission.add'
,
'uses'
=>
'PermissionsController@addRole'
]);
$api
->
post
(
'/adminapi/permission/role/edit'
,
[
'permission'
=>
'role.permission.edit'
,
'uses'
=>
'PermissionsController@editRole'
]);
$api
->
post
(
'/adminapi/permission/role/delByIds'
,
[
'permission'
=>
'role.permission.del'
,
'uses'
=>
'PermissionsController@delByIds'
]);
$api
->
post
(
'/adminapi/permission/role/editRolePermission'
,
[
'permission'
=>
'role.permission.edit'
,
'uses'
=>
'PermissionsController@editRolePermission'
]);
$api
->
post
(
'/adminapi/permission/role/setDefault'
,
[
'permission'
=>
'role.permission.edit'
,
'uses'
=>
'PermissionsController@editRoleDefault'
]);
$api
->
get
(
'/adminapi/permission/dictData/defaultButtonPermission'
,
[
'uses'
=>
'PermissionsController@getDefaultButtonPermission'
]);
});
});
server/routes/api/
tools
.php
→
server/routes/api/
zhenkunhang
.php
View file @
95b68a5b
File moved
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