Save.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php namespace Upload\Api;
  2. use Dever;
  3. use Upload\Lib\Util;
  4. use Upload\Lib\Save as Service;
  5. class Save
  6. {
  7. public $id = null;
  8. public $file = null;
  9. public $cate_id = null;
  10. public $group_id = null;
  11. public $user_id = null;
  12. public $project = null;
  13. public function __construct()
  14. {
  15. $this->id = Dever::input('id', 'is_numeric', '上传规则错误', 1);
  16. $this->file = Dever::input('file', '!empty', '上传文件错误');
  17. $this->cate_id = Dever::input('cate_id', 'is_numeric', '上传分类', 1);
  18. $this->project = Dever::input('project', 'is_string', '项目', 'api');
  19. $this->group_id = Dever::load(Util::class)->getGroup();
  20. $this->user_id = Dever::load(Util::class)->getUser();
  21. }
  22. public function act()
  23. {
  24. return Dever::load(Service::class)->init($this->id, $this->cate_id, $this->group_id, $this->user_id, $this->project)->act($this->file);
  25. }
  26. public function wangEditor()
  27. {
  28. Dever::config('setting', ['output_app' => [], 'output' => [
  29. 'status' => ['errno', ['1' => 0, '2' => 1]],
  30. 'msg' => 'message',
  31. ]]);
  32. return $this->act();
  33. }
  34. public function avatar()
  35. {
  36. $uid = Dever::input('uid', 'is_numeric', '用户ID');
  37. return Dever::load(Service::class)->init($this->id, $this->cate_id, $this->group_id, $this->user_id, $this->project)->act($this->file, 'jpg', $uid);
  38. }
  39. }