66 lines
1.4 KiB
PHP
66 lines
1.4 KiB
PHP
<?php
|
|
/**
|
|
* This service file is part of item.
|
|
*
|
|
* @author ctexthuang
|
|
* @contact ctexthuang@qq.com
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Service\Api\Chef;
|
|
|
|
use App\Exception\ErrException;
|
|
use App\Model\AdminUser;
|
|
use App\Model\Chef;
|
|
use App\Service\Api\BaseService;
|
|
use App\Service\ServiceTrait\Common\OssTrait;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
|
|
class IndexService extends BaseService
|
|
{
|
|
use OssTrait;
|
|
|
|
/**
|
|
* @var AdminUser
|
|
*/
|
|
#[Inject]
|
|
protected AdminUser $adminUserModel;
|
|
|
|
/**
|
|
* @var Chef
|
|
*/
|
|
#[Inject]
|
|
protected Chef $chefModel;
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function handle(): array
|
|
{
|
|
$chefId = $this->request->input('chef_id');
|
|
|
|
$chef = $this->chefModel
|
|
->leftJoin('admin_user', 'admin_user.id', '=', 'chef.user_id')
|
|
->where('chef.user_id', $chefId)
|
|
->select([
|
|
'admin_user.id',
|
|
'admin_user.username',
|
|
'admin_user.avatar',
|
|
'admin_user.chinese_name',
|
|
'chef.profile',
|
|
'chef.specialties',
|
|
])
|
|
->first();
|
|
|
|
if (empty($chef)) throw new ErrException('厨师不存在');
|
|
|
|
$avatarUrl = $this->getOssObjectById($chef->avatar);
|
|
$res = $chef->toArray();
|
|
$res['avatar_url'] = $avatarUrl;
|
|
|
|
// todo 评价补全
|
|
|
|
return $this->return->success('success', $res);
|
|
}
|
|
} |