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
43b77201
...
43b77201a012bf0ffcdda94217a3dcccf29552a2
authored
2021-07-19 12:00:24 +0800
by
lemon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
*
1 parent
b220205c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
6 deletions
app/Models/Legal/Song.php
app/Services/MusicianSongService.php
app/Models/Legal/Song.php
View file @
43b7720
...
...
@@ -25,7 +25,7 @@ class Song extends BaseModel
/**
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public
function
cover
()
public
function
cover
Resource
()
{
return
$this
->
hasOne
(
SongFile
::
class
,
'song_id'
)
->
where
(
'type'
,
4
);
}
...
...
app/Services/MusicianSongService.php
View file @
43b7720
...
...
@@ -31,20 +31,21 @@ class MusicianSongService extends Service
$songip_table
=
SongsIp
::
table
();
$res
=
Song
::
query
()
->
join
(
$songip_table
,
"
{
$song_table
}
.id"
,
'='
,
"
{
$songip_table
}
.song_id"
)
->
with
([
'contractDetail'
,
'cover'
])
->
whereIn
(
"
{
$songip_table
}
.song_id"
,
$song_ids
)
->
select
([
"
{
$song_table
}
.id"
,
'publish_song'
])
->
groupBy
([
"song_id"
])
->
paginate
(
$this
->
pageSize
);
->
with
([
'contractDetail'
,
'cover
Resource
'
])
->
whereIn
(
"
{
$songip_table
}
.song_id"
,
$song_ids
)
->
select
([
"
{
$song_table
}
.id"
,
'publish_song'
])
->
groupBy
([
"song_id"
])
->
get
(
);
foreach
(
$res
as
&
$item
)
{
list
(
$name
,
$singer
)
=
explode
(
'|'
,
$item
->
publish_song
);
$item
->
setAttribute
(
'name'
,
$name
);
$item
->
setAttribute
(
'singer'
,
$singer
);
$item
->
setAttribute
(
'cover'
,
empty
(
$item
->
cover
->
url
)
?
''
:
$item
->
cover
->
url
);
$item
->
setAttribute
(
'cover'
,
empty
(
$item
->
cover
Resource
)
?
''
:
$item
->
coverResource
->
url
);
$tmp
=
$item
->
toArray
();
if
(
empty
(
$tmp
[
'contract_detail'
]))
{
$item
->
setAttribute
(
'role'
,
[]);
unset
(
$item
->
contractDetail
);
unset
(
$item
->
contractDetail
,
$item
->
publish_song
,
$item
->
coverResource
);
continue
;
}
...
...
@@ -61,7 +62,7 @@ class MusicianSongService extends Service
}
}
$item
->
setAttribute
(
'role'
,
array_unique
(
$role
));
unset
(
$item
->
contractDetail
,
$item
->
publish_song
);
unset
(
$item
->
contractDetail
,
$item
->
publish_song
,
$item
->
coverResource
);
}
return
Response
::
success
(
$res
);
...
...
Please
register
or
sign in
to post a comment