mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-11-04 10:57:10 +08:00 
			
		
		
		
	新增:新增系统监控/系统日志功能,优化日志表结构
This commit is contained in:
		@@ -0,0 +1,67 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 *     http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package top.charles7c.cnadmin.webapi.controller.monitor;
 | 
			
		||||
 | 
			
		||||
import lombok.RequiredArgsConstructor;
 | 
			
		||||
 | 
			
		||||
import io.swagger.v3.oas.annotations.Operation;
 | 
			
		||||
import io.swagger.v3.oas.annotations.tags.Tag;
 | 
			
		||||
 | 
			
		||||
import org.springframework.http.MediaType;
 | 
			
		||||
import org.springframework.validation.annotation.Validated;
 | 
			
		||||
import org.springframework.web.bind.annotation.GetMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.PathVariable;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 | 
			
		||||
import top.charles7c.cnadmin.common.model.query.PageQuery;
 | 
			
		||||
import top.charles7c.cnadmin.common.model.vo.PageInfo;
 | 
			
		||||
import top.charles7c.cnadmin.common.model.vo.R;
 | 
			
		||||
import top.charles7c.cnadmin.monitor.model.query.SystemLogQuery;
 | 
			
		||||
import top.charles7c.cnadmin.monitor.model.vo.SystemLogDetailVO;
 | 
			
		||||
import top.charles7c.cnadmin.monitor.model.vo.SystemLogVO;
 | 
			
		||||
import top.charles7c.cnadmin.monitor.service.LogService;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 系统日志 API
 | 
			
		||||
 *
 | 
			
		||||
 * @author Charles7c
 | 
			
		||||
 * @since 2023/1/17 23:27
 | 
			
		||||
 */
 | 
			
		||||
@Tag(name = "操作日志 API")
 | 
			
		||||
@Validated
 | 
			
		||||
@RestController
 | 
			
		||||
@RequiredArgsConstructor
 | 
			
		||||
@RequestMapping(value = "/monitor/log/system", produces = MediaType.APPLICATION_JSON_VALUE)
 | 
			
		||||
public class SystemLogController {
 | 
			
		||||
 | 
			
		||||
    private final LogService logService;
 | 
			
		||||
 | 
			
		||||
    @Operation(summary = "分页查询系统日志列表")
 | 
			
		||||
    @GetMapping
 | 
			
		||||
    public R<PageInfo<SystemLogVO>> list(@Validated SystemLogQuery query, @Validated PageQuery pageQuery) {
 | 
			
		||||
        PageInfo<SystemLogVO> pageInfo = logService.list(query, pageQuery);
 | 
			
		||||
        return R.ok(pageInfo);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Operation(summary = "系统日志列表")
 | 
			
		||||
    @GetMapping("/{logId}")
 | 
			
		||||
    public R<SystemLogDetailVO> detail(@PathVariable Long logId) {
 | 
			
		||||
        SystemLogDetailVO detailVO = logService.detail(logId);
 | 
			
		||||
        return R.ok(detailVO);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -29,10 +29,10 @@ CREATE TABLE IF NOT EXISTS `sys_log` (
 | 
			
		||||
    `description` varchar(255) DEFAULT NULL COMMENT '日志描述',
 | 
			
		||||
    `request_url` varchar(512) NOT NULL DEFAULT '' COMMENT '请求URL',
 | 
			
		||||
    `request_method` varchar(10) DEFAULT NULL COMMENT '请求方式',
 | 
			
		||||
    `request_header` text COMMENT '请求头',
 | 
			
		||||
    `request_headers` text COMMENT '请求头',
 | 
			
		||||
    `request_body` text DEFAULT NULL COMMENT '请求体',
 | 
			
		||||
    `status_code` int(11) unsigned DEFAULT NULL COMMENT '状态码',
 | 
			
		||||
    `response_header` text DEFAULT NULL COMMENT '响应头',
 | 
			
		||||
    `response_headers` text DEFAULT NULL COMMENT '响应头',
 | 
			
		||||
    `response_body` mediumtext DEFAULT NULL COMMENT '响应体',
 | 
			
		||||
    `elapsed_time` bigint(20) unsigned DEFAULT NULL COMMENT '请求耗时(ms)',
 | 
			
		||||
    `status` tinyint(1) unsigned DEFAULT 1 COMMENT '操作状态(1成功 2失败)',
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user