Skip to content

Commit

Permalink
feat: 系统日志新增导出 API
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Apr 9, 2024
1 parent 7793f82 commit bd0f40c
Show file tree
Hide file tree
Showing 9 changed files with 398 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.ibatis.annotations.Param;
import top.charles7c.continew.admin.system.model.entity.LogDO;
import top.charles7c.continew.admin.system.model.resp.*;
import top.charles7c.continew.admin.system.model.resp.log.LogResp;
import top.charles7c.continew.starter.data.mybatis.plus.base.BaseMapper;

import java.util.List;
Expand All @@ -45,6 +46,14 @@ public interface LogMapper extends BaseMapper<LogDO> {
IPage<LogResp> selectLogPage(@Param("page") IPage<LogDO> page,
@Param(Constants.WRAPPER) QueryWrapper<LogDO> queryWrapper);

/**
* 查询列表
*
* @param queryWrapper 查询条件
* @return 列表信息
*/
List<LogResp> selectLogList(@Param(Constants.WRAPPER) QueryWrapper<LogDO> queryWrapper);

/**
* 查询仪表盘总计信息
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package top.charles7c.continew.admin.system.model.resp;
package top.charles7c.continew.admin.system.model.resp.log;

import cn.crane4j.annotation.Assemble;
import cn.crane4j.annotation.Mapping;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package top.charles7c.continew.admin.system.model.resp;
package top.charles7c.continew.admin.system.model.resp.log;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
* 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:https://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.continew.admin.system.model.resp.log;

import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import top.charles7c.continew.admin.system.enums.LogStatusEnum;
import top.charles7c.continew.starter.extension.crud.converter.ExcelBaseEnumConverter;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
* 登录日志导出信息
*
* @author Charles7c
* @since 2023/1/14 18:27
*/
@Data
@ExcelIgnoreUnannotated
@Schema(description = "登录日志导出信息")
public class LoginLogExportResp implements Serializable {

@Serial
private static final long serialVersionUID = 1L;

/**
* ID
*/
@Schema(description = "ID", example = "1")
@ExcelProperty(value = "ID")
private Long id;

/**
* 登录时间
*/
@Schema(description = "登录时间", example = "2023-08-08 08:08:08", type = "string")
@ExcelProperty(value = "登录时间")
private LocalDateTime createTime;

/**
* 用户昵称
*/
@Schema(description = "用户昵称", example = "张三")
@ExcelProperty(value = "用户昵称")
private String createUserString;

/**
* 登录行为
*/
@Schema(description = "登录行为", example = "账号登录")
@ExcelProperty(value = "登录行为")
private String description;

/**
* 状态
*/
@Schema(description = "状态(1:成功;2:失败)", type = "Integer", allowableValues = {"1", "2"}, example = "1")
@ExcelProperty(value = "状态", converter = ExcelBaseEnumConverter.class)
private LogStatusEnum status;

/**
* 登录 IP
*/
@Schema(description = "登录 IP", example = "192.168.0.1")
@ExcelProperty(value = "登录 IP")
private String ip;

/**
* 登录地点
*/
@Schema(description = "登录地点", example = "中国北京北京市")
@ExcelProperty(value = "登录地点")
private String address;

/**
* 浏览器
*/
@Schema(description = "浏览器", example = "Chrome 115.0.0.0")
@ExcelProperty(value = "浏览器")
private String browser;

/**
* 终端系统
*/
@Schema(description = "终端系统", example = "Windows 10")
@ExcelProperty(value = "终端系统")
private String os;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/*
* 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:https://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.continew.admin.system.model.resp.log;

import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import top.charles7c.continew.admin.system.enums.LogStatusEnum;
import top.charles7c.continew.starter.extension.crud.converter.ExcelBaseEnumConverter;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
* 操作日志导出信息
*
* @author Charles7c
* @since 2023/1/14 18:27
*/
@Data
@ExcelIgnoreUnannotated
@Schema(description = "操作日志导出信息")
public class OperationLogExportResp implements Serializable {

@Serial
private static final long serialVersionUID = 1L;

/**
* ID
*/
@Schema(description = "ID", example = "1")
@ExcelProperty(value = "ID")
private Long id;

/**
* 操作时间
*/
@Schema(description = "操作时间", example = "2023-08-08 08:08:08", type = "string")
@ExcelProperty(value = "操作时间")
private LocalDateTime createTime;

/**
* 操作人
*/
@Schema(description = "操作人", example = "张三")
@ExcelProperty(value = "操作人")
private String createUserString;

/**
* 操作内容
*/
@Schema(description = "操作内容", example = "账号登录")
@ExcelProperty(value = "操作内容")
private String description;

/**
* 所属模块
*/
@Schema(description = "所属模块", example = "部门管理")
@ExcelProperty(value = "所属模块")
private String module;

/**
* 状态
*/
@Schema(description = "状态(1:成功;2:失败)", type = "Integer", allowableValues = {"1", "2"}, example = "1")
@ExcelProperty(value = "状态", converter = ExcelBaseEnumConverter.class)
private LogStatusEnum status;

/**
* 操作 IP
*/
@Schema(description = "操作 IP", example = "192.168.0.1")
@ExcelProperty(value = "操作 IP")
private String ip;

/**
* 操作地点
*/
@Schema(description = "操作地点", example = "中国北京北京市")
@ExcelProperty(value = "操作地点")
private String address;

/**
* 耗时(ms)
*/
@Schema(description = "耗时(ms)", example = "58")
@ExcelProperty(value = "耗时(ms)")
private Long timeTaken;

/**
* 浏览器
*/
@Schema(description = "浏览器", example = "Chrome 115.0.0.0")
@ExcelProperty(value = "浏览器")
private String browser;

/**
* 终端系统
*/
@Schema(description = "终端系统", example = "Windows 10")
@ExcelProperty(value = "终端系统")
private String os;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@

package top.charles7c.continew.admin.system.service;

import jakarta.servlet.http.HttpServletResponse;
import top.charles7c.continew.admin.system.model.query.LogQuery;
import top.charles7c.continew.admin.system.model.resp.*;
import top.charles7c.continew.admin.system.model.resp.log.LogDetailResp;
import top.charles7c.continew.admin.system.model.resp.log.LogResp;
import top.charles7c.continew.starter.extension.crud.model.query.PageQuery;
import top.charles7c.continew.starter.extension.crud.model.query.SortQuery;
import top.charles7c.continew.starter.extension.crud.model.resp.PageResp;

import java.util.List;
Expand All @@ -42,13 +46,31 @@ public interface LogService {
PageResp<LogResp> page(LogQuery query, PageQuery pageQuery);

/**
* 查看详情
* 查询详情
*
* @param id ID
* @return 详情信息
*/
LogDetailResp get(Long id);

/**
* 导出登录日志
*
* @param query 查询条件
* @param sortQuery 排序查询条件
* @param response 响应对象
*/
void exportLoginLog(LogQuery query, SortQuery sortQuery, HttpServletResponse response);

/**
* 导出操作日志
*
* @param query 查询条件
* @param sortQuery 排序查询条件
* @param response 响应对象
*/
void exportOperationLog(LogQuery query, SortQuery sortQuery, HttpServletResponse response);

/**
* 查询仪表盘总计信息
*
Expand Down
Loading

0 comments on commit bd0f40c

Please sign in to comment.