Initial commit
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace app\console\controller;
|
||||
|
||||
use app\console\model\BrandModel;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\console\model\VehicleDataModel;
|
||||
use app\console\service\VehicleDataService;
|
||||
use app\console\validate\VehicleDataValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class HomeController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = VehicleDataValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new VehicleDataService(new VehicleDataModel());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function datas(Request $request): Response
|
||||
{
|
||||
try {
|
||||
|
||||
$vehicleCounts = VehicleDataModel::count('id');
|
||||
$inTransitCounts = VehicleDataModel::where('store_status', 2)->count('id');
|
||||
$inOrderCounts = VehicleDataModel::where('store_status', 3)->count('id');
|
||||
$brandCounts = BrandModel::count('id');
|
||||
|
||||
$data = [
|
||||
'vehicleCounts' => $vehicleCounts,
|
||||
'inTransitCounts' => $inTransitCounts,
|
||||
'inOrderCounts' => $inOrderCounts,
|
||||
'brandCounts' => $brandCounts
|
||||
];
|
||||
return $this->successResponse($data);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user