From ea2cf36816fdd18c2b41aac056c7775eef7fff29 Mon Sep 17 00:00:00 2001 From: weigang Date: Wed, 16 Sep 2020 16:13:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E6=88=B7logo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Model/v3/Store.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/Model/v3/Store.php b/app/Model/v3/Store.php index 93d5dad..830c019 100644 --- a/app/Model/v3/Store.php +++ b/app/Model/v3/Store.php @@ -3,13 +3,16 @@ declare (strict_types=1); namespace App\Model\v3; +use App\Constants\v3\OssThumbnail; use App\Constants\v3\SsdbKeys; use App\Model\Model; +use App\Service\v3\Interfaces\AttachmentServiceInterface; use App\TaskWorker\SSDBTask; use Hyperf\Database\Model\Builder; use Hyperf\Database\Model\SoftDeletes; use Hyperf\Utils\ApplicationContext; use App\Constants\v3\Store as StoreConstants; +use Hyperf\Di\Annotation\Inject; /** */ @@ -40,6 +43,12 @@ class Store extends Model 'month_sales' ]; + /** + * @Inject + * @var AttachmentServiceInterface + */ + protected $attachmentService; + protected function boot(): void { parent::boot(); @@ -63,6 +72,11 @@ class Store extends Model return (integer)$ssdb->exec('get', SsdbKeys::STORE_MONTH_SALES.date('Ym').'_'.$this->id); } + public function getLogoAttribute($value) + { + return $this->attachmentService->switchImgToAliOss($value, OssThumbnail::THUMBNAIL_300_Q80); + } + public function goods() { return $this->hasMany(Goods::class, 'store_id', 'id')->limit(5);