|
@@ -5,6 +5,7 @@
|
|
|
* Date: 2019/7/4
|
|
|
* Time: 上午9:50
|
|
|
*/
|
|
|
+
|
|
|
namespace App\Repositories;
|
|
|
|
|
|
use App\Models\PostMusicCategory;
|
|
@@ -14,7 +15,7 @@ use Illuminate\Support\Facades\Cache;
|
|
|
|
|
|
class MusicRepository
|
|
|
{
|
|
|
- public function __construct(PostMusicCategoryRel $postMusicCategoryRel,PostMusicCategory $postMusicCategory,PostMusicUser $postMusicUser)
|
|
|
+ public function __construct(PostMusicCategoryRel $postMusicCategoryRel, PostMusicCategory $postMusicCategory, PostMusicUser $postMusicUser)
|
|
|
{
|
|
|
$this->postMusicCategoryRel = $postMusicCategoryRel;
|
|
|
$this->postMusicCategory = $postMusicCategory;
|
|
@@ -25,7 +26,8 @@ class MusicRepository
|
|
|
public function lists($request)
|
|
|
{
|
|
|
$perPage = isset($request['per_page']) ? $request['per_page'] : 20;
|
|
|
- $music_key = config('constants.MUSIC_LIST');
|
|
|
+ $key = config('constants.MUSIC_LIST');
|
|
|
+ $music_key = sprintf($key, md5($perPage));
|
|
|
if (Cache::has($music_key)) {
|
|
|
return Cache::store('redis')->get($music_key);
|
|
|
}
|
|
@@ -49,7 +51,7 @@ class MusicRepository
|
|
|
public function category_list($request)
|
|
|
{
|
|
|
$perPage = isset($request['per_page']) ? $request['per_page'] : 20;
|
|
|
- return $this->postMusicCategory->where('is_open',1)->orderBy('sort', 'asc')->paginate($perPage);
|
|
|
+ return $this->postMusicCategory->where('is_open', 1)->orderBy('sort', 'asc')->paginate($perPage);
|
|
|
}
|
|
|
|
|
|
public function postMusicList($request)
|
|
@@ -59,7 +61,7 @@ class MusicRepository
|
|
|
$postMusicList = $this->postMusicCategoryRel
|
|
|
->join('post_music_category', 'post_music_category.id', '=', 'post_music_category_rel.music_category_id')
|
|
|
->join('post_music', 'post_music.id', '=', 'post_music_category_rel.mid')
|
|
|
- ->select('post_music.*','post_music_category_rel.sort')
|
|
|
+ ->select('post_music.*', 'post_music_category_rel.sort')
|
|
|
->where(['post_music_category.id' => $request['category_id'], 'post_music_category.is_open' => 1])
|
|
|
->orderBy('post_music_category_rel.sort', 'asc')
|
|
|
->paginate($perPage);
|