1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-28 05:11:39 +08:00
course-tencent-cloud/db/migrations/20230611193031.php
xiaochong0302 a72f44225f 1.优化课程章节权限
2.优化钉钉机器人
2023-06-15 18:05:27 +08:00

52 lines
1.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* @copyright Copyright (c) 2023 深圳市酷瓜软件有限公司
* @license https://opensource.org/licenses/GPL-2.0
* @link https://www.koogua.com
*/
require_once 'SettingTrait.php';
use Phinx\Migration\AbstractMigration;
final class V20230611193031 extends AbstractMigration
{
use SettingTrait;
public function up()
{
$this->handleDingTalkRobotSettings();
}
protected function handleDingTalkRobotSettings()
{
$row = $this->getQueryBuilder()
->select('*')
->from('kg_setting')
->where(['section' => 'dingtalk.robot'])
->andWhere(['item_key' => 'app_token'])
->execute()->fetch(PDO::FETCH_ASSOC);
$webhookUrl = '';
/**
* 直接使用webhook地址不用单独分离出access_token简化用户操作
*/
if (!empty($row['item_value'])) {
$webhookUrl = "https://oapi.dingtalk.com/robot/send?access_token={$row['item_value']}";
}
$rows = [
[
'section' => 'dingtalk.robot',
'item_key' => 'webhook_url',
'item_value' => $webhookUrl,
],
];
$this->insertSettings($rows);
}
}