6
0
Fork 0

OssCopyCommand

base
panliang 2022-07-29 15:01:58 +08:00
parent 33c30077c2
commit e6e3ee7abd
1 changed files with 26 additions and 47 deletions

View File

@ -49,54 +49,33 @@ class OssCopy extends Command
public function handle()
{
// 用户头像
foreach(UserInfo::get() as $item) {
$this->updateModel($item, ['avatar']);
}
// 文章
foreach(Article::get() as $item) {
$this->updateModel($item, ['cover', 'content']);
}
// 广告
foreach(Ad::get() as $item) {
$this->updateModel($item, ['image']);
}
// 门店
foreach(Store::get() as $item) {
$this->updateModel($item, ['image']);
}
// 商品
foreach(ProductSpu::get() as $item) {
$this->updateModel($item, ['cover', 'images', 'media', 'description']);
}
foreach(ProductSku::get() as $item) {
$this->updateModel($item, ['cover', 'images', 'media', 'description']);
}
// 商品分类
foreach(ProductCategory::get() as $item) {
$this->updateModel($item, ['icon']);
}
// 商品特点
foreach(ProductFeature::get() as $item) {
$this->updateModel($item, ['icon']);
}
// 购买须知
foreach(ProductBuynote::get() as $item) {
$this->updateModel($item, ['content']);
}
// 分享背景
foreach(ShareBg::get() as $item) {
$this->updateModel($item, ['image']);
}
// 抽奖活动
foreach(DrawActivity::get() as $item) {
$this->updateModel($item, ['desc', 'bg_image']);
}
// 抽奖奖品
foreach(DrawPrize::get() as $item) {
$this->updateModel($item, ['icon']);
}
$list = [
['name' => '用户', 'list' => UserInfo::get(), 'attributes' => ['avatar']],
['name' => '文章', 'list' => Article::get(), 'attributes' => ['cover', 'content']],
['name' => '广告', 'list' => Ad::get(), 'attributes' => ['image']],
['name' => '门店', 'list' => Store::get(), 'attributes' => ['image']],
['name' => '商品SPU', 'list' => ProductSpu::get(), 'attributes' => ['cover', 'images', 'media', 'description']],
['name' => '商品SKU', 'list' => ProductSku::get(), 'attributes' => ['cover', 'images', 'media', 'description']],
['name' => '商品分类', 'list' => ProductCategory::get(), 'attributes' => ['icon']],
['name' => '商品特点', 'list' => ProductFeature::get(), 'attributes' => ['icon']],
['name' => '购买须知', 'list' => ProductBuynote::get(), 'attributes' => ['content']],
['name' => '分享背景', 'list' => ShareBg::get(), 'attributes' => ['image']],
['name' => '抽奖活动', 'list' => DrawActivity::get(), 'attributes' => ['desc', 'bg_image']],
['name' => '抽奖奖品', 'list' => DrawPrize::get(), 'attributes' => ['icon']],
];
foreach($list as $item) {
$collection = $item['list'];
$this->info($item['name'] . ': ' . $collection->count());
$bar = $this->output->createProgressBar($collection->count());
$bar->start();
foreach($collection as $model) {
$this->updateModel($model, $item['attributes']);
$bar->advance();
}
$bar->finish();
}
return 0;
}