Skip to content

Commit

Permalink
doc
Browse files Browse the repository at this point in the history
  • Loading branch information
kuaifan committed Aug 29, 2021
1 parent f5534f4 commit 5fb9a52
Show file tree
Hide file tree
Showing 52 changed files with 9,615 additions and 13 deletions.
16 changes: 8 additions & 8 deletions app/Http/Controllers/Api/SystemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function setting()
}

/**
* @api {post} api/system/priority 01. 获取优先级、保存优先级
* @api {post} api/system/priority 02. 获取优先级、保存优先级
*
* @apiVersion 1.0.0
* @apiGroup system
Expand Down Expand Up @@ -103,7 +103,7 @@ public function priority()
}

/**
* @api {get} api/system/get/info 02. 获取终端详细信息
* @api {get} api/system/get/info 03. 获取终端详细信息
*
* @apiVersion 1.0.0
* @apiGroup system
Expand Down Expand Up @@ -132,7 +132,7 @@ public function get__info()
}

/**
* @api {get} api/system/get/ip 03. 获取IP地址
* @api {get} api/system/get/ip 04. 获取IP地址
*
* @apiVersion 1.0.0
* @apiGroup system
Expand All @@ -147,7 +147,7 @@ public function get__ip() {
}

/**
* @api {get} api/system/get/cnip 04. 是否中国IP地址
* @api {get} api/system/get/cnip 05. 是否中国IP地址
*
* @apiVersion 1.0.0
* @apiGroup system
Expand All @@ -164,7 +164,7 @@ public function get__cnip() {
}

/**
* @api {get} api/system/get/ipgcj02 05. 获取IP地址经纬度
* @api {get} api/system/get/ipgcj02 06. 获取IP地址经纬度
*
* @apiVersion 1.0.0
* @apiGroup system
Expand All @@ -181,7 +181,7 @@ public function get__ipgcj02() {
}

/**
* @api {get} api/system/get/ipinfo 06. 获取IP地址详细信息
* @api {get} api/system/get/ipinfo 07. 获取IP地址详细信息
*
* @apiVersion 1.0.0
* @apiGroup system
Expand All @@ -198,7 +198,7 @@ public function get__ipinfo() {
}

/**
* @api {get} api/system/get/appinfo 06. 获取应用下载信息
* @api {get} api/system/get/appinfo 08. 获取应用下载信息
*
* @apiVersion 1.0.0
* @apiGroup system
Expand Down Expand Up @@ -255,7 +255,7 @@ public function get__appinfo() {
}

/**
* @api {get} api/system/get/appdown 06. 下载应用
* @api {get} api/system/get/appdown 09. 下载应用
*
* @apiVersion 1.0.0
* @apiGroup system
Expand Down
8 changes: 4 additions & 4 deletions app/Http/Controllers/Api/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function login__codeimg()
}

/**
* @api {get} api/users/login/codejson 07. 验证码json
* @api {get} api/users/login/codejson 04. 验证码json
*
* @apiDescription 用于判断是否需要登录验证码
* @apiVersion 1.0.0
Expand All @@ -155,7 +155,7 @@ public function login__codejson()
}

/**
* @api {get} api/users/info 04. 获取我的信息
* @api {get} api/users/info 05. 获取我的信息
*
* @apiDescription 需要token身份
* @apiVersion 1.0.0
Expand Down Expand Up @@ -191,7 +191,7 @@ public function info()
}

/**
* @api {get} api/users/editdata 05. 修改自己的资料
* @api {get} api/users/editdata 06. 修改自己的资料
*
* @apiDescription 需要token身份
* @apiVersion 1.0.0
Expand Down Expand Up @@ -250,7 +250,7 @@ public function editdata()
}

/**
* @api {get} api/users/editpass 06. 修改自己的密码
* @api {get} api/users/editpass 07. 修改自己的密码
*
* @apiDescription 需要token身份
* @apiVersion 1.0.0
Expand Down
10 changes: 10 additions & 0 deletions app/Http/Controllers/Api/apidoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "API",
"title": "APP接口",
"version": "1.0.0",
"description": "APP接口文档",
"url": "https://你的域名/",
"template": {
"withGenerator": false
}
}
89 changes: 89 additions & 0 deletions app/Http/Controllers/Api/apidoc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php

/**
* 给apidoc项目增加顺序编号
*/

error_reporting(E_ALL & ~E_NOTICE);

$path = dirname(__FILE__). '/';
$lists = scandir($path);
//
foreach ($lists AS $item) {
$fillPath = $path . $item;
if (str_ends_with($fillPath, 'Controller.php')) {
$content = file_get_contents($fillPath);
preg_match_all("/\* @api \{(.+?)\} (.*?)\n/i", $content, $matchs);
$i = 1;
foreach ($matchs[2] AS $key=>$text) {
if (in_array(strtolower($matchs[1][$key]), array('get', 'post'))) {
$expl = explode(" ", __sRemove($text));
$end = $expl[1];
if ($expl[2]) {
$end = '';
foreach ($expl AS $k=>$v) { if ($k >= 2) { $end.= " ".$v; } }
}
$newtext = "* @api {".$matchs[1][$key]."} ".$expl[0]." ".__zeroFill($i, 2).". ".trim($end);
$content = str_replace("* @api {".$matchs[1][$key]."} ".$text, $newtext, $content);
$i++;
//
echo $newtext;
echo "\r\n";
}
}
if ($i > 1) {
file_put_contents($fillPath, $content);
}
}
}
echo "Success \n";

/** ************************************************************** */
/** ************************************************************** */
/** ************************************************************** */

/**
* 替换所有空格
* @param $str
* @return mixed
*/
function __sRemove($str) {
$str = str_replace(" ", " ", $str);
if (__strExists($str, " ")) {
return __sRemove($str);
}
return $str;
}

/**
* 是否包含字符
* @param $string
* @param $find
* @return bool
*/
function __strExists($string, $find)
{
return str_contains($string, $find);
}

/**
* @param string $str 补零
* @param int $length
* @param int $after
* @return bool|string
*/
function __zeroFill($str, $length = 0, $after = 1) {
if (strlen($str) >= $length) {
return $str;
}
$_str = '';
for ($i = 0; $i < $length; $i++) {
$_str .= '0';
}
if ($after) {
$_ret = substr($_str . $str, $length * -1);
} else {
$_ret = substr($str . $_str, 0, $length);
}
return $_ret;
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "DooTask",
"version": "0.3.14",
"version": "0.3.16",
"description": "DooTask is task management system.",
"scripts": {
"start": "./cmd dev",
Expand Down
Loading

0 comments on commit 5fb9a52

Please sign in to comment.