Commit 93fe78ba 93fe78ba0c69bbcdded30a18f43db3f014993e0d by lemon

发行作品

1 parent 3964663d
<?php
namespace App\Http\Controllers\Common;
use App\Http\Controllers\Controller;
use App\Services\ReleaseSongService;
/**
* Class ReleaseSongController
* @package App\Http\Controllers\Musician
*/
class ReleaseSongController extends Controller
{
/**
* @var ReleaseSongService
*/
protected $releaseSongService;
/**
* ReleaseSongController constructor.
* @param ReleaseSongService $releaseSongService
*/
public function __construct(ReleaseSongService $releaseSongService)
{
$this->releaseSongService = $releaseSongService;
}
/**
* 授权歌曲列表
* @return \Illuminate\Http\JsonResponse
*/
public function list()
{
return $this->releaseSongService->releaseSong();
}
}
......@@ -53,4 +53,5 @@ class MusicianSongController extends Controller
{
return $this->musicianSongService->right($song_id);
}
}
......
......@@ -26,4 +26,12 @@ class SongsIp extends BaseModel
{
return $this->belongsTo(Contract::class, 'contract_id');
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function songsIpExt()
{
return $this->hasOne(SongsIpExts::class, 'song_ip_id');
}
}
......
......@@ -38,15 +38,22 @@ class RouteServiceProvider extends ServiceProvider
$this->configureRateLimiting();
$this->routes(function () {
//需授权
Route::prefix('api')
->middleware('api')
->namespace($this->namespace . '\Musician')
->group(base_path('routes/api.php'));
Route::prefix('admin')
//公用
Route::prefix('api')
->middleware('api')
->namespace($this->namespace . '\Admin')
->group(base_path('routes/admin.php'));
->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'));
Route::middleware('web')
......
<?php
namespace App\Services;
use App\Helper\Response;
use App\Models\Legal\SongsIp;
/**
* Class ReleaseSongService
* @package App\Services
*/
class ReleaseSongService extends Service
{
/**
* 最新的发行作品
* @return \Illuminate\Http\JsonResponse
*/
public function releaseSong()
{
$res = SongsIp::query()->with('songsIpExt')->select(['id','song_id', 'name', 'singer', 'online_time'])
->orderByDesc('online_time')->paginate($this->pageSize);
return Response::success($res);
}
}
<?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');
});