62 lines
1.4 KiB
PHP
62 lines
1.4 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Controllers\Api;
|
||
|
|
|
||
|
|
use App\BaseApp\BaseController;
|
||
|
|
use App\Service\business\ListService;
|
||
|
|
use Illuminate\Http\JsonResponse;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 清单管理
|
||
|
|
*/
|
||
|
|
class ListController extends BaseController
|
||
|
|
{
|
||
|
|
public function __construct()
|
||
|
|
{
|
||
|
|
parent::__construct();
|
||
|
|
$this->service = ListService::getInstance();
|
||
|
|
$this->insertField = ['name', 'user_id'];
|
||
|
|
$this->updateField = ['id', 'name'];
|
||
|
|
$this->notRequest = ['remark', 'enterprise_id'];
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 某用户的清单
|
||
|
|
* @Method GET
|
||
|
|
*/
|
||
|
|
public function byUser(): JsonResponse
|
||
|
|
{
|
||
|
|
return jok($this->service->byUser((int) request()->get('user_id', 0)));
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 清单生成订单
|
||
|
|
* @Method POST
|
||
|
|
*/
|
||
|
|
public function toOrder(): JsonResponse
|
||
|
|
{
|
||
|
|
return jok(
|
||
|
|
$this->service->toOrder((int) request()->post('id', 0), request()->post()),
|
||
|
|
'订单已生成'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 保存清单明细
|
||
|
|
* @Method POST
|
||
|
|
*/
|
||
|
|
public function saveItem(): JsonResponse
|
||
|
|
{
|
||
|
|
return jok($this->service->saveItem(request()->post()), '保存成功');
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 删除清单明细
|
||
|
|
* @Method POST
|
||
|
|
*/
|
||
|
|
public function deleteItem(): JsonResponse
|
||
|
|
{
|
||
|
|
return jok($this->service->deleteItem(request()->post('ids', [])), '删除成功');
|
||
|
|
}
|
||
|
|
}
|