allocatr/application/services/BaseService.php
2025-03-28 10:01:30 +08:00

45 lines
810 B
PHP

<?php
namespace app\services;
use app\api\library\ApiException;
use app\common\model\Worker;
use think\Log;
//{%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 WorkerService
*/
protected function getWorkerService()
{
return app(WorkerService::class);
}
/**
* @return Worker
*/
protected function getWorkerModel()
{
return app(Worker::class, true);
}
//{%add function code%}
}