4
This commit is contained in:
@@ -85,8 +85,8 @@ class ArchivesController extends Crud
|
||||
$result = $this->model->save($params);
|
||||
Db::commit();
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
return $this->fail($e->getMessage());
|
||||
Db::rollback();
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
if ($result === false) {
|
||||
return $this->fail(__('No rows were inserted'));
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\admin\app\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use support\think\Db;
|
||||
use taoser\facade\Validate;
|
||||
use Shopwwi\WebmanFilesystem\Facade\Storage;
|
||||
|
||||
/**
|
||||
* 附件管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AttachController extends Crud
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \app\model\Files
|
||||
*/
|
||||
protected $model = null;
|
||||
/**
|
||||
* 构造函数
|
||||
* @return void
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
$this->model = new \app\model\Files();
|
||||
}
|
||||
function list(Request $request)
|
||||
{
|
||||
return view('', [
|
||||
|
||||
]);
|
||||
}
|
||||
function feupload(Request $request): Response
|
||||
{
|
||||
$user = ['id'=>admin_id()];
|
||||
$savePath = $request->post('savePath','files');
|
||||
$validate = Validate::rule('savePath', 'alphaNum');
|
||||
$data = ['savePath' => $savePath];
|
||||
if (!$validate->check($data)) {
|
||||
return $this->fail( '参数错误:'.$validate->getError());
|
||||
}
|
||||
$savePath = trim($savePath,'/');
|
||||
$savePath = 'upload/'.$savePath.'/'.$user['id'];
|
||||
$maxSize = 1024*1024*100; //100M
|
||||
//多文件上传
|
||||
$files = $request->file();
|
||||
try {
|
||||
$result = Storage::adapter('public')
|
||||
->path($savePath)
|
||||
->size(1024*1024*10)
|
||||
->extYes(['image/jpeg','image/png'])
|
||||
->uploads($files,0,$maxSize,false);
|
||||
$save_datas = [];
|
||||
foreach($result as $k=>$fileinfo){
|
||||
$save_datas[] = [
|
||||
'user_id' => $user['id'],
|
||||
'title' => $fileinfo->origin_name,
|
||||
'path' => $fileinfo->file_name,
|
||||
'size' => $fileinfo->size,
|
||||
'mime_type' => $fileinfo->mime_type,
|
||||
'extension' => $fileinfo->extension,
|
||||
'height' => $fileinfo->file_height,
|
||||
'width' => $fileinfo->file_width,
|
||||
'sha1' => sha1_file(public_path($fileinfo->file_name)),
|
||||
'use_count' => 0,
|
||||
];
|
||||
}
|
||||
\app\model\Files::saveAll($save_datas);
|
||||
return $this->success(__('successful'),[
|
||||
'link' => $result[0]['path'],
|
||||
]);
|
||||
}catch (\Exception $e){
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
function upload(Request $request): Response
|
||||
{
|
||||
log_alert(0);
|
||||
$savePath = $request->post('savePath','files');
|
||||
$validate = Validate::rule('savePath', 'alphaNum');
|
||||
$data = ['savePath' => $savePath];
|
||||
log_alert($data);
|
||||
if (!$validate->check($data)) {
|
||||
cp($validate->getError());
|
||||
return $this->fail( '参数错误:'.$validate->getError());
|
||||
}
|
||||
log_alert('1');
|
||||
$file = current($request->file());
|
||||
if (!$file || !$file->isValid()) {
|
||||
return $this->fail('未找到文件');
|
||||
}
|
||||
log_alert('2');
|
||||
try {
|
||||
$data = $this->base($request, $savePath);
|
||||
} catch (\Exception $e) {
|
||||
log_alert($e->getMessage());
|
||||
//throw $th;
|
||||
}
|
||||
log_alert('3');
|
||||
//cp($data);
|
||||
return $this->success( '上传成功', [
|
||||
'url' => $data['realpath'],
|
||||
'name' => $data['name'],
|
||||
'fullurl' => $data['url'],
|
||||
'size' => $data['size'],
|
||||
'url1' => $data['url'],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上传数据
|
||||
* @param Request $request
|
||||
* @param $savePath 保存位置
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function base(Request $request, $savePath): array
|
||||
{
|
||||
$user = ['id'=>admin_id()];
|
||||
// 适配器 local默认是存储在runtime目录下 public默认是存储在public目录下
|
||||
// 可访问的静态文件建议public
|
||||
// 默认适配器是local
|
||||
//Storage::adapter('public');
|
||||
$savePath = trim($savePath,'/');
|
||||
$savePath = 'upload/'.$savePath;
|
||||
cp($savePath);
|
||||
$file = current($request->file());
|
||||
cp($file);
|
||||
$mimetype = explode(',',Config('site.upload_mimetype'));
|
||||
$maxsize = Config('site.upload_maxsize')*1024*1024;
|
||||
$result = Storage::adapter('public')
|
||||
->path($savePath)
|
||||
->size($maxsize)
|
||||
->extYes($mimetype)
|
||||
->upload($file);
|
||||
cp($result);
|
||||
|
||||
$save_datas = [
|
||||
'user_id' => $user['id'],
|
||||
'category' => 'default',
|
||||
'title' => $result->origin_name,
|
||||
'path' => $result->file_name,
|
||||
'size' => $result->size,
|
||||
'mime_type' => $result->mime_type,
|
||||
'extension' => $result->extension,
|
||||
'height' => $result->file_height,
|
||||
'width' => $result->file_width,
|
||||
'sha1' => sha1_file(public_path($result->file_name)),
|
||||
'use_count' => 0,
|
||||
];
|
||||
(new \app\model\Files)->save($save_datas);
|
||||
return [
|
||||
'code' => 0,
|
||||
'url' => $result->file_url,
|
||||
'name' => $result->origin_name,
|
||||
'realpath' => '/'.$result->file_name,
|
||||
'size' => $result->size,
|
||||
'mime_type' => $result->mime_type,
|
||||
'image_with'=> $result->file_width,
|
||||
'image_height' => $result->file_height,
|
||||
'ext' => $result->extension,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\admin\app\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use support\think\Db;
|
||||
use Shopwwi\WebmanFilesystem\Facade\Storage;
|
||||
|
||||
/**
|
||||
* 附件管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AttachmentController extends Crud
|
||||
{
|
||||
function list(Request $request)
|
||||
{
|
||||
|
||||
return view('', [
|
||||
|
||||
]);
|
||||
}
|
||||
function feupload(Request $request): Response
|
||||
{
|
||||
|
||||
$file = current($request->file());
|
||||
if (!$file || !$file->isValid()) {
|
||||
return $this->fail('未找到文件');
|
||||
}
|
||||
$data = $this->base($request, '/upload/files/' . date('Ymd'));
|
||||
return json([
|
||||
'link' => $data['url'],
|
||||
]);
|
||||
}
|
||||
function upload(Request $request): Response
|
||||
{
|
||||
|
||||
$file = current($request->file());
|
||||
if (!$file || !$file->isValid()) {
|
||||
return $this->fail('未找到文件');
|
||||
}
|
||||
$data = $this->base($request, '/upload/files/' . date('Ymd'));
|
||||
//cp($data);
|
||||
return $this->json(0, '上传成功', [
|
||||
'url' => $data['realpath'],
|
||||
'name' => $data['name'],
|
||||
'fullurl' => $data['url'],
|
||||
'size' => $data['size'],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上传数据
|
||||
* @param Request $request
|
||||
* @param $relative_dir
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function base(Request $request, $relative_dir): array
|
||||
{
|
||||
// 适配器 local默认是存储在runtime目录下 public默认是存储在public目录下
|
||||
// 可访问的静态文件建议public
|
||||
// 默认适配器是local
|
||||
//Storage::adapter('public');
|
||||
$relative_dir = ltrim($relative_dir, '\\/');
|
||||
$file = current($request->file());
|
||||
try {
|
||||
if (!$file || !$file->isValid()) {
|
||||
throw new \support\exception\BusinessException('未找到上传文件', 400);
|
||||
}
|
||||
|
||||
$ext = $file->getUploadExtension() ?: null;
|
||||
$mime_type = $file->getUploadMimeType();
|
||||
$file_name = $file->getUploadName();
|
||||
$file_size = $file->getSize();
|
||||
|
||||
if (!$ext && $file_name === 'blob') {
|
||||
[$___image, $ext] = explode('/', $mime_type);
|
||||
unset($___image);
|
||||
}
|
||||
|
||||
$ext = strtolower($ext);
|
||||
$ext_forbidden_map = ['php', 'php3', 'php5', 'css', 'js', 'html', 'htm', 'asp', 'jsp'];
|
||||
if (in_array($ext, $ext_forbidden_map)) {
|
||||
throw new \support\exception\BusinessException('不支持该格式的文件上传', 400);
|
||||
}
|
||||
$mimetype = explode(',',Config('site.mimetype'));
|
||||
$result = Storage::adapter('public')
|
||||
->path($relative_dir)
|
||||
->size(1024 * 1024 * 5)
|
||||
->extYes($mimetype)
|
||||
//->extNo(['image/png'])
|
||||
->upload($file);
|
||||
} catch (\Exception $e) {
|
||||
return [
|
||||
'code' => 1,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
// cp($result);
|
||||
// stdClass Object
|
||||
// (
|
||||
// [adapter] => public
|
||||
// [origin_name] => OIP-C (1).jpg
|
||||
// [file_name] => upload/files/20250527/eb14c1bfe6e7a22415bbbb30dfe90ba1_6834f0974db76.jpg
|
||||
// [storage_key] => eb14c1bfe6e7a22415bbbb30dfe90ba1_6834f0974db76
|
||||
// [file_url] => //luru.oss-ap-southeast-1.aliyuncs.com/upload/files/20250527/eb14c1bfe6e7a22415bbbb30dfe90ba1_6834f0974db76.jpg
|
||||
// [size] => 15370
|
||||
// [mime_type] => image/jpeg
|
||||
// [extension] => jpg
|
||||
// [file_height] => 474
|
||||
// [file_width] => 474
|
||||
// )
|
||||
return [
|
||||
'code' => 0,
|
||||
'url' => $result->file_url,
|
||||
'name' => $result->origin_name,
|
||||
'realpath' => '/'.$result->file_name,
|
||||
'size' => $result->size,
|
||||
'mime_type' => $result->mime_type,
|
||||
'image_with' => $result->file_width,
|
||||
'image_height' => $result->file_height,
|
||||
'ext' => $result->extension,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\admin\app\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use support\think\Db;
|
||||
use taoser\facade\Validate;
|
||||
use Shopwwi\WebmanFilesystem\Facade\Storage;
|
||||
|
||||
/**
|
||||
* 附件管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class FilesController extends Crud
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \app\model\Files
|
||||
*/
|
||||
protected $model = null;
|
||||
/**
|
||||
* 构造函数
|
||||
* @return void
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
$this->model = new \app\model\Files();
|
||||
}
|
||||
function list(Request $request)
|
||||
{
|
||||
return view('', [
|
||||
|
||||
]);
|
||||
}
|
||||
function feupload(Request $request): Response
|
||||
{
|
||||
$user = ['id'=>admin_id()];
|
||||
$savePath = $request->post('savePath','files');
|
||||
$validate = Validate::rule('savePath', 'alphaNum');
|
||||
$data = ['savePath' => $savePath];
|
||||
if (!$validate->check($data)) {
|
||||
return $this->fail( '参数错误:'.$validate->getError());
|
||||
}
|
||||
$savePath = trim($savePath,'/');
|
||||
$savePath = 'upload/'.$savePath.'/'.$user['id'];
|
||||
$maxSize = 1024*1024*100; //100M
|
||||
//多文件上传
|
||||
$files = $request->file();
|
||||
try {
|
||||
$result = Storage::adapter('public')
|
||||
->path($savePath)
|
||||
->size(1024*1024*10)
|
||||
->extYes(['image/jpeg','image/png'])
|
||||
->uploads($files,0,$maxSize,false);
|
||||
$save_datas = [];
|
||||
foreach($result as $k=>$fileinfo){
|
||||
$save_datas[] = [
|
||||
'user_id' => $user['id'],
|
||||
'title' => $fileinfo->origin_name,
|
||||
'path' => $fileinfo->file_name,
|
||||
'size' => $fileinfo->size,
|
||||
'mime_type' => $fileinfo->mime_type,
|
||||
'extension' => $fileinfo->extension,
|
||||
'height' => $fileinfo->file_height,
|
||||
'width' => $fileinfo->file_width,
|
||||
'sha1' => sha1_file(public_path($fileinfo->file_name)),
|
||||
'use_count' => 0,
|
||||
];
|
||||
}
|
||||
\app\model\Files::saveAll($save_datas);
|
||||
return $this->success(__('successful'),[
|
||||
'link' => $result[0]['path'],
|
||||
]);
|
||||
}catch (\Exception $e){
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
function upload(Request $request): Response
|
||||
{
|
||||
cp('0');
|
||||
$savePath = $request->post('savePath','files');
|
||||
$validate = Validate::rule('savePath', 'alphaNum');
|
||||
$data = ['savePath' => $savePath];
|
||||
cp($data);
|
||||
if (!$validate->check($data)) {
|
||||
cp($validate->getError());
|
||||
return $this->fail( '参数错误:'.$validate->getError());
|
||||
}
|
||||
cp('1');
|
||||
$file = current($request->file());
|
||||
if (!$file || !$file->isValid()) {
|
||||
return $this->fail('未找到文件');
|
||||
}
|
||||
cp('2');
|
||||
$data = $this->base($request, $savePath);
|
||||
cp('3');
|
||||
//cp($data);
|
||||
return $this->success( '上传成功', [
|
||||
'url' => $data['realpath'],
|
||||
'name' => $data['name'],
|
||||
'fullurl' => $data['url'],
|
||||
'size' => $data['size'],
|
||||
'url1' => $data['url'],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上传数据
|
||||
* @param Request $request
|
||||
* @param $savePath 保存位置
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function base(Request $request, $savePath): array
|
||||
{
|
||||
$user = ['id'=>admin_id()];
|
||||
// 适配器 local默认是存储在runtime目录下 public默认是存储在public目录下
|
||||
// 可访问的静态文件建议public
|
||||
// 默认适配器是local
|
||||
//Storage::adapter('public');
|
||||
$savePath = trim($savePath,'/');
|
||||
$savePath = 'upload/'.$savePath;
|
||||
$file = current($request->file());
|
||||
$mimetype = explode(',',Config('site.upload_mimetype'));
|
||||
$maxsize = Config('site.upload_maxsize')*1024*1024;
|
||||
$result = Storage::adapter('public')
|
||||
->path($savePath)
|
||||
->size($maxsize)
|
||||
->extYes($mimetype)
|
||||
->upload($file);
|
||||
|
||||
$save_datas = [
|
||||
'user_id' => $user['id'],
|
||||
'category' => 'default',
|
||||
'title' => $result->origin_name,
|
||||
'path' => $result->file_name,
|
||||
'size' => $result->size,
|
||||
'mime_type' => $result->mime_type,
|
||||
'extension' => $result->extension,
|
||||
'height' => $result->file_height,
|
||||
'width' => $result->file_width,
|
||||
'sha1' => sha1_file(public_path($result->file_name)),
|
||||
'use_count' => 0,
|
||||
];
|
||||
(new \app\model\Files)->save($save_datas);
|
||||
return [
|
||||
'code' => 0,
|
||||
'url' => $result->file_url,
|
||||
'name' => $result->origin_name,
|
||||
'realpath' => '/'.$result->file_name,
|
||||
'size' => $result->size,
|
||||
'mime_type' => $result->mime_type,
|
||||
'image_with'=> $result->file_width,
|
||||
'image_height' => $result->file_height,
|
||||
'ext' => $result->extension,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ class IndexController extends Base
|
||||
$admin = admin();
|
||||
if (!$admin) {
|
||||
$title = config('site.name') ?? 'admin';
|
||||
$logo = cdnurl(config('site.admin_logo') ?? '/app/admin/images/logo.png');
|
||||
$logo = cdnurl(config('site.admin_logo') ?? admin_path().'/images/logo.png');
|
||||
return view('account/login',['logo'=>$logo,'title'=>$title]);
|
||||
}
|
||||
//缓存
|
||||
|
||||
@@ -8,7 +8,7 @@ use support\Request;
|
||||
use support\Response;
|
||||
|
||||
/**
|
||||
* 用户管理
|
||||
* 团队管理
|
||||
*/
|
||||
class TeamController extends Crud
|
||||
{
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\admin\app\controller;
|
||||
use plugin\admin\app\controller\Crud;
|
||||
use app\model\Thali;
|
||||
use support\exception\BusinessException;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
|
||||
/**
|
||||
* 套餐管理
|
||||
*/
|
||||
class ThaliController extends Crud
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Thali
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
* @return void
|
||||
*/
|
||||
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$this->model = new Thali();
|
||||
$statusList = $this->model->getStatusList();
|
||||
$this->assign("statusList", $statusList);
|
||||
$this->assignconfig("statusList", $statusList);
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ class UserController extends Crud
|
||||
['value'=>1,'label'=>"内部用户"],
|
||||
['value'=>2,'label'=>"联盟商"],
|
||||
];
|
||||
$roleList = \app\model\UserRole::order('id','desc')->column('name as label,id as value');
|
||||
$roleList = \app\model\UserRole::order('id','asc')->column('name as label,id as value');
|
||||
$this->assign('groupList',$groupList);
|
||||
$this->assignconfig('groupList',$groupList);
|
||||
$this->assign('roleList',$roleList);
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\admin\app\controller;
|
||||
|
||||
use app\model\User;
|
||||
use plugin\admin\app\controller\Crud;
|
||||
use support\exception\BusinessException;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* 版本管理
|
||||
*/
|
||||
class VersionController extends Crud
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \app\model\Version
|
||||
*/
|
||||
protected $model = null;
|
||||
/**
|
||||
* 构造函数
|
||||
* @return void
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
$this->model = new \app\model\Version();
|
||||
$osList = $this->model->getOsList();
|
||||
$this->assign("osList", $osList);
|
||||
$this->assignconfig("osList", $osList);
|
||||
$forceList = $this->model->getForceList();
|
||||
$this->assign("forceList", $forceList);
|
||||
$this->assignconfig("forceList", $forceList);
|
||||
$typeList = $this->model->getTypeList();
|
||||
$this->assign("typeList", $typeList);
|
||||
$this->assignconfig("typeList", $typeList);
|
||||
$statusList = $this->model->getStatusList();
|
||||
$this->assign("statusList", $statusList);
|
||||
$this->assignconfig("statusList", $statusList);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user