/** * @param Tasks $model * * @since 1.0 * @author Choate <*****@*****.**> * @return bool|int * @throws \Exception */ public function audit(Tasks $model) { if (!$model->getIsApply()) { $model->addError('status', '该任务已经审核'); return false; } $model->status = Tasks::STATUS_PASS; $model->auditor = (int) \Yii::$app->user->id; $model->audit_time = time(); return $model->update(false); }
private function execDeploy($form, $model) { $models = Tasks::find()->byId($form->tasks_id)->all(); $hashItem = ArrayHelper::getColumn($models, 'hash'); $messageItem = ArrayHelper::getColumn($models, 'title'); $website = $model->website; DepControl::run(['deployScript' => $website->deploy_script, 'deployProject' => $website->deploy_project])->deploy(implode(';', $hashItem), implode(';', $messageItem)); }
public function actionPass($id) { /* @var Tasks $model */ $model = Tasks::find()->getById($id); WebsiteService::checkAccess($model->websites_id); $this->_tasksService->audit($model); return Json::encode(['status' => !$model->hasErrors()]); }
public function safeDown() { $this->dropTable('IF EXISTS ' . Websites::tableName()); $this->dropTable('IF EXISTS ' . Tasks::tableName()); $this->dropTable('IF EXISTS ' . Deploy::tableName()); $this->dropTable('IF EXISTS ' . DeployHasTasks::tableName()); $this->dropTable('IF EXISTS ' . WebsiteHasUser::tableName()); return true; }
public function actionStatus($hash) { $model = Tasks::find()->getByHash($hash); $result = 0; if ($model) { $result = 1; } $this->stdout((int) $result); }
public function actionRedeploy($id) { $model = Deploy::find()->getById($id); WebsiteService::checkAccess($model->websites_id); $tasks = Tasks::find()->byWebsite($model->websites_id)->isPass()->all(); $service = new DeployService(); $form = $service->redeploy($model, \Yii::$app->request->post('DeployForm')); return $this->render('deploy', ['model' => $form, 'tasks' => $tasks]); }
public function getTaskItem() { return $this->hasMany(Tasks::className(), ['id' => 'tasks_id'])->via('deployHasTask'); }
/** * @inheritDoc */ public function __construct(array $config = []) { $this->_model = new Tasks(); parent::__construct($this->_model->attributes(), $config); }
public function rules() { return [[['websites_id', 'tasks_id'], 'required'], ['websites_id', 'exist', 'targetClass' => Websites::className(), 'targetAttribute' => 'id'], ['tasks_id', 'exist', 'targetClass' => Tasks::className(), 'targetAttribute' => 'id', 'allowArray' => true, 'filter' => function ($query) { return $query->isPass(); }], ['deployer', 'default', 'value' => (int) \Yii::$app->user->id], ['deploy_time', 'default', 'value' => time()], ['status', 'default', 'value' => Deploy::DEPLOY_SUCCESS]]; }