UploadService.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2017~2021 LARAVEL研发中心
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://www.laravel.cn
  8. // +----------------------------------------------------------------------
  9. // | Author: laravel开发员 <laravel.qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace App\Services\Common;
  12. use App\Models\ActionLogModel;
  13. use App\Services\BaseService;
  14. use Illuminate\Support\Facades\File;
  15. /**
  16. * 会员管理-服务类
  17. * @author laravel开发员
  18. * @since 2020/11/11
  19. * Class MemberService
  20. * @package App\Services\Common
  21. */
  22. class UploadService extends BaseService
  23. {
  24. /**
  25. * 构造函数
  26. * @author laravel开发员
  27. * @since 2020/11/11
  28. * MemberService constructor.
  29. */
  30. public function __construct()
  31. {
  32. // $this->model = new UploadModel();
  33. }
  34. public function save($file_path, $ext, $channel)
  35. {
  36. $data = [
  37. 'group_id' => 0,
  38. 'channel' => $channel,
  39. 'storage' => 0,
  40. 'domain' => 0,
  41. 'file_type' => 0,
  42. 'file_name' => 0,
  43. 'file_path' => $file_path,
  44. 'file_size' => File::size(public_path() . "/uploads/" . $file_path),
  45. 'file_ext' => $ext,
  46. 'cover' => $file_path,
  47. 'uploader_id' => session('userId') ?? 0,
  48. 'is_recycle' => 0,
  49. 'status' => 1,
  50. ];
  51. $error = '';
  52. $rowId = $this->model->edit($data, $error, false);
  53. }
  54. /**
  55. * 删除七天之前标记软删除的数据
  56. */
  57. public function delete()
  58. {
  59. // 设置日志标题
  60. ActionLogModel::setRecord(session('userId'), ['type' => 1, 'title' => "删除上传文件信息", 'content' => json_encode(request()->post(), 256), 'module' => 'admin']);
  61. ActionLogModel::record();
  62. $this->model->where('mark', 0)->where('update_time', '<=', time() - 7 * 86400)->delete();
  63. return parent::delete();
  64. }
  65. }