Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lakernote
EasyAdmin
提交
80b9d289
E
EasyAdmin
项目概览
lakernote
/
EasyAdmin
8 个月 前同步成功
通知
14
Star
3
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
EasyAdmin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
80b9d289
编写于
9月 24, 2021
作者:
lakernote
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
(update)[整体](nginxui功能新增)
上级
c01928c3
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
196 addition
and
9 deletion
+196
-9
src/main/java/com/laker/admin/config/LakerConfig.java
src/main/java/com/laker/admin/config/LakerConfig.java
+32
-0
src/main/java/com/laker/admin/module/sys/controller/NginxController.java
...om/laker/admin/module/sys/controller/NginxController.java
+42
-2
src/main/resources/application.yaml
src/main/resources/application.yaml
+1
-1
web/admin/view/system/nginx.html
web/admin/view/system/nginx.html
+120
-5
web/admin/view/system/onlineUser.html
web/admin/view/system/onlineUser.html
+1
-1
未找到文件。
src/main/java/com/laker/admin/config/LakerConfig.java
浏览文件 @
80b9d289
...
...
@@ -28,6 +28,38 @@ public class LakerConfig {
*/
private
Waf
waf
=
new
Waf
();
/**
* nginx
*/
private
Nginx
nginx
=
new
Nginx
();
public
static
class
Nginx
{
/**
* nginx路径
*/
private
String
path
;
/**
* nginx配置文件路径
*/
private
String
confPath
=
"file/nginx.conf"
;
public
String
getPath
()
{
return
path
;
}
public
void
setPath
(
String
path
)
{
this
.
path
=
path
;
}
public
String
getConfPath
()
{
return
confPath
;
}
public
void
setConfPath
(
String
confPath
)
{
this
.
confPath
=
confPath
;
}
}
public
static
class
Waf
{
private
boolean
xssEnabled
=
true
;
private
boolean
sqlEnabled
=
true
;
...
...
src/main/java/com/laker/admin/module/sys/controller/NginxController.java
浏览文件 @
80b9d289
...
...
@@ -2,9 +2,11 @@ package com.laker.admin.module.sys.controller;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.util.RuntimeUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.github.odiszapc.nginxparser.NgxConfig
;
import
com.github.odiszapc.nginxparser.NgxDumper
;
import
com.laker.admin.config.LakerConfig
;
import
com.laker.admin.framework.model.Response
;
import
com.laker.admin.module.sys.pojo.NginxQo
;
import
com.laker.admin.module.sys.service.ISysDeptService
;
...
...
@@ -28,11 +30,16 @@ import java.util.Date;
public
class
NginxController
{
@Autowired
ISysDeptService
sysDeptService
;
@Autowired
LakerConfig
lakerConfig
;
@GetMapping
public
Response
get
(
@RequestParam
(
required
=
false
,
defaultValue
=
"file/nginx.conf"
)
String
path
)
{
public
Response
get
(
@RequestParam
(
required
=
false
)
String
path
)
{
NgxConfig
conf
=
null
;
try
{
if
(
StrUtil
.
isBlank
(
path
))
{
path
=
lakerConfig
.
getNginx
().
getConfPath
();
}
conf
=
NgxConfig
.
read
(
path
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
...
...
@@ -45,10 +52,43 @@ public class NginxController {
@PostMapping
public
Response
update
(
@RequestBody
NginxQo
nginxQo
)
{
if
(
StrUtil
.
isBlank
(
nginxQo
.
getPath
()))
{
nginxQo
.
setPath
(
"file/nginx.conf"
);
nginxQo
.
setPath
(
lakerConfig
.
getNginx
().
getConfPath
()
);
}
FileUtil
.
rename
(
new
File
(
nginxQo
.
getPath
()),
"nginx.conf-bak-"
+
DateUtil
.
format
(
new
Date
(),
"yyyy-MM-dd-HH-mm-ss"
),
true
);
FileUtil
.
writeString
(
nginxQo
.
getContext
(),
new
File
(
nginxQo
.
getPath
()),
"utf-8"
);
return
Response
.
ok
();
}
@PostMapping
(
"/check"
)
public
Response
check
(
@RequestBody
NginxQo
nginxQo
)
{
if
(
StrUtil
.
isBlank
(
nginxQo
.
getPath
()))
{
nginxQo
.
setPath
(
lakerConfig
.
getNginx
().
getConfPath
());
}
String
res
=
RuntimeUtil
.
execForStr
(
"nginx -t -c "
+
nginxQo
.
getPath
());
return
Response
.
ok
(
res
);
}
@PostMapping
(
"/reload"
)
public
Response
reload
(
@RequestBody
NginxQo
nginxQo
)
{
if
(
StrUtil
.
isBlank
(
nginxQo
.
getPath
()))
{
nginxQo
.
setPath
(
lakerConfig
.
getNginx
().
getConfPath
());
}
String
res
=
RuntimeUtil
.
execForStr
(
"nginx -s reload -c "
+
nginxQo
.
getPath
());
return
Response
.
ok
(
res
);
}
@PostMapping
(
"/start"
)
public
Response
start
(
@RequestBody
NginxQo
nginxQo
)
{
if
(
StrUtil
.
isBlank
(
nginxQo
.
getPath
()))
{
nginxQo
.
setPath
(
lakerConfig
.
getNginx
().
getConfPath
());
}
String
res
=
RuntimeUtil
.
execForStr
(
"nginx -c "
+
nginxQo
.
getPath
());
return
Response
.
ok
(
res
);
}
@PostMapping
(
"/stop"
)
public
Response
stop
()
{
String
res
=
RuntimeUtil
.
execForStr
(
"nginx -s quit"
);
return
Response
.
ok
(
res
);
}
}
\ No newline at end of file
src/main/resources/application.yaml
浏览文件 @
80b9d289
...
...
@@ -57,4 +57,4 @@ laker:
waf
:
sql-enabled
:
true
xss-enabled
:
true
excludes
:
/flow/*
\ No newline at end of file
excludes
:
/flow/*,/sys/nginx/*
\ No newline at end of file
web/admin/view/system/nginx.html
浏览文件 @
80b9d289
...
...
@@ -9,14 +9,16 @@
<div
class=
"layui-card"
>
<div
class=
"layui-card-body"
>
<div
class=
"layui-btn-group"
>
<button
type=
"button"
class=
"layui-btn"
>
校验
</button>
<button
type=
"button"
class=
"layui-btn
"
>
启动
</button>
<button
type=
"button"
class=
"layui-btn"
>
停止
</button>
<button
type=
"button"
class=
"layui-btn"
>
热启动
</button>
<button
type=
"button"
class=
"layui-btn"
id=
"check"
>
校验
</button>
<button
type=
"button"
class=
"layui-btn
"
id=
"start
"
>
启动
</button>
<button
type=
"button"
class=
"layui-btn"
id=
"stop"
>
停止
</button>
<button
type=
"button"
class=
"layui-btn"
id=
"reload"
>
热启动
</button>
</div>
</div>
</div>
<div
class=
"layui-card"
>
<div
class=
"layui-card-body"
>
<form
class=
"layui-form"
action=
""
>
<form
class=
"layui-form"
action=
""
lay-filter=
"nginx"
>
<div
class=
"layui-form-item"
style=
"width: 100%;"
>
<label
class=
"layui-form-label"
>
配置路径
</label>
...
...
@@ -41,6 +43,7 @@
</div>
</div>
</body>
<script
src=
"../../component/layui/layui.js"
></script>
...
...
@@ -54,6 +57,118 @@
$
(
"
#getConf
"
).
click
(
function
()
{
getConfContent
();
});
$
(
"
#check
"
).
click
(
function
()
{
easyAdmin
.
http
({
url
:
"
/sys/nginx/check
"
,
data
:
JSON
.
stringify
(
form
.
val
(
"
nginx
"
)),
dataType
:
'
json
'
,
contentType
:
'
application/json
'
,
type
:
'
post
'
,
success
:
function
(
result
)
{
if
(
result
.
success
)
{
layer
.
msg
(
result
.
msg
,
{
icon
:
1
,
time
:
2000
,
area
:
[
'
100px
'
,
'
65px
'
],
content
:
"
执行成功
"
});
}
else
{
layer
.
msg
(
result
.
msg
,
{
icon
:
2
,
time
:
2000
,
area
:
[
'
220px
'
,
'
70px
'
]
}
);
}
}
})
});
$
(
"
#start
"
).
click
(
function
()
{
easyAdmin
.
http
({
url
:
"
/sys/nginx/start
"
,
data
:
JSON
.
stringify
(
form
.
val
(
"
nginx
"
)),
dataType
:
'
json
'
,
contentType
:
'
application/json
'
,
type
:
'
post
'
,
success
:
function
(
result
)
{
if
(
result
.
success
)
{
layer
.
msg
(
result
.
msg
,
{
icon
:
1
,
time
:
2000
,
area
:
[
'
100px
'
,
'
65px
'
],
content
:
"
执行成功
"
});
}
else
{
layer
.
msg
(
result
.
msg
,
{
icon
:
2
,
time
:
2000
,
area
:
[
'
220px
'
,
'
70px
'
]
}
);
}
}
})
});
$
(
"
#stop
"
).
click
(
function
()
{
easyAdmin
.
http
({
url
:
"
/sys/nginx/stop
"
,
dataType
:
'
json
'
,
contentType
:
'
application/json
'
,
type
:
'
post
'
,
success
:
function
(
result
)
{
if
(
result
.
success
)
{
layer
.
msg
(
result
.
msg
,
{
icon
:
1
,
time
:
2000
,
area
:
[
'
100px
'
,
'
65px
'
],
content
:
"
执行成功
"
});
}
else
{
layer
.
msg
(
result
.
msg
,
{
icon
:
2
,
time
:
2000
,
area
:
[
'
220px
'
,
'
70px
'
]
}
);
}
}
})
});
$
(
"
#reload
"
).
click
(
function
()
{
easyAdmin
.
http
({
url
:
"
/sys/nginx/reload
"
,
data
:
JSON
.
stringify
(
form
.
val
(
"
nginx
"
)),
dataType
:
'
json
'
,
contentType
:
'
application/json
'
,
type
:
'
post
'
,
success
:
function
(
result
)
{
if
(
result
.
success
)
{
layer
.
msg
(
result
.
msg
,
{
icon
:
1
,
time
:
2000
,
area
:
[
'
100px
'
,
'
65px
'
],
content
:
"
执行成功
"
});
}
else
{
layer
.
msg
(
result
.
msg
,
{
icon
:
2
,
time
:
2000
,
area
:
[
'
220px
'
,
'
70px
'
]
}
);
}
}
})
});
form
.
on
(
'
submit(save)
'
,
function
(
data
)
{
// 转换
easyAdmin
.
http
({
...
...
web/admin/view/system/onlineUser.html
浏览文件 @
80b9d289
...
...
@@ -14,7 +14,7 @@
<div
class=
"layui-input-inline"
>
<input
type=
"text"
name=
"keyWord"
placeholder=
""
class=
"layui-input"
>
</div>
<button
class=
"pear-btn pear-btn-md pear-btn-primary"
lay-submit
lay-filter=
"
dict-type-
query"
>
<button
class=
"pear-btn pear-btn-md pear-btn-primary"
lay-submit
lay-filter=
"query"
>
<i
class=
"layui-icon layui-icon-search"
></i>
查询
</button>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录