diff --git a/app/Service/Api/Good/OptionalListService.php b/app/Service/Api/Good/OptionalListService.php index 2007d7f..d065dd0 100644 --- a/app/Service/Api/Good/OptionalListService.php +++ b/app/Service/Api/Good/OptionalListService.php @@ -20,6 +20,7 @@ use App\Constants\ConfigCode; use App\Exception\ErrException; use App\Model\Category; use App\Service\Api\BaseService; +use App\Service\ServiceTrait\Api\BannerTrait; use App\Service\ServiceTrait\Common\CycleTrait; use App\Service\ServiceTrait\Common\OssTrait; use Hyperf\Di\Annotation\Inject; @@ -30,6 +31,7 @@ use function Hyperf\Config\config; class OptionalListService extends BaseService { use CycleTrait; + use BannerTrait; /** * @var GoodCache @@ -86,7 +88,7 @@ class OptionalListService extends BaseService $res = $this->buildData($data); - return $this->return->success('success', ['list' => $res]); + return $this->return->success('success', ['list' => $res,'banner' => $this->getBanner((int)$this->request->input('city_id',config('system.default_city_id')))]); } use OssTrait; diff --git a/app/Service/Api/User/IndexService.php b/app/Service/Api/User/IndexService.php index 36b3319..ea906fb 100644 --- a/app/Service/Api/User/IndexService.php +++ b/app/Service/Api/User/IndexService.php @@ -34,7 +34,7 @@ class IndexService extends BaseService $avatar = $this->getOssObjectById($userInfo->avatar_id); $res = [ - 'banner' => $this->getBanner(), +// 'banner' => $this->getBanner(), 'nickname' => $userInfo->nickname, 'avatar' => $avatar, 'point' => 0, diff --git a/app/Service/ServiceTrait/Api/BannerTrait.php b/app/Service/ServiceTrait/Api/BannerTrait.php new file mode 100644 index 0000000..868ae34 --- /dev/null +++ b/app/Service/ServiceTrait/Api/BannerTrait.php @@ -0,0 +1,41 @@ +bannerModel + ->where('city_id',$cityId) + ->where('status',BannerCode::DISPLAYED) + ->orderBy('sort') + ->get(); + if ($res->isEmpty()) return []; + $res = $res->toArray(); + + $imageList = $this->getOssObjects(array_column($res, 'image_id')); + + foreach ($res as &$v) { + $v['url'] = $imageList[$v['image_id']]['url'] ?? ''; + } + + return $res; + } +} \ No newline at end of file diff --git a/config/autoload/system.php b/config/autoload/system.php index 98015a0..2635da2 100644 --- a/config/autoload/system.php +++ b/config/autoload/system.php @@ -30,5 +30,7 @@ return [ // upload_dir 'upload_dir' => BASE_PATH.'/uploads/', // 默认的厨房 id - 'default_kitchen_id' => env('DEFAULT_KITCHEN_ID',''), + 'default_kitchen_id' => env('DEFAULT_KITCHEN_ID',1), + // 默认 城市 id + 'default_city_id' => env('DEFAULT_CITY_ID',3), ]; \ No newline at end of file