v1.0.19: 修复人员编辑入口缺失(person.js addPerson/editPerson) + 渠道明细数量字段名(analysis.php cnt) + CDP全量验证43项PASS
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* 企业官媒新增接口 POST /api/company/official_media_add.php
|
||||
* 为指定公司快速新增一条官媒记录(social_accounts owner_type=company)
|
||||
* 入参:company_id(必填)/ platform(平台)/ account_id(账号名称)/ profile_url(主页链接)/
|
||||
* remark / is_active(1启用 0停用)/ is_defult(1常用)
|
||||
*/
|
||||
require_once __DIR__ . '/../common/db.php';
|
||||
require_once __DIR__ . '/../common/response.php';
|
||||
require_once __DIR__ . '/../common/auth.php';
|
||||
require_once __DIR__ . '/../common/helpers.php';
|
||||
require_once __DIR__ . '/../common/logger.php';
|
||||
|
||||
checkAjax();
|
||||
checkPermission('company');
|
||||
|
||||
$companyId = (int)($_POST['company_id'] ?? 0);
|
||||
$platform = trim($_POST['platform'] ?? '');
|
||||
$accountId = trim($_POST['account_id'] ?? '');
|
||||
if ($companyId <= 0 || $platform === '' || $accountId === '') {
|
||||
Response::error('平台与账号名称为必填项', 400);
|
||||
}
|
||||
|
||||
$pdo = DB::getInstance()->getPdo();
|
||||
|
||||
$chk = $pdo->prepare("SELECT COUNT(*) FROM companies WHERE id = ?");
|
||||
$chk->execute([$companyId]);
|
||||
if ((int)$chk->fetchColumn() === 0) {
|
||||
Response::error('企业不存在');
|
||||
}
|
||||
|
||||
$ins = $pdo->prepare(
|
||||
"INSERT INTO social_accounts (owner_type, owner_id, platform, account_id, profile_url, remark, is_primary, is_defult, is_active)
|
||||
VALUES ('company', ?, ?, ?, ?, ?, 0, ?, ?)"
|
||||
);
|
||||
$ins->execute([
|
||||
$companyId,
|
||||
$platform,
|
||||
$accountId,
|
||||
strOrNull($_POST['profile_url'] ?? null),
|
||||
strOrNull($_POST['remark'] ?? null),
|
||||
!empty($_POST['is_defult']) ? 1 : 0,
|
||||
isset($_POST['is_active']) && (int)$_POST['is_active'] === 0 ? 0 : 1,
|
||||
]);
|
||||
$newId = (int)$pdo->lastInsertId();
|
||||
|
||||
logCurrent('add', 'official_media', 'social_accounts', $newId, ['company_id' => $companyId, 'platform' => $platform, 'account_id' => $accountId]);
|
||||
Response::success(['id' => $newId], '新增成功');
|
||||
Reference in New Issue
Block a user