no message

This commit is contained in:
hajimi
2026-06-11 12:15:29 +08:00
parent 10ebe39c30
commit 96efa1d905
5859 changed files with 815501 additions and 5 deletions
@@ -0,0 +1,97 @@
<?php
namespace app\adminapi\lists\shortlink;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\lists\ListsSearchInterface;
use app\common\model\ShortLink;
use app\common\model\user\User;
use think\facade\Db;
class ShortLinkLists extends BaseAdminDataLists implements ListsSearchInterface
{
public function setSearch(): array
{
return [
'=' => ['user_id'],
'%like%' => ['code'],
];
}
public function lists(): array
{
$where = $this->searchWhere;
$linkPageType = $this->request->get('link_page_type', '');
if ($linkPageType !== '') {
$where[] = ['page_type', '=', $linkPageType];
}
$lists = ShortLink::where($where)
->order('id', 'desc')
->limit($this->limitOffset, $this->limitLength)
->select()
->toArray();
$userIds = array_unique(array_column($lists, 'user_id'));
$users = User::whereIn('id', $userIds)->column('nickname,avatar', 'id');
// 页面类型字典映射
$pageTypeMap = Db::name('dict_data')
->where('type_value', 'short_link_page_type')
->where('status', 1)
->column('name', 'value');
// 按 page_type 分组收集 page_id,批量查标题
$grouped = [];
foreach ($lists as $item) {
$grouped[$item['page_type']][] = $item['page_id'];
}
$titleMap = [];
foreach ($grouped as $type => $ids) {
$ids = array_unique(array_filter($ids));
if (empty($ids))
continue;
switch ($type) {
case 'news':
$titleMap[$type] = Db::name('article')->whereIn('id', $ids)->column('title', 'id');
break;
case 'match':
$rows = Db::name('match')->whereIn('id', $ids)->column('home_team,away_team', 'id');
$titleMap[$type] = array_map(fn($m) => $m['home_team'] . ' vs ' . $m['away_team'], $rows);
break;
case 'post':
case 'community':
$rows = Db::name('community_post')->whereIn('id', $ids)->column('content', 'id');
$titleMap[$type] = array_map(fn($c) => mb_substr(strip_tags($c), 0, 20), $rows);
break;
}
}
foreach ($lists as &$item) {
$item['nickname'] = $users[$item['user_id']]['nickname'] ?? '游客';
$item['avatar'] = $users[$item['user_id']]['avatar'] ?? '';
$item['short_url'] = request()->domain() . '/s/' . $item['code'];
$item['page_type_name'] = $pageTypeMap[$item['page_type']] ?? $item['page_type'];
$item['page_title'] = $titleMap[$item['page_type']][$item['page_id']] ?? '-';
if (!empty($item['qrcode'])) {
$absPath = public_path() . $item['qrcode'];
$ver = is_file($absPath) ? filemtime($absPath) : time();
$item['qrcode_url'] = \app\common\service\FileService::getFileUrl($item['qrcode']) . '?v=' . $ver;
} else {
$item['qrcode_url'] = '';
}
}
return $lists;
}
public function count(): int
{
$where = $this->searchWhere;
$linkPageType = $this->request->get('link_page_type', '');
if ($linkPageType !== '') {
$where[] = ['page_type', '=', $linkPageType];
}
return ShortLink::where($where)->count();
}
}
@@ -0,0 +1,36 @@
<?php
namespace app\adminapi\lists\shortlink;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\lists\ListsSearchInterface;
use app\common\model\ShortLinkLog;
class ShortLinkLogLists extends BaseAdminDataLists implements ListsSearchInterface
{
public function setSearch(): array
{
return [
'=' => ['short_link_id', 'code', 'platform'],
'%like%' => ['ip'],
];
}
public function lists(): array
{
$lists = ShortLinkLog::where($this->searchWhere)
->order('id', 'desc')
->limit($this->limitOffset, $this->limitLength)
->select()
->toArray();
// create_time 已由 ThinkPHP auto_timestamp + datetime_format 自动格式化
return $lists;
}
public function count(): int
{
return ShortLinkLog::where($this->searchWhere)->count();
}
}