This commit is contained in:
parent
0437334bb8
commit
118832c909
|
|
@ -21,12 +21,31 @@ use Hyperf\HttpServer\Annotation\PostMapping;
|
|||
use MathCaptcha\Captcha;
|
||||
use App\Request\Account as aRequest;
|
||||
use function Hyperf\Config\config;
|
||||
use Hyperf\Swagger\Annotation as SA;
|
||||
|
||||
#[Controller(prefix: "admin")]
|
||||
class Login extends Base
|
||||
{
|
||||
#[GetMapping(path: "captcha")]
|
||||
#[Auth(needLogin: false)]
|
||||
#[SA\Post(path: '/captcha', summary: '登录接口', tags: ['登录接口'])]
|
||||
#[SA\RequestBody(
|
||||
description: '请求参数',
|
||||
content: [
|
||||
new SA\MediaType(
|
||||
mediaType: 'application/json',
|
||||
schema: new SA\Schema(
|
||||
required: ['username', 'age'],
|
||||
properties: [
|
||||
new SA\Property(property: 'username', description: '用户名字段描述', type: 'string'),
|
||||
new SA\Property(property: 'age', description: '年龄字段描述', type: 'string'),
|
||||
new SA\Property(property: 'city', description: '城市字段描述', type: 'string'),
|
||||
]
|
||||
),
|
||||
),
|
||||
],
|
||||
)]
|
||||
#[SA\Response(response: 200, description: '返回值的描述')]
|
||||
public function captcha()
|
||||
{
|
||||
// 获取uuid
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
"hyperf/process": "~3.1.0",
|
||||
"hyperf/rate-limit": "^3.1",
|
||||
"hyperf/redis": "~3.1.0",
|
||||
"hyperf/swagger": "^3.1",
|
||||
"hyperf/validation": "^3.1",
|
||||
"hyperf/websocket-server": "^3.1",
|
||||
"phpoffice/phpspreadsheet": "^4.5",
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
<?php
|
||||
|
||||
use function Hyperf\Support\env;
|
||||
|
||||
/**
|
||||
* Author: cfn <cfn@leapy.cn>
|
||||
*/
|
||||
return [
|
||||
// 域名
|
||||
'domain' => 'https://server.leapy.cn/'
|
||||
'domain' => env('DOMAIN')
|
||||
];
|
||||
|
|
@ -11,7 +11,7 @@ return [
|
|||
'storage' => [
|
||||
'local' => [
|
||||
'driver' => LocalAdapterFactory::class,
|
||||
'root' => BASE_PATH . '/runtime',
|
||||
'root' => BASE_PATH . '/static',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ return [
|
|||
Constant::OPTION_BUFFER_OUTPUT_SIZE => 2 * 1024 * 1024,
|
||||
Constant::OPTION_PACKAGE_MAX_LENGTH => 50 * 1024 * 1024,
|
||||
|
||||
'document_root' => BASE_PATH . '/runtime',
|
||||
'document_root' => BASE_PATH . '/static',
|
||||
'enable_static_handler' => true,
|
||||
],
|
||||
'callbacks' => [
|
||||
|
|
|
|||
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use function Hyperf\Support\env;
|
||||
|
||||
return [
|
||||
'enable' => true,
|
||||
'port' => (int)env("SWAGGER_PORT", 9500),
|
||||
'json_dir' => BASE_PATH . '/static/swagger/json',
|
||||
'html' => <<<'HTML'
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta
|
||||
name="description"
|
||||
content="SwaggerUI"
|
||||
/>
|
||||
<title>SwaggerUI</title>
|
||||
<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@4.5.0/swagger-ui.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="swagger-ui"></div>
|
||||
<script src="https://unpkg.com/swagger-ui-dist@4.5.0/swagger-ui-bundle.js" crossorigin></script>
|
||||
<script src="https://unpkg.com/swagger-ui-dist@4.5.0/swagger-ui-standalone-preset.js" crossorigin></script>
|
||||
<script>
|
||||
window.onload = () => {
|
||||
window.ui = SwaggerUIBundle({
|
||||
url: GetQueryString("search"),
|
||||
dom_id: '#swagger-ui',
|
||||
presets: [
|
||||
SwaggerUIBundle.presets.apis,
|
||||
SwaggerUIStandalonePreset
|
||||
],
|
||||
layout: "StandaloneLayout",
|
||||
});
|
||||
};
|
||||
function GetQueryString(name) {
|
||||
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
|
||||
var r = window.location.search.substr(1).match(reg); //获取url中"?"符后的字符串并正则匹配
|
||||
var context = "";
|
||||
if (r != null)
|
||||
context = decodeURIComponent(r[2]);
|
||||
reg = null;
|
||||
r = null;
|
||||
return context == null || context == "" || context == "undefined" ? "/http.json" : context;
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
HTML,
|
||||
'url' => '/swagger',
|
||||
'path' =>'/swagger',
|
||||
'auto_generate' => true,
|
||||
'scan' => [
|
||||
'paths' => [
|
||||
BASE_PATH . '/app/Controller/Admin'
|
||||
],
|
||||
],
|
||||
'processors' => [
|
||||
// users can append their own processors here
|
||||
],
|
||||
'server' => [
|
||||
'http' => [
|
||||
'servers' => [
|
||||
[
|
||||
'url' => env('DOMAIN') . '/admin',
|
||||
'description' => '后台接口',
|
||||
],
|
||||
],
|
||||
'info' => [
|
||||
'title' => '里派基础接口',
|
||||
'description' => '管理端接口',
|
||||
'version' => '1.0.0',
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
Loading…
Reference in New Issue