Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Письменов Дмитрий Иванович
/
yourroomads
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit f93f2d53
authored
May 11, 2021
by
Vladislav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#19458 Обновление справочника городов.
1 parent
42d0c148
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
95 additions
and
8 deletions
app/Console/Commands/CallCheckDictionariesChange.php → app/Console/Commands/DictionariesLoad.php
app/Console/Kernel.php
app/Models/Dictionary.php
app/Service/Requests/APIRequest.php
app/Service/Requests/Direct/GetDictionaries.php
database/migrations/2021_05_11_094828_create_dictionaries_table.php
app/Console/Commands/
CallCheckDictionariesChange
.php
→
app/Console/Commands/
DictionariesLoad
.php
View file @
f93f2d5
...
...
@@ -2,28 +2,29 @@
namespace
App\Console\Commands
;
use
App\Models\Tokens
;
use
App\Service\API\API
;
use
App\Service\Direct\CheckDictionaries
;
use
App\Service\Direct\GetCampaigns
;
use
App\Service\Requests\Direct\
CheckDictionariesChange
;
use
App\Service\Requests\Direct\
GetDictionaries
;
use
Illuminate\Console\Command
;
use
Illuminate\Support\Facades\Bus
;
class
CallCheckDictionariesChange
extends
Command
class
DictionariesLoad
extends
Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected
$signature
=
'
call-check-dictionaries-change
'
;
protected
$signature
=
'
dictionaries:load
'
;
/**
* The console command description.
*
* @var string
*/
protected
$description
=
'
Запрос остатка балл
ов'
;
protected
$description
=
'
Обновление справочника город
ов'
;
/**
* Create a new command instance.
...
...
@@ -39,9 +40,17 @@ class CallCheckDictionariesChange extends Command
* Execute the console command.
*
* @return void
* @throws \Exception
*/
public
function
handle
()
{
CheckDictionariesChange
::
getInstance
(
API
::
YANDEX
)
->
call
();
$token
=
Tokens
::
where
(
'type'
,
Tokens
::
MAIN
)
->
first
();
if
(
!
$token
){
throw
new
\Exception
(
'Не найден токен блин'
);
}
GetDictionaries
::
getInstance
(
API
::
YANDEX
)
->
setToken
(
$token
)
->
call
();
}
}
app/Console/Kernel.php
View file @
f93f2d5
...
...
@@ -2,7 +2,7 @@
namespace
App\Console
;
use
App\Console\Commands\
CallCheckDictionariesChange
;
use
App\Console\Commands\
DictionariesLoad
;
use
Illuminate\Console\Scheduling\Schedule
;
use
Illuminate\Foundation\Console\Kernel
as
ConsoleKernel
;
...
...
@@ -26,7 +26,7 @@ class Kernel extends ConsoleKernel
protected
function
schedule
(
Schedule
$schedule
)
{
$schedule
->
command
(
'refreshLimits'
)
->
hourly
();
$schedule
->
command
(
CallCheckDictionariesChange
::
class
)
->
saturdays
()
->
at
(
'05:00'
);
$schedule
->
command
(
DictionariesLoad
::
class
)
->
saturdays
()
->
at
(
'05:00'
);
}
/**
...
...
app/Models/Dictionary.php
0 → 100644
View file @
f93f2d5
<?php
namespace
App\Models
;
class
Dictionary
extends
Model
{
}
app/Service/Requests/APIRequest.php
View file @
f93f2d5
...
...
@@ -15,10 +15,12 @@ class APIRequest implements \App\Service\Contract\APIRequest {
$this
->
api
=
$api
;
}
static
function
getInstance
(
$type
){
static
function
getInstance
(
$type
){
switch
(
$type
){
case
API
::
YANDEX
:
return
new
DirectRequest
(
$type
);
default
:
null
;
}
}
...
...
@@ -30,6 +32,7 @@ class APIRequest implements \App\Service\Contract\APIRequest {
function
setService
(
string
$service
)
{
$this
->
service
=
$service
;
return
$this
;
}
function
getService
()
...
...
@@ -40,6 +43,7 @@ class APIRequest implements \App\Service\Contract\APIRequest {
function
setMethod
(
string
$method
)
{
$this
->
method
=
$method
;
return
$this
;
}
function
getMethod
()
...
...
@@ -50,6 +54,7 @@ class APIRequest implements \App\Service\Contract\APIRequest {
function
setParams
(
array
$params
)
{
$this
->
params
=
$params
;
return
$this
;
}
function
getParams
()
...
...
@@ -60,6 +65,7 @@ class APIRequest implements \App\Service\Contract\APIRequest {
function
setToken
(
Tokens
$token
)
{
$this
->
token
=
$token
;
return
$this
;
}
function
getToken
()
:
Tokens
...
...
app/Service/Requests/Direct/GetDictionaries.php
0 → 100644
View file @
f93f2d5
<?php
namespace
App\Service\Requests\Direct
;
use
App\Jobs\ProcessCallLimitedAPI
;
use
App\Service\Requests\DirectRequest
;
class
GetDictionaries
extends
DirectRequest
{
protected
$next
;
function
call
(
$next
=
null
,
$response
=
null
)
{
$this
->
next
=
$next
;
$this
->
requestPrepare
(
$response
);
$process
=
new
ProcessCallLimitedAPI
(
$this
);
dispatch
(
$process
)
->
onQueue
(
'limits'
);
}
function
handle
(
$response
)
{
if
(
$this
->
next
)
{
$this
->
next
->
call
(
null
,
$response
);
}
}
private
function
requestPrepare
(
$response
)
{
$this
->
setService
(
'dictionaries'
);
$this
->
setMethod
(
'get'
);
}
}
database/migrations/2021_05_11_094828_create_dictionaries_table.php
0 → 100644
View file @
f93f2d5
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
CreateCitiesTable
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'dictionaries'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
string
(
'name'
,
255
);
$table
->
timestamps
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'dictionaries'
);
}
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment