72 lines
1.3 KiB
PHP
72 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace app\services;
|
|
|
|
use app\api\library\ApiException;
|
|
use app\common\controller\WorkerApi;
|
|
use app\common\model\Worker;
|
|
use think\Log;
|
|
|
|
use app\common\model\WorkerVendor;
|
|
//{%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);
|
|
}
|
|
|
|
//{%add function code%}
|
|
}
|