v1.0.12: 企业/人员/媒体去删除入口;企业/人员加产品入口;企业详情去产品品类/关联联系人;编辑企业改Tab卡(工商信息/财务信息/资质认证)
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* 企业产品品类列表接口 GET /api/company/products.php
|
||||
* 入参:company_id(必填)/ page / limit
|
||||
*/
|
||||
require_once __DIR__ . '/../common/db.php';
|
||||
require_once __DIR__ . '/../common/response.php';
|
||||
require_once __DIR__ . '/../common/auth.php';
|
||||
|
||||
checkPermission('company');
|
||||
|
||||
$companyId = (int)($_REQUEST['company_id'] ?? 0);
|
||||
if ($companyId <= 0) {
|
||||
Response::error('参数错误', 400);
|
||||
}
|
||||
|
||||
[$page, $limit] = pageParams(5);
|
||||
|
||||
$pdo = DB::getInstance()->getPdo();
|
||||
|
||||
$chk = $pdo->prepare("SELECT COUNT(*) FROM companies WHERE id = ?");
|
||||
$chk->execute([$companyId]);
|
||||
if ((int)$chk->fetchColumn() === 0) {
|
||||
Response::error('企业不存在');
|
||||
}
|
||||
|
||||
$stmt = $pdo->prepare("SELECT COUNT(*) FROM company_products WHERE company_id = ? AND is_active = 1");
|
||||
$stmt->execute([$companyId]);
|
||||
$total = (int)$stmt->fetchColumn();
|
||||
|
||||
$offset = ($page - 1) * $limit;
|
||||
$stmt = $pdo->prepare(
|
||||
"SELECT id, category_name, category_description, is_core, is_active
|
||||
FROM company_products
|
||||
WHERE company_id = ? AND is_active = 1
|
||||
ORDER BY is_core DESC, id DESC
|
||||
LIMIT $limit OFFSET $offset"
|
||||
);
|
||||
$stmt->execute([$companyId]);
|
||||
|
||||
Response::success(['list' => $stmt->fetchAll(), 'total' => $total, 'page' => $page, 'limit' => $limit]);
|
||||
Reference in New Issue
Block a user