Commit 93fe78ba 93fe78ba0c69bbcdded30a18f43db3f014993e0d by lemon

发行作品

1 parent 3964663d
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 }
...@@ -53,4 +53,5 @@ class MusicianSongController extends Controller ...@@ -53,4 +53,5 @@ class MusicianSongController extends Controller
53 { 53 {
54 return $this->musicianSongService->right($song_id); 54 return $this->musicianSongService->right($song_id);
55 } 55 }
56
56 } 57 }
......
...@@ -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,15 +38,22 @@ class RouteServiceProvider extends ServiceProvider ...@@ -38,15 +38,22 @@ 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
46 Route::prefix('admin') 47 //公用
48 Route::prefix('api')
47 ->middleware('api') 49 ->middleware('api')
48 ->namespace($this->namespace . '\Admin') 50 ->namespace($this->namespace . '\Common')
49 ->group(base_path('routes/admin.php')); 51 ->group(base_path('routes/common.php'));
52
53 Route::prefix('admin')
54 ->middleware('api')
55 ->namespace($this->namespace . '\Admin')
56 ->group(base_path('routes/admin.php'));
50 57
51 58
52 Route::middleware('web') 59 Route::middleware('web')
......
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 }
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 });