Blame view

稻城亚丁小程序/backend/app/controller/api/DownloadAsset.php 1.04 KB
bc518174   王天杨   提交两个项目文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  <?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',
              ],
          ]);
      }
  }