mirror of
https://github.com/crmeb/CRMEB.git
synced 2025-12-10 17:42:50 +00:00
139 lines
3.7 KiB
PHP
139 lines
3.7 KiB
PHP
<?php
|
||
// +----------------------------------------------------------------------
|
||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||
// +----------------------------------------------------------------------
|
||
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
|
||
// +----------------------------------------------------------------------
|
||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||
// +----------------------------------------------------------------------
|
||
// | Author: CRMEB Team <admin@crmeb.com>
|
||
// +----------------------------------------------------------------------
|
||
namespace app\adminapi\controller\v1\file;
|
||
|
||
use app\adminapi\controller\AuthController;
|
||
use app\services\system\attachment\SystemAttachmentServices;
|
||
use think\facade\App;
|
||
|
||
/**
|
||
* 附件管理类
|
||
* Class SystemAttachment
|
||
* @package app\adminapi\controller\v1\file
|
||
*/
|
||
class SystemAttachment extends AuthController
|
||
{
|
||
/**
|
||
* @var SystemAttachmentServices
|
||
*/
|
||
protected $service;
|
||
|
||
/**
|
||
* @param App $app
|
||
* @param SystemAttachmentServices $service
|
||
*/
|
||
public function __construct(App $app, SystemAttachmentServices $service)
|
||
{
|
||
parent::__construct($app);
|
||
$this->service = $service;
|
||
}
|
||
|
||
/**
|
||
* 显示列表
|
||
* @return mixed
|
||
*/
|
||
public function index()
|
||
{
|
||
$where = $this->request->getMore([
|
||
['pid', 0]
|
||
]);
|
||
return app('json')->success($this->service->getImageList($where));
|
||
}
|
||
|
||
/**
|
||
* 删除指定资源
|
||
* @return mixed
|
||
*/
|
||
public function delete()
|
||
{
|
||
[$ids] = $this->request->postMore([
|
||
['ids', '']
|
||
], true);
|
||
$this->service->del($ids);
|
||
return app('json')->success(100002);
|
||
}
|
||
|
||
/**
|
||
* 图片上传
|
||
* @param int $upload_type
|
||
* @param int $type
|
||
* @return mixed
|
||
*/
|
||
public function upload($upload_type = 0, $type = 0)
|
||
{
|
||
[$pid, $file, $menuName] = $this->request->postMore([
|
||
['pid', 0],
|
||
['file', 'file'],
|
||
['menu_name', '']
|
||
], true);
|
||
$res = $this->service->upload((int)$pid, $file, $upload_type, $type, $menuName);
|
||
return app('json')->success(100032, ['src' => $res]);
|
||
}
|
||
|
||
/**
|
||
* 移动图片
|
||
* @return mixed
|
||
*/
|
||
public function moveImageCate()
|
||
{
|
||
$data = $this->request->postMore([
|
||
['pid', 0],
|
||
['images', '']
|
||
]);
|
||
$this->service->move($data);
|
||
return app('json')->success(100034);
|
||
}
|
||
|
||
/**
|
||
* 修改文件名
|
||
* @param $id
|
||
* @return mixed
|
||
*/
|
||
public function update($id)
|
||
{
|
||
$realName = $this->request->post('real_name', '');
|
||
if (!$realName) {
|
||
return app('json')->fail(400104);
|
||
}
|
||
$this->service->update($id, ['real_name' => $realName]);
|
||
return app('json')->success(100001);
|
||
}
|
||
|
||
/**
|
||
* 获取上传类型
|
||
* @return mixed
|
||
*/
|
||
public function uploadType()
|
||
{
|
||
$data['upload_type'] = (string)sys_config('upload_type', 1);
|
||
return app('json')->success($data);
|
||
}
|
||
|
||
/**
|
||
* 视频分片上传
|
||
* @return mixed
|
||
*/
|
||
public function videoUpload()
|
||
{
|
||
$data = $this->request->postMore([
|
||
['chunkNumber', 0],//第几分片
|
||
['currentChunkSize', 0],//分片大小
|
||
['chunkSize', 0],//总大小
|
||
['totalChunks', 0],//分片总数
|
||
['file', 'file'],//文件
|
||
['md5', ''],//MD5
|
||
['filename', ''],//文件名称
|
||
]);
|
||
$res = $this->service->videoUpload($data, $_FILES['file']);
|
||
return app('json')->success($res);
|
||
}
|
||
}
|