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
6fe52fec
...
6fe52fecbb552f4631b225b0b321b8d1e56922f2
authored
2021-12-01 15:11:37 +0800
by
lemon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
授权歌曲信息
1 parent
e77ede5c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
109 additions
and
28 deletions
app/Http/Controllers/Musician/V2/MusicianSongController.php
app/Models/BaseModel.php
app/Providers/RouteServiceProvider.php
app/Services/V2/MusicianSongService.php
routes/api.php
routes/common.php
app/Http/Controllers/Musician/V2/MusicianSongController.php
0 → 100644
View file @
6fe52fe
<?php
namespace
App\Http\Controllers\Musician\V2
;
use
App\Http\Controllers\Controller
;
use
App\Services\V2\MusicianSongService
;
/**
* Class MusicianSongController
* @package App\Http\Controllers\Musician
*/
class
MusicianSongController
extends
Controller
{
/**
* @var MusicianSongService
*/
protected
$musicianSongService
;
/**
* MusicianSongController constructor.
* @param MusicianSongService $musicianSongService
*/
public
function
__construct
(
MusicianSongService
$musicianSongService
)
{
$this
->
musicianSongService
=
$musicianSongService
;
}
/**
* @return \Illuminate\Http\JsonResponse
*/
public
function
list
()
{
return
$this
->
musicianSongService
->
releaseSong
();
}
}
app/Models/BaseModel.php
View file @
6fe52fe
...
...
@@ -58,6 +58,8 @@ class BaseModel extends Model
return
$builder
;
}
/**
* @param Builder $builder
* @return Builder
...
...
@@ -67,5 +69,21 @@ class BaseModel extends Model
return
$builder
->
whereIn
(
'stakeholder_id'
,
request
()
->
get
(
'stakeholder_ids'
));
}
/**
* 排序
* @param $sort
* @return mixed
*/
public
function
scopeSorted
(
Builder
$query
,
$sort
)
:
Builder
{
$table
=
(
new
static
)
->
getTable
();
try
{
$sort
=
json_decode
(
$sort
,
true
);
return
$query
->
orderBy
(
$sort
[
'prop'
]
??
"
{
$table
}
.updated_at"
,
$sort
[
'order'
]
??
'desc'
);
}
catch
(
\Exception
$e
)
{
return
$query
->
orderBy
(
"
{
$table
}
.updated_at"
,
'desc'
);
}
}
}
...
...
app/Providers/RouteServiceProvider.php
View file @
6fe52fe
...
...
@@ -44,18 +44,13 @@ class RouteServiceProvider extends ServiceProvider
->
namespace
(
$this
->
namespace
.
'\Musician'
)
->
group
(
base_path
(
'routes/api.php'
));
//公用
Route
::
prefix
(
'common'
)
->
middleware
(
'api'
)
->
namespace
(
$this
->
namespace
.
'\Common'
)
->
group
(
base_path
(
'routes/common.php'
));
//后台
Route
::
prefix
(
'admin'
)
->
middleware
(
'api'
)
->
namespace
(
$this
->
namespace
.
'\Admin'
)
->
group
(
base_path
(
'routes/admin.php'
));
//web
Route
::
middleware
(
'web'
)
->
namespace
(
$this
->
namespace
)
->
group
(
base_path
(
'routes/web.php'
));
...
...
app/Services/V2/MusicianSongService.php
0 → 100644
View file @
6fe52fe
<?php
namespace
App\Services\V2
;
use
App\Helper\CosHelper
;
use
App\Helper\Response
;
use
App\Models\Legal\Contract
;
use
App\Models\Legal\Song
;
use
App\Models\Legal\SongsIp
;
use
App\Models\Legal\SongsIpExts
;
use
App\Models\Legal\SongStakeholder
;
use
App\Services\Service
;
use
Illuminate\Database\Eloquent\Builder
;
/**
* Class MusicianSongService
* @package App\Services
*/
class
MusicianSongService
extends
Service
{
/**
* 授权发行歌曲
* @return \Illuminate\Http\JsonResponse
*/
public
function
releaseSong
()
{
$song_ids
=
array_filter
(
array_unique
(
SongStakeholder
::
query
()
->
identify
()
->
pluck
(
'song_id'
)
->
toArray
()));
if
(
empty
(
$song_ids
))
return
Response
::
success
();
$res
=
Song
::
query
()
->
join
(
'songs_ip'
,
"songs.id"
,
'='
,
"songs_ip.song_id"
)
->
join
(
'songs_ip_exts as ext'
,
'songs_ip.id'
,
'='
,
'ext.song_ip_id'
)
->
whereIn
(
"songs.id"
,
$song_ids
)
->
whereNull
(
"songs_ip.deleted_at"
)
->
where
(
'auth_channel'
,
1
)
->
select
([
"songs.id"
,
"songs_ip.id as sp_id"
,
'track_name'
,
'singer_name'
,
'album_name'
,
'public_time'
,
'track_version'
,
'favCnt'
,
'playCnt'
,
'downloadCnt'
,
'favCnt_week'
,
'playCnt_week'
,
'downloadCnt_week'
,
'favCnt_years'
,
'playCnt_years'
,
'downloadCnt_years'
,
])
->
when
(
filled
(
$this
->
request
->
name
),
function
(
Builder
$builder
)
{
$builder
->
where
(
function
(
Builder
$builder
){
$builder
->
where
(
'album_name'
,
'like'
,
"
{
$this
->
request
->
name
}
"
)
->
orWhere
(
'track_name'
,
'like'
,
"
{
$this
->
request
->
name
}
"
);
});
})
->
sorted
(
$this
->
request
->
sort
)
->
paginate
(
$this
->
pageSize
);
return
Response
::
success
(
$res
);
}
}
routes/api.php
View file @
6fe52fe
...
...
@@ -52,3 +52,8 @@ Route::group([], function (){
});
//api-v2
Route
::
group
([
"prefix"
=>
"v2"
,
"namespace"
=>
"V2"
],
function
(){
Route
::
get
(
'musician_song'
,
'MusicianSongController@list'
);
});
...
...
routes/common.php
deleted
100644 → 0
View file @
e77ede5
<?php
use
Illuminate\Support\Facades\Route
;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route
::
group
([],
function
(){
//首页-最新发行作品
Route
::
get
(
'release_song'
,
'ReleaseSongController@list'
);
});
Please
register
or
sign in
to post a comment