first commit

This commit is contained in:
2020-08-06 15:26:41 +08:00
commit 8c0aa3edc1
1416 changed files with 238374 additions and 0 deletions

View File

@@ -0,0 +1,106 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\system\controller;
use app\common\model\JobLog as JobLogModel;
use app\common\model\Logs as LogsModel;
use app\common\model\Storage as StorageModel;
use app\common\service\Storage as StorageService;
use think\Response;
class Storage extends _Init
{
/**
* 资源管理
* @param string $type [description]
*/
public function index($type = '')
{
$map = [];
if ($type) {
$map['type'] = $type;
}
$this->assign('total', StorageService::total($map));
$this->assign('types', StorageService::types());
$this->assign('disk_use', StorageService::diskUse());
$list = StorageModel::where($map)->order('id desc')->paginate();
$this->assign('list', $list);
return $this->fetch();
}
/**
* 日志管理
*/
public function logs()
{
$list = LogsModel::order('id desc')->paginate();
$this->assign('list', $list);
return $this->fetch();
}
public function queue()
{
$list = JobLogModel::order('id desc')->paginate();
$this->assign('list', $list);
return $this->fetch();
}
/**
* 上传单文件
* @param string $type [description]
* @return [type] [description]
*/
public function upload($type = '')
{
if (!in_array($type, ['image', 'file', 'video', 'audio'])) {
$result = ['code' => 0, 'msg' => '不支持的上传类型'];
} else {
$result = StorageService::upload($type);
}
if (is_array($result) && !empty($result) && !isset($result['code'])) {
$ret = [
'code' => 1,
'data' => $result,
];
} else {
$ret = [
'code' => 0,
'msg' => $result,
];
}
return Response::create($ret, 'json');
}
/**
* 编辑器上传文件
*/
public function editor()
{
$result = StorageService::upload('file');
if (is_array($result) && !empty($result)) {
$res = [
'code' => 0,
'data' => [
'src' => $result['path'],
'title' => $result['name'],
],
];
} else {
$res = [
'code' => 1,
'msg' => $result,
];
}
return Response::create($res, 'json');
}
}