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
f32854e9
Commit
f32854e9
authored
Jul 06, 2025
by
hj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新提交
parent
9c84835d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
33 deletions
+48
-33
server/app/Http/Controllers/V1/Controller.php
server/app/Http/Controllers/V1/Controller.php
+48
-33
No files found.
server/app/Http/Controllers/V1/Controller.php
View file @
f32854e9
<?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\Http\Controllers\V1
;
use
App\Services\CustomerService
;
use
App\Exceptions\ServerRunTimeException
;
use
App\Services\AuthService
;
use
App\Services\YyBao\CustomersService
;
use
App\Support\Traits\Helpers
;
use
Illuminate\Auth\AuthenticationException
;
use
Illuminate\Http\Request
;
use
Jiannei\Response\Laravel\Support\Facades\Response
;
use
Jiannei\Response\Laravel\Support\Traits\ExceptionTrait
;
use
Laravel\Lumen\Routing\Controller
as
BaseController
;
use
OpenApi\Annotations\Info
;
use
OpenApi\Annotations\Schema
;
use
OpenApi\Annotations\Server
;
use
OpenApi\Annotations\Property
;
use
OpenApi\Annotations\SecurityScheme
;
use
OpenApi\Annotations\Schema
;
/**
*
* @Info(
* version="1.0",
* title="
罗恩开放平台 API接口文档
"
* title="
研易宝
"
* )
*
* @Schema(
...
...
@@ -46,11 +38,24 @@ use OpenApi\Annotations\SecurityScheme;
* )
*
*/
abstract
class
Controller
extends
BaseController
{
use
ExceptionTrait
;
use
Helpers
,
ExceptionTrait
;
public
function
getRequestRulesInputs
(
Request
$request
)
:
array
{
$inputs
=
$request
->
request
->
all
();
$rules
=
$request
->
rules
();
foreach
(
$inputs
as
$key
=>
$in
){
if
(
!
empty
(
$rules
)
&&
!
in_array
(
$key
,
array_keys
(
$rules
))){
unset
(
$inputs
[
$key
]);
}
$inputs
[
$key
]
=
$this
->
stripHtml
(
$in
);
}
$inputs
[
'platform_source'
]
=
current
(
$this
->
getUriPath
());
return
$inputs
;
}
/**
* request 参数验证
...
...
@@ -76,26 +81,36 @@ abstract class Controller extends BaseController
return
true
;
}
p
rotected
function
returnErrorExecptionResponse
(
\Exception
$exception
,
string
$message
=
''
)
p
ublic
function
getGuardName
(
)
{
if
(
$exception
->
getCode
()
==
500
||
$exception
->
getCode
()
==
502
){
return
Response
::
fail
(
$exception
->
getMessage
(),
200
);
}
return
Response
::
fail
(
$message
==
''
?
$exception
->
getMessage
()
:
$message
,
200
);
return
app
()
->
request
->
headers
->
get
(
'guardName'
);
}
protected
function
checkCustomerType
(
$customerCode
,
$type
)
protected
function
returnErrorExecptionResponse
(
\Exception
$exception
,
string
$message
=
''
)
:
\Illuminate\Http\JsonResponse
{
$customer
=
app
(
CustomerService
::
class
)
->
getPlatformCustomer
([
'cus_number'
=>
$customerCode
,
'cus_type'
=>
$type
]);
if
(
$customer
){
if
(
$customer
[
'cus_type'
]
!=
$type
){
switch
(
$type
){
case
'bh'
:
$this
->
returnErrorExecptionResponse
(
new
AuthenticationException
(
'不是百化用户,无法访问该类型接口'
));
break
;
case
'rhawn'
:
$this
->
returnErrorExecptionResponse
(
new
AuthenticationException
(
'不是罗恩用户,无法访问该类型接口'
));
break
;
case
'chemsite'
:
$this
->
returnErrorExecptionResponse
(
new
AuthenticationException
(
'不是chemsite用户,无法访问该类型接口'
));
break
;
default
:
$this
->
returnErrorExecptionResponse
(
new
AuthenticationException
(
'用户类型未知'
));
if
(
$exception
instanceof
AuthenticationException
){
return
Response
::
fail
(
$exception
->
getMessage
(),
401
);
}
if
(
$exception
->
getCode
()
==
500
||
$exception
->
getCode
()
==
0
){
return
Response
::
fail
(
$exception
->
getMessage
(),
500
);
}
else
{
return
Response
::
fail
(
$message
==
''
?
$exception
->
getMessage
()
:
$message
,
$exception
->
getCode
());
}
}
public
function
setService
(
$service
)
{
$this
->
service
=
$service
;
}
public
function
getService
()
{
return
$this
->
service
;
}
public
function
getUriPath
()
{
$urls
=
explode
(
'/'
,
app
()
->
request
->
url
);
return
array_values
(
array_filter
(
$urls
));
}
}
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