Skip to content

Commit

Permalink
⬆️优化依赖
Browse files Browse the repository at this point in the history
  • Loading branch information
osuuu committed Feb 19, 2022
1 parent 2ff267b commit 0ca54dc
Show file tree
Hide file tree
Showing 695 changed files with 58,915 additions and 13,435 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@


## 程序功能
* 支持第三方云储存,本地、阿里云 OSS、腾讯云 COS、七牛云
* 支持多桶储存,可同时添加多个对象存储桶管理
* 支持第三方云储存,本地、阿里云OSS、腾讯云COS、七牛云KODO、又拍云USS、华为云OBS等等
* 支持多桶储存,可同时添加多个对象存储桶管理,适合团队多桶协作
* 多图上传、拖拽上传、粘贴上传、上传预览、全屏预览、一键复制图片外链
* 多用户管理、分组管理;不同分组用户控制不同的存储桶
* 完整的权限控制功能,不同用户组可分配不同的操作权限,控制其上传删除及查看
* 完整的可视化日志功能,记录用户所有操作,方便事件溯源
* 全局配置用户初始剩余储存空间、设置指定用户剩余储存空间
* 支持接口上传、接口删除
* 原创Geek扁平化页面风格,简约大气;前端使用vue开发,前后端分离
* 原创Geek扁平化页面风格,高性能 / 精致 / 优雅 / 简洁而不简单


## 安装要求
Expand Down
4 changes: 2 additions & 2 deletions app/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@


// 程序版本
define("VERSION", "1.1");
define("VERSION", "1.2.0");
// 版本号
define("RELRAASE_TIME", "20220217");
define("RELRAASE_TIME", "20220219");
// 本地存储根目录
define("FOLDER", "LightPicture/");
// TOKEN KEY
Expand Down
65 changes: 12 additions & 53 deletions app/controller/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@ public function upload(Request $request)
return $this->create(null, '图片大小超出限制', 400);
}
$user = UserModel::where("Secret_key", $key)->find();
if(!isset($user) ||$user['state'] == 0) return $this->create(null, '用户不存在或被停用', 400);
if (!isset($user) || $user['state'] == 0) return $this->create(null, '用户不存在或被停用', 400);

$allSize = ImagesModel::where('user_id', $user['id'])->sum('size');
if($allSize + $_FILES["file"]['size'] > $user['capacity']){
if ($allSize + $_FILES["file"]['size'] > $user['capacity']) {
return $this->create(null, '您的存储配额不足', 400);
}

$role = RoleModel::find($user['role_id']);
$result = $this->toUpload($_FILES["file"], $role['storage_id']);
$UploadCLass = new UploadCLass;
$result = $UploadCLass->create($_FILES["file"], $role['storage_id']);
if ($result['state'] == 1) {
$img = new ImagesModel;
$img->save([
Expand All @@ -70,29 +71,7 @@ public function upload(Request $request)
}
}

/**
* 上传
*/
public function toUpload($file, $sid)
{
$UploadCLass = new UploadCLass;
$storage = StorageModel::find($sid);
switch ($storage['type']) {
case 'local':
return $UploadCLass->location_upload($file, $sid);
break;
case 'cos':
return $UploadCLass->tencent_upload($file, $sid);
break;
case 'oss':
return $UploadCLass->aliyuncs_upload($file, $sid);
break;
case 'kodo':
return $UploadCLass->qiniu_upload($file, $sid);
break;
default:
}
}


// 删除
public function delete(Request $request)
Expand All @@ -104,54 +83,34 @@ public function delete(Request $request)
}
if (!$id) return $this->create([], '图片id为空', 400);
$user = UserModel::where("Secret_key", $key)->find();
if(!isset($user) ||$user['state'] == 0) return $this->create(null, '用户不存在或被停用', 400);
if (!isset($user) || $user['state'] == 0) return $this->create(null, '用户不存在或被停用', 400);
$role = RoleModel::find($user['role_id']);
$imgs = ImagesModel::find($id);
$uid = $user['id'];
$UploadCLass = new UploadCLass;

if ($role['is_admin'] == 1) {
$this->toDel($imgs["path"], $imgs['storage_id']);
$UploadCLass->delete($imgs["path"], $imgs['storage_id']);
$name = $imgs['name'];
$imgs->delete();
$this->setLog($uid, "删除了图片", "ID:" . $id, $name, 2);
return $this->create($name, '删除成功', 200);
} else if ($role['is_del_own'] == 1 && $imgs['user_id'] == $uid) {
$this->toDel($imgs["path"], $imgs['storage_id']);
$UploadCLass->delete($imgs["path"], $imgs['storage_id']);
$name = $imgs['name'];
$imgs->delete();
$this->setLog($uid, "删除了图片", "ID:" . $id, $name, 2);
return $this->create($name, '删除成功', 200);
} else if ($role['is_del_all'] == 1 && $imgs['storage_id'] == $role['storage_id']) {
$this->toDel($imgs["path"], $imgs['storage_id']);
$UploadCLass->delete($imgs["path"], $imgs['storage_id']);
$name = $imgs['name'];
$imgs->delete();
$this->setLog($uid, "删除了图片", "ID:" . $id, $name, 2);
return $this->create($name, '删除成功', 200);
} else {
return $this->create('当前角色组没有删除权限', '删除失败', 400);
}

}

