发行作品
Showing
6 changed files
with
102 additions
and
0 deletions
| 1 | <?php | ||
| 2 | |||
| 3 | namespace App\Http\Controllers\Common; | ||
| 4 | |||
| 5 | use App\Http\Controllers\Controller; | ||
| 6 | use App\Services\ReleaseSongService; | ||
| 7 | |||
| 8 | /** | ||
| 9 | * Class ReleaseSongController | ||
| 10 | * @package App\Http\Controllers\Musician | ||
| 11 | */ | ||
| 12 | class ReleaseSongController extends Controller | ||
| 13 | { | ||
| 14 | |||
| 15 | /** | ||
| 16 | * @var ReleaseSongService | ||
| 17 | */ | ||
| 18 | protected $releaseSongService; | ||
| 19 | |||
| 20 | /** | ||
| 21 | * ReleaseSongController constructor. | ||
| 22 | * @param ReleaseSongService $releaseSongService | ||
| 23 | */ | ||
| 24 | public function __construct(ReleaseSongService $releaseSongService) | ||
| 25 | { | ||
| 26 | $this->releaseSongService = $releaseSongService; | ||
| 27 | } | ||
| 28 | |||
| 29 | /** | ||
| 30 | * 授权歌曲列表 | ||
| 31 | * @return \Illuminate\Http\JsonResponse | ||
| 32 | */ | ||
| 33 | public function list() | ||
| 34 | { | ||
| 35 | return $this->releaseSongService->releaseSong(); | ||
| 36 | } | ||
| 37 | |||
| 38 | |||
| 39 | |||
| 40 | } |
| ... | @@ -26,4 +26,12 @@ class SongsIp extends BaseModel | ... | @@ -26,4 +26,12 @@ class SongsIp extends BaseModel |
| 26 | { | 26 | { |
| 27 | return $this->belongsTo(Contract::class, 'contract_id'); | 27 | return $this->belongsTo(Contract::class, 'contract_id'); |
| 28 | } | 28 | } |
| 29 | |||
| 30 | /** | ||
| 31 | * @return \Illuminate\Database\Eloquent\Relations\HasOne | ||
| 32 | */ | ||
| 33 | public function songsIpExt() | ||
| 34 | { | ||
| 35 | return $this->hasOne(SongsIpExts::class, 'song_ip_id'); | ||
| 36 | } | ||
| 29 | } | 37 | } | ... | ... |
| ... | @@ -38,11 +38,18 @@ class RouteServiceProvider extends ServiceProvider | ... | @@ -38,11 +38,18 @@ class RouteServiceProvider extends ServiceProvider |
| 38 | $this->configureRateLimiting(); | 38 | $this->configureRateLimiting(); |
| 39 | 39 | ||
| 40 | $this->routes(function () { | 40 | $this->routes(function () { |
| 41 | //需授权 | ||
| 41 | Route::prefix('api') | 42 | Route::prefix('api') |
| 42 | ->middleware('api') | 43 | ->middleware('api') |
| 43 | ->namespace($this->namespace . '\Musician') | 44 | ->namespace($this->namespace . '\Musician') |
| 44 | ->group(base_path('routes/api.php')); | 45 | ->group(base_path('routes/api.php')); |
| 45 | 46 | ||
| 47 | //公用 | ||
| 48 | Route::prefix('api') | ||
| 49 | ->middleware('api') | ||
| 50 | ->namespace($this->namespace . '\Common') | ||
| 51 | ->group(base_path('routes/common.php')); | ||
| 52 | |||
| 46 | Route::prefix('admin') | 53 | Route::prefix('admin') |
| 47 | ->middleware('api') | 54 | ->middleware('api') |
| 48 | ->namespace($this->namespace . '\Admin') | 55 | ->namespace($this->namespace . '\Admin') | ... | ... |
app/Services/ReleaseSongService.php
0 → 100644
| 1 | <?php | ||
| 2 | |||
| 3 | namespace App\Services; | ||
| 4 | |||
| 5 | use App\Helper\Response; | ||
| 6 | use App\Models\Legal\SongsIp; | ||
| 7 | |||
| 8 | /** | ||
| 9 | * Class ReleaseSongService | ||
| 10 | * @package App\Services | ||
| 11 | */ | ||
| 12 | class ReleaseSongService extends Service | ||
| 13 | { | ||
| 14 | /** | ||
| 15 | * 最新的发行作品 | ||
| 16 | * @return \Illuminate\Http\JsonResponse | ||
| 17 | */ | ||
| 18 | public function releaseSong() | ||
| 19 | { | ||
| 20 | $res = SongsIp::query()->with('songsIpExt')->select(['id','song_id', 'name', 'singer', 'online_time']) | ||
| 21 | ->orderByDesc('online_time')->paginate($this->pageSize); | ||
| 22 | |||
| 23 | return Response::success($res); | ||
| 24 | } | ||
| 25 | } |
routes/common.php
0 → 100644
| 1 | <?php | ||
| 2 | |||
| 3 | use Illuminate\Support\Facades\Route; | ||
| 4 | |||
| 5 | /* | ||
| 6 | |-------------------------------------------------------------------------- | ||
| 7 | | API Routes | ||
| 8 | |-------------------------------------------------------------------------- | ||
| 9 | | | ||
| 10 | | Here is where you can register API routes for your application. These | ||
| 11 | | routes are loaded by the RouteServiceProvider within a group which | ||
| 12 | | is assigned the "api" middleware group. Enjoy building your API! | ||
| 13 | | | ||
| 14 | */ | ||
| 15 | |||
| 16 | Route::group([], function (){ | ||
| 17 | |||
| 18 | //首页-最新发行作品 | ||
| 19 | Route::get('release_song', 'ReleaseSongController@list'); | ||
| 20 | |||
| 21 | }); |
-
Please register or sign in to post a comment