resetImagePath.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. declare(strict_types=1);
  3. namespace app\command;
  4. use app\common\model\article\Article;
  5. use app\common\model\article\ArticleCategory;
  6. use app\common\model\community\Community;
  7. use app\common\model\community\CommunityTopic;
  8. use app\common\model\store\broadcast\BroadcastGoods;
  9. use app\common\model\store\broadcast\BroadcastRoom;
  10. use app\common\model\store\Guarantee;
  11. use app\common\model\store\product\Product;
  12. use app\common\model\store\product\ProductAssistUser;
  13. use app\common\model\store\product\ProductAttrValue;
  14. use app\common\model\store\product\ProductGroupUser;
  15. use app\common\model\store\product\ProductReply;
  16. use app\common\model\store\product\Spu;
  17. use app\common\model\store\service\StoreService;
  18. use app\common\model\store\StoreCategory;
  19. use app\common\model\store\StoreSeckillTime;
  20. use app\common\model\system\attachment\Attachment;
  21. use app\common\model\system\financial\Financial;
  22. use app\common\model\system\merchant\Merchant;
  23. use app\common\model\system\merchant\MerchantIntention;
  24. use app\common\model\user\MemberInterests;
  25. use app\common\model\user\User;
  26. use app\common\model\user\UserBrokerage;
  27. use crmeb\services\ImageHostService;
  28. use think\console\Command;
  29. use think\console\Input;
  30. use think\console\input\Argument;
  31. use think\console\input\Option;
  32. use think\console\Output;
  33. use think\facade\Log;
  34. class resetImagePath extends Command
  35. {
  36. protected function configure()
  37. {
  38. // 指令配置
  39. $this->setName('reset:imagePath')
  40. ->addArgument('origin', Argument::OPTIONAL, 'path:http:/crmeb.com')
  41. ->addArgument('replace', Argument::OPTIONAL, 'path:http:/crmeb.com')
  42. ->setDescription('php think reset:imagePath http://old.com http://new.com');
  43. }
  44. /**
  45. * 重置图片路径
  46. * @param Input $input
  47. * @param Output $output
  48. * @return int|void|null
  49. * @author wuhaotian
  50. * @email 442384644@qq.com
  51. * @date 2024/7/12
  52. */
  53. protected function execute(Input $input, Output $output)
  54. {
  55. $origin = $input->getArgument('origin');
  56. $replace = $input->getArgument('replace');
  57. $output->writeln('开始执行');
  58. $service = ImageHostService::getInstance();
  59. $res = $service->execute($origin,$replace);
  60. if ($res) {
  61. $output->info('执行完成');
  62. } else {
  63. $output->warning('执行过程中存在错误,请在runtime/log中查看具体错误信息');
  64. }
  65. }
  66. }