Files
lgp-admin-plus-api/app/Http/Controllers/Api/FactoryInfoController.php
2026-08-20 19:16:49 +08:00

55 lines
1.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Http\Controllers\Api;
use App\BaseApp\BaseController;
use App\Service\business\FactoryInfoService;
use Exception;
use Illuminate\Http\JsonResponse;
/**
* 工厂管理
*/
class FactoryInfoController extends BaseController
{
public function __construct()
{
parent::__construct();
$this->service = FactoryInfoService::getInstance();
$this->insertField = ['name', 'classification'];
$this->updateField = ['id', 'name', 'classification'];
$this->notRequest = ['phone', 'cover', 'address', 'status'];
}
/**
* 启用 / 禁用
* @Method POST
* @throws Exception
*/
public function status(): JsonResponse
{
$this->insertField = ['id', 'status'];
$params = $this->checkRequiredFields(request()->post());
return jok($this->service->status($params['id'], $params['status']), '操作成功');
}
/**
* 导出工厂表(结构化数据,前端 ExcelJS 画 xlsx
* @Method GET
*/
public function export(): JsonResponse
{
return jok($this->service->exportExcel());
}
/**
* 导入工厂表:前端已把 xlsx 拆成 rows
* @Method POST
*/
public function import(): JsonResponse
{
$rows = request()->post('rows', []);
return jok($this->service->importRows(is_array($rows) ? $rows : []), '导入完成');
}
}