Commit 77e062bc by Phạm Văn Đoan

tạo task để lấy bài hát

No related merge requests found
<?php
namespace App\Console\Commands\Zing;
use Illuminate\Console\Command;
class ZingCrawlerTrackCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'zing:get-track';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Lấy thông tin bài hát từ ZingMp3';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//
}
}
......@@ -3,6 +3,7 @@
namespace App\Console;
use App\Console\Commands\CrontjobCommand;
use App\Console\Commands\Zing\ZingCrawlerTrackCommand;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
......@@ -15,6 +16,8 @@ class Kernel extends ConsoleKernel
*/
protected $commands = [
CrontjobCommand::class,
ZingCrawlerTrackCommand::class,
];
/**
......
<?php
namespace App\Helpers;
class Constants
{
const TABLE_ARTISTS = 'artists';
const TABLE_FAILED_JOBS = 'failed_jobs';
const TABLE_JOBS = 'jobs';
const TABLE_MIGRATIONS = 'migrations';
const TABLE_NOTIFICATIONS = 'notifications';
const TABLE_OAUTH_ACCESS_TOKENS = 'oauth_access_tokens';
const TABLE_OAUTH_AUTH_CODES = 'oauth_auth_codes';
const TABLE_OAUTH_CLIENTS = 'oauth_clients';
const TABLE_OAUTH_PERSONAL_ACCESS_CLIENTS = 'oauth_personal_access_clients';
const TABLE_OAUTH_REFRESH_TOKENS = 'oauth_refresh_tokens';
const TABLE_PASSWORD_RESETS = 'password_resets';
const TABLE_PERMISSION_USER = 'permission_user';
const TABLE_PERMISSIONS = 'permissions';
const TABLE_ROLE_USER = 'role_user';
const TABLE_ROLES = 'roles';
const TABLE_TRACK_ARTIST = 'track_artist';
const TABLE_TRACK_USER = 'track_user';
const TABLE_TRACKS = 'tracks';
const TABLE_USER_LOGS = 'user_logs';
const TABLE_USERS = 'users';
const USER_STATUS_INACTIVE = 0;
const USER_STATUS_ACTIVE = 1;
const USER_STATUS_LOCKED = 2;
const USER_STATUS_LEFT = 3;
const DB_NO_CONNECTION = 2002;
const SYSTEM_ERROR = -500;
const ACCESS_DENIED = 403;
const KILL_MYSELF = 'KILL_MYSELF';
const SYSTEM_MAINTENANCE = 503;
const CODE_SUCCESS = 0;
const CODE_ERROR = 1;
const CODE_EMPTY = 2;
const MESSAGE_SUCCESS = 'success';
const MESSAGE_ERROR = 'error';
const MESSAGE_EMPTY = 'empty';
const BIRTHDAY_STATUS_NEW = 0;
const BIRTHDAY_STATUS_PROCESSING = 1;
const BIRTHDAY_STATUS_SUCCESS = 2;
const BIRTHDAY_STATUS_FAILED = 3;
const BIRTHDAY_STATUS_SUCCESS_AGAIN = 4;
const BIRTHDAY_STATUS_CANCEL = 5;
const BIRTHDAY_CHANNEL_CODE_SMS = 'SMS';
const BIRTHDAY_CHANNEL_CODE_EMAIL = 'EMAIL';
const BIRTHDAY_CHANNEL_CODE_EMAIL_SMS = 'EMAIL_SMS';
const CHANNEL_CODE_DEFAULT = 'EMAIL';
const EMAIL_CONTENT_DEFAULT = 'Hi! Thay mặt Công Đoàn Công ty DCV, tôi xin gửi lời chúc sinh nhật vui vẻ, thành công và hạnh phúc tới đồng chí. Chúc đồng chí luôn hoàn thành tốt nhiệm vụ!';
const SMS_CONTENT_DEFAULT = '(DCV - CONG DOAN) Thay mat Cong Doan Cong ty DCV, chuc Ban sinh nhat VUI VE.';
/* Cấu hình khoảng giá trị sinh mã bảo mật */
const VERIFICATION_CODE_MIN = 100000;
const VERIFICATION_CODE_MAX = 999999;
/* Cấu hình thời gian bắt đầu gửi chúc mừng sinh nhật */
const BIRTHDAY_START_SEND_HOUR = '09';
const BIRTHDAY_START_SEND_MINUTE = '00';
const BIRTHDAY_START_SEND_SECOND = '00';
const BIRTHDAY_EMAIL_TEMPLATE_FILENAME = 'mail_birthday.html';
const BIRTHDAY_EMAIL_TEMPLATE_FROM_PUBLIC = 'storage/templates/mail/';
const BIRTHDAY_EMAIL_TEMPLATE_FROM_STORAGE = 'app/public/templates/mail/';
/* Backend view path */
const BE_VIEW_PATH_DASHBOARD = 'pages.backend.dashboard.index';
/* Tên Tab ứng dụng extension PMS */
const BROWSER_TYPE_NOTIFICATION = 'NOTIFICATION';
const BROWSER_TYPE_PROJECT = 'PROJECT';
const BROWSER_TYPE_TASK = 'TASK';
const BROWSER_TYPE_COWORKER = 'COWORKER';
/* Tên Tab ứng dụng extension SmartJob */
const SMARTJOB_TYPE_JOBS = 'JOBS';
const SMARTJOB_TYPE_COMPANIES = 'COMPANIES';
const SMARTJOB_TYPE_BLOG = 'BLOG';
/* Tên Tab ứng dụng extension AHoaDon */
const AHOADON_TYPE_SEARCH = 'SEARCH';
const AHOADON_TYPE_PACKAGE = 'PACKAGE';
const AHOADON_TYPE_TEMPLATE = 'TEMPLATE';
const AHOADON_PRICE_INIT = 500000;
const AHOADON_VAT = 10;
const STORAGE_OPENWEATHERMAP_ICON = 'storage/weather/openweathermap';
const STORAGE_COURSE_ICON = 'storage/courses';
const STORAGE_IMG_TRACKS_DB = 'storage/tracks/images/';
const STORAGE_IMG_TRACKS = 'storage/app/public/tracks/images/';
const STORAGE_IMG_EMPTY_PNG = 'storage/app/public/empty-1x1-png.png';
const STORAGE_IMG_EMPTY_JPG = 'storage/app/public/empty-1x1-jpg.jpg';
const STORAGE_IMG_EMPTY_GIF = 'storage/app/public/empty-1x1-gif.gif';
const STORAGE_FILE_TRACKS_DB = 'storage/tracks/files/';
const STORAGE_FILE_TRACKS = 'storage/app/public/tracks/files/';
const STORAGE_COVER_ARTISTS_DB = 'storage/artists/covers/';
const STORAGE_COVER_ARTISTS = 'storage/app/public/artists/covers/';
const STORAGE_THUMBNAIL_ARTISTS_DB = 'storage/artists/thumbnails/';
const STORAGE_THUMBNAIL_ARTISTS = 'storage/app/public/artists/thumbnails/';
}
\ No newline at end of file
<?php
namespace App\Models;
use App\Helpers\Constants;
use Illuminate\Database\Eloquent\Model;
class Artist extends Model
{
protected $table = Constants::TABLE_ARTISTS;
/**
* Hàm lấy ds bài hát của 1 ca sĩ
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function tracks()
{
return $this->belongsToMany(
'App\Models\Track',
Constants::TABLE_TRACKS,
'artist_id',
'track_id'
);
}
}
<?php
namespace App\Models;
use App\Helpers\Constants;
use Illuminate\Database\Eloquent\Model;
class Track extends Model
{
protected $table = Constants::TABLE_TRACKS;
/**
* Hàm lấy ds nghệ sĩ biểu diễn 1 bài hát
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function artists()
{
return $this->belongsToMany(
'App\Models\Artist',
Constants::TABLE_ARTISTS,
'track_id',
'artist_id'
);
}
}
<?php
namespace App\Models;
use App\Helpers\Constants;
use Illuminate\Database\Eloquent\Model;
class TrackArtist extends Model
{
protected $table = Constants::TABLE_TRACK_ARTIST;
}
<?php
namespace App\Repositories;
use App\Models\Artist;
class ArtistRepository extends BaseRepository
{
public function __construct()
{
}
/**
* Lấy mảng ID do bên nguồn quản lý đã insert trong tracks
* @param string $src
* @return null
*/
public function getArtistSrcIdInserted($src='all')
{
$query = Artist::select(['id', 'source', 'id_zing', 'id_nct', 'id_keeng']);
if ($src != 'all') {
$query->where('source', $src);
switch ($src) {
case 'zing': return $query->pluck('id_zing')->toArray(); break;
case 'nct': return $query->pluck('id_nct')->toArray(); break;
case 'keeng': return $query->pluck('id_keeng')->toArray(); break;
}
return null;
}
return $query->get();
}
public function getArtistThumbnailEmpty()
{
$query = Artist::select(['id', 'thumbnail', 'source', 'id_zing', 'id_nct', 'id_keeng', 'src_thumbnail'])->whereNull('thumbnail');
return $query->get()->toArray();
}
public function getArtistCoverEmpty()
{
$query = Artist::select(['id', 'cover', 'source', 'id_zing', 'id_nct', 'id_keeng', 'src_cover'])->whereNull('cover');
return $query->get()->toArray();
}
}
\ No newline at end of file
<?php
namespace App\Repositories;
class BaseRepository
{
public function __construct()
{
}
}
\ No newline at end of file
<?php
namespace App\Repositories;
use App\Models\Crontjob;
class CrontjobRepository
{
protected $crontjob;
public function __construct(Crontjob $crontjob)
{
$this->crontjob = $crontjob;
}
public function listing()
{
}
public function store($params)
{
$crontjob = new Crontjob();
$crontjob->fill($params);
if ($crontjob->save()) {
return true;
} else {
return false;
}
}
}
\ No newline at end of file
<?php
namespace App\Repositories;
use App\Models\Track;
class TrackRepository extends BaseRepository
{
public function __construct()
{
}
/**
* Lấy mảng ID do bên nguồn quản lý đã insert trong tracks
* @param string $src
* @return null
*/
public function getTrackSrcIdInserted($src='all')
{
$query = Track::select(['id', 'source', 'id_zing', 'id_nct', 'id_keeng']);
if ($src != 'all') {
$query->where('source', $src);
switch ($src) {
case 'zing': return $query->pluck('id_zing')->toArray(); break;
case 'nct': return $query->pluck('id_nct')->toArray(); break;
case 'keeng': return $query->pluck('id_keeng')->toArray(); break;
}
return null;
}
return $query->get();
}
public function getTrackImageEmpty()
{
$query = Track::select(['id', 'image', 'source', 'id_zing', 'id_nct', 'id_keeng', 'thumbnail_medium'])->whereNull('image');
return $query->get()->toArray();
}
}
\ No newline at end of file
<?php
namespace App\Repositories;
use App\User;
class UserRepository extends BaseRepository
{
public function __construct()
{
}
public function getAllUser() {
return User::all();
}
}
\ No newline at end of file
......@@ -20,7 +20,10 @@
],
"psr-4": {
"App\\": "app/"
}
},
"files": [
"app/Helpers/Functions.php"
]
},
"autoload-dev": {
"psr-4": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment