52 lines
899 B
PHP
52 lines
899 B
PHP
<?php
|
|
/**
|
|
* This service file is part of item.
|
|
*
|
|
* @author ctexthuang
|
|
* @contact ctexthuang@qq.com
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Service\Api;
|
|
|
|
use App\Lib\ApiReturn;
|
|
use Hyperf\Context\Context;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
use Hyperf\HttpServer\Contract\RequestInterface;
|
|
|
|
abstract class BaseService
|
|
{
|
|
/**
|
|
* 请求对象
|
|
* @var RequestInterface
|
|
*/
|
|
#[Inject]
|
|
protected RequestInterface $request;
|
|
|
|
/**
|
|
* 通用返回对象
|
|
* @var ApiReturn $return
|
|
*/
|
|
#[Inject]
|
|
protected ApiReturn $return;
|
|
|
|
/**
|
|
* 用户id
|
|
* @var int $userId
|
|
*/
|
|
protected int $userId = 0;
|
|
|
|
/**
|
|
* 主构造函数(获取请求对象)
|
|
*/
|
|
public function __construct()
|
|
{
|
|
$this->userId = Context::get("user_id",0);
|
|
}
|
|
|
|
/**
|
|
* 主体函数抽象类
|
|
*/
|
|
abstract public function handle();
|
|
} |