Commit 38d5f154 authored by wangtao's avatar wangtao

管理后台 看板

parent d518036a
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
* Licensed: 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行 * Licensed: 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
* --------------------------------------------------------------------------- * ---------------------------------------------------------------------------
*/ */
namespace app\admin\controller\system; namespace app\admin\controller\system;
use app\admin\controller\AdminBase; use app\admin\controller\AdminBase;
...@@ -31,31 +32,31 @@ class Upload extends BaseController ...@@ -31,31 +32,31 @@ class Upload extends BaseController
* @var array * @var array
*/ */
private $CF = [ private $CF = [
'upload_engine'=>'local', 'upload_engine' => 'local',
'upload_image_type'=> 'jpg,png,gif,jpeg', 'upload_image_type' => 'jpg,png,gif,jpeg',
'upload_image_size'=> 2, 'upload_image_size' => 2,
'upload_file_type'=> 'rar,zip,pdf,docx,doc,xlsx,xls', 'upload_file_type' => 'rar,zip,pdf,docx,doc,xlsx,xls',
'upload_file_size'=> 10, 'upload_file_size' => 10,
'upload_video_type'=> 'mp4,flv,wmv,avi,mov,mpeg', 'upload_video_type' => 'mp4,flv,wmv,avi,mov,mpeg',
'upload_video_size'=> 20, 'upload_video_size' => 20,
'upload_audio_type'=> 'mp3', 'upload_audio_type' => 'mp3',
'upload_audio_size'=> 10, 'upload_audio_size' => 10,
//七牛云 //七牛云
'qiniu_bucket'=> '', 'qiniu_bucket' => '',
'access_key'=> '', 'access_key' => '',
'qiniu_secret_key'=> '', 'qiniu_secret_key' => '',
'qiniu_domain'=> '', 'qiniu_domain' => '',
//阿里云 //阿里云
'aliyun_bucket'=> '', 'aliyun_bucket' => '',
'access_key_id'=> '', 'access_key_id' => '',
'access_key_secret'=> '', 'access_key_secret' => '',
'aliyun_domain'=> '', 'aliyun_domain' => '',
//腾讯云 //腾讯云
'qcloud_bucket'=> '', 'qcloud_bucket' => '',
'region'=> '', 'region' => '',
'secret_id'=> '', 'secret_id' => '',
'qcloud_secret_key'=> '', 'qcloud_secret_key' => '',
'qcloud_domain'=> '', 'qcloud_domain' => '',
]; ];
/** /**
...@@ -67,35 +68,40 @@ class Upload extends BaseController ...@@ -67,35 +68,40 @@ class Upload extends BaseController
$this->manUser = session(VT_MANAGER); $this->manUser = session(VT_MANAGER);
$this->CF = array_merge($this->CF, vconfig()); $this->CF = array_merge($this->CF, vconfig());
$this->config = array( $this->config = array(
'default'=>$this->CF['upload_engine'], 'default' => $this->CF['upload_engine'],
'engine'=> array( 'engine' => array(
'local'=>array( 'local' => array(
'domain'=> '/static/file/upload',//上传的本地地址 'domain' => '/static/file/upload',//上传的本地地址
'image' => array('ext'=>$this->CF['upload_image_type'],'size'=>$this->CF['upload_image_size']), 'image' => array('ext' => $this->CF['upload_image_type'], 'size' => $this->CF['upload_image_size']),
'file' => array('ext'=>$this->CF['upload_file_type'],'size'=>$this->CF['upload_file_size']), 'file' => array('ext' => $this->CF['upload_file_type'], 'size' => $this->CF['upload_file_size']),
'video' => array('ext'=>$this->CF['upload_video_type'],'size'=>$this->CF['upload_video_size']), 'video' => array('ext' => $this->CF['upload_video_type'], 'size' => $this->CF['upload_video_size']),
'audio' => array('ext'=>$this->CF['upload_audio_type'],'size'=>$this->CF['upload_audio_size']), 'audio' => array('ext' => $this->CF['upload_audio_type'], 'size' => $this->CF['upload_audio_size']),
'upfile'=>'' 'upfile' => ''
), ),
'qiniu'=>array( 'qiniu' => array(
'bucket'=>$this->CF['qiniu_bucket'], 'bucket' => $this->CF['qiniu_bucket'],
'access_key'=>$this->CF['access_key'], 'access_key' => $this->CF['access_key'],
'secret_key'=>$this->CF['qiniu_secret_key'], 'secret_key' => $this->CF['qiniu_secret_key'],
'domain'=>$this->CF['qiniu_domain'] 'domain' => $this->CF['qiniu_domain']
), ),
'aliyun'=>array( 'aliyun' => array(
'bucket'=>$this->CF['aliyun_bucket'], 'bucket' => $this->CF['aliyun_bucket'],
'access_key_id'=>$this->CF['access_key_id'], 'access_key_id' => $this->CF['access_key_id'],
'access_key_secret'=>$this->CF['access_key_secret'], 'access_key_secret' => $this->CF['access_key_secret'],
'domain'=>$this->CF['aliyun_domain'], 'domain' => $this->CF['aliyun_domain'],
'upfile'=>'public/', 'upfile' => 'public/',
'image' => array('ext' => $this->CF['upload_image_type'], 'size' => $this->CF['upload_image_size']),
'file' => array('ext' => $this->CF['upload_file_type'], 'size' => $this->CF['upload_file_size']),
'video' => array('ext' => $this->CF['upload_video_type'], 'size' => $this->CF['upload_video_size']),
'audio' => array('ext' => $this->CF['upload_audio_type'], 'size' => $this->CF['upload_audio_size']),
), ),
'qcloud'=>array( 'qcloud' => array(
'bucket'=>$this->CF['qcloud_bucket'], 'bucket' => $this->CF['qcloud_bucket'],
'region'=>$this->CF['region'], 'region' => $this->CF['region'],
'secret_id'=>$this->CF['secret_id'], 'secret_id' => $this->CF['secret_id'],
'secret_key'=>$this->CF['qcloud_secret_key'], 'secret_key' => $this->CF['qcloud_secret_key'],
'domain'=>$this->CF['qcloud_domain'] 'domain' => $this->CF['qcloud_domain']
) )
) )
); );
...@@ -114,7 +120,7 @@ class Upload extends BaseController ...@@ -114,7 +120,7 @@ class Upload extends BaseController
{ {
$action = $action ? $action : input('action'); $action = $action ? $action : input('action');
if(!$action) return $this->returnMsg('参数错误'); if (!$action) return $this->returnMsg('参数错误');
$this->init(); $this->init();
$engine = $this->config['default']; $engine = $this->config['default'];
$this->config['engine'][$engine]['type'] = $action; $this->config['engine'][$engine]['type'] = $action;
...@@ -123,43 +129,50 @@ class Upload extends BaseController ...@@ -123,43 +129,50 @@ class Upload extends BaseController
//实例化存储驱动 //实例化存储驱动
$StorageDriver = new StorageDriver($this->config); $StorageDriver = new StorageDriver($this->config);
try{ try {
//设置上传文件的信息 //设置上传文件的信息
$StorageDriver->setUploadFile($file); $StorageDriver->setUploadFile($file);
}catch(\think\Exception $e){ } catch (\think\Exception $e) {
return $this->returnMsg('上传失败!'.$e->getMessage()); return $this->returnMsg('上传失败!' . $e->getMessage());
}
if($engine == 'aliyun'){
$_FILES['file']['name'] = 'public/'.$_FILES['file']['name'];
} }
// if ($engine == 'aliyun') {
// $_FILES['file']['name'] = 'public/' . $_FILES['file']['name'];
// }
//上传图片 //上传图片
if(!$StorageDriver->upload()) return $this->returnMsg('上传失败!'.$StorageDriver->getError()); if (!$StorageDriver->upload()) return $this->returnMsg('上传失败!' . $StorageDriver->getError());
//图片上传路径 //图片上传路径
$fileName = $StorageDriver->getFileName(); $fileName = $StorageDriver->getFileName();
//获取图片信息 //获取图片信息
$fileInfo = $StorageDriver->getFileInfo(); $fileInfo = $StorageDriver->getFileInfo();
//保存到数据库 //保存到数据库
$file_http_url = '';
if ($engine == 'local') {
$file_http_url = config('app.file_http_url');
}
$data['storage'] = $engine; $data['storage'] = $engine;
$data['fileurl'] = VT_DIR.$domain.'/'.$fileName; $data['fileurl'] = VT_DIR . $domain . '/' . $fileName;
$data['filename'] = $fileInfo['oname']; $data['filename'] = $fileInfo['oname'];
$data['filesize'] = round($fileInfo['size']/1024,2); $data['filesize'] = round($fileInfo['size'] / 1024, 2);
$data['filetype'] = $action; $data['filetype'] = $action;
$data['groupid'] = intval($groupid)>=0 ? intval($groupid) : 0; $data['groupid'] = intval($groupid) >= 0 ? intval($groupid) : 0;
$data['fileext'] = $fileInfo['ext']; $data['fileext'] = $fileInfo['ext'];
$data['addtime'] = time(); $data['addtime'] = time();
$data['username'] = isset($this->manUser['username']) ? $this->manUser['username'] : 'webapi'; $data['username'] = isset($this->manUser['username']) ? $this->manUser['username'] : 'webapi';
$data['fileid'] = UploadFile::insertGetId($data); $data['fileid'] = UploadFile::insertGetId($data);
$data['fileurl'] = $file_http_url . VT_DIR . $domain . '/' . $fileName;
//压缩容量 //压缩容量
if($data['filesize']>300 && $engine == 'local'){ if ($data['filesize'] > 300 && $engine == 'local') {
$pic = ROOT_PATH . 'public' . $data['fileurl']; $pic = ROOT_PATH . 'public' . $data['fileurl'];
if($data['fileext']=='jpg'){ if ($data['fileext'] == 'jpg') {
$pics = Imagecreatefromjpeg($pic); $pics = Imagecreatefromjpeg($pic);
Imagejpeg($pics,$pic,70); Imagejpeg($pics, $pic, 70);
imagedestroy($pics); imagedestroy($pics);
}elseif($data['fileext']=='png'){ } elseif ($data['fileext'] == 'png') {
$pics = imagecreatefrompng($pic); $pics = imagecreatefrompng($pic);
imagepng($pics,$pic,9); imagepng($pics, $pic, 9);
imagedestroy($pics); imagedestroy($pics);
} }
} }
...@@ -176,111 +189,111 @@ class Upload extends BaseController ...@@ -176,111 +189,111 @@ class Upload extends BaseController
public function ueditor(string $file = 'file', int $groupid = 0, string $action = '') public function ueditor(string $file = 'file', int $groupid = 0, string $action = '')
{ {
$action = $action ? $action : input('action'); $action = $action ? $action : input('action');
if(!$action) return $this->returnMsg('参数错误'); if (!$action) return $this->returnMsg('参数错误');
if($action == 'config'){ //百度编辑器获取配置 if ($action == 'config') { //百度编辑器获取配置
$this->CF = array_merge($this->CF, vconfig()); $this->CF = array_merge($this->CF, vconfig());
$imageAllowFiles = explode(',', '.'.str_replace(',', ',.', $this->CF['upload_image_type'])); $imageAllowFiles = explode(',', '.' . str_replace(',', ',.', $this->CF['upload_image_type']));
$videoAllowFiles = explode(',', '.'.str_replace(',', ',.', $this->CF['upload_video_type'])); $videoAllowFiles = explode(',', '.' . str_replace(',', ',.', $this->CF['upload_video_type']));
$fileAllowFiles = explode(',', '.'.str_replace(',', ',.', $this->CF['upload_file_type'])); $fileAllowFiles = explode(',', '.' . str_replace(',', ',.', $this->CF['upload_file_type']));
$data = [ $data = [
/* 上传图片配置项 */ /* 上传图片配置项 */
"imageActionName"=>"image", /* 执行上传图片的action名称 */ "imageActionName" => "image", /* 执行上传图片的action名称 */
"imageFieldName"=>"file", /* 提交的图片表单名称 */ "imageFieldName" => "file", /* 提交的图片表单名称 */
"imageMaxSize"=>$this->CF['upload_image_size']*1024*1024, /* 上传大小限制,单位B */ "imageMaxSize" => $this->CF['upload_image_size'] * 1024 * 1024, /* 上传大小限制,单位B */
"imageAllowFiles"=>$imageAllowFiles, /* 上传图片格式显示 */ "imageAllowFiles" => $imageAllowFiles, /* 上传图片格式显示 */
"imageCompressEnable"=>true, /* 是否压缩图片,默认是true */ "imageCompressEnable" => true, /* 是否压缩图片,默认是true */
"imageCompressBorder"=>1600, /* 图片压缩最长边限制 */ "imageCompressBorder" => 1600, /* 图片压缩最长边限制 */
"imageInsertAlign"=>"none", /* 插入的图片浮动方式 */ "imageInsertAlign" => "none", /* 插入的图片浮动方式 */
"imageUrlPrefix"=>"", /* 图片访问路径前缀 */ "imageUrlPrefix" => "", /* 图片访问路径前缀 */
"imagePathFormat"=>"/file/upload/", /* 上传保存路径,可以自定义保存路径和文件名格式 image/{yyyy}{mm}{dd}/{time}{rand:6} */ "imagePathFormat" => "/file/upload/", /* 上传保存路径,可以自定义保存路径和文件名格式 image/{yyyy}{mm}{dd}/{time}{rand:6} */
/* 涂鸦图片上传配置项 */ /* 涂鸦图片上传配置项 */
"scrawlActionName"=>"image", /* 执行上传涂鸦的action名称 */ "scrawlActionName" => "image", /* 执行上传涂鸦的action名称 */
"scrawlFieldName"=>"file", /* 提交的图片表单名称 */ "scrawlFieldName" => "file", /* 提交的图片表单名称 */
"scrawlPathFormat"=>"/file/", /* 上传保存路径,可以自定义保存路径和文件名格式 */ "scrawlPathFormat" => "/file/", /* 上传保存路径,可以自定义保存路径和文件名格式 */
"scrawlMaxSize"=>$this->CF['upload_image_size']*1024*1024, /* 上传大小限制,单位B */ "scrawlMaxSize" => $this->CF['upload_image_size'] * 1024 * 1024, /* 上传大小限制,单位B */
"scrawlUrlPrefix"=>"", /* 图片访问路径前缀 */ "scrawlUrlPrefix" => "", /* 图片访问路径前缀 */
"scrawlInsertAlign"=>"none", "scrawlInsertAlign" => "none",
/* 截图工具上传 */ /* 截图工具上传 */
"snapscreenActionName"=>"image", /* 执行上传截图的action名称 */ "snapscreenActionName" => "image", /* 执行上传截图的action名称 */
"snapscreenPathFormat"=>"/file/", /* 上传保存路径,可以自定义保存路径和文件名格式 */ "snapscreenPathFormat" => "/file/", /* 上传保存路径,可以自定义保存路径和文件名格式 */
"snapscreenUrlPrefix"=>"", /* 图片访问路径前缀 */ "snapscreenUrlPrefix" => "", /* 图片访问路径前缀 */
"snapscreenInsertAlign"=>"none", /* 插入的图片浮动方式 */ "snapscreenInsertAlign" => "none", /* 插入的图片浮动方式 */
/* 抓取远程图片配置 */ /* 抓取远程图片配置 */
"catcherLocalDomain"=>["127.0.0.1", "localhost", "img.baidu.com"], "catcherLocalDomain" => ["127.0.0.1", "localhost", "img.baidu.com"],
"catcherActionName"=>"image", /* 执行抓取远程图片的action名称 */ "catcherActionName" => "image", /* 执行抓取远程图片的action名称 */
"catcherFieldName"=>"source", /* 提交的图片列表表单名称 */ "catcherFieldName" => "source", /* 提交的图片列表表单名称 */
"catcherPathFormat"=>"/file/", /* 上传保存路径,可以自定义保存路径和文件名格式 */ "catcherPathFormat" => "/file/", /* 上传保存路径,可以自定义保存路径和文件名格式 */
"catcherUrlPrefix"=>"", /* 图片访问路径前缀 */ "catcherUrlPrefix" => "", /* 图片访问路径前缀 */
"catcherMaxSize"=>$this->CF['upload_image_size']*1024*1024, /* 上传大小限制,单位B */ "catcherMaxSize" => $this->CF['upload_image_size'] * 1024 * 1024, /* 上传大小限制,单位B */
"catcherAllowFiles"=>$imageAllowFiles, /* 抓取图片格式显示 */ "catcherAllowFiles" => $imageAllowFiles, /* 抓取图片格式显示 */
/* 上传视频配置 */ /* 上传视频配置 */
"videoActionName"=>"video", /* 执行上传视频的action名称 */ "videoActionName" => "video", /* 执行上传视频的action名称 */
"videoFieldName"=>"file", /* 提交的视频表单名称 */ "videoFieldName" => "file", /* 提交的视频表单名称 */
"videoPathFormat"=>"/file/", /* 上传保存路径,可以自定义保存路径和文件名格式 */ "videoPathFormat" => "/file/", /* 上传保存路径,可以自定义保存路径和文件名格式 */
"videoUrlPrefix"=>"", /* 视频访问路径前缀 */ "videoUrlPrefix" => "", /* 视频访问路径前缀 */
"videoMaxSize"=>$this->CF['upload_video_size']*1024*1024, /* 上传大小限制,单位B,默认100MB */ "videoMaxSize" => $this->CF['upload_video_size'] * 1024 * 1024, /* 上传大小限制,单位B,默认100MB */
"videoAllowFiles"=>$videoAllowFiles, /* 上传视频格式显示 */ "videoAllowFiles" => $videoAllowFiles, /* 上传视频格式显示 */
/* 上传文件配置 */ /* 上传文件配置 */
"fileActionName"=>"file", /* controller里,执行上传视频的action名称 */ "fileActionName" => "file", /* controller里,执行上传视频的action名称 */
"fileFieldName"=>"file", /* 提交的文件表单名称 */ "fileFieldName" => "file", /* 提交的文件表单名称 */
"filePathFormat"=>"/file/", /* 上传保存路径,可以自定义保存路径和文件名格式 */ "filePathFormat" => "/file/", /* 上传保存路径,可以自定义保存路径和文件名格式 */
"fileUrlPrefix"=>"", /* 文件访问路径前缀 */ "fileUrlPrefix" => "", /* 文件访问路径前缀 */
"fileMaxSize"=>$this->CF['upload_file_size']*1024*1024, /* 上传大小限制,单位B,默认50MB */ "fileMaxSize" => $this->CF['upload_file_size'] * 1024 * 1024, /* 上传大小限制,单位B,默认50MB */
"fileAllowFiles"=>$fileAllowFiles, /* 上传文件格式显示 */ "fileAllowFiles" => $fileAllowFiles, /* 上传文件格式显示 */
/* 列出指定目录下的图片 */ /* 列出指定目录下的图片 */
"imageManagerActionName"=>"listimage", /* 执行图片管理的action名称 */ "imageManagerActionName" => "listimage", /* 执行图片管理的action名称 */
"imageManagerListPath"=>"/file/upload/", /* 指定要列出图片的目录 */ "imageManagerListPath" => "/file/upload/", /* 指定要列出图片的目录 */
"imageManagerListSize"=>20, /* 每次列出文件数量 */ "imageManagerListSize" => 20, /* 每次列出文件数量 */
"imageManagerUrlPrefix"=>"", /* 图片访问路径前缀 */ "imageManagerUrlPrefix" => "", /* 图片访问路径前缀 */
"imageManagerInsertAlign"=>"none", /* 插入的图片浮动方式 */ "imageManagerInsertAlign" => "none", /* 插入的图片浮动方式 */
"imageManagerAllowFiles"=>$imageAllowFiles, /* 列出的文件类型 */ "imageManagerAllowFiles" => $imageAllowFiles, /* 列出的文件类型 */
/* 列出指定目录下的文件 */ /* 列出指定目录下的文件 */
"fileManagerActionName"=>"listfile", /* 执行文件管理的action名称 */ "fileManagerActionName" => "listfile", /* 执行文件管理的action名称 */
"fileManagerListPath"=>"/file/upload/", /* 指定要列出文件的目录 */ "fileManagerListPath" => "/file/upload/", /* 指定要列出文件的目录 */
"fileManagerUrlPrefix"=>"", /* 文件访问路径前缀 */ "fileManagerUrlPrefix" => "", /* 文件访问路径前缀 */
"fileManagerListSize"=>20, /* 每次列出文件数量 */ "fileManagerListSize" => 20, /* 每次列出文件数量 */
"fileManagerAllowFiles"=>$fileAllowFiles "fileManagerAllowFiles" => $fileAllowFiles
]; ];
return json($data); return json($data);
}elseif($action == 'listimage'){ //百度编辑器列出图片 } elseif ($action == 'listimage') { //百度编辑器列出图片
$file = new UploadFile(); $file = new UploadFile();
$where[] = ['isdel','=',0]; $where[] = ['isdel', '=', 0];
$where[] = ['filetype','=','image']; $where[] = ['filetype', '=', 'image'];
$rs = $file->listQuery($where)->toArray(); $rs = $file->listQuery($where)->toArray();
if($rs['total']>0){ if ($rs['total'] > 0) {
$data['start'] = $this->request->param('start',0); $data['start'] = $this->request->param('start', 0);
$data['state'] = 'SUCCESS'; $data['state'] = 'SUCCESS';
$data['total'] = $rs['total']; $data['total'] = $rs['total'];
foreach($rs['data'] as $v){ foreach ($rs['data'] as $v) {
$data['list'][] = ['url'=>$v['fileurl'],'mtime'=>$v['addtime']]; $data['list'][] = ['url' => $v['fileurl'], 'mtime' => $v['addtime']];
} }
}else{ } else {
$data['start'] = 0; $data['start'] = 0;
$data['state'] = 'no match file'; $data['state'] = 'no match file';
$data['total'] = 0; $data['total'] = 0;
$data['list'] = []; $data['list'] = [];
} }
return json($data); return json($data);
}elseif($action == 'listfile'){ //百度编辑器列出附件 } elseif ($action == 'listfile') { //百度编辑器列出附件
$file = new UploadFile(); $file = new UploadFile();
$where[] = ['isdel','=',0]; $where[] = ['isdel', '=', 0];
$where[] = ['filetype','=','file']; $where[] = ['filetype', '=', 'file'];
$rs = $file->listQuery($where)->toArray(); $rs = $file->listQuery($where)->toArray();
if($rs['total']>0){ if ($rs['total'] > 0) {
$data['start'] = $this->request->param('start',0); $data['start'] = $this->request->param('start', 0);
$data['state'] = 'SUCCESS'; $data['state'] = 'SUCCESS';
$data['total'] = $rs['total']; $data['total'] = $rs['total'];
foreach($rs['data'] as $v){ foreach ($rs['data'] as $v) {
$data['list'][] = ['url'=>$v['fileurl'],'mtime'=>$v['addtime']]; $data['list'][] = ['url' => $v['fileurl'], 'mtime' => $v['addtime']];
} }
}else{ } else {
$data['start'] = 0; $data['start'] = 0;
$data['state'] = 'no match file'; $data['state'] = 'no match file';
$data['total'] = 0; $data['total'] = 0;
$data['list'] = []; $data['list'] = [];
} }
return json($data); return json($data);
}else{ } else {
$this->init(); $this->init();
$engine = $this->config['default']; $engine = $this->config['default'];
$this->config['engine'][$engine]['type'] = $action; $this->config['engine'][$engine]['type'] = $action;
...@@ -291,28 +304,28 @@ class Upload extends BaseController ...@@ -291,28 +304,28 @@ class Upload extends BaseController
//设置上传文件的信息 //设置上传文件的信息
$StorageDriver->setUploadFile($file); $StorageDriver->setUploadFile($file);
//上传图片 //上传图片
if(!$StorageDriver->upload()) return $this->returnMsg('上传失败!'.$StorageDriver->getError()); if (!$StorageDriver->upload()) return $this->returnMsg('上传失败!' . $StorageDriver->getError());
//图片上传路径 //图片上传路径
$fileName = $StorageDriver->getFileName(); $fileName = $StorageDriver->getFileName();
//获取图片信息 //获取图片信息
$fileInfo = $StorageDriver->getFileInfo(); $fileInfo = $StorageDriver->getFileInfo();
//保存到数据库 //保存到数据库
$data['storage'] = $engine; $data['storage'] = $engine;
$data['fileurl'] = VT_DIR.$domain.'/'.$fileName; $data['fileurl'] = VT_DIR . $domain . '/' . $fileName;
$data['filename'] = $fileInfo['oname']; $data['filename'] = $fileInfo['oname'];
$data['filesize'] = round($fileInfo['size']/1024,2); $data['filesize'] = round($fileInfo['size'] / 1024, 2);
$data['filetype'] = $action; $data['filetype'] = $action;
$data['groupid'] = intval($groupid)>=0 ? intval($groupid) : 0; $data['groupid'] = intval($groupid) >= 0 ? intval($groupid) : 0;
$data['fileext'] = $fileInfo['ext']; $data['fileext'] = $fileInfo['ext'];
$data['addtime'] = time(); $data['addtime'] = time();
$data['username'] =isset($this->manUser['username']) ? $this->manUser['username'] : 'webapi'; $data['username'] = isset($this->manUser['username']) ? $this->manUser['username'] : 'webapi';
$data['fileid'] = UploadFile::insertGetId($data); $data['fileid'] = UploadFile::insertGetId($data);
//百度编辑器返回数据 //百度编辑器返回数据
$UE['original'] = ''; $UE['original'] = '';
$UE['size'] = $fileInfo['size']; $UE['size'] = $fileInfo['size'];
$UE['state'] = "SUCCESS"; $UE['state'] = "SUCCESS";
$UE['title'] = $data['filename']; $UE['title'] = $data['filename'];
$UE['type'] = '.'.$fileInfo['ext']; $UE['type'] = '.' . $fileInfo['ext'];
$UE['url'] = $data['fileurl']; $UE['url'] = $data['fileurl'];
return json($UE); return json($UE);
} }
...@@ -326,39 +339,39 @@ class Upload extends BaseController ...@@ -326,39 +339,39 @@ class Upload extends BaseController
*/ */
public function files(string $action = '', string $type = 'image') public function files(string $action = '', string $type = 'image')
{ {
if($action=='move'){ if ($action == 'move') {
$d = $this->only(['groupid/d','fileids/a']); $d = $this->only(['groupid/d', 'fileids/a']);
$fileids = implode(',', array_map('intval',$d['fileids'])); $fileids = implode(',', array_map('intval', $d['fileids']));
$rs = UploadFile::update(['groupid'=>$d['groupid']],[['fileid','in',$fileids]]); $rs = UploadFile::update(['groupid' => $d['groupid']], [['fileid', 'in', $fileids]]);
if($rs){ if ($rs) {
return $this->returnMsg("移动成功", 1); return $this->returnMsg("移动成功", 1);
}else{ } else {
return $this->returnMsg("移动失败"); return $this->returnMsg("移动失败");
} }
}elseif($action=='del'){ } elseif ($action == 'del') {
$d = $this->only(['fileids/a']); $d = $this->only(['fileids/a']);
$fileids = implode(',',array_map('intval',$d['fileids'])); $fileids = implode(',', array_map('intval', $d['fileids']));
$rs = UploadFile::update(['isdel'=>1],[['fileid','in',$fileids]]); $rs = UploadFile::update(['isdel' => 1], [['fileid', 'in', $fileids]]);
if($rs){ if ($rs) {
return $this->returnMsg("删除成功", 1); return $this->returnMsg("删除成功", 1);
}else{ } else {
return $this->returnMsg("删除失败"); return $this->returnMsg("删除失败");
} }
} }
//获取文件记录 //获取文件记录
$groupid = $this->request->get('groupid/d',-1); $groupid = $this->request->get('groupid/d', -1);
$file = new UploadFile(); $file = new UploadFile();
$where[] = ['isdel','=',0]; $where[] = ['isdel', '=', 0];
$where[] = ['filetype','=',$type]; $where[] = ['filetype', '=', $type];
if($groupid>-1) $where[] = ['groupid','=',$groupid]; if ($groupid > -1) $where[] = ['groupid', '=', $groupid];
$data['file_list'] = $file->listQuery($where)->toArray(); $data['file_list'] = $file->listQuery($where)->toArray();
//获取文件分类 //获取文件分类
$where = []; $where = [];
$where[] = ['grouptype','=',$type]; $where[] = ['grouptype', '=', $type];
$where[] = ['isdel','=',0]; $where[] = ['isdel', '=', 0];
$data['group_list'] = UploadGroup::where($where)->column('groupid,groupname'); $data['group_list'] = UploadGroup::where($where)->column('groupid,groupname');
//返回json数据 //返回json数据
return $this->returnMsg($data,1); return $this->returnMsg($data, 1);
} }
/** /**
...@@ -368,36 +381,36 @@ class Upload extends BaseController ...@@ -368,36 +381,36 @@ class Upload extends BaseController
*/ */
public function group(string $action = '') public function group(string $action = '')
{ {
if(!$action) return $this->returnMsg('参数错误'); if (!$action) return $this->returnMsg('参数错误');
$d = $this->only(['groupid/d','groupname/h','grouptype/h']); $d = $this->only(['groupid/d', 'groupname/h', 'grouptype/h']);
if($action=='add'){ if ($action == 'add') {
if(!$d['groupname']) return $this->returnMsg("分组名称不能为空"); if (!$d['groupname']) return $this->returnMsg("分组名称不能为空");
$d["addtime"] = time(); $d["addtime"] = time();
$d["listorder"] = 10; $d["listorder"] = 10;
$id = UploadGroup::insertGetId($d); $id = UploadGroup::insertGetId($d);
if($id){ if ($id) {
$d['msg'] = '添加成功'; $d['msg'] = '添加成功';
$d['groupid'] = $id; $d['groupid'] = $id;
return $this->returnMsg($d, 1); return $this->returnMsg($d, 1);
}else{ } else {
return $this->returnMsg("添加失败"); return $this->returnMsg("添加失败");
} }
}elseif($action=='edit'){ } elseif ($action == 'edit') {
if(!$d['groupname']) return $this->returnMsg("分组名称不能为空"); if (!$d['groupname']) return $this->returnMsg("分组名称不能为空");
$d["edittime"] = time(); $d["edittime"] = time();
unset($d['grouptype']); unset($d['grouptype']);
$rs = UploadGroup::update($d); $rs = UploadGroup::update($d);
if($rs !== false){ if ($rs !== false) {
return $this->returnMsg("编辑成功", 1); return $this->returnMsg("编辑成功", 1);
}else{ } else {
return $this->returnMsg("编辑失败"); return $this->returnMsg("编辑失败");
} }
}elseif($action=='del'){ } elseif ($action == 'del') {
$groupid = $d['groupid']; $groupid = $d['groupid'];
$rs = UploadGroup::del("groupid IN($groupid)"); $rs = UploadGroup::del("groupid IN($groupid)");
if($rs){ if ($rs) {
return $this->returnMsg("删除成功", 1); return $this->returnMsg("删除成功", 1);
}else{ } else {
return $this->returnMsg("删除失败"); return $this->returnMsg("删除失败");
} }
} }
......
...@@ -34,6 +34,11 @@ class User extends AdminBase ...@@ -34,6 +34,11 @@ class User extends AdminBase
$map[] = ['username|mobile|realname', 'like', '%' . $post['kw'] . '%']; $map[] = ['username|mobile|realname', 'like', '%' . $post['kw'] . '%'];
} }
if (isset($post['role']) && !empty($post['role'])) {
$map[] = ['role', '=', $post['role']];
}
$list = $this->user->where($map)->append(['headericourl', 'sexdata', 'roletxt'])->paginate($post['limit']); $list = $this->user->where($map)->append(['headericourl', 'sexdata', 'roletxt'])->paginate($post['limit']);
return $this->returnMsg($list); return $this->returnMsg($list);
} }
...@@ -91,7 +96,7 @@ class User extends AdminBase ...@@ -91,7 +96,7 @@ class User extends AdminBase
{ {
$post = input(); $post = input();
$user = $this->user->find($post['id']); $user = $this->user->find($post['id']);
$pwd = md5('123456' . $user['salt']); $pwd = md5('ls123456' . $user['salt']);
$result = $this->user->where('id', $post['id'])->update(['password' => $pwd]); $result = $this->user->where('id', $post['id'])->update(['password' => $pwd]);
if ($result) { if ($result) {
return $this->returnMsg("成功", 1); return $this->returnMsg("成功", 1);
......
...@@ -12,7 +12,15 @@ ...@@ -12,7 +12,15 @@
<div class="layui-inline" style="width:250px;"><input type="text" name="kw" placeholder="关键词" autocomplete="off" class="layui-input" lay-affix="clear"/></div> <div class="layui-inline" style="width:250px;"><input type="text" name="kw" placeholder="关键词" autocomplete="off" class="layui-input" lay-affix="clear"/></div>
<div class="layui-inline" style="width:150px;">
<select name="role">
<option value="">审核状态</option>
<option value="1" >普通用户</option>
<option value="2" >企业用户</option>
<option value="3" >高校用户</option>
</select>
</div>
<div class="layui-inline"> <div class="layui-inline">
<div class="layui-btn-group"> <div class="layui-btn-group">
...@@ -139,7 +147,7 @@ ...@@ -139,7 +147,7 @@
usermoneylogOpen(id); usermoneylogOpen(id);
}else if(menudata.id === 'restpwd'){ }else if(menudata.id === 'restpwd'){
layer.confirm('确定要重置【'+data.username+'】的密码为123456?', function(){ layer.confirm('确定要重置【'+data.username+'】的密码为ls123456?', function(){
$.ajax({ $.ajax({
method: "post", method: "post",
url: layui.cache.maps+'/users.user/resetpwd', url: layui.cache.maps+'/users.user/resetpwd',
......
...@@ -25,7 +25,7 @@ class ShCourse extends BaseController ...@@ -25,7 +25,7 @@ class ShCourse extends BaseController
$where = ['sh_course.is_del' => 0, 'user_id' => $request->userId]; $where = ['sh_course.is_del' => 0, 'user_id' => $request->userId];
$map = []; $map = [];
if (isset($parm['searchKeyWords']) && $parm['searchKeyWords']) { if (isset($parm['searchKeyWords']) && $parm['searchKeyWords']) {
$map[] = ['title', 'like', '%' . $parm['searchKeyWords'] . '%']; $map[] = ['sh_course.title', 'like', '%' . $parm['searchKeyWords'] . '%'];
} }
if (isset($parm['status']) && $parm['status'] || $parm['status'] === '0') { if (isset($parm['status']) && $parm['status'] || $parm['status'] === '0') {
$map[] = ['status', '=', $parm['status']]; $map[] = ['status', '=', $parm['status']];
...@@ -38,8 +38,8 @@ class ShCourse extends BaseController ...@@ -38,8 +38,8 @@ class ShCourse extends BaseController
$start_time = strtotime($parm['start_time']); $start_time = strtotime($parm['start_time']);
$end_time = strtotime($parm['end_time']); $end_time = strtotime($parm['end_time']);
$map[] = ['createtime', '>=', $start_time]; $map[] = ['sh_course.createtime', '>=', $start_time];
$map[] = ['createtime', '<=', $end_time]; $map[] = ['sh_course.createtime', '<=', $end_time];
} }
$page = $request->param('page', 1); $page = $request->param('page', 1);
......
...@@ -134,7 +134,8 @@ class Student extends BaseController ...@@ -134,7 +134,8 @@ class Student extends BaseController
return $vo; return $vo;
} }
$parm = $request->param(); $parm = $request->param();
$result = StudentModel::destroy([$parm['student_id']]); $student_id = is_array($parm['student_id']) ? $parm['student_id'] : explode(',', $parm['student_id']);
$result = StudentModel::destroy($student_id);
return $this->returnMsg('success', 1, $result); return $this->returnMsg('success', 1, $result);
} }
......
...@@ -39,6 +39,25 @@ class Aliyun extends Server ...@@ -39,6 +39,25 @@ class Aliyun extends Server
*/ */
public function upload() public function upload()
{ {
$type = $this->config['type'];
$type = isset($this->config[$type]) && is_array($this->config[$type]) ? $type : 'image';
$ext = $this->config[$type]['ext'];
$size = $this->config[$type]['size'];
try{
validate(['file'=>[
'fileSize' => $size * 1024 * 1024,
'fileExt' => $ext
]],[
'file.fileSize' => '上传的文件大小不能超过'.$size.'M',
'file.fileExt' => '请上传后缀为:'.$ext.'的文件'
])->check(['file'=> $this->file]);
}catch(\think\exception\ValidateException $e){
$this->error = $e->getError();
return false;
}
try { try {
$ossClient = new OssClient( $ossClient = new OssClient(
$this->config['access_key_id'], $this->config['access_key_id'],
......
...@@ -44,6 +44,7 @@ abstract class Server ...@@ -44,6 +44,7 @@ abstract class Server
{ {
// 接收上传的文件 // 接收上传的文件
$this->file = request()->file($name); $this->file = request()->file($name);
if (empty($this->file)) { if (empty($this->file)) {
throw new Exception('未找到上传文件的信息'); throw new Exception('未找到上传文件的信息');
} }
...@@ -97,6 +98,7 @@ abstract class Server ...@@ -97,6 +98,7 @@ abstract class Server
{ {
// 要上传图片的本地路径 // 要上传图片的本地路径
$realPath = $this->file->getRealPath(); $realPath = $this->file->getRealPath();
// 扩展名 // 扩展名
$ext = $this->file->getOriginalExtension(); $ext = $this->file->getOriginalExtension();
// 自动生成文件名 // 自动生成文件名
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment