allocatr/application/services/BaseService.php
2025-04-19 21:40:42 +08:00

115 lines
2.1 KiB
PHP

<?php
namespace app\services;
use app\api\library\ApiException;
use app\common\controller\WorkerApi;
use app\common\Logic\OrderLogic;
use app\common\model\Worker;
use think\Log;
use app\common\model\WorkerVendor;
use app\common\model\OrderDispatch;
use app\common\model\Order;
//{%add use model%}
class BaseService
{
protected function apiError($msg, $code = 0, $data = [])
{
if (!empty($data)) {
array_unshift($data, ['msg' => $msg]);
$log = [
'请求参数' => $_REQUEST,
'结果' => $data,
];
Log::log($log);
}
throw new ApiException($msg, $code);
}
/**
* @return WorkerApi
*/
protected function getWorkerApi()
{
return app(WorkerApi::class);
}
/**
* @return WorkerService
*/
protected function getWorkerService()
{
return app(WorkerService::class);
}
/**
* @return Worker
*/
protected function getWorkerModel()
{
return app(Worker::class, true);
}
/**
* @return WorkerVendorService
*/
protected function getWorkerVendorService()
{
return app(WorkerVendorService::class);
}
/**
* @return WorkerVendor
*/
protected function getWorkerVendorModel()
{
return app(WorkerVendor::class, true);
}
/**
* @return OrderDispatchService
*/
protected function getOrderDispatchService()
{
return app(OrderDispatchService::class);
}
/**
* @return OrderDispatch
*/
protected function getOrderDispatchModel()
{
return app(OrderDispatch::class, true);
}
/**
* @return OrderService
*/
protected function getOrderService()
{
return app(OrderService::class);
}
/**
* @return Order
*/
protected function getOrderModel()
{
return app(Order::class, true);
}
/**
* @return OrderLogic
*/
protected function getOrderLogic()
{
return app(OrderLogic::class);
}
//{%add function code%}
}