Merge branch 'master' of github.com:kuaifan/dootask into develop
# Conflicts: # app/Http/Controllers/Api/DialogController.php # electron/package.json # package.json # public/css/app.css # public/js/app.js # public/js/build/146.js # public/js/build/146.js.LICENSE.txt # public/js/build/178.js # public/js/build/178.js.LICENSE.txt # public/js/build/199.js # public/js/build/199.js.LICENSE.txt # public/js/build/309.js # public/js/build/328.js.LICENSE.txt # public/js/build/388.js # public/js/build/43.js # public/js/build/46.js.LICENSE.txt # public/js/build/857.js # public/js/build/857.js.LICENSE.txt # public/js/build/893.js
This commit is contained in:
@@ -12,6 +12,7 @@ use App\Models\WebSocketDialogUser;
|
||||
use App\Module\Base;
|
||||
use Carbon\Carbon;
|
||||
use Request;
|
||||
use Response;
|
||||
|
||||
/**
|
||||
* @apiDefine dialog
|
||||
@@ -329,6 +330,38 @@ class DialogController extends AbstractController
|
||||
return Base::retSuccess('success', $read ?: []);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} api/dialog/msg/download 09. 文件下载
|
||||
*
|
||||
* @apiDescription 需要token身份
|
||||
* @apiVersion 1.0.0
|
||||
* @apiGroup dialog
|
||||
* @apiName msg__download
|
||||
*
|
||||
* @apiParam {Number} msg_id 消息ID
|
||||
*
|
||||
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
||||
* @apiSuccess {String} msg 返回信息(错误描述)
|
||||
* @apiSuccess {Object} data 返回数据
|
||||
*/
|
||||
public function msg__download()
|
||||
{
|
||||
User::auth();
|
||||
//
|
||||
$msg_id = intval(Request::input('msg_id'));
|
||||
//
|
||||
$msg = WebSocketDialogMsg::whereId($msg_id)->first();
|
||||
if (empty($msg)) {
|
||||
abort(403, "This file not exist.");
|
||||
}
|
||||
if ($msg->type != 'file') {
|
||||
abort(403, "This file not support download.");
|
||||
}
|
||||
$array = Base::json2array($msg->getRawOriginal('msg'));
|
||||
//
|
||||
return Response::download(public_path($array['path']), $array['name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 聊天消息撤回
|
||||
* @return array
|
||||
@@ -342,19 +375,19 @@ class DialogController extends AbstractController
|
||||
return Base::retError("此消息不可撤回");
|
||||
}
|
||||
$send_dt = Carbon::parse($msg->created_at)->addMinutes(5);
|
||||
if ( $send_dt->lt( Carbon::now() ) )
|
||||
if ($send_dt->lt(Carbon::now()))
|
||||
return Base::retError("已超过5分钟,此消息不能撤回");
|
||||
|
||||
|
||||
// 删除文件、图片
|
||||
if ( $msg->type == WebSocketDialogMsg::MSG_TYPE_FILE) {
|
||||
if ($msg->type == WebSocketDialogMsg::MSG_TYPE_FILE) {
|
||||
if (is_array($msg->msg)) {
|
||||
// 删除本体
|
||||
if ( !empty( $msg->msg["file"] ) )
|
||||
@unlink( $msg->msg["file"] );
|
||||
if (!empty($msg->msg["file"]))
|
||||
@unlink($msg->msg["file"]);
|
||||
// 删除缩略图
|
||||
if ( !empty( $msg->msg["thumb"] ) )
|
||||
@unlink( $msg->msg["thumb"] );
|
||||
if (!empty($msg->msg["thumb"]))
|
||||
@unlink($msg->msg["thumb"]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,6 +399,7 @@ class DialogController extends AbstractController
|
||||
// WebSocketDialogMsg::sendMsg($msg->dialog_id, 'withdraw', [
|
||||
// "msg_id" => $msg->id, // 被撤回的消息Id
|
||||
// ], $user->userid);
|
||||
|
||||
return Base::retSuccess("success");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
|
||||
use App\Exceptions\ApiException;
|
||||
use App\Models\AbstractModel;
|
||||
use App\Models\File;
|
||||
use App\Models\FileContent;
|
||||
@@ -205,7 +206,6 @@ class FileController extends AbstractController
|
||||
'folder',
|
||||
'document',
|
||||
'mind',
|
||||
'sheet',
|
||||
'flow',
|
||||
'word',
|
||||
'excel',
|
||||
@@ -382,6 +382,9 @@ class FileController extends AbstractController
|
||||
* @apiParam {Number|String} id
|
||||
* - Number 文件ID(需要登录)
|
||||
* - String 链接码(不需要登录,用于预览)
|
||||
* @apiParam {String} down 直接下载
|
||||
* - no: 浏览(默认)
|
||||
* - yes: 下载
|
||||
*
|
||||
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
||||
* @apiSuccess {String} msg 返回信息(错误描述)
|
||||
@@ -390,6 +393,7 @@ class FileController extends AbstractController
|
||||
public function content()
|
||||
{
|
||||
$id = Request::input('id');
|
||||
$down = Request::input('down', 'no');
|
||||
//
|
||||
if (Base::isNumber($id)) {
|
||||
User::auth();
|
||||
@@ -405,7 +409,7 @@ class FileController extends AbstractController
|
||||
}
|
||||
//
|
||||
$content = FileContent::whereFid($file->id)->orderByDesc('id')->first();
|
||||
return FileContent::formatContent($file->type, $content ? $content->content : []);
|
||||
return FileContent::formatContent($file, $content?->content, $down == 'yes');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -543,6 +547,7 @@ class FileController extends AbstractController
|
||||
$user = User::auth();
|
||||
//
|
||||
$pid = intval(Request::input('pid'));
|
||||
$webkitRelativePath = Request::input('webkitRelativePath');
|
||||
//
|
||||
$userid = $user->userid;
|
||||
if ($pid > 0) {
|
||||
@@ -557,7 +562,34 @@ class FileController extends AbstractController
|
||||
}
|
||||
}
|
||||
//
|
||||
$path = 'uploads/office/' . date("Ym") . '/u' . $user->userid . '/';
|
||||
$dirs = explode("/", $webkitRelativePath);
|
||||
AbstractModel::transaction(function() use ($user, $userid, $dirs, &$pid) {
|
||||
while (count($dirs) > 1) {
|
||||
$dirName = array_shift($dirs);
|
||||
if ($dirName) {
|
||||
$dirRow = File::wherePid($pid)->whereType('folder')->whereName($dirName)->lockForUpdate()->first();
|
||||
if (empty($dirRow)) {
|
||||
$dirRow = File::createInstance([
|
||||
'pid' => $pid,
|
||||
'type' => 'folder',
|
||||
'name' => $dirName,
|
||||
'userid' => $userid,
|
||||
'created_id' => $user->userid,
|
||||
]);
|
||||
if ($dirRow->save()) {
|
||||
$tmpRow = File::find($dirRow->id);
|
||||
$tmpRow->pushMsg('add', $tmpRow);
|
||||
}
|
||||
}
|
||||
if (empty($dirRow)) {
|
||||
throw new ApiException('创建文件夹失败');
|
||||
}
|
||||
$pid = $dirRow->id;
|
||||
}
|
||||
}
|
||||
});
|
||||
//
|
||||
$path = 'uploads/file/' . date("Ym") . '/u' . $user->userid . '/';
|
||||
$data = Base::upload([
|
||||
"file" => Request::file('files'),
|
||||
"type" => 'more',
|
||||
@@ -581,8 +613,13 @@ class FileController extends AbstractController
|
||||
'ofd' => "ofd",
|
||||
'pdf' => "pdf",
|
||||
'txt' => "txt",
|
||||
'html', 'htm', 'asp', 'jsp', 'xml', 'json', 'properties', 'md', 'gitignore', 'log', 'java', 'py', 'c', 'cpp', 'sql', 'sh', 'bat', 'm', 'bas', 'prg', 'cmd',
|
||||
'php', 'go', 'python', 'js', 'ftl', 'css', 'lua', 'rb', 'yaml', 'yml', 'h', 'cs', 'aspx' => "code",
|
||||
'htaccess', 'htgroups', 'htpasswd', 'conf', 'bat', 'cmd', 'cpp', 'c', 'cc', 'cxx', 'h', 'hh', 'hpp', 'ino', 'cs', 'css',
|
||||
'dockerfile', 'go', 'html', 'htm', 'xhtml', 'vue', 'we', 'wpy', 'java', 'js', 'jsm', 'jsx', 'json', 'jsp', 'less', 'lua', 'makefile', 'gnumakefile',
|
||||
'ocamlmakefile', 'make', 'md', 'markdown', 'mysql', 'nginx', 'ini', 'cfg', 'prefs', 'm', 'mm', 'pl', 'pm', 'p6', 'pl6', 'pm6', 'pgsql', 'php',
|
||||
'inc', 'phtml', 'shtml', 'php3', 'php4', 'php5', 'phps', 'phpt', 'aw', 'ctp', 'module', 'ps1', 'py', 'r', 'rb', 'ru', 'gemspec', 'rake', 'guardfile', 'rakefile',
|
||||
'gemfile', 'rs', 'sass', 'scss', 'sh', 'bash', 'bashrc', 'sql', 'sqlserver', 'swift', 'ts', 'typescript', 'str', 'vbs', 'vb', 'v', 'vh', 'sv', 'svh', 'xml',
|
||||
'rdf', 'rss', 'wsdl', 'xslt', 'atom', 'mathml', 'mml', 'xul', 'xbl', 'xaml', 'yaml', 'yml',
|
||||
'asp', 'properties', 'gitignore', 'log', 'bas', 'prg', 'python', 'ftl', 'aspx' => "code",
|
||||
'mp3', 'wav', 'mp4', 'flv',
|
||||
'avi', 'mov', 'wmv', 'mkv', '3gp', 'rm' => "media",
|
||||
default => "",
|
||||
@@ -596,7 +633,8 @@ class FileController extends AbstractController
|
||||
'created_id' => $user->userid,
|
||||
]);
|
||||
// 开始创建
|
||||
return AbstractModel::transaction(function () use ($type, $user, $data, $file) {
|
||||
return AbstractModel::transaction(function () use ($webkitRelativePath, $type, $user, $data, $file) {
|
||||
$file->size = $data['size'] * 1024;
|
||||
$file->save();
|
||||
//
|
||||
$content = FileContent::createInstance([
|
||||
@@ -608,16 +646,16 @@ class FileController extends AbstractController
|
||||
'url' => $data['path']
|
||||
],
|
||||
'text' => '',
|
||||
'size' => $data['size'] * 1024,
|
||||
'size' => $file->size,
|
||||
'userid' => $user->userid,
|
||||
]);
|
||||
$content->save();
|
||||
//
|
||||
$file->size = $content->size;
|
||||
$file->save();
|
||||
$tmpRow = File::find($file->id);
|
||||
$tmpRow->pushMsg('add', $tmpRow);
|
||||
//
|
||||
$data = File::find($file->id);
|
||||
$data->pushMsg('add', $data);
|
||||
$data = $tmpRow->toArray();
|
||||
$data['full_name'] = $webkitRelativePath ?: $data['name'];
|
||||
return Base::retSuccess($data['name'] . ' 上传成功', $data);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ use App\Module\Base;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Arr;
|
||||
use Request;
|
||||
use Response;
|
||||
|
||||
/**
|
||||
* @apiDefine project
|
||||
@@ -1083,7 +1084,41 @@ class ProjectController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} api/project/task/add 23. 添加任务
|
||||
* @api {get} api/project/task/filedown 23. 下载任务文件
|
||||
*
|
||||
* @apiDescription 需要token身份(限:项目、任务负责人)
|
||||
* @apiVersion 1.0.0
|
||||
* @apiGroup project
|
||||
* @apiName task__filedown
|
||||
*
|
||||
* @apiParam {Number} file_id 文件ID
|
||||
*
|
||||
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
||||
* @apiSuccess {String} msg 返回信息(错误描述)
|
||||
* @apiSuccess {Object} data 返回数据
|
||||
*/
|
||||
public function task__filedown()
|
||||
{
|
||||
User::auth();
|
||||
//
|
||||
$file_id = intval(Request::input('file_id'));
|
||||
//
|
||||
$file = ProjectTaskFile::find($file_id);
|
||||
if (empty($file)) {
|
||||
abort(403, "This file not exist.");
|
||||
}
|
||||
//
|
||||
try {
|
||||
ProjectTask::userTask($file->task_id, true, true);
|
||||
} catch (\Exception $e) {
|
||||
abort(403, $e->getMessage() ?: "This file not support download.");
|
||||
}
|
||||
//
|
||||
return Response::download(public_path($file->getRawOriginal('path')), $file->name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} api/project/task/add 24. 添加任务
|
||||
*
|
||||
* @apiDescription 需要token身份
|
||||
* @apiVersion 1.0.0
|
||||
@@ -1154,7 +1189,7 @@ class ProjectController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} api/project/task/addsub 24. 添加子任务
|
||||
* @api {get} api/project/task/addsub 25. 添加子任务
|
||||
*
|
||||
* @apiDescription 需要token身份(限:项目、任务负责人)
|
||||
* @apiVersion 1.0.0
|
||||
@@ -1194,7 +1229,7 @@ class ProjectController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} api/project/task/update 25. 修改任务、子任务
|
||||
* @api {post} api/project/task/update 26. 修改任务、子任务
|
||||
*
|
||||
* @apiDescription 需要token身份(限:项目、任务负责人)
|
||||
* @apiVersion 1.0.0
|
||||
@@ -1240,7 +1275,7 @@ class ProjectController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} api/project/task/upload 26. 上传文件
|
||||
* @api {post} api/project/task/upload 27. 上传文件
|
||||
*
|
||||
* @apiDescription 需要token身份(限:项目、任务负责人)
|
||||
* @apiVersion 1.0.0
|
||||
@@ -1306,7 +1341,7 @@ class ProjectController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} api/project/task/dialog 27. 创建/获取聊天室
|
||||
* @api {get} api/project/task/dialog 28. 创建/获取聊天室
|
||||
*
|
||||
* @apiDescription 需要token身份
|
||||
* @apiVersion 1.0.0
|
||||
@@ -1353,7 +1388,7 @@ class ProjectController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} api/project/task/archived 28. 归档任务
|
||||
* @api {get} api/project/task/archived 29. 归档任务
|
||||
*
|
||||
* @apiDescription 需要token身份(限:项目、任务负责人)
|
||||
* @apiVersion 1.0.0
|
||||
@@ -1395,7 +1430,7 @@ class ProjectController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} api/project/task/remove 29. 删除任务
|
||||
* @api {get} api/project/task/remove 30. 删除任务
|
||||
*
|
||||
* @apiDescription 需要token身份(限:项目、任务负责人)
|
||||
* @apiVersion 1.0.0
|
||||
@@ -1421,7 +1456,7 @@ class ProjectController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} api/project/task/resetfromlog 29. 根据日志重置任务
|
||||
* @api {get} api/project/task/resetfromlog 31. 根据日志重置任务
|
||||
*
|
||||
* @apiDescription 需要token身份(限:项目、任务负责人)
|
||||
* @apiVersion 1.0.0
|
||||
@@ -1480,7 +1515,7 @@ class ProjectController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} api/project/task/flow 29. 任务工作流信息
|
||||
* @api {get} api/project/task/flow 32. 任务工作流信息
|
||||
*
|
||||
* @apiDescription 需要token身份
|
||||
* @apiVersion 1.0.0
|
||||
@@ -1562,7 +1597,7 @@ class ProjectController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} api/project/flow/list 29. 工作流列表
|
||||
* @api {get} api/project/flow/list 33. 工作流列表
|
||||
*
|
||||
* @apiDescription 需要token身份(限:项目负责人)
|
||||
* @apiVersion 1.0.0
|
||||
@@ -1589,7 +1624,7 @@ class ProjectController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} api/project/flow/save 29. 保存工作流
|
||||
* @api {post} api/project/flow/save 34. 保存工作流
|
||||
*
|
||||
* @apiDescription 需要token身份(限:项目负责人)
|
||||
* @apiVersion 1.0.0
|
||||
@@ -1708,7 +1743,7 @@ class ProjectController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} api/project/flow/delete 29. 删除工作流
|
||||
* @api {get} api/project/flow/delete 35. 删除工作流
|
||||
*
|
||||
* @apiDescription 需要token身份(限:项目负责人)
|
||||
* @apiVersion 1.0.0
|
||||
@@ -1740,7 +1775,7 @@ class ProjectController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} api/project/log/lists 30. 获取项目、任务日志
|
||||
* @api {get} api/project/log/lists 36. 获取项目、任务日志
|
||||
*
|
||||
* @apiDescription 需要token身份
|
||||
* @apiVersion 1.0.0
|
||||
@@ -1766,7 +1801,7 @@ class ProjectController extends AbstractController
|
||||
//
|
||||
$builder = ProjectLog::select(["*"]);
|
||||
if ($task_id > 0) {
|
||||
$task = ProjectTask::userTask($task_id);
|
||||
$task = ProjectTask::userTask($task_id, null);
|
||||
$builder->whereTaskId($task->id);
|
||||
} else {
|
||||
$project = Project::userProject($project_id);
|
||||
|
||||
Reference in New Issue
Block a user