feat 还原日志列表的UI和接口

feat 还原系统配置的显示
This commit is contained in:
damonyuan 2024-10-26 01:49:23 +08:00
parent b694076f45
commit 845d5a526a
6 changed files with 150 additions and 98 deletions

View File

@ -1,54 +1,112 @@
<!-- 系统环境 --> <!-- 系统环境 -->
<template> <template>
<div class="system-environment"> <div class="system-environment" v-loading="loading">
<div class="lg:flex">
<el-card class="!border-none flex-1 mb-4 lg:mr-4" shadow="never">
<div>CPU</div>
<div class="mt-4">
<div class="flex flex-wrap">
<div class="sm:flex-1 w-1/2 mb-4">
<div class="text-4xl mb-3">{{ info.cpu.cpuNum }}</div>
<div class="text-tx-regular">核心数</div>
</div>
<div class="sm:flex-1 w-1/2 mb-4">
<div class="text-4xl mb-3">
{{ info.cpu.used ? `${info.cpu.used}%` : '-' }}
</div>
<div class="text-tx-regular">用户使用率</div>
</div>
<div class="sm:flex-1 w-1/2 mb-4">
<div class="text-4xl mb-3">
{{ info.cpu.sys ? `${info.cpu.sys}%` : '-' }}
</div>
<div class="text-tx-regular">系统使用率</div>
</div>
<div class="sm:flex-1 w-1/2 mb-4">
<div class="text-4xl mb-3">
{{ info.cpu.free ? `${info.cpu.free}%` : '-' }}
</div>
<div class="text-tx-regular">当前空闲率</div>
</div>
</div>
</div>
</el-card>
<el-card class="!border-none flex-1 mb-4" shadow="never">
<div>内存</div>
<div class="mt-4">
<div class="flex flex-wrap">
<div class="sm:flex-1 w-1/2 mb-4">
<div class="text-4xl mb-3">{{ info.mem.total }}</div>
<div class="text-tx-regular">总内存</div>
</div>
<div class="sm:flex-1 w-1/2 mb-4">
<div class="text-4xl mb-3">
{{ info.mem.used ? `${info.mem.used}%` : '-' }}
</div>
<div class="text-tx-regular">已用内存</div>
</div>
<div class="sm:flex-1 w-1/2 mb-4">
<div class="text-4xl mb-3">
{{ info.mem.free ? `${info.mem.free}%` : '-' }}
</div>
<div class="text-tx-regular">剩余内存</div>
</div>
<div class="sm:flex-1 w-1/2 mb-4">
<div class="text-4xl mb-3">
{{ info.mem.usage ? `${info.mem.usage}%` : '-' }}
</div>
<div class="text-tx-regular">使用率</div>
</div>
</div>
</div>
</el-card>
</div>
<el-card class="!border-none" shadow="never"> <el-card class="!border-none" shadow="never">
<div>服务器信息</div> <div>服务器信息</div>
<div class="mt-4"> <div class="mt-4">
<el-table :data="info.server"> <el-table :data="[info.sys]" size="large">
<el-table-column prop="param" label="参数"></el-table-column> <el-table-column prop="computerName" label="服务器名称" min-width="150" />
<el-table-column prop="value" label="值"></el-table-column> <el-table-column prop="computerIp" label="服务器IP" min-width="120" />
<el-table-column prop="osName" label="操作系统" min-width="100" />
<el-table-column prop="osArch" label="系统架构" min-width="100" />
<el-table-column prop="userDir" label="项目路径" min-width="250" />
</el-table> </el-table>
</div> </div>
</el-card> </el-card>
<el-card shadow="never" class="!border-none mt-4"> <el-card shadow="never" class="!border-none mt-4">
<div>PHP环境要求</div> <div>Java虚拟机信息</div>
<div class="mt-4"> <div class="mt-4">
<el-table :data="info.env"> <el-table :data="[info.jvm]" size="large">
<el-table-column prop="option" label="选项"></el-table-column> <el-table-column prop="name" label="Java名称" min-width="120" />
<el-table-column prop="require" label="要求"></el-table-column> <el-table-column prop="startTime" label="启动时间" min-width="120" />
<el-table-column label="状态"> <el-table-column prop="home" label="安装路径" min-width="120" />
<template #default="scope"> <el-table-column prop="inputArgs" label="运行参数" min-width="120" />
<icon <el-table-column prop="version" label="Java版本" min-width="120" />
v-if="scope.row.status" <el-table-column prop="runTime" label="运行时长" min-width="120" />
name="el-icon-Select"
class="text-success"
/>
<icon v-else name="el-icon-CloseBold" class="text-danger" />
</template>
</el-table-column>
<el-table-column prop="remark" label="说明及帮助"></el-table-column>
</el-table> </el-table>
</div> </div>
</el-card> </el-card>
<el-card shadow="never" class="!border-none mt-4"> <el-card shadow="never" class="!border-none mt-4">
<div>目录权限</div> <div>硬盘状态</div>
<div class="mt-4"> <div class="mt-4">
<el-table :data="info.auth"> <el-table :data="info.disk" size="large">
<el-table-column prop="dir" label="选项"></el-table-column> <el-table-column prop="dirName" label="盘符路径" min-width="100" />
<el-table-column prop="require" label="要求"></el-table-column> <el-table-column prop="sysTypeName" label="文件系统" min-width="100" />
<el-table-column label="状态"> <el-table-column prop="typeName" label="盘符类型" min-width="100" />
<template #default="scope"> <el-table-column prop="total" label="总大小" min-width="100" />
<icon <el-table-column prop="free" label="可用大小" min-width="100" />
v-if="scope.row.status" <el-table-column prop="used" label="已用大小" min-width="100" />
name="el-icon-Select" <el-table-column prop="usage" label="已用百分比" min-width="100">
class="text-success" <template #default="{ row }"> {{ row.usage }}% </template>
/>
<icon v-else name="el-icon-CloseBold" class="text-danger" />
</template>
</el-table-column> </el-table-column>
<el-table-column prop="remark" label="说明及帮助"></el-table-column>
</el-table> </el-table>
</div> </div>
</el-card> </el-card>
@ -57,24 +115,28 @@
<script lang="ts" setup name="environment"> <script lang="ts" setup name="environment">
import { systemInfo } from '@/api/setting/system' import { systemInfo } from '@/api/setting/system'
const loading = ref(false)
const info = reactive({ const info = ref({
server: [], // cpu: {} as any,
env: [], // PHP disk: [],
auth: [] // jvm: {},
mem: {} as any,
sys: {}
}) })
const getSystemInfo = () => { const getSystemInfo = async () => {
systemInfo().then((res) => { try {
info.server = res.server loading.value = true
info.env = res.env const data = await systemInfo()
info.auth = res.auth info.value = data
})
loading.value = false
} catch (error) {
loading.value = false
}
} }
onMounted(() => {
getSystemInfo() getSystemInfo()
})
</script> </script>
<style lang="scss" scoped></style> <style lang="scss" scoped></style>

