+ Add api for zdisk.

This commit is contained in:
zhujinyong
2021-09-29 14:47:41 +08:00
parent 1cf925a37c
commit 533c559b0c
10 changed files with 265 additions and 2 deletions
+35
View File
@@ -0,0 +1,35 @@
<?php
global $lang;
$config->zdisk = new stdclass();
$config->zdisk->root = array();
$config->zdisk->root['my'] = array('name' => $lang->my->common, 'type' => 'folder');
$config->zdisk->root['program'] = array('name' => $lang->program->common, 'type' => 'folder');
$config->zdisk->root['product'] = array('name' => $lang->product->common, 'type' => 'folder');
$config->zdisk->root['project'] = array('name' => $lang->project->common, 'type' => 'folder');
$config->zdisk->root['qa'] = array('name' => $lang->qa->common, 'type' => 'folder');
$config->zdisk->my = array();
$config->zdisk->my['todo'] = array('name' => $lang->user->todo, 'type' => 'file');
$config->zdisk->my['work'] = array('name' => $lang->my->work, 'type' => 'folder');
$config->zdisk->my['myproject'] = array('name' => $lang->projectCommon, 'type' => 'folder');
$config->zdisk->my['myexecution'] = array('name' => $lang->executionCommon, 'type' => 'folder');
$config->zdisk->work = array();
$config->zdisk->work['task'] = array('name' => $lang->user->task, 'type' => 'file');
$config->zdisk->work['story'] = array('name' => $lang->user->story, 'type' => 'file');
$config->zdisk->work['bug'] = array('name' => $lang->user->bug, 'type' => 'file');
$config->zdisk->work['case'] = array('name' => $lang->user->testCase, 'type' => 'file');
$config->zdisk->work['testtask'] = array('name' => $lang->user->testTask, 'type' => 'file');
$config->zdisk->myproject = array();
$config->zdisk->myproject['doing'] = array('name' => $lang->zdisk->doing, 'type' => 'file');
$config->zdisk->myproject['wait'] = array('name' => $lang->zdisk->wait, 'type' => 'file');
$config->zdisk->myproject['suspend'] = array('name' => $lang->zdisk->suspend, 'type' => 'file');
$config->zdisk->myproject['closed'] = array('name' => $lang->zdisk->closed, 'type' => 'file');
$config->zdisk->myproject['openedbyme'] = array('name' => $lang->zdisk->openedByMe, 'type' => 'file');
$config->zdisk->myexecution = array();
$config->zdisk->myexecution['undone'] = array('name' => $lang->zdisk->undone, 'type' => 'file');
$config->zdisk->myexecution['done'] = array('name' => $lang->zdisk->done, 'type' => 'file');
+38
View File
@@ -0,0 +1,38 @@
<?php
/**
* The file entry point for yueku.
*
* @copyright Copyright 2009-2021 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL (http://zpl.pub/page/zplv12.html)
* @author Chunsheng Wang <chunsheng@cnezsoft.com>
* @package entries
* @version 1
* @link http://www.zentao.net
*/
class zfileEntry extends entry
{
/**
* GET method.
*
* @param string $fileID
* @access public
* @return void
*/
public function get($fileID)
{
$now = gmdate("Y-m-d\TH:i:s\Z");
$info = new stdclass();
$info->id = $fileID;
$info->name = '';
$info->type = 'file';
$info->parentID = '';
$info->size = 1000000;
$info->createdTime = $now;
$info->accessedTime = $now;
$info->editedTime = $now;
$info->modifiedTime = $now;
$this->send(200, $info);
}
}
+33
View File
@@ -0,0 +1,33 @@
<?php
/**
* The file entry point for yueku.
*
* @copyright Copyright 2009-2021 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL (http://zpl.pub/page/zplv12.html)
* @author Chunsheng Wang <chunsheng@cnezsoft.com>
* @package entries
* @version 1
* @link http://www.zentao.net
*/
class zfileContentEntry extends entry
{
/**
* GET method.
*
* @param string $fileID
* @access public
* @return void
*/
public function get($fileID)
{
ob_end_clean();
header("Content-type: application/octet-stream");
header("Content-Transfer-Encoding: binary");
header("Accept-Ranges: bytes");
// header("Content-Length: " . filesize($filePath));
header("Content-Disposition: attachment; filename=\"hello.txt\"");
echo 'hello';
}
}
+48
View File
@@ -0,0 +1,48 @@
<?php
/**
* The root folder entry point for yueku.
*
* @copyright Copyright 2009-2021 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL (http://zpl.pub/page/zplv12.html)
* @author Chunsheng Wang <chunsheng@cnezsoft.com>
* @package entries
* @version 1
* @link http://www.zentao.net
*/
class zfolderEntry extends entry
{
/**
* GET method.
*
* @param string $folderID
* @access public
* @return void
*/
public function get($folderID)
{
$this->app->loadApiConfig('zdisk');
$nodes = array();
$now = gmdate("Y-m-d\TH:i:s\Z");
if(isset($this->config->zdisk->$folderID))
{
foreach($this->config->zdisk->$folderID as $nodeID => $node)
{
$nodes[] = array(
'id' => $nodeID,
'parentID' => $folderID,
'storeID' => 0,
'name' => $node['name'],
'type' => $node['type'],
'size' => $node['type'] == 'file' ? 1000000 : 0,
'createdTime' => $now,
'accessedTime' => $now,
'editedTime' => $now,
'modifiedTime' => $now,
);
}
}
$this->send(200, array('nodes' => $nodes));
}
}
+44
View File
@@ -0,0 +1,44 @@
<?php
/**
* The root folder entry point for yueku.
*
* @copyright Copyright 2009-2021 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL (http://zpl.pub/page/zplv12.html)
* @author Chunsheng Wang <chunsheng@cnezsoft.com>
* @package entries
* @version 1
* @link http://www.zentao.net
*/
class zfoldersEntry extends entry
{
/**
* GET method.
*
* @access public
* @return void
*/
public function get()
{
$this->app->loadApiConfig('zdisk');
$nodes = array();
$now = gmdate("Y-m-d\TH:i:s\Z");
foreach($this->config->zdisk->root as $code => $node)
{
$nodes[] = array(
'id' => $code,
'parentID' => null,
'storeID' => 0,
'name' => $node['name'],
'type' => $node['type'],
'size' => 0,
'createdTime' => $now,
'accessedTime' => $now,
'editedTime' => $now,
'modifiedTime' => $now,
);
}
$this->send(200, array('nodes' => $nodes));
}
}
+9
View File
@@ -1 +1,10 @@
<?php
$lang->zdisk = new stdclass();
$lang->zdisk->doing = 'Doing';
$lang->zdisk->wait = 'Wait';
$lang->zdisk->suspend = 'Suspend';
$lang->zdisk->closed = 'Closed';
$lang->zdisk->openedByMe = 'OpenedByMe';
$lang->zdisk->undone = 'Undone';
$lang->zdisk->done = 'Done';
+9
View File
@@ -1 +1,10 @@
<?php
$lang->zdisk = new stdclass();
$lang->zdisk->doing = '进行中';
$lang->zdisk->wait = '未开始';
$lang->zdisk->suspend = '已暂停';
$lang->zdisk->closed = '已关闭';
$lang->zdisk->openedByMe = '由我创建';
$lang->zdisk->undone = '未完成';
$lang->zdisk->done = '已完成';
+5
View File
@@ -84,4 +84,9 @@ $routes['/risks/:id'] = 'risk';
$routes['/departments'] = 'departments';
$routes['/departments/:id'] = 'department';
$routes['/z/folders'] = 'zfolders';
$routes['/z/folders/:id'] = 'zfolder';
$routes['/z/files/:id'] = 'zfile';
$routes['/z/files/:id/content'] = 'zfileContent';
$config->routes = $routes;
+13 -2
View File
@@ -5,7 +5,7 @@
*
* @package framework
*
* The author disclaims copyright to this source code. In place of
* The author disclaims copyright to this source code. In place of
* a legal notice, here is a blessing:
*
* May you do good and not evil.
@@ -40,6 +40,15 @@ class baseEntry
*/
public $app;
/**
* 语言项 $lang。
* The global $app object.
*
* @var object
* @access public
*/
public $lang;
/**
* 提交的POST数据
* The decoded request body.
@@ -58,9 +67,11 @@ class baseEntry
*/
public function __construct()
{
global $app, $config;
global $app, $config, $lang;
$this->app = $app;
$this->config = $config;
$this->lang = $lang;
$this->parseRequestBody();
}
+31
View File
@@ -98,6 +98,8 @@ class api extends router
$this->version = $subPos ? substr($this->path, 1, $subPos - 1) : '';
$this->path = $subPos ? substr($this->path, $subPos) : $this->path;
$this->loadApiLang();
}
/**
@@ -202,6 +204,35 @@ class api extends router
call_user_func_array(array($entry, $this->action), $this->params);
}
/**
* 加载配置文件
*
* Load config file of api.
*
* @param configPath
* @access public
* @return void
*/
public function loadApiConfig($configPath)
{
global $config;
include($this->appRoot . "api/$this->version/config/$configPath.php");
}
/**
* 加载语言文件
*
* Load lang file of api.
*
* @access public
* @return void
*/
public function loadApiLang()
{
global $lang;
include($this->appRoot . "api/$this->version/lang/$this->clientLang.php");
}
/**
* 格式化旧版本API响应数据
*