// 删除
public function toDel($path, $sid)
{
$UploadCLass = new UploadCLass;
$storage = StorageModel::find($sid);
switch ($storage['type']) {
case 'local':
return $UploadCLass->location_delete($path, $sid);
break;
case 'cos':
return $UploadCLass->tencent_delete($path, $sid);
break;
case 'oss':
return $UploadCLass->aliyuncs_delete($path, $sid);
break;
case 'kodo':
return $UploadCLass->qiniu_delete($path, $sid);
break;
default:
}
}

}
29 changes: 4 additions & 25 deletions app/controller/Images.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,22 @@ public function delete(Request $request, $id)
$userInfo = UserModel::find($uid);
$role = RoleModel::find($userInfo['role_id']);
$imgs = ImagesModel::find($id);
$UploadCLass = new UploadCLass;

if ($role['is_admin'] == 1) {
$this->toDel($imgs["path"], $imgs['storage_id']);
$UploadCLass->delete($imgs["path"], $imgs['storage_id']);
$name = $imgs['name'];
$imgs->delete();
$this->setLog($uid, "删除了图片", "ID:".$id, $name,2);
return $this->create($name, '删除成功', 200);
} else if ($role['is_del_own'] == 1 && $imgs['user_id'] == $uid) {
$this->toDel($imgs["path"], $imgs['storage_id']);
$UploadCLass->delete($imgs["path"], $imgs['storage_id']);
$name = $imgs['name'];
$imgs->delete();
$this->setLog($uid, "删除了图片", "ID:".$id, $name,2);
return $this->create($name, '删除成功', 200);
} else if ($role['is_del_all'] == 1 && $imgs['storage_id'] == $role['storage_id']) {
$this->toDel($imgs["path"], $imgs['storage_id']);
$UploadCLass->delete($imgs["path"], $imgs['storage_id']);
$name = $imgs['name'];
$imgs->delete();
$this->setLog($uid, "删除了图片", "ID:".$id, $name,2);
Expand All @@ -98,26 +99,4 @@ public function delete(Request $request, $id)
return $this->create('当前角色组没有删除权限', '删除失败', 400);
}
}

// 删除
public function toDel($path, $sid)
{
$UploadCLass = new UploadCLass;
$storage = StorageModel::find($sid);
switch ($storage['type']) {
case 'local':
return $UploadCLass->location_delete($path, $sid);
break;
case 'cos':
return $UploadCLass->tencent_delete($path, $sid);
break;
case 'oss':
return $UploadCLass->aliyuncs_delete($path, $sid);
break;
case 'kodo':
return $UploadCLass->qiniu_delete($path, $sid);
break;
default:
}
}
}
8 changes: 5 additions & 3 deletions app/controller/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,11 @@ public function type()
{
$result = array(
'local' => '本地存储',
'cos' => '腾讯云cos',
'oss' => '阿里云oss',
'kodo' => '七牛云kodo',
'cos' => '腾讯云 COS',
'oss' => '阿里云 OSS',
'kodo' => '七牛云 KODO',
'uss' => '又拍云 USS',
'obs' => '华为云 OBS',
);
return $this->create($result, '成功', 200);
}
Expand Down
18 changes: 13 additions & 5 deletions app/controller/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,15 @@ public function info(Request $request)
$scheme = $request->scheme();
$user = UserModel::find($uid);
$role = RoleModel::find($user['role_id']);
$user['role'] = $role;
$user['role'] = array(
"is_add" => $role['is_add'],
"is_admin" => $role['is_admin'],
"is_del_all" => $role['is_del_all'],
"is_del_own" => $role['is_del_own'],
"is_read" => $role['is_read'],
"is_read_all" => $role['is_read_all'],
"name" => $role['name']
);
$user['scheme'] = $scheme;
$user['url'] = $url;
$user['capacity'] = (int)$user['capacity'];
Expand Down Expand Up @@ -139,13 +147,13 @@ public function log(Request $request)
$query['type'] = $data['type'];
if ($data['type'] == 1) unset($query['type']);

if($role['is_admin'] == 1){
if($data['read'] == 1){
if ($role['is_admin'] == 1) {
if ($data['read'] == 1) {
$query['uid'] = $uid;
}else{
} else {
unset($query['uid']);
}
}else{
} else {
$query['uid'] = $uid;
}

Expand Down
Loading

0 comments on commit 0ca54dc

Please sign in to comment.