c86f08c325
Co-Authored-By: Claude Code <noreply@anthropic.com>
43 lines
1.4 KiB
PHP
43 lines
1.4 KiB
PHP
<?php
|
|
/**
|
|
* 需求推送接口(占位) POST /api/need/push.php
|
|
* 入参:id(或 ids 逗号分隔)
|
|
* 说明:当前为占位实现,仅写日志并返回成功;
|
|
* 后续可扩展为调用第三方API推送JSON数据 / 通过SMTP发送邮件。
|
|
*/
|
|
require_once __DIR__ . '/../common/Api.php';
|
|
$pdo = Api::boot(['module' => 'need']);
|
|
|
|
|
|
$id = (int)($_POST['id'] ?? 0);
|
|
$ids = trim($_POST['ids'] ?? '');
|
|
$idList = [];
|
|
if ($id > 0) $idList[] = $id;
|
|
if ($ids !== '') {
|
|
foreach (explode(',', $ids) as $v) {
|
|
$v = (int)trim($v);
|
|
if ($v > 0) $idList[] = $v;
|
|
}
|
|
}
|
|
$idList = array_unique($idList);
|
|
if (!$idList) {
|
|
Response::error('参数错误', 400);
|
|
}
|
|
|
|
$pdo = DB::getInstance()->getPdo();
|
|
$in = implode(',', array_fill(0, count($idList), '?'));
|
|
$stmt = $pdo->prepare("SELECT id, company_id FROM company_needs WHERE id IN ($in) AND is_valid = 1");
|
|
$stmt->execute($idList);
|
|
$needs = $stmt->fetchAll();
|
|
|
|
if (!$needs) {
|
|
Response::error('没有可推送的有效需求');
|
|
}
|
|
|
|
// TODO: 在此接入第三方API推送 / SMTP邮件发送
|
|
// 示例:
|
|
// foreach ($needs as $n) { sendToThirdParty($n); sendEmail($n); }
|
|
|
|
logCurrent('push', 'need', 'company_needs', null, ['ids' => $idList, 'count' => count($needs)]);
|
|
Response::success(['count' => count($needs)], "已推送 " . count($needs) . " 条需求(占位实现,后续接入第三方API/邮件)");
|