Storage.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Niucloud-admin 企业快速开发的saas管理平台
  4. // +----------------------------------------------------------------------
  5. // | 官方网址:https://www.niucloud.com
  6. // +----------------------------------------------------------------------
  7. // | niucloud团队 版权所有 开源版本可自由商用
  8. // +----------------------------------------------------------------------
  9. // | Author: Niucloud Team
  10. // +----------------------------------------------------------------------
  11. namespace app\adminapi\controller\upload;
  12. use app\dict\sys\StorageDict;
  13. use app\service\admin\upload\StorageConfigService;
  14. use core\base\BaseAdminController;
  15. use core\exception\AdminException;
  16. use think\Response;
  17. class Storage extends BaseAdminController
  18. {
  19. /**
  20. * 云存储配置列表
  21. */
  22. public function storageList()
  23. {
  24. $res = (new StorageConfigService())->getStorageList();
  25. return success($res);
  26. }
  27. /**
  28. * 存储配置详情
  29. * @param $storage_type 存储驱动类型
  30. * @return Response
  31. */
  32. public function storageConfig($storage_type)
  33. {
  34. $res = (new StorageConfigService())->getStorageConfig($storage_type);
  35. return success($res);
  36. }
  37. /**
  38. * 存储设置修改
  39. * @return Response
  40. */
  41. public function editStorage($storage_type)
  42. {
  43. //参数获取
  44. $storage_type_list = StorageDict::getType();
  45. if (!array_key_exists($storage_type, $storage_type_list)) throw new AdminException('OSS_TYPE_NOT_EXIST');
  46. //数据验证
  47. $data = [
  48. ['is_use', 0]
  49. ];
  50. foreach ($storage_type_list[$storage_type]['params'] as $k_param => $v_param) {
  51. $data[] = [$k_param, ''];
  52. }
  53. $request_data = $this->request->params($data);
  54. (new StorageConfigService())->setStorageConfig($storage_type, $request_data);
  55. return success('SET_SUCCESS');
  56. }
  57. }