0806
This commit is contained in:
@@ -32,7 +32,7 @@ $whereSql = implode(' AND ', $where);
|
||||
|
||||
$pdo = DB::getInstance()->getPdo();
|
||||
$stmt = $pdo->prepare(
|
||||
"SELECT sa.id, sa.owner_type, sa.owner_id, sa.platform, sa.account_id, sa.profile_url, sa.remark,
|
||||
"SELECT sa.id, sa.owner_type, sa.owner_id, sa.platform, sa.account_id, sa.profile_url, sa.remark, sa.is_defult,
|
||||
mca.account_level, mca.content_categories, mca.follower_count, mca.avg_read_count,
|
||||
mca.certification_type, sa.created_at,
|
||||
CASE sa.owner_type
|
||||
@@ -52,11 +52,11 @@ header('Content-Type: text/csv; charset=utf-8');
|
||||
header('Content-Disposition: attachment; filename="media_' . date('Ymd_His') . '.csv"');
|
||||
echo "\xEF\xBB\xBF";
|
||||
$out = fopen('php://output', 'w');
|
||||
fputcsv($out, ['ID', '归属类型', '归属ID', '归属名称', '平台', '账号', '主页链接', '备注', '等级', '内容领域', '粉丝数', '平均阅读', '认证类型', '创建时间']);
|
||||
fputcsv($out, ['ID', '归属类型', '归属ID', '归属名称', '平台', '账号', '主页链接', '备注', '是否常用', '等级', '内容领域', '粉丝数', '平均阅读', '认证类型', '创建时间']);
|
||||
foreach ($list as $r) {
|
||||
fputcsv($out, [
|
||||
$r['id'], $r['owner_type'], $r['owner_id'], $r['owner_name'], $r['platform'],
|
||||
$r['account_id'], $r['profile_url'], $r['remark'], $r['account_level'],
|
||||
$r['account_id'], $r['profile_url'], $r['remark'], $r['is_defult'] ? '常用' : '备用', $r['account_level'],
|
||||
$r['content_categories'], $r['follower_count'], $r['avg_read_count'],
|
||||
$r['certification_type'], $r['created_at'],
|
||||
]);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* 媒体数据 CSV 导入接口 POST /api/media/import.php (multipart/form-data, 字段名 file)
|
||||
* CSV 表头:owner_type,owner_id,platform,account_id,profile_url,remark,is_primary,
|
||||
* CSV 表头:owner_type,owner_id,platform,account_id,profile_url,remark,is_primary,is_defult,
|
||||
* account_level,content_categories,follower_count,avg_read_count,certification_type
|
||||
* owner_type 为 person/company 时 owner_id 也可填对应名称(display_name/full_name),自动解析为ID。
|
||||
*/
|
||||
@@ -26,8 +26,8 @@ $header = str_getcsv(trim($first));
|
||||
|
||||
$pdo = DB::getInstance()->getPdo();
|
||||
$insAccount = $pdo->prepare(
|
||||
"INSERT INTO social_accounts (owner_type, owner_id, platform, account_id, profile_url, remark, is_primary, is_active)
|
||||
VALUES (?,?,?,?,?,?,?,1)"
|
||||
"INSERT INTO social_accounts (owner_type, owner_id, platform, account_id, profile_url, remark, is_primary, is_defult, is_active)
|
||||
VALUES (?,?,?,?,?,?,?,?,1)"
|
||||
);
|
||||
$insAttr = $pdo->prepare(
|
||||
"INSERT INTO media_commercial_attributes
|
||||
@@ -75,6 +75,7 @@ while (($row = fgetcsv($handle)) !== false) {
|
||||
$insAccount->execute([
|
||||
$ownerType, $ownerId, $rec['platform'], $rec['account_id'],
|
||||
$rec['profile_url'] ?? null, $rec['remark'] ?? null, !empty($rec['is_primary']) ? 1 : 0,
|
||||
!empty($rec['is_defult']) ? 1 : 0,
|
||||
]);
|
||||
$newId = (int)$pdo->lastInsertId();
|
||||
if (!empty($rec['account_level']) || !empty($rec['certification_type'])) {
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ $total = (int)$stmt->fetchColumn();
|
||||
$offset = ($page - 1) * $limit;
|
||||
$stmt = $pdo->prepare(
|
||||
"SELECT sa.id, sa.owner_type, sa.owner_id, sa.platform, sa.account_id, sa.profile_url,
|
||||
sa.remark, sa.is_primary, sa.is_active, sa.created_at,
|
||||
sa.remark, sa.is_primary, sa.is_defult, sa.is_active, sa.created_at,
|
||||
mca.account_level, mca.content_categories, mca.follower_count, mca.avg_read_count,
|
||||
mca.certification_type, mca.special_requirements, mca.media_remark,
|
||||
CASE sa.owner_type
|
||||
|
||||
Reference in New Issue
Block a user