处理数据
Showing
5 changed files
with
98 additions
and
1 deletions
... | @@ -48,4 +48,13 @@ class IssueController extends Controller | ... | @@ -48,4 +48,13 @@ class IssueController extends Controller |
48 | return $this->issueService->subCompany(); | 48 | return $this->issueService->subCompany(); |
49 | } | 49 | } |
50 | 50 | ||
51 | /** | ||
52 | * 最新发行记录 | ||
53 | * @return \Illuminate\Http\JsonResponse | ||
54 | */ | ||
55 | public function latestOnlineRecord() | ||
56 | { | ||
57 | return $this->issueService->latestOnlineRecord(); | ||
58 | } | ||
59 | |||
51 | } | 60 | } | ... | ... |
app/Models/Legal/SongsApply.php
0 → 100644
1 | <?php | ||
2 | |||
3 | |||
4 | namespace App\Models\Legal; | ||
5 | |||
6 | |||
7 | use App\Models\BaseModel; | ||
8 | use Illuminate\Database\Eloquent\SoftDeletes; | ||
9 | |||
10 | class SongsApply extends BaseModel | ||
11 | { | ||
12 | use SoftDeletes; | ||
13 | |||
14 | /** | ||
15 | * @var string | ||
16 | */ | ||
17 | protected $table = 'songs_apply'; | ||
18 | |||
19 | /** | ||
20 | * @var array | ||
21 | */ | ||
22 | public $guarded = []; | ||
23 | |||
24 | /** | ||
25 | * @var string[] | ||
26 | */ | ||
27 | public $hidden = ['album_id']; | ||
28 | |||
29 | /** | ||
30 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo | ||
31 | */ | ||
32 | public function songs_album() | ||
33 | { | ||
34 | return $this->belongsTo(SongsIssueAlbum::class, 'album_id', 'id'); | ||
35 | } | ||
36 | } |
app/Models/Legal/SongsIssueAlbum.php
0 → 100644
1 | <?php | ||
2 | |||
3 | |||
4 | namespace App\Models\Legal; | ||
5 | |||
6 | use App\Models\BaseModel; | ||
7 | use Illuminate\Database\Eloquent\SoftDeletes; | ||
8 | |||
9 | class SongsIssueAlbum extends BaseModel | ||
10 | { | ||
11 | use SoftDeletes; | ||
12 | |||
13 | protected $table = 'songs_issue_album'; | ||
14 | |||
15 | public $guarded = []; | ||
16 | |||
17 | |||
18 | /** | ||
19 | * 关联封面 | ||
20 | * @return \Illuminate\Database\Eloquent\Relations\HasOne | ||
21 | */ | ||
22 | public function cover() | ||
23 | { | ||
24 | return $this->hasOne(FileMap::class, 'id','cover_map_id'); | ||
25 | } | ||
26 | } |
... | @@ -3,8 +3,10 @@ | ... | @@ -3,8 +3,10 @@ |
3 | namespace App\Services; | 3 | namespace App\Services; |
4 | 4 | ||
5 | use App\Helper\AesEncrypt; | 5 | use App\Helper\AesEncrypt; |
6 | use App\Helper\CosHelper; | ||
6 | use App\Helper\ErrorCode; | 7 | use App\Helper\ErrorCode; |
7 | use App\Helper\Response; | 8 | use App\Helper\Response; |
9 | use App\Models\Legal\SongsApply; | ||
8 | use App\Models\Legal\Stakeholder; | 10 | use App\Models\Legal\Stakeholder; |
9 | use App\Models\Legal\Subject; | 11 | use App\Models\Legal\Subject; |
10 | use Illuminate\Support\Facades\Log; | 12 | use Illuminate\Support\Facades\Log; |
... | @@ -69,7 +71,30 @@ class IssueService extends Service | ... | @@ -69,7 +71,30 @@ class IssueService extends Service |
69 | ->get(['no as value', 'name']); | 71 | ->get(['no as value', 'name']); |
70 | 72 | ||
71 | return Response::success($subject); | 73 | return Response::success($subject); |
74 | } | ||
75 | |||
76 | /** | ||
77 | * 发行(上架成功记录) | ||
78 | * @return \Illuminate\Http\JsonResponse | ||
79 | */ | ||
80 | public function latestOnlineRecord() | ||
81 | { | ||
82 | $res = SongsApply::query()->where(['from'=>1, 'user_id'=>$this->request->get('identifier')->company_id]) | ||
83 | ->whereNotNull('qy_url')->with(['songs_album:id,cover_map_id', 'songs_album.cover:id,link_id,key']) | ||
84 | ->select(['name','album_id','singer','online_time','qy_url'])->orderByDesc('online_time') | ||
85 | ->paginate($this->pageSize); | ||
86 | |||
87 | $cos = new CosHelper(env('MATERIAL_BUCKET')); | ||
88 | |||
89 | foreach ($res as &$item) { | ||
90 | if (!empty($item->songs_album->cover)) { | ||
91 | $item->cover = $cos->getPreviewUrl($item->songs_album->cover->key); | ||
92 | } | ||
93 | unset($item->songs_album); | ||
94 | $item->singer = explode(',', $item->singer); | ||
95 | } | ||
72 | 96 | ||
97 | return Response::success($res); | ||
73 | } | 98 | } |
74 | 99 | ||
75 | 100 | ... | ... |
... | @@ -53,7 +53,8 @@ Route::group([], function (){ | ... | @@ -53,7 +53,8 @@ Route::group([], function (){ |
53 | //发行 | 53 | //发行 |
54 | Route::group(["prefix"=>"issue"], function (){ | 54 | Route::group(["prefix"=>"issue"], function (){ |
55 | Route::post('/album/subCompany', 'IssueController@subCompany'); | 55 | Route::post('/album/subCompany', 'IssueController@subCompany'); |
56 | Route::any('{uri}', 'IssueController@index')->where(['uri'=>'.*+']); | 56 | Route::get('/song/latestOnlineRecord', 'IssueController@latestOnlineRecord'); |
57 | Route::post('{uri}', 'IssueController@index')->where(['uri'=>'.*+']); | ||
57 | }); | 58 | }); |
58 | 59 | ||
59 | //api-v2 | 60 | //api-v2 | ... | ... |
-
Please register or sign in to post a comment