DownloadAsset.php 1.04 KB
<?php
declare(strict_types=1);

namespace app\controller\api;

use app\BaseController;
use think\facade\Db;
use Throwable;

class DownloadAsset extends BaseController
{
    public function get()
    {
        $map = [];
        try {
            $rows = Db::name('download_asset')->select()->toArray();
            foreach ($rows as $r) {
                $type = strtolower(trim((string) ($r['type'] ?? '')));
                if ($type !== 'certificate' && $type !== 'guide') {
                    continue;
                }
                $map[$type] = trim((string) ($r['image_url'] ?? ''));
            }
        } catch (Throwable) {
            // 若未执行补丁 SQL,回退到内置静态图,避免影响用户下载流程。
        }

        return json([
            'code' => 0,
            'msg'  => 'ok',
            'data' => [
                'certificate' => $map['certificate'] ?? '/static/certificate-dialog-bg.png',
                'guide'       => $map['guide'] ?? '/static/daocheng-yading-map.png',
            ],
        ]);
    }
}