整合提交
This commit is contained in:
+67
@@ -0,0 +1,67 @@
|
||||
|
||||
package com.weather.modules.log.controller;
|
||||
|
||||
import com.weather.common.annotation.LogOperation;
|
||||
import com.weather.common.constant.Constant;
|
||||
import com.weather.common.page.PageData;
|
||||
import com.weather.common.utils.ExcelUtils;
|
||||
import com.weather.common.utils.Result;
|
||||
import com.weather.modules.log.dto.SysLogErrorDTO;
|
||||
import com.weather.modules.log.excel.SysLogErrorExcel;
|
||||
import com.weather.modules.log.service.SysLogErrorService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 异常日志
|
||||
*
|
||||
* @author 123
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("sys/log/error")
|
||||
@Tag(name = "异常日志")
|
||||
@AllArgsConstructor
|
||||
public class SysLogErrorController {
|
||||
private final SysLogErrorService sysLogErrorService;
|
||||
|
||||
@GetMapping("page")
|
||||
@Operation(summary = "分页")
|
||||
@Parameters({
|
||||
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始", in = ParameterIn.QUERY, required = true, ref = "int"),
|
||||
@Parameter(name = Constant.LIMIT, description = "每页显示记录数", in = ParameterIn.QUERY, required = true, ref = "int"),
|
||||
@Parameter(name = Constant.ORDER_FIELD, description = "排序字段", in = ParameterIn.QUERY, ref = "String"),
|
||||
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)", in = ParameterIn.QUERY, ref = "String")
|
||||
})
|
||||
@RequiresPermissions("sys:log:error")
|
||||
public Result<PageData<SysLogErrorDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params) {
|
||||
PageData<SysLogErrorDTO> page = sysLogErrorService.page(params);
|
||||
|
||||
return new Result<PageData<SysLogErrorDTO>>().ok(page);
|
||||
}
|
||||
|
||||
@GetMapping("export")
|
||||
@Operation(summary = "导出")
|
||||
@LogOperation("导出")
|
||||
@RequiresPermissions("sys:log:error")
|
||||
public void export(@Parameter(hidden = true) @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
|
||||
List<SysLogErrorDTO> list = sysLogErrorService.list(params);
|
||||
|
||||
ExcelUtils.exportExcelToTarget(response, null, "异常日志", list, SysLogErrorExcel.class);
|
||||
}
|
||||
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
|
||||
package com.weather.modules.log.controller;
|
||||
|
||||
import com.weather.common.annotation.LogOperation;
|
||||
import com.weather.common.constant.Constant;
|
||||
import com.weather.common.page.PageData;
|
||||
import com.weather.common.utils.ExcelUtils;
|
||||
import com.weather.common.utils.Result;
|
||||
import com.weather.modules.log.dto.SysLogLoginDTO;
|
||||
import com.weather.modules.log.excel.SysLogLoginExcel;
|
||||
import com.weather.modules.log.service.SysLogLoginService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 登录日志
|
||||
*
|
||||
* @author 123
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("sys/log/login")
|
||||
@Tag(name = "登录日志")
|
||||
@AllArgsConstructor
|
||||
public class SysLogLoginController {
|
||||
private final SysLogLoginService sysLogLoginService;
|
||||
|
||||
@GetMapping("page")
|
||||
@Operation(summary = "分页")
|
||||
@Parameters({
|
||||
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始", in = ParameterIn.QUERY, required = true, ref = "int"),
|
||||
@Parameter(name = Constant.LIMIT, description = "每页显示记录数", in = ParameterIn.QUERY, required = true, ref = "int"),
|
||||
@Parameter(name = Constant.ORDER_FIELD, description = "排序字段", in = ParameterIn.QUERY, ref = "String"),
|
||||
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)", in = ParameterIn.QUERY, ref = "String"),
|
||||
@Parameter(name = "status", description = "状态 0:失败 1:成功 2:账号已锁定", in = ParameterIn.QUERY, ref = "int"),
|
||||
@Parameter(name = "creatorName", description = "用户名", in = ParameterIn.QUERY, ref = "String")
|
||||
})
|
||||
@RequiresPermissions("sys:log:login")
|
||||
public Result<PageData<SysLogLoginDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params) {
|
||||
PageData<SysLogLoginDTO> page = sysLogLoginService.page(params);
|
||||
|
||||
return new Result<PageData<SysLogLoginDTO>>().ok(page);
|
||||
}
|
||||
|
||||
@GetMapping("export")
|
||||
@Operation(summary = "导出")
|
||||
@LogOperation("导出")
|
||||
@Parameters({
|
||||
@Parameter(name = "status", description = "状态 0:失败 1:成功 2:账号已锁定", in = ParameterIn.QUERY, ref = "int"),
|
||||
@Parameter(name = "creatorName", description = "用户名", in = ParameterIn.QUERY, ref = "String")
|
||||
})
|
||||
@RequiresPermissions("sys:log:login")
|
||||
public void export(@Parameter(hidden = true) @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
|
||||
List<SysLogLoginDTO> list = sysLogLoginService.list(params);
|
||||
|
||||
ExcelUtils.exportExcelToTarget(response, null, "登录日志", list, SysLogLoginExcel.class);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
|
||||
package com.weather.modules.log.controller;
|
||||
|
||||
import com.weather.common.annotation.LogOperation;
|
||||
import com.weather.common.constant.Constant;
|
||||
import com.weather.common.page.PageData;
|
||||
import com.weather.common.utils.ExcelUtils;
|
||||
import com.weather.common.utils.Result;
|
||||
import com.weather.modules.log.dto.SysLogOperationDTO;
|
||||
import com.weather.modules.log.excel.SysLogOperationExcel;
|
||||
import com.weather.modules.log.service.SysLogOperationService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 操作日志
|
||||
*
|
||||
* @author 123
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("sys/log/operation")
|
||||
@Tag(name = "操作日志")
|
||||
@AllArgsConstructor
|
||||
public class SysLogOperationController {
|
||||
private final SysLogOperationService sysLogOperationService;
|
||||
|
||||
@GetMapping("page")
|
||||
@Operation(summary = "分页")
|
||||
@Parameters({
|
||||
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始", in = ParameterIn.QUERY, required = true, ref = "int"),
|
||||
@Parameter(name = Constant.LIMIT, description = "每页显示记录数", in = ParameterIn.QUERY, required = true, ref = "int"),
|
||||
@Parameter(name = Constant.ORDER_FIELD, description = "排序字段", in = ParameterIn.QUERY, ref = "String"),
|
||||
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)", in = ParameterIn.QUERY, ref = "String"),
|
||||
@Parameter(name = "status", description = "状态 0:失败 1:成功", in = ParameterIn.QUERY, ref = "int")
|
||||
})
|
||||
@RequiresPermissions("sys:log:operation")
|
||||
public Result<PageData<SysLogOperationDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params) {
|
||||
PageData<SysLogOperationDTO> page = sysLogOperationService.page(params);
|
||||
|
||||
return new Result<PageData<SysLogOperationDTO>>().ok(page);
|
||||
}
|
||||
|
||||
@GetMapping("export")
|
||||
@Operation(summary = "导出")
|
||||
@LogOperation("导出")
|
||||
@RequiresPermissions("sys:log:operation")
|
||||
public void export(@Parameter(hidden = true) @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
|
||||
List<SysLogOperationDTO> list = sysLogOperationService.list(params);
|
||||
|
||||
ExcelUtils.exportExcelToTarget(response, null, "操作日志", list, SysLogOperationExcel.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
|
||||
package com.weather.modules.log.dao;
|
||||
|
||||
import com.weather.common.dao.BaseDao;
|
||||
import com.weather.modules.log.entity.SysLogErrorEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 异常日志
|
||||
*
|
||||
* @author 123
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysLogErrorDao extends BaseDao<SysLogErrorEntity> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
|
||||
package com.weather.modules.log.dao;
|
||||
|
||||
import com.weather.common.dao.BaseDao;
|
||||
import com.weather.modules.log.entity.SysLogLoginEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 登录日志
|
||||
*
|
||||
* @author 123
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysLogLoginDao extends BaseDao<SysLogLoginEntity> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
|
||||
package com.weather.modules.log.dao;
|
||||
|
||||
import com.weather.common.dao.BaseDao;
|
||||
import com.weather.modules.log.entity.SysLogOperationEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 操作日志
|
||||
*
|
||||
* @author 123
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysLogOperationDao extends BaseDao<SysLogOperationEntity> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
|
||||
|
||||
package com.weather.modules.log.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 异常日志
|
||||
*
|
||||
* @author 123
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Data
|
||||
@Schema(title = "异常日志")
|
||||
public class SysLogErrorDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(title = "id")
|
||||
private Long id;
|
||||
@Schema(title = "请求URI")
|
||||
private String requestUri;
|
||||
@Schema(title = "请求方式")
|
||||
private String requestMethod;
|
||||
@Schema(title = "请求参数")
|
||||
private String requestParams;
|
||||
@Schema(title = "用户代理")
|
||||
private String userAgent;
|
||||
@Schema(title = "操作IP")
|
||||
private String ip;
|
||||
@Schema(title = "异常信息")
|
||||
private String errorInfo;
|
||||
@Schema(title = "创建时间")
|
||||
private Date createDate;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
|
||||
|
||||
package com.weather.modules.log.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 登录日志
|
||||
*
|
||||
* @author 123
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Data
|
||||
@Schema(title = "登录日志")
|
||||
public class SysLogLoginDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(title = "id")
|
||||
private Long id;
|
||||
|
||||
@Schema(title = "用户操作 0:用户登录 1:用户退出")
|
||||
private Integer operation;
|
||||
|
||||
@Schema(title = "状态 0:失败 1:成功 2:账号已锁定")
|
||||
private Integer status;
|
||||
|
||||
@Schema(title = "用户代理")
|
||||
private String userAgent;
|
||||
|
||||
@Schema(title = "操作IP")
|
||||
private String ip;
|
||||
|
||||
@Schema(title = "用户名")
|
||||
private String creatorName;
|
||||
|
||||
@Schema(title = "创建时间")
|
||||
private Date createDate;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
|
||||
|
||||
package com.weather.modules.log.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 操作日志
|
||||
*
|
||||
* @author 123
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Data
|
||||
@Schema(title = "操作日志")
|
||||
public class SysLogOperationDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(title = "id")
|
||||
private Long id;
|
||||
|
||||
@Schema(title = "用户操作")
|
||||
private String operation;
|
||||
|
||||
@Schema(title = "请求URI")
|
||||
private String requestUri;
|
||||
|
||||
@Schema(title = "请求方式")
|
||||
private String requestMethod;
|
||||
|
||||
@Schema(title = "请求参数")
|
||||
private String requestParams;
|
||||
|
||||
@Schema(title = "请求时长(毫秒)")
|
||||
private Integer requestTime;
|
||||
|
||||
@Schema(title = "用户代理")
|
||||
private String userAgent;
|
||||
|
||||
@Schema(title = "操作IP")
|
||||
private String ip;
|
||||
|
||||
@Schema(title = "状态 0:失败 1:成功")
|
||||
private Integer status;
|
||||
|
||||
@Schema(title = "用户名")
|
||||
private String creatorName;
|
||||
|
||||
@Schema(title = "创建时间")
|
||||
private Date createDate;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
|
||||
|
||||
package com.weather.modules.log.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.weather.common.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 异常日志
|
||||
*
|
||||
* @author 123
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@TableName("sys_log_error")
|
||||
public class SysLogErrorEntity extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 请求URI
|
||||
*/
|
||||
private String requestUri;
|
||||
/**
|
||||
* 请求方式
|
||||
*/
|
||||
private String requestMethod;
|
||||
/**
|
||||
* 请求参数
|
||||
*/
|
||||
private String requestParams;
|
||||
/**
|
||||
* 用户代理
|
||||
*/
|
||||
private String userAgent;
|
||||
/**
|
||||
* 操作IP
|
||||
*/
|
||||
private String ip;
|
||||
/**
|
||||
* 异常信息
|
||||
*/
|
||||
private String errorInfo;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
|
||||
|
||||
package com.weather.modules.log.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.weather.common.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 登录日志
|
||||
*
|
||||
* @author 123
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@TableName("sys_log_login")
|
||||
public class SysLogLoginEntity extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户操作 0:用户登录 1:用户退出
|
||||
*/
|
||||
private Integer operation;
|
||||
/**
|
||||
* 状态 0:失败 1:成功 2:账号已锁定
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 用户代理
|
||||
*/
|
||||
private String userAgent;
|
||||
/**
|
||||
* 操作IP
|
||||
*/
|
||||
private String ip;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String creatorName;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
|
||||
|
||||
package com.weather.modules.log.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.weather.common.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 操作日志
|
||||
*
|
||||
* @author 123
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@TableName("sys_log_operation")
|
||||
public class SysLogOperationEntity extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户操作
|
||||
*/
|
||||
private String operation;
|
||||
/**
|
||||
* 请求URI
|
||||
*/
|
||||
private String requestUri;
|
||||
/**
|
||||
* 请求方式
|
||||
*/
|
||||
private String requestMethod;
|
||||
/**
|
||||
* 请求参数
|
||||
*/
|
||||
private String requestParams;
|
||||
/**
|
||||
* 请求时长(毫秒)
|
||||
*/
|
||||
private Integer requestTime;
|
||||
/**
|
||||
* 用户代理
|
||||
*/
|
||||
private String userAgent;
|
||||
/**
|
||||
* 操作IP
|
||||
*/
|
||||
private String ip;
|
||||
/**
|
||||
* 状态 0:失败 1:成功
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String creatorName;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
|
||||
|
||||
package com.weather.modules.log.enums;
|
||||
|
||||
/**
|
||||
* 登录操作枚举
|
||||
*
|
||||
* @author 123
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public enum LoginOperationEnum {
|
||||
/**
|
||||
* 用户登录
|
||||
*/
|
||||
LOGIN(0),
|
||||
/**
|
||||
* 用户退出
|
||||
*/
|
||||
LOGOUT(1);
|
||||
|
||||
private int value;
|
||||
|
||||
LoginOperationEnum(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int value() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
|
||||
|
||||
package com.weather.modules.log.enums;
|
||||
|
||||
/**
|
||||
* 登录状态枚举
|
||||
*
|
||||
* @author 123
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public enum LoginStatusEnum {
|
||||
/**
|
||||
* 失败
|
||||
*/
|
||||
FAIL(0),
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
SUCCESS(1),
|
||||
/**
|
||||
* 账号已锁定
|
||||
*/
|
||||
LOCK(2);
|
||||
|
||||
private int value;
|
||||
|
||||
LoginStatusEnum(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int value() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
|
||||
|
||||
package com.weather.modules.log.enums;
|
||||
|
||||
/**
|
||||
* 操作状态枚举
|
||||
*
|
||||
* @author 123
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public enum OperationStatusEnum {
|
||||
/**
|
||||
* 失败
|
||||
*/
|
||||
FAIL(0),
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
SUCCESS(1);
|
||||
|
||||
private int value;
|
||||
|
||||
OperationStatusEnum(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int value() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
|
||||
|
||||
package com.weather.modules.log.excel;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.format.DateTimeFormat;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
|
||||
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 异常日志
|
||||
*
|
||||
* @author 123
|
||||
*/
|
||||
@Data
|
||||
@ContentRowHeight(20)
|
||||
@HeadRowHeight(20)
|
||||
@ColumnWidth(25)
|
||||
public class SysLogErrorExcel {
|
||||
@ExcelProperty("请求URI")
|
||||
private String requestUri;
|
||||
|
||||
@ExcelProperty("请求方式")
|
||||
private String requestMethod;
|
||||
|
||||
@ExcelProperty("请求参数")
|
||||
private String requestParams;
|
||||
|
||||
@ExcelProperty("User-Agent")
|
||||
private String userAgent;
|
||||
|
||||
@ExcelProperty("操作IP")
|
||||
private String ip;
|
||||
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@ExcelProperty("创建时间")
|
||||
private Date createDate;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
|
||||
|
||||
package com.weather.modules.log.excel;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.format.DateTimeFormat;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
|
||||
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
|
||||
import com.weather.modules.log.excel.converter.SysLogOperationConverter;
|
||||
import com.weather.modules.log.excel.converter.SysLogStatusConverter;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 登录日志
|
||||
*
|
||||
* @author 123
|
||||
*/
|
||||
@Data
|
||||
@ContentRowHeight(20)
|
||||
@HeadRowHeight(20)
|
||||
@ColumnWidth(25)
|
||||
public class SysLogLoginExcel {
|
||||
@ExcelProperty(value = "操作类型", converter = SysLogOperationConverter.class)
|
||||
private Integer operation;
|
||||
|
||||
@ExcelProperty(value = "状态", converter = SysLogStatusConverter.class)
|
||||
private Integer status;
|
||||
|
||||
@ExcelProperty("User-Agent")
|
||||
private String userAgent;
|
||||
|
||||
@ExcelProperty("操作IP")
|
||||
private String ip;
|
||||
|
||||
@ExcelProperty("用户名")
|
||||
private String creatorName;
|
||||
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@ExcelProperty("创建时间")
|
||||
private Date createDate;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
|
||||
package com.weather.modules.log.excel;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.format.DateTimeFormat;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
|
||||
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 操作日志
|
||||
*
|
||||
* @author 123
|
||||
*/
|
||||
@Data
|
||||
@ContentRowHeight(20)
|
||||
@HeadRowHeight(20)
|
||||
@ColumnWidth(25)
|
||||
public class SysLogOperationExcel {
|
||||
@ExcelProperty("用户操作")
|
||||
private String operation;
|
||||
|
||||
@ExcelProperty("请求URI")
|
||||
private String requestUri;
|
||||
|
||||
@ExcelProperty("请求方式")
|
||||
private String requestMethod;
|
||||
|
||||
@ExcelProperty("请求参数")
|
||||
private String requestParams;
|
||||
|
||||
@ExcelProperty("请求时长(毫秒)")
|
||||
private Integer requestTime;
|
||||
|
||||
@ExcelProperty("User-Agent")
|
||||
private String userAgent;
|
||||
|
||||
@ExcelProperty("操作IP")
|
||||
private String ip;
|
||||
|
||||
@ExcelProperty("状态")
|
||||
private Integer status;
|
||||
|
||||
@ExcelProperty("用户名")
|
||||
private String creatorName;
|
||||
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@ExcelProperty("创建时间")
|
||||
private Date createDate;
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package com.weather.modules.log.excel.converter;
|
||||
|
||||
import com.alibaba.excel.converters.Converter;
|
||||
import com.alibaba.excel.enums.CellDataTypeEnum;
|
||||
import com.alibaba.excel.metadata.GlobalConfiguration;
|
||||
import com.alibaba.excel.metadata.data.ReadCellData;
|
||||
import com.alibaba.excel.metadata.data.WriteCellData;
|
||||
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
||||
|
||||
public class SysLogOperationConverter implements Converter<Integer> {
|
||||
|
||||
@Override
|
||||
public Class<Integer> supportJavaTypeKey() {
|
||||
return Integer.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CellDataTypeEnum supportExcelTypeKey() {
|
||||
return CellDataTypeEnum.STRING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
|
||||
if(cellData.getStringValue().equals("用户登录")){
|
||||
return 0;
|
||||
}else{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WriteCellData<?> convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
|
||||
if(value == 0){
|
||||
return new WriteCellData<>("用户登录");
|
||||
}else{
|
||||
return new WriteCellData<>("用户退出");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package com.weather.modules.log.excel.converter;
|
||||
|
||||
import com.alibaba.excel.converters.Converter;
|
||||
import com.alibaba.excel.enums.CellDataTypeEnum;
|
||||
import com.alibaba.excel.metadata.GlobalConfiguration;
|
||||
import com.alibaba.excel.metadata.data.ReadCellData;
|
||||
import com.alibaba.excel.metadata.data.WriteCellData;
|
||||
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
||||
|
||||
public class SysLogStatusConverter implements Converter<Integer> {
|
||||
|
||||
@Override
|
||||
public Class<Integer> supportJavaTypeKey() {
|
||||
return Integer.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CellDataTypeEnum supportExcelTypeKey() {
|
||||
return CellDataTypeEnum.STRING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
|
||||
if(cellData.getStringValue().equals("失败")){
|
||||
return 0;
|
||||
}else if(cellData.getStringValue().equals("成功")){
|
||||
return 1;
|
||||
}else if(cellData.getStringValue().equals("账号已锁定")){
|
||||
return 2;
|
||||
}else{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WriteCellData<?> convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
|
||||
if(value == 0){
|
||||
return new WriteCellData<>("失败");
|
||||
}else if(value == 1){
|
||||
return new WriteCellData<>("成功");
|
||||
}else if(value == 2){
|
||||
return new WriteCellData<>("账号已锁定");
|
||||
}else{
|
||||
return new WriteCellData<>("未知");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
|
||||
|
||||
package com.weather.modules.log.service;
|
||||
|
||||
|
||||
import com.weather.common.page.PageData;
|
||||
import com.weather.common.service.BaseService;
|
||||
import com.weather.modules.log.dto.SysLogErrorDTO;
|
||||
import com.weather.modules.log.entity.SysLogErrorEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 异常日志
|
||||
*
|
||||
* @author 123
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface SysLogErrorService extends BaseService<SysLogErrorEntity> {
|
||||
|
||||
PageData<SysLogErrorDTO> page(Map<String, Object> params);
|
||||
|
||||
List<SysLogErrorDTO> list(Map<String, Object> params);
|
||||
|
||||
void save(SysLogErrorEntity entity);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
|
||||
|
||||
package com.weather.modules.log.service;
|
||||
|
||||
import com.weather.common.page.PageData;
|
||||
import com.weather.common.service.BaseService;
|
||||
import com.weather.modules.log.dto.SysLogLoginDTO;
|
||||
import com.weather.modules.log.entity.SysLogLoginEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 登录日志
|
||||
*
|
||||
* @author 123
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface SysLogLoginService extends BaseService<SysLogLoginEntity> {
|
||||
|
||||
PageData<SysLogLoginDTO> page(Map<String, Object> params);
|
||||
|
||||
List<SysLogLoginDTO> list(Map<String, Object> params);
|
||||
|
||||
void save(SysLogLoginEntity entity);
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
|
||||
|
||||
package com.weather.modules.log.service;
|
||||
|
||||
import com.weather.common.page.PageData;
|
||||
import com.weather.common.service.BaseService;
|
||||
import com.weather.modules.log.dto.SysLogOperationDTO;
|
||||
import com.weather.modules.log.entity.SysLogOperationEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 操作日志
|
||||
*
|
||||
* @author 123
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface SysLogOperationService extends BaseService<SysLogOperationEntity> {
|
||||
|
||||
PageData<SysLogOperationDTO> page(Map<String, Object> params);
|
||||
|
||||
List<SysLogOperationDTO> list(Map<String, Object> params);
|
||||
|
||||
void save(SysLogOperationEntity entity);
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
|
||||
|
||||
package com.weather.modules.log.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.weather.common.constant.Constant;
|
||||
import com.weather.common.page.PageData;
|
||||
import com.weather.common.service.impl.BaseServiceImpl;
|
||||
import com.weather.common.utils.ConvertUtils;
|
||||
import com.weather.modules.log.dao.SysLogErrorDao;
|
||||
import com.weather.modules.log.dto.SysLogErrorDTO;
|
||||
import com.weather.modules.log.entity.SysLogErrorEntity;
|
||||
import com.weather.modules.log.service.SysLogErrorService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 异常日志
|
||||
*
|
||||
* @author 123
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Service
|
||||
public class SysLogErrorServiceImpl extends BaseServiceImpl<SysLogErrorDao, SysLogErrorEntity> implements SysLogErrorService {
|
||||
|
||||
@Override
|
||||
public PageData<SysLogErrorDTO> page(Map<String, Object> params) {
|
||||
IPage<SysLogErrorEntity> page = baseDao.selectPage(
|
||||
getPage(params, Constant.CREATE_DATE, false),
|
||||
getWrapper(params)
|
||||
);
|
||||
|
||||
return getPageData(page, SysLogErrorDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysLogErrorDTO> list(Map<String, Object> params) {
|
||||
List<SysLogErrorEntity> entityList = baseDao.selectList(getWrapper(params));
|
||||
|
||||
return ConvertUtils.sourceToTarget(entityList, SysLogErrorDTO.class);
|
||||
}
|
||||
|
||||
private QueryWrapper<SysLogErrorEntity> getWrapper(Map<String, Object> params){
|
||||
QueryWrapper<SysLogErrorEntity> wrapper = new QueryWrapper<>();
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void save(SysLogErrorEntity entity) {
|
||||
insert(entity);
|
||||
}
|
||||
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
|
||||
|
||||
package com.weather.modules.log.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.weather.common.constant.Constant;
|
||||
import com.weather.common.page.PageData;
|
||||
import com.weather.common.service.impl.BaseServiceImpl;
|
||||
import com.weather.common.utils.ConvertUtils;
|
||||
import com.weather.modules.log.dao.SysLogLoginDao;
|
||||
import com.weather.modules.log.dto.SysLogLoginDTO;
|
||||
import com.weather.modules.log.entity.SysLogLoginEntity;
|
||||
import com.weather.modules.log.service.SysLogLoginService;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 登录日志
|
||||
*
|
||||
* @author 123
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Service
|
||||
public class SysLogLoginServiceImpl extends BaseServiceImpl<SysLogLoginDao, SysLogLoginEntity> implements SysLogLoginService {
|
||||
|
||||
@Override
|
||||
public PageData<SysLogLoginDTO> page(Map<String, Object> params) {
|
||||
IPage<SysLogLoginEntity> page = baseDao.selectPage(
|
||||
getPage(params, Constant.CREATE_DATE, false),
|
||||
getWrapper(params)
|
||||
);
|
||||
|
||||
return getPageData(page, SysLogLoginDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysLogLoginDTO> list(Map<String, Object> params) {
|
||||
List<SysLogLoginEntity> entityList = baseDao.selectList(getWrapper(params));
|
||||
|
||||
return ConvertUtils.sourceToTarget(entityList, SysLogLoginDTO.class);
|
||||
}
|
||||
|
||||
private QueryWrapper<SysLogLoginEntity> getWrapper(Map<String, Object> params){
|
||||
String status = (String) params.get("status");
|
||||
String creatorName = (String) params.get("creatorName");
|
||||
|
||||
QueryWrapper<SysLogLoginEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq(StrUtil.isNotBlank(status), "status", status);
|
||||
wrapper.like(StrUtil.isNotBlank(creatorName), "creator_name", creatorName);
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void save(SysLogLoginEntity entity) {
|
||||
insert(entity);
|
||||
}
|
||||
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
|
||||
|
||||
package com.weather.modules.log.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.weather.common.constant.Constant;
|
||||
import com.weather.common.page.PageData;
|
||||
import com.weather.common.service.impl.BaseServiceImpl;
|
||||
import com.weather.common.utils.ConvertUtils;
|
||||
import com.weather.modules.log.dao.SysLogOperationDao;
|
||||
import com.weather.modules.log.dto.SysLogOperationDTO;
|
||||
import com.weather.modules.log.entity.SysLogOperationEntity;
|
||||
import com.weather.modules.log.service.SysLogOperationService;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 操作日志
|
||||
*
|
||||
* @author 123
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Service
|
||||
public class SysLogOperationServiceImpl extends BaseServiceImpl<SysLogOperationDao, SysLogOperationEntity> implements SysLogOperationService {
|
||||
|
||||
@Override
|
||||
public PageData<SysLogOperationDTO> page(Map<String, Object> params) {
|
||||
IPage<SysLogOperationEntity> page = baseDao.selectPage(
|
||||
getPage(params, Constant.CREATE_DATE, false),
|
||||
getWrapper(params)
|
||||
);
|
||||
|
||||
return getPageData(page, SysLogOperationDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysLogOperationDTO> list(Map<String, Object> params) {
|
||||
List<SysLogOperationEntity> entityList = baseDao.selectList(getWrapper(params));
|
||||
|
||||
return ConvertUtils.sourceToTarget(entityList, SysLogOperationDTO.class);
|
||||
}
|
||||
|
||||
private QueryWrapper<SysLogOperationEntity> getWrapper(Map<String, Object> params){
|
||||
String status = (String) params.get("status");
|
||||
|
||||
QueryWrapper<SysLogOperationEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq(StrUtil.isNotBlank(status), "status", status);
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void save(SysLogOperationEntity entity) {
|
||||
insert(entity);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user