25 lines
778 B
PHP
25 lines
778 B
PHP
<?php
|
|
/**
|
|
* 产品参数属性定义接口 GET /api/company/product_attrs.php?industry=汽车制造
|
|
* 返回指定行业的参数属性定义(EAV),供新增产品弹窗动态生成参数输入项
|
|
*/
|
|
require_once __DIR__ . '/../common/db.php';
|
|
require_once __DIR__ . '/../common/response.php';
|
|
require_once __DIR__ . '/../common/auth.php';
|
|
|
|
checkPermission('company');
|
|
|
|
$industry = trim($_REQUEST['industry'] ?? '');
|
|
if ($industry === '') {
|
|
Response::error('参数错误', 400);
|
|
}
|
|
|
|
$pdo = DB::getInstance()->getPdo();
|
|
$attrs = $pdo->prepare(
|
|
"SELECT id, attr_name, attr_type, unit FROM company_products_attr
|
|
WHERE industry = ? AND is_active = 1 ORDER BY sort_order, id"
|
|
);
|
|
$attrs->execute([$industry]);
|
|
|
|
Response::success(['attrs' => $attrs->fetchAll()]);
|