allocatr/application/services/BaseService.php
2025-07-03 15:01:00 +08:00

166 lines
3.0 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;
use app\common\model\Abnormal;
use app\common\model\OrderAbnormal;
use app\common\model\DebugLog;
//{%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);
}
/**
* @return AbnormalService
*/
protected function getAbnormalService()
{
return app(AbnormalService::class);
}
/**
* @return Abnormal
*/
protected function getAbnormalModel()
{
return app(Abnormal::class, true);
}
/**
* @return OrderAbnormalService
*/
protected function getOrderAbnormalService()
{
return app(OrderAbnormalService::class);
}
/**
* @return OrderAbnormal
*/
protected function getOrderAbnormalModel()
{
return app(OrderAbnormal::class, true);
}
/**
* @return DebugLogService
*/
protected function getDebugLogService()
{
return app(DebugLogService::class);
}
/**
* @return DebugLog
*/
protected function getDebugLogModel()
{
return app(DebugLog::class, true);
}
//{%add function code%}
}