SystemBucket.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\admin\model\system;
  12. use traits\ModelTrait;
  13. use basic\ModelBasic;
  14. /**
  15. * Class SystemBucket
  16. * @package app\admin\model\system
  17. */
  18. class SystemBucket extends ModelBasic
  19. {
  20. use ModelTrait;
  21. /**获取数据表中的储存空间信息
  22. * @param $where
  23. * @return false|\PDOStatement|string|\think\Collection
  24. * @throws \think\db\exception\DataNotFoundException
  25. * @throws \think\db\exception\ModelNotFoundException
  26. * @throws \think\exception\DbException
  27. */
  28. public static function bucKetList($where){
  29. $model=new self();
  30. if($where['endpoint']!='') $model=$model->where('endpoint',$where['endpoint']);
  31. $list=$model->where('is_del',0)->order('add_time desc')->select();
  32. return $list;
  33. }
  34. /**
  35. * 拉取保存存储空间
  36. * @param $list
  37. */
  38. public static function addListBucket($list=[])
  39. {
  40. foreach ($list as $key=>$value){
  41. $data=[
  42. 'bucket_name'=>$value->getName(),
  43. 'endpoint'=>$value->getLocation().'.aliyuncs.com',
  44. 'domain_name'=>$value->getName().'.'.$value->getLocation().'.aliyuncs.com',
  45. 'creation_time'=>$value->getCreatedate(),
  46. 'add_time'=>time()
  47. ];
  48. if(!self::be(['bucket_name'=>$data['bucket_name']])){
  49. self::set($data);
  50. }
  51. }
  52. return true;
  53. }
  54. /**
  55. * 保存存储空间
  56. * @param $value
  57. */
  58. public static function addBucket($value=[])
  59. {
  60. $data=[
  61. 'bucket_name'=>$value['bucket_name'],
  62. 'endpoint'=>$value['endpoint'],
  63. 'domain_name'=>$value['bucket_name'].'.'.$value['endpoint'],
  64. 'creation_time'=>date('Y/m/d H:i',time()),
  65. 'add_time'=>time()
  66. ];
  67. $res=true;
  68. if(!self::be(['bucket_name'=>$data['bucket_name']])){
  69. $res=self::set($data);
  70. }
  71. return $res;
  72. }
  73. }