Ejemplo n.º 1
0
 /**
  * @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);
 }
Ejemplo n.º 2
0
 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));
 }
Ejemplo n.º 3
0
 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()]);
 }
Ejemplo n.º 4
0
 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;
 }
Ejemplo n.º 5
0
 public function actionStatus($hash)
 {
     $model = Tasks::find()->getByHash($hash);
     $result = 0;
     if ($model) {
         $result = 1;
     }
     $this->stdout((int) $result);
 }
Ejemplo n.º 6
0
 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]);
 }
Ejemplo n.º 7
0
 public function getTaskItem()
 {
     return $this->hasMany(Tasks::className(), ['id' => 'tasks_id'])->via('deployHasTask');
 }
Ejemplo n.º 8
0
 /**
  * @inheritDoc
  */
 public function __construct(array $config = [])
 {
     $this->_model = new Tasks();
     parent::__construct($this->_model->attributes(), $config);
 }
Ejemplo n.º 9
0
 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]];
 }