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
71f7c907
...
71f7c9077d4b03d9b3cb7d0edc78a9ef49408e1c
authored
2022-09-16 17:41:14 +0800
by
wei.feng
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
..
1 parent
5aad5096
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
19 deletions
app/Http/Controllers/OpenApi/SongController.php
app/Models/Legal/Song.php
app/Http/Controllers/OpenApi/SongController.php
View file @
71f7c90
...
...
@@ -20,7 +20,7 @@ class SongController extends Controller
public
function
list
(
Request
$request
)
{
if
(
!
$request
->
has
(
'type'
)
||
!
$request
->
has
(
'value'
))
{
/*
if (!$request->has('type') || !$request->has('value')) {
return Response::successWithCode(ErrorCode::MISSING_PARAMS, ErrorCode::$messages[ErrorCode::MISSING_PARAMS]);
}
...
...
@@ -30,7 +30,7 @@ class SongController extends Controller
if (!in_array($request->get('type'), static::$input_types)) {
return Response::successWithCode(ErrorCode::ILLEGAL_PARAMS, ErrorCode::$messages[ErrorCode::ILLEGAL_PARAMS]);
}
}
*/
$songs
=
Song
::
with
(
'subject'
,
'tags'
,
'files'
)
->
where
([
...
...
@@ -39,26 +39,23 @@ class SongController extends Controller
'performer_right'
=>
1
,
'tape_right'
=>
1
,
])
->
when
(
$request
->
filled
(
'value'
),
function
(
$query
)
use
(
$request
)
{
switch
(
$request
->
get
(
'type'
))
{
case
1
:
$query
->
where
(
'custom_id'
,
$request
->
get
(
'value'
));
break
;
case
2
:
$query
->
where
(
'name'
,
'like'
,
"%
{
$request
->
get
(
'value'
)
}
%"
);
break
;
case
3
:
$query
->
where
(
'singer'
,
'like'
,
"%
{
$request
->
get
(
'value'
)
}
%"
);
break
;
}
});
->
when
(
$request
->
filled
(
'song_id'
),
function
(
$query
)
use
(
$request
)
{
$query
->
where
(
'custom_id'
,
'like'
,
"%
{
$request
->
get
(
'song_id'
)
}
%"
);
})
->
when
(
$request
->
filled
(
'song_name'
),
function
(
$query
)
use
(
$request
)
{
$query
->
where
(
'name'
,
'like'
,
"%
{
$request
->
get
(
'song_name'
)
}
%"
);
})
->
when
(
$request
->
filled
(
'singer'
),
function
(
$query
)
use
(
$request
)
{
$query
->
where
(
'singer'
,
'like'
,
"%
{
$request
->
get
(
'singer'
)
}
%"
);
})
->
where
(
'has_all_files'
,
1
);
$total
=
$songs
->
count
();
$songs
=
$songs
->
orderByDesc
(
'id'
)
->
forPage
(
$request
->
get
(
'page'
,
1
),
static
::
$songs_limit
)
$songs
=
$songs
->
forPage
(
$request
->
get
(
'page'
,
1
),
$request
->
get
(
'limit'
,
static
::
$songs_limit
))
->
get
([
'custom_id as song_id'
,
'name as song_name'
,
'lyricist'
,
'composer'
,
'singer'
,
'lyrics_right'
,
'tune_right'
,
'performer_right'
,
'tape_right'
,
'status'
,
'subject_no'
,
'tag_id'
])
'tune_right'
,
'performer_right'
,
'tape_right'
,
'status'
,
'subject_no'
,
'tag_id'
,
'lyrics_right_date'
,
'tune_right_date'
,
'performer_right_date'
,
'tape_right_date'
])
->
toArray
();
if
(
count
(
$songs
))
{
...
...
@@ -75,6 +72,11 @@ class SongController extends Controller
$song
[
'files'
]
=
$this
->
coverFiles
(
$song
[
'files'
]);
}
$song
[
'lyrics_right_date'
]
=
$this
->
coverRightDate
(
$song
[
'lyrics_right_date'
]);
$song
[
'tune_right_date'
]
=
$this
->
coverRightDate
(
$song
[
'tune_right_date'
]);
$song
[
'performer_right_date'
]
=
$this
->
coverRightDate
(
$song
[
'performer_right_date'
]);
$song
[
'tape_right_date'
]
=
$this
->
coverRightDate
(
$song
[
'tape_right_date'
]);
$song
[
'type'
]
=
1
;
unset
(
$song
[
'subject_no'
],
$song
[
'tag_id'
]);
...
...
@@ -131,6 +133,23 @@ class SongController extends Controller
return
$files_arr
;
}
public
function
coverRightDate
(
$right_date
)
{
$date
=
[
'start'
=>
'无'
,
'end'
=>
'无'
];
try
{
if
(
$right_date
)
{
$tmp
=
explode
(
' - '
,
$right_date
);
$date
=
[
'start'
=>
$tmp
[
0
],
'end'
=>
$tmp
[
1
],
];
}
}
catch
(
\Exception
$exception
)
{
return
$date
;
}
return
$date
;
}
}
...
...
app/Models/Legal/Song.php
View file @
71f7c90
...
...
@@ -14,7 +14,7 @@ class Song extends BaseModel
{
use
HasFactory
,
SoftDeletes
;
p
rotected
static
$file_only
=
[
1
,
2
,
4
,
11
,
12
];
p
ublic
static
$file_only
=
[
1
,
2
,
4
,
11
,
12
];
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
...
...
Please
register
or
sign in
to post a comment