Manage.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php namespace Upload\Api;
  2. use Dever;
  3. use Manage\Lib\Auth;
  4. class Manage extends Auth
  5. {
  6. # 获取图片组件信息
  7. public function getImage($value = false)
  8. {
  9. Dever::project('image');
  10. $result = array();
  11. $option = array();
  12. if ($value == 1) {
  13. $option = Dever::db('thumb', 'image')->select([]);
  14. } elseif ($value == 2) {
  15. $option = Dever::db('crop', 'image')->select([]);
  16. } elseif ($value == 3) {
  17. $option = Dever::db('water_pic', 'image')->select([]);
  18. } elseif ($value == 4) {
  19. $option = Dever::db('water_txt', 'image')->select([]);
  20. }
  21. $result['type_id']['type'] = 'select';
  22. $result['type_id']['option'] = $option;
  23. $result['type_id']['value'] = $option[0]['id'] ?? '';
  24. return $result;
  25. }
  26. # 删除文件
  27. public function delFile($id, $file)
  28. {
  29. $info = pathinfo($file);
  30. $file = explode('.', $info['filename']);
  31. $file = $file[0];
  32. return Dever::db('file', 'upload')->update(array('rule_id' => $id, 'name' => $file), array('status' => 2));
  33. }
  34. # 添加文件
  35. public function addFile($id, $url, $file, $source, $name, $size)
  36. {
  37. $data = Dever::load('save', 'upload')->init($id)->addFile($url, $source, $name, $file, $size);
  38. return $data;
  39. }
  40. }