Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Cong.Zhao
/
musician-api.hikoon.com
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
ebede106
...
ebede106248cc9357259c37f88806c87c12b26ed
authored
2022-07-12 16:26:48 +0800
by
lemon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
发行转发
1 parent
1ab2a2f0
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
129 additions
and
7 deletions
app/Http/Controllers/Musician/IssueController.php
app/Http/Middleware/AuthIdentifier.php
app/Models/Legal/Stakeholder.php
app/Providers/RouteServiceProvider.php
app/Services/IssueService.php
app/Services/Service.php
config/logging.php
routes/api.php
app/Http/Controllers/Musician/IssueController.php
0 → 100644
View file @
ebede10
<?php
namespace
App\Http\Controllers\Musician
;
use
App\Http\Controllers\Controller
;
use
App\Http\Requests\Musician\MusicianWithdrawBillConfirmRequest
;
use
App\Http\Requests\Musician\MusicianWithdrawReceiptByNameRequest
;
use
App\Http\Requests\Musician\MusicianWithdrawReceiptByNoRequest
;
use
App\Http\Requests\Musician\MusicianWithdrawReceiptRequest
;
use
App\Http\Requests\Musician\MusicianWithdrawStatusRequest
;
use
App\Services\IssueService
;
use
App\Services\MusicianWithdrawService
;
use
App\Services\WithdrawService
;
/**
* Class IssueController
* @package App\Http\Controllers\Musician
*/
class
IssueController
extends
Controller
{
/**
* @var
*/
private
$issueService
;
/**
* @param IssueService $issueService
*/
public
function
__construct
(
IssueService
$issueService
)
{
$this
->
issueService
=
$issueService
;
}
/**
* @return \Illuminate\Http\JsonResponse
*/
public
function
index
()
{
return
$this
->
issueService
->
forward
();
}
}
app/Http/Middleware/AuthIdentifier.php
View file @
ebede10
...
...
@@ -6,6 +6,7 @@ use App\Helper\AesEncrypt;
use
App\Helper\ErrorCode
;
use
App\Helper\Identifier
;
use
App\Helper\Response
;
use
App\Helper\Snowflake
;
use
App\Models\Legal\Stakeholder
;
use
Closure
;
use
Illuminate\Http\Request
;
...
...
@@ -30,6 +31,9 @@ class AuthIdentifier
*/
public
function
handle
(
Request
$request
,
Closure
$next
)
{
//增加额外属性
$request
->
attributes
->
add
([
'request_id'
=>
Snowflake
::
gen
(),]);
$prefix
=
current
(
explode
(
'/'
,
$request
->
path
()));
if
(
!
in_array
(
$prefix
,
$this
->
auth
))
goto
AUTH
;
...
...
@@ -52,10 +56,10 @@ class AuthIdentifier
//通过身份证查询id
$stakeholder_ids
=
Stakeholder
::
stakeholderIds
(
$identifier
);
if
(
empty
(
$stakeholder_ids
))
return
Response
::
error
(
ErrorCode
::
MATCH_IDENTIFIER_FAIL
);
$request
->
attributes
->
add
([
'identifier'
=>
$identifier
,
'stakeholder_ids'
=>
$stakeholder_ids
,
'identifier'
=>
$identifier
,
'stakeholder_ids'
=>
$stakeholder_ids
,
]);
AUTH
:
...
...
app/Models/Legal/Stakeholder.php
View file @
ebede10
...
...
@@ -33,7 +33,7 @@ class Stakeholder extends BaseModel
case
1
:
//个人
$stakeholder
=
Stakeholder
::
query
()
->
join
(
'stakeholder_detail as sd'
,
'stakeholders.id'
,
'='
,
'sd.stakeholder_id'
)
->
where
([
'stakeholders.card_no'
=>
$identifier
->
identifier
])
->
pluck
(
'stakeholders.id'
)
->
toArray
();
->
where
([
'stakeholders.card_no'
=>
$identifier
->
identifier
,
'type'
=>
1
])
->
pluck
(
'stakeholders.id'
)
->
toArray
();
break
;
case
2
:
$stakeholder
=
Stakeholder
::
query
()
->
where
([
'type'
=>
2
,
'credit_code'
=>
$identifier
->
identifier
])
->
pluck
(
'id'
)
->
toArray
();
...
...
app/Providers/RouteServiceProvider.php
View file @
ebede10
...
...
@@ -38,7 +38,8 @@ class RouteServiceProvider extends ServiceProvider
$this
->
configureRateLimiting
();
$this
->
routes
(
function
()
{
//需授权
//音乐人
Route
::
prefix
(
'api'
)
->
middleware
(
'api'
)
->
namespace
(
$this
->
namespace
.
'\Musician'
)
...
...
@@ -55,7 +56,7 @@ class RouteServiceProvider extends ServiceProvider
->
namespace
(
$this
->
namespace
)
->
group
(
base_path
(
'routes/web.php'
));
//发行接口
//发行接口
- 对接生态平台
Route
::
prefix
(
'release'
)
->
namespace
(
$this
->
namespace
.
'\Release'
)
->
group
(
base_path
(
'routes/release.php'
));
...
...
app/Services/IssueService.php
0 → 100644
View file @
ebede10
<?php
namespace
App\Services
;
use
App\Helper\AesEncrypt
;
use
App\Helper\ErrorCode
;
use
App\Helper\Response
;
use
GuzzleHttp\Client
;
use
Illuminate\Support\Facades\Log
;
/**
* Class IssueService
* @package App\Services
*/
class
IssueService
extends
Service
{
/**
* 转发
* @return \Illuminate\Http\JsonResponse
*/
public
function
forward
()
{
$client
=
new
Client
([
'base_uri'
=>
env
(
'resource_url'
),
'timeout'
=>
3.0
,
]);
$method
=
$this
->
request
->
getMethod
();
$data
=
[];
try
{
$params
[
'data'
]
=
$this
->
request
->
all
();
$params
[
'ext'
]
=
[
'user_id'
=>
$this
->
identifier
->
user_id
,
'stakeholder_ids'
=>
$this
->
stakeholder_ids
,
];
$data
[
'json'
]
=
[
'params'
=>
AesEncrypt
::
encrypt
(
json_encode
(
$params
))];
$response
=
$client
->
request
(
$method
,
$this
->
request
->
getRequestUri
(),
$data
);
$respArr
=
json_decode
(
$response
->
getBody
()
->
getContents
(),
true
);
return
response
()
->
json
(
$respArr
,
200
);
}
catch
(
\Throwable
$throwable
)
{
return
Response
::
error
(
ErrorCode
::
SERVER_ERROR
,
$throwable
->
getMessage
());
}
}
}
app/Services/Service.php
View file @
ebede10
...
...
@@ -2,6 +2,7 @@
namespace
App\Services
;
use
App\Helper\Snowflake
;
use
Carbon\Carbon
;
use
Illuminate\Http\Request
;
...
...
@@ -12,6 +13,16 @@ use Illuminate\Http\Request;
class
Service
{
/**
* @var Request
*/
protected
$request
;
/**
* @var mixed
*/
protected
$user_id
;
/**
* @var mixed
*/
protected
$identifier
;
...
...
config/logging.php
View file @
ebede10
...
...
@@ -113,7 +113,13 @@ return [
'driver'
=>
'daily'
,
'path'
=>
storage_path
(
'logs/laravel-api.log'
),
'level'
=>
env
(
'LOG_LEVEL'
,
'debug'
),
]
],
'issue'
=>
[
'driver'
=>
'daily'
,
'path'
=>
storage_path
(
'logs/issue/issue.log'
),
'level'
=>
env
(
'LOG_LEVEL'
,
'debug'
),
],
],
];
...
...
routes/api.php
View file @
ebede10
...
...
@@ -53,7 +53,16 @@ Route::group([], function (){
});
//发行
Route
::
group
([
"prefix"
=>
"issue"
],
function
(){
Route
::
any
(
'{uri}'
,
'IssueController@index'
)
->
where
([
'uri'
=>
'[\w_]{1,}'
]);
});
//api-v2
Route
::
group
([
"prefix"
=>
"v2"
,
"namespace"
=>
"V2"
],
function
(){
Route
::
get
(
'musician_song'
,
'MusicianSongController@list'
);
});
...
...
Please
register
or
sign in
to post a comment