View File

@ -7,7 +7,7 @@
<el-input <el-input
class="w-[280px]" class="w-[280px]"
placeholder="请输入" placeholder="请输入"
v-model="formData.admin_name" v-model="formData.username"
clearable clearable
@keyup.enter="resetPage" @keyup.enter="resetPage"
/> />
@ -36,8 +36,8 @@
<el-form-item label="访问时间"> <el-form-item label="访问时间">
<daterange-picker <daterange-picker
v-model:startTime="formData.start_time" v-model:startTime="formData.startTime"
v-model:endTime="formData.end_time" v-model:endTime="formData.endTime"
/> />
</el-form-item> </el-form-item>
@ -54,12 +54,6 @@
<el-form-item> <el-form-item>
<el-button type="primary" @click="resetPage">查询</el-button> <el-button type="primary" @click="resetPage">查询</el-button>
<el-button @click="resetParams">重置</el-button> <el-button @click="resetParams">重置</el-button>
<export-data
class="ml-2.5"
:fetch-fun="systemLogLists"
:params="formData"
:page-size="pager.size"
/>
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-card> </el-card>
@ -68,14 +62,14 @@
<div> <div>
<el-table :data="pager.lists" size="large"> <el-table :data="pager.lists" size="large">
<el-table-column label="记录ID" prop="id" /> <el-table-column label="记录ID" prop="id" />
<el-table-column label="操作" prop="action" min-width="120" /> <el-table-column label="操作" prop="title" min-width="120" />
<el-table-column label="管理员" prop="admin_name" min-width="120" /> <el-table-column label="管理员" prop="username" min-width="120" />
<el-table-column label="管理员ID" prop="admin_id" min-width="120" />
<el-table-column label="访问链接" prop="url" min-width="160" /> <el-table-column label="访问链接" prop="url" min-width="160" />
<el-table-column label="访问方式" prop="type" /> <el-table-column label="访问方式" prop="type" min-width="100" />
<el-table-column label="访问参数" prop="params" min-width="160" />
<el-table-column label="来源IP" prop="ip" min-width="160" /> <el-table-column label="来源IP" prop="ip" min-width="160" />
<el-table-column label="日志时间" prop="create_time" min-width="180" /> <el-table-column label="错误信息" prop="error" min-width="160" />
<el-table-column label="执行耗时(毫秒)" prop="taskTime" min-width="100" />
<el-table-column label="日志时间" prop="createTime" min-width="180" />
</el-table> </el-table>
</div> </div>
<div class="flex mt-4 justify-end"> <div class="flex mt-4 justify-end">
@ -89,23 +83,14 @@
import { systemLogLists } from '@/api/setting/system' import { systemLogLists } from '@/api/setting/system'
import { usePaging } from '@/hooks/usePaging' import { usePaging } from '@/hooks/usePaging'
interface formDataObj {
admin_name?: string //
url?: string // 访
ip?: string // ip
type?: string // 访
start_time?: string //
end_time?: string //
}
// //
const formData = ref<formDataObj>({ const formData = ref({
admin_name: '', username: '',
url: '', url: '',
ip: '', ip: '',
type: '', type: '',
start_time: '', startTime: '',
end_time: '' endTime: ''
}) })
// 访 // 访
@ -121,18 +106,6 @@ const visitType = ref<Array<any>>([
{ {
label: 'post', label: 'post',
value: 'post' value: 'post'
},
{
label: 'put',
value: 'put'
},
{
label: 'delete',
value: 'delete'
},
{
label: 'option',
value: 'option'
} }
]) ])
@ -141,9 +114,7 @@ const { pager, getLists, resetParams, resetPage } = usePaging({
params: formData.value params: formData.value
}) })
onMounted(() => {
getLists() getLists()
})
</script> </script>
<style lang="scss" scoped></style> <style lang="scss" scoped></style>

View File

@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.Map; import java.util.Map;
@RestController @RestController
@RequestMapping("api/monitor") @RequestMapping("adminapi/setting/system.system")
@Api(tags = "监控服务管理") @Api(tags = "监控服务管理")
public class MonitorServerController { public class MonitorServerController {
@ -23,7 +23,7 @@ public class MonitorServerController {
* @return AjaxResult<Map<String, Object>> * @return AjaxResult<Map<String, Object>>
*/ */
@Log(title = "服务监控") @Log(title = "服务监控")
@GetMapping("/server") @GetMapping("/info")
@ApiOperation(value="服务监控") @ApiOperation(value="服务监控")
public AjaxResult<Map<String, Object>> info() { public AjaxResult<Map<String, Object>> info() {
ServerResult server = new ServerResult(); ServerResult server = new ServerResult();

View File

@ -25,9 +25,9 @@ public class SystemLogsController {
@Resource @Resource
ISystemLogsServer iSystemLogsServer; ISystemLogsServer iSystemLogsServer;
@GetMapping("/operate") @GetMapping("/lists")
@ApiOperation(value="系统操作日志") @ApiOperation(value="系统操作日志")
public AjaxResult<PageResult<SystemLogOperateVo>> operate(@Validated PageValidate pageValidate, public AjaxResult<PageResult<SystemLogOperateVo>> lists(@Validated PageValidate pageValidate,
@Validated SystemSearchOperateValidate searchValidate) { @Validated SystemSearchOperateValidate searchValidate) {
PageResult<SystemLogOperateVo> list = iSystemLogsServer.operate(pageValidate, searchValidate); PageResult<SystemLogOperateVo> list = iSystemLogsServer.operate(pageValidate, searchValidate);
return AjaxResult.success(list); return AjaxResult.success(list);

View File

@ -52,13 +52,13 @@ public class SystemLogsServerImpl implements ISystemLogsServer {
MPJQueryWrapper<SystemLogOperate> mpjQueryWrapper = new MPJQueryWrapper<SystemLogOperate>() MPJQueryWrapper<SystemLogOperate> mpjQueryWrapper = new MPJQueryWrapper<SystemLogOperate>()
.selectAll(SystemLogOperate.class) .selectAll(SystemLogOperate.class)
.select("sa.username,sa.nickname") .select("sa.account as username,sa.name nickname")
.leftJoin("?_system_auth_admin sa ON sa.id=t.admin_id".replace("?_", GlobalConfig.tablePrefix)) .leftJoin("?_admin sa ON sa.id=t.admin_id".replace("?_", GlobalConfig.tablePrefix))
.orderByDesc("id"); .orderByDesc("id");
logOperateMapper.setSearch(mpjQueryWrapper, searchValidate, new String[]{ logOperateMapper.setSearch(mpjQueryWrapper, searchValidate, new String[]{
"like:title:str", "like:title:str",
"like:username@sa.username:str", "like:username@sa.name:str",
"like:ip:str", "like:ip:str",
"=:type:str", "=:type:str",
"=:status:int", "=:status:int",

View File

@ -826,3 +826,22 @@ CREATE TABLE `la_user_session` (
-- 2024-10-10 06:08:15 -- 2024-10-10 06:08:15
INSERT INTO `la_admin` (`id`, `root`, `name`, `avatar`, `account`, `password`, `login_time`, `login_ip`, `multipoint_login`, `disable`, `create_time`, `update_time`, `delete_time`) VALUES INSERT INTO `la_admin` (`id`, `root`, `name`, `avatar`, `account`, `password`, `login_time`, `login_ip`, `multipoint_login`, `disable`, `create_time`, `update_time`, `delete_time`) VALUES
(1, 1, 'admin', '', 'admin', '949ca431823932409b34f208d499f151', 1728627656, '', 1, 0, 1728627656, 1728627656, NULL); (1, 1, 'admin', '', 'admin', '949ca431823932409b34f208d499f151', 1728627656, '', 1, 0, 1728627656, 1728627656, NULL);
DROP TABLE IF EXISTS `la_system_log_operate`;
CREATE TABLE `la_system_log_operate` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`admin_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '操作人ID',
`type` varchar(30) NOT NULL DEFAULT '' COMMENT '请求类型: GET/POST/PUT',
`title` varchar(30) DEFAULT '' COMMENT '操作标题',
`ip` varchar(30) NOT NULL DEFAULT '' COMMENT '请求IP',
`url` varchar(200) NOT NULL DEFAULT '' COMMENT '请求接口',
`method` varchar(200) NOT NULL DEFAULT '' COMMENT '请求方法',
`args` text COMMENT '请求参数',
`error` text COMMENT '错误信息',
`status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '执行状态: 1=成功, 2=失败',
`start_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '开始时间',
`end_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '结束时间',
`task_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '执行耗时',
`create_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='系统操作日志表';