init
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Controllers\AdvertisementManager\Automation\AutomationController;
|
||||
use App\Services\LoggerService;
|
||||
use CodeIgniter\CLI\BaseCommand;
|
||||
use CodeIgniter\CLI\CLI;
|
||||
use DateTime;
|
||||
|
||||
class Automation extends BaseCommand
|
||||
{
|
||||
/**
|
||||
* The Command's Group
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $group = 'CodeIgniter';
|
||||
|
||||
/**
|
||||
* The Command's Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'Automation';
|
||||
|
||||
/**
|
||||
* The Command's Description
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '';
|
||||
|
||||
/**
|
||||
* The Command's Usage
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $usage = 'command:Automation [arguments] [options]';
|
||||
|
||||
/**
|
||||
* The Command's Arguments
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $arguments = [];
|
||||
|
||||
/**
|
||||
* The Command's Options
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $options = [];
|
||||
|
||||
/**
|
||||
* Actually execute a command.
|
||||
*
|
||||
* @param array $params
|
||||
*/
|
||||
public function run(array $params)
|
||||
{
|
||||
$automation = new AutomationController;
|
||||
$automation->automation();
|
||||
|
||||
//로그 기록
|
||||
$data = [
|
||||
'type' => 'tasks',
|
||||
'command' => $this->name
|
||||
];
|
||||
|
||||
$logger = new LoggerService();
|
||||
$logger->insertLog($data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use CodeIgniter\CLI\BaseCommand;
|
||||
use CodeIgniter\CLI\CLI;
|
||||
use App\Controllers\HumanResource\HumanResourceController;
|
||||
use App\Libraries\slack_api\SlackChat;
|
||||
use App\Services\LoggerService;
|
||||
use App\ThirdParty\googleclient\GoogleCalendar; // GoogleCalendar 클래스 추가
|
||||
|
||||
|
||||
class CheckDayOff extends BaseCommand
|
||||
{
|
||||
/**
|
||||
* The Command's Group
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $group = 'Slack';
|
||||
|
||||
/**
|
||||
* The Command's Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'todayDayOff';
|
||||
|
||||
/**
|
||||
* The Command's Description
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '당일 연차/시차 슬랙 전송';
|
||||
|
||||
/**
|
||||
* The Command's Usage
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $usage = 'command:dayoff [arguments] [options]';
|
||||
|
||||
/**
|
||||
* The Command's Arguments
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $arguments = [];
|
||||
|
||||
/**
|
||||
* The Command's Options
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $options = [];
|
||||
|
||||
private $sendList = ['개발팀', '디자인실', '운영실'];
|
||||
|
||||
/**
|
||||
* Actually execute a command.
|
||||
*
|
||||
* @param array $params
|
||||
*/
|
||||
public function run(array $params)
|
||||
{
|
||||
$sendType = "";
|
||||
if(isset($params[0]))
|
||||
$sendType = $params[0];
|
||||
$Tdate = date('Ymd'); //기본값은 오늘
|
||||
if(isset($params[1]) && preg_match('/^\d{8}$/', $params[1])) $Tdate = $params[1];
|
||||
$dayOff = new HumanResourceController();
|
||||
$lists = $dayOff->getTodayDayOff($Tdate);
|
||||
$slack = new SlackChat();
|
||||
$googleCalendar = new GoogleCalendar(); // GoogleCalendar 인스턴스 생성
|
||||
$msg = [];
|
||||
$now = date('H');
|
||||
foreach($lists as $row) {
|
||||
if($now == "10" || $sendType == 'today') { //업무시작시간에 당일 연/시차 전체 전송
|
||||
if(date('Ymd', strtotime($row['start'])) != $Tdate) continue;
|
||||
} else { //그 외 매시간 새로 등록된 당일 연/시차 전송
|
||||
if(date('Ymd', strtotime($row['start'])) != $Tdate || strtotime($row['datetime']) <= strtotime('-1 hour')) continue;
|
||||
}
|
||||
if($row['type'] == '시차') {
|
||||
$start = date('Y년m월d일 H시부터', strtotime($row['start']));
|
||||
$end = date('H시까지', strtotime($row['end']));
|
||||
$term = "{$start} {$end}({$row['term']}시간)";
|
||||
$remain = "잔여:{$row['total_remain']}시간";
|
||||
if(date('H', strtotime($row['start'])) == 10)
|
||||
$term = date('Y년m월d일 H시', strtotime($row['end']))." 출근({$row['term']}시간 사용)";
|
||||
if(date('H', strtotime($row['end'])) == 19)
|
||||
$term = date('Y년m월d일 H시', strtotime($row['start']))." 퇴근({$row['term']}시간 사용)";
|
||||
if($row['total_remain'] <= 0) {
|
||||
$data = [
|
||||
'channel' => $row['name'],
|
||||
'text' => "{$row['name']}님, 시차 잔여량이 부족합니다. [{$remain}]",
|
||||
];
|
||||
$slack->sendMessage($data);
|
||||
}
|
||||
} else {
|
||||
$start = date('Y년m월d일부터', strtotime($row['start']));
|
||||
$end = date('Y년m월d일까지', strtotime($row['end']));
|
||||
$remain = "사용:{$row['total_used']}일/잔여:{$row['total_remain']}일";
|
||||
$term = "{$start} {$end}({$row['term']}일)";
|
||||
if($row['start'] == $row['end'])
|
||||
$term = date('Y년m월d일', strtotime($row['start']));
|
||||
}
|
||||
// Google Calendar 이벤트 생성
|
||||
$eventData = [
|
||||
'summary' => "[{$row['type']}]{$row['name']}({$row['team']})",
|
||||
'description' => "{$term}",
|
||||
];
|
||||
if ($row['type'] == '연차' || $row['type'] == '출산휴가' || $row['type'] == '예비군훈련') {
|
||||
$eventData['start'] = [
|
||||
'date' => date('Y-m-d', strtotime($row['start'])),
|
||||
];
|
||||
$eventData['end'] = [
|
||||
'date' => date('Y-m-d', strtotime($row['end'] . ' +1 day')),
|
||||
];
|
||||
$eventData['colorId'] = '11';
|
||||
} else {
|
||||
$eventData['start'] = [
|
||||
'dateTime' => date('Y-m-d\TH:00:00P', strtotime($row['start'])),
|
||||
];
|
||||
$eventData['end'] = [
|
||||
'dateTime' => date('Y-m-d\TH:00:00P', strtotime($row['end'])),
|
||||
];
|
||||
//type에 생일휴가 또는 오후가 포함되어 있을 경우 start, end를 각각 당일 15시, 19시로 강제로 조정
|
||||
if(strpos($row['type'], '생일휴가') !== false || strpos($row['type'], '오후') !== false) {
|
||||
$eventData['start']['dateTime'] = date('Y-m-d\T15:00:00P', strtotime($row['start']));
|
||||
$eventData['end']['dateTime'] = date('Y-m-d\T19:00:00P', strtotime($row['end']));
|
||||
}
|
||||
//type에 오전 포함되어 있을 경우 start, end를 각각 당일 10시, 15시로 강제로 조정
|
||||
if(strpos($row['type'], '오전') !== false) {
|
||||
$eventData['start']['dateTime'] = date('Y-m-d\T10:00:00P', strtotime($row['start']));
|
||||
$eventData['end']['dateTime'] = date('Y-m-d\T15:00:00P', strtotime($row['end']));
|
||||
}
|
||||
$eventData['colorId'] = '5';
|
||||
}
|
||||
$googleCalendar->createEvent($eventData); // 이벤트 생성 메서드 호출
|
||||
$slackMsg = [
|
||||
"type" => "section",
|
||||
"text" => [
|
||||
"type" => "mrkdwn",
|
||||
"text" => "*{$row['name']}* _({$row['team']})_ [{$remain}]\n`[{$row['type']}]` {$term}"
|
||||
]
|
||||
];
|
||||
$msg['연차공유'][] = ["type"=>"divider"];
|
||||
$msg['연차공유'][] = $slackMsg;
|
||||
$msg['연차알림'][] = ["type"=>"divider"];
|
||||
$msg['연차알림'][] = $slackMsg;
|
||||
foreach($this->sendList as $list) {
|
||||
if($list != $row['team'] && $list != $row['division']) continue;
|
||||
$msg[$list][] = ["type"=>"divider"];
|
||||
$msg[$list][] = $slackMsg;
|
||||
}
|
||||
}
|
||||
if(!count($msg)) return;
|
||||
if($sendType == 'debug') dd($msg);
|
||||
foreach($msg as $channel => $row) {
|
||||
if(preg_match('/.+(팀|실)/', $channel))
|
||||
$channel = $channel."_연차공유";
|
||||
$data = [
|
||||
'channel' => $channel,
|
||||
'text' => '',
|
||||
'blocks' => json_encode($row,JSON_UNESCAPED_UNICODE)
|
||||
];
|
||||
// d($data);
|
||||
$response = $slack->sendMessage($data);
|
||||
}
|
||||
|
||||
//로그 기록
|
||||
$data = [
|
||||
'type' => 'tasks',
|
||||
'command' => $this->name
|
||||
];
|
||||
|
||||
$logger = new LoggerService();
|
||||
$logger->insertLog($data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use CodeIgniter\CLI\BaseCommand;
|
||||
use CodeIgniter\CLI\CLI;
|
||||
|
||||
class Encryption extends BaseCommand
|
||||
{
|
||||
/**
|
||||
* The Command's Group
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $group = 'Encryption';
|
||||
|
||||
/**
|
||||
* The Command's Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'encryption';
|
||||
|
||||
/**
|
||||
* The Command's Description
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '데이터 암호화/복호화';
|
||||
|
||||
/**
|
||||
* The Command's Usage
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $usage = 'command:name [arguments] [options]';
|
||||
|
||||
/**
|
||||
* The Command's Arguments
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $arguments = [
|
||||
'type' => 'Set encrypt/decrypt',
|
||||
'text' => 'Encrypt(Decrypt) for Text',
|
||||
'key' => 'Encrypt(Decrypt) for Key'
|
||||
];
|
||||
|
||||
/**
|
||||
* The Command's Options
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $options = [];
|
||||
|
||||
protected $encrypter;
|
||||
protected $key = 'f907464a49e95e8d778cf87374cc59ccd7669f5924e25776320ec69479206a22';
|
||||
|
||||
/**
|
||||
* Actually execute a command.
|
||||
*
|
||||
* @param array $params
|
||||
*/
|
||||
public function run(array $params)
|
||||
{
|
||||
if(!isset($params[0]))
|
||||
throw new \Exception('"encrypt"또는"decrypt"를 지정해주세요.');
|
||||
if(!isset($params[1]))
|
||||
throw new \Exception('암호화(복호화) 할 문자를 입력해주세요.');
|
||||
|
||||
$type = $params[0];
|
||||
$this->encrypter = \Config\Services::encrypter();
|
||||
switch($type) {
|
||||
case 'encrypt' :
|
||||
$result = $this->encrypt($params[1]);
|
||||
break;
|
||||
case 'decrypt' :
|
||||
$result = $this->decrypt($params[1]);
|
||||
break;
|
||||
case 'sodium_encrypt' :
|
||||
$result = $this->sodium_encrypt($params[1]);
|
||||
break;
|
||||
case 'sodium_decrypt' :
|
||||
$result = $this->sodium_decrypt($params[1]);
|
||||
break;
|
||||
default :
|
||||
throw new \RuntimeException('"encrypt"또는"decrypt"를 지정해주세요.');
|
||||
break;
|
||||
}
|
||||
var_dump($result);
|
||||
}
|
||||
|
||||
private function encrypt($text) {
|
||||
$result = $this->encrypter->encrypt($text);
|
||||
return sodium_bin2hex($result);
|
||||
}
|
||||
|
||||
private function decrypt($text) {
|
||||
$text = sodium_hex2bin($text);
|
||||
return $this->encrypter->decrypt($text);
|
||||
}
|
||||
|
||||
private function sodium_encrypt($text) {
|
||||
// create a nonce for this operation
|
||||
$nonce = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES); // 24 bytes
|
||||
|
||||
$data = sodium_pad($text, 16);
|
||||
|
||||
// encrypt message and combine with nonce
|
||||
$ciphertext = $nonce . sodium_crypto_secretbox($data, $nonce, sodium_hex2bin($this->key));
|
||||
|
||||
// cleanup buffers
|
||||
sodium_memzero($data);
|
||||
sodium_memzero($this->key);
|
||||
|
||||
return sodium_bin2hex($ciphertext);
|
||||
}
|
||||
|
||||
private function sodium_decrypt($text) {
|
||||
$text = sodium_hex2bin($text);
|
||||
// Extract info from encrypted data
|
||||
$nonce = mb_substr($text, 0, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, '8bit');
|
||||
$ciphertext = mb_substr($text, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, null, '8bit');
|
||||
|
||||
// decrypt data
|
||||
$data = sodium_crypto_secretbox_open($ciphertext, $nonce, sodium_hex2bin($this->key));
|
||||
$data = sodium_unpad($data,16);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Services\LoggerService;
|
||||
use CodeIgniter\CLI\BaseCommand;
|
||||
use CodeIgniter\CLI\CLI;
|
||||
|
||||
class EventCron extends BaseCommand
|
||||
{
|
||||
/**
|
||||
* The Command's Group
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $group = 'cron';
|
||||
|
||||
/**
|
||||
* The Command's Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'EventCron';
|
||||
|
||||
/**
|
||||
* The Command's Description
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '';
|
||||
|
||||
/**
|
||||
* Actually execute a command.
|
||||
*
|
||||
* @param array $params
|
||||
*/
|
||||
public function run(array $params)
|
||||
{
|
||||
CLI::write('DB수 업데이트 작업을 시작합니다.', 'green');
|
||||
try {
|
||||
$zenith = \Config\Database::connect();
|
||||
$sql = "SELECT event_seq, site, count(*) AS db_count, DATE(reg_date) AS date FROM event_leads WHERE status = 1 GROUP BY event_seq, site, DATE(reg_date)";
|
||||
$result = $zenith->query($sql)->getResultArray();
|
||||
$data = [];
|
||||
|
||||
foreach($result as $row) {
|
||||
$data[] = "('{$row['event_seq']}', '{$row['site']}', '{$row['date']}', '{$row['db_count']}', NOW())";
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO event_leads_count(seq, site, date, db_count, update_time) VALUES ".implode(',', $data)." ON DUPLICATE KEY
|
||||
UPDATE db_count = VALUES(db_count), update_time = VALUES(update_time)";
|
||||
$result = $zenith->query($sql);
|
||||
CLI::write('DB수 업데이트 작업 완료', 'green');
|
||||
} catch (\Exception $e) {
|
||||
$this->showError($e);
|
||||
}
|
||||
|
||||
//로그 기록
|
||||
$data = [
|
||||
'type' => 'tasks',
|
||||
'command' => $this->name
|
||||
];
|
||||
|
||||
$logger = new LoggerService();
|
||||
$logger->insertLog($data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Controllers\Api\JiraController;
|
||||
use App\Services\LoggerService;
|
||||
use CodeIgniter\CLI\BaseCommand;
|
||||
use CodeIgniter\CLI\CLI;
|
||||
|
||||
class EventDataUpdateCron extends BaseCommand
|
||||
{
|
||||
/**
|
||||
* The Command's Group
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $group = 'CodeIgniter';
|
||||
|
||||
/**
|
||||
* The Command's Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'EventDataUpdateCron';
|
||||
|
||||
/**
|
||||
* The Command's Description
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '';
|
||||
|
||||
/**
|
||||
* The Command's Usage
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $usage = 'command:EventDataUpdateCron [arguments] [options]';
|
||||
|
||||
/**
|
||||
* The Command's Arguments
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $arguments = [];
|
||||
|
||||
/**
|
||||
* The Command's Options
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $options = [];
|
||||
|
||||
/**
|
||||
* Actually execute a command.
|
||||
*
|
||||
* @param array $params
|
||||
*/
|
||||
public function run(array $params)
|
||||
{
|
||||
$jira = new JiraController;
|
||||
$jira->getIssueEventData();
|
||||
|
||||
//로그 기록
|
||||
$data = [
|
||||
'type' => 'tasks',
|
||||
'command' => $this->name
|
||||
];
|
||||
|
||||
$logger = new LoggerService();
|
||||
$logger->insertLog($data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use CodeIgniter\CLI\BaseCommand;
|
||||
use CodeIgniter\CLI\CLI;
|
||||
use App\Controllers\EventManage\AdvertiserController;
|
||||
use App\Services\LoggerService;
|
||||
|
||||
class EvtOverwatch extends BaseCommand
|
||||
{
|
||||
/**
|
||||
* The Command's Group
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $group = 'cron';
|
||||
|
||||
/**
|
||||
* The Command's Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'EvtOverwatch';
|
||||
|
||||
/**
|
||||
* The Command's Description
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '';
|
||||
|
||||
/**
|
||||
* Actually execute a command.
|
||||
*
|
||||
* @param array $params
|
||||
*/
|
||||
public function run(array $params)
|
||||
{
|
||||
CLI::write('그룹웨어 데이터 연동 작업을 시작합니다.', 'green');
|
||||
try{
|
||||
$advertiser = new AdvertiserController();
|
||||
$advertiser->evtOverwatch();
|
||||
CLI::write('오버워치 실행 완료', 'green');
|
||||
} catch (\Exception $e) {
|
||||
$this->showError($e);
|
||||
}
|
||||
|
||||
//로그 기록
|
||||
$data = [
|
||||
'type' => 'tasks',
|
||||
'command' => $this->name
|
||||
];
|
||||
|
||||
$logger = new LoggerService();
|
||||
$logger->insertLog($data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use CodeIgniter\CLI\BaseCommand;
|
||||
use CodeIgniter\CLI\CLI;
|
||||
use App\Controllers\HumanResource\HumanResourceController;
|
||||
use App\Services\LoggerService;
|
||||
|
||||
class GwCron extends BaseCommand
|
||||
{
|
||||
/**
|
||||
* The Command's Group
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $group = 'cron';
|
||||
|
||||
/**
|
||||
* The Command's Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'GwCron';
|
||||
|
||||
/**
|
||||
* The Command's Description
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '';
|
||||
|
||||
/**
|
||||
* Actually execute a command.
|
||||
*
|
||||
* @param array $params
|
||||
*/
|
||||
public function run(array $params)
|
||||
{
|
||||
CLI::write('그룹웨어 데이터 연동 작업을 시작합니다.', 'green');
|
||||
try{
|
||||
$hr = new HumanResourceController();
|
||||
$hr->updateUsersByDouzone();
|
||||
CLI::write('그룹웨어 데이터 연동 작업 완료', 'green');
|
||||
} catch (\Exception $e) {
|
||||
$this->showError($e);
|
||||
}
|
||||
|
||||
//로그 기록
|
||||
$data = [
|
||||
'type' => 'tasks',
|
||||
'command' => $this->name
|
||||
];
|
||||
|
||||
$logger = new LoggerService();
|
||||
$logger->insertLog($data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use CodeIgniter\CLI\BaseCommand;
|
||||
use CodeIgniter\CLI\CLI;
|
||||
use App\Controllers\HumanResource\HumanResourceController;
|
||||
use App\Services\LoggerService;
|
||||
|
||||
class HumanResource extends BaseCommand
|
||||
{
|
||||
/**
|
||||
* The Command's Group
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $group = 'cron';
|
||||
|
||||
/**
|
||||
* The Command's Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'HumanResource';
|
||||
|
||||
/**
|
||||
* The Command's Description
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '';
|
||||
|
||||
/**
|
||||
* Actually execute a command.
|
||||
*
|
||||
* @param array $params
|
||||
*/
|
||||
public function run(array $params)
|
||||
{
|
||||
CLI::write('그룹웨어 데이터 연동 작업을 시작합니다.', 'green');
|
||||
try{
|
||||
$hr = new HumanResourceController();
|
||||
$hr->gwData();
|
||||
CLI::write('그룹웨어 데이터 연동 작업 완료', 'green');
|
||||
} catch (\Exception $e) {
|
||||
$this->showError($e);
|
||||
}
|
||||
|
||||
//로그 기록
|
||||
$data = [
|
||||
'type' => 'tasks',
|
||||
'command' => $this->name
|
||||
];
|
||||
|
||||
$logger = new LoggerService();
|
||||
$logger->insertLog($data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Controllers\Api\JiraController;
|
||||
use App\Services\LoggerService;
|
||||
use CodeIgniter\CLI\BaseCommand;
|
||||
use CodeIgniter\CLI\CLI;
|
||||
|
||||
class PreparingIssueMessageCron extends BaseCommand
|
||||
{
|
||||
/**
|
||||
* The Command's Group
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $group = 'CodeIgniter';
|
||||
|
||||
/**
|
||||
* The Command's Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'PreparingIssueMessage';
|
||||
|
||||
/**
|
||||
* The Command's Description
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '';
|
||||
|
||||
/**
|
||||
* The Command's Usage
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $usage = 'command:PreparingIssueMessage [arguments] [options]';
|
||||
|
||||
/**
|
||||
* The Command's Arguments
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $arguments = [];
|
||||
|
||||
/**
|
||||
* The Command's Options
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $options = [];
|
||||
|
||||
/**
|
||||
* Actually execute a command.
|
||||
*
|
||||
* @param array $params
|
||||
*/
|
||||
public function run(array $params)
|
||||
{
|
||||
$hour = date('G');
|
||||
$week = date('w');
|
||||
if($hour < "10" || $hour >= "19" || $week == "0" || $week == "6") return;
|
||||
$jira = new JiraController;
|
||||
$jira->getIssuePreparing();
|
||||
|
||||
//로그 기록
|
||||
$data = [
|
||||
'type' => 'tasks',
|
||||
'command' => $this->name
|
||||
];
|
||||
|
||||
$logger = new LoggerService();
|
||||
$logger->insertLog($data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use CodeIgniter\CLI\BaseCommand;
|
||||
use CodeIgniter\CLI\CLI;
|
||||
use DateTime;
|
||||
|
||||
class ZenithLogTable extends BaseCommand
|
||||
{
|
||||
/**
|
||||
* The Command's Group
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $group = 'CodeIgniter';
|
||||
|
||||
/**
|
||||
* The Command's Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'ZenithLogTable';
|
||||
|
||||
/**
|
||||
* The Command's Description
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '';
|
||||
|
||||
/**
|
||||
* The Command's Usage
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $usage = 'command:name [arguments] [options]';
|
||||
|
||||
/**
|
||||
* The Command's Arguments
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $arguments = [];
|
||||
|
||||
/**
|
||||
* The Command's Options
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $options = [];
|
||||
|
||||
/**
|
||||
* Actually execute a command.
|
||||
*
|
||||
* @param array $params
|
||||
*/
|
||||
public function run(array $params)
|
||||
{
|
||||
$db = \Config\Database::connect();
|
||||
$nextMonth = date('Ym', strtotime('+1 month'));
|
||||
$tableName = 'zenith_logs_'.$nextMonth;
|
||||
$sql = "CREATE TABLE `$tableName` (
|
||||
`seq` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`type` VARCHAR(100),
|
||||
`scheme` VARCHAR(100),
|
||||
`host` VARCHAR(255),
|
||||
`path` VARCHAR(255),
|
||||
`method` VARCHAR(100),
|
||||
`command` VARCHAR(255),
|
||||
`query_string` TEXT,
|
||||
`data` TEXT,
|
||||
`content_type` VARCHAR(100),
|
||||
`remote_addr` VARCHAR(100),
|
||||
`server_addr` VARCHAR(100),
|
||||
`nickname` VARCHAR(100),
|
||||
`datetime` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`seq`),
|
||||
KEY `zenith_logs_type_IDX` (`type`) USING BTREE,
|
||||
KEY `zenith_logs_path_IDX` (`path`) USING BTREE,
|
||||
KEY `zenith_logs_method_IDX` (`method`) USING BTREE,
|
||||
KEY `zenith_logs_nickname_IDX` (`nickname`) USING BTREE,
|
||||
KEY `zenith_logs_datetime_IDX` (`datetime`) USING BTREE
|
||||
)";
|
||||
$db->query($sql);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user