新增系统操作日志
parent
d505666984
commit
6f00ab30d8
@ -0,0 +1,40 @@
|
||||
package com.glxp.api.admin.annotation;
|
||||
|
||||
|
||||
import com.glxp.api.admin.constant.BusinessType;
|
||||
import com.glxp.api.admin.constant.OperatorType;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 自定义操作日志记录注解
|
||||
*/
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface Log {
|
||||
/**
|
||||
* 模块
|
||||
*/
|
||||
String title() default "";
|
||||
|
||||
/**
|
||||
* 功能
|
||||
*/
|
||||
BusinessType businessType() default BusinessType.OTHER;
|
||||
|
||||
/**
|
||||
* 操作人类别
|
||||
*/
|
||||
OperatorType operatorType() default OperatorType.MANAGE;
|
||||
|
||||
/**
|
||||
* 是否保存请求的参数
|
||||
*/
|
||||
boolean isSaveRequestData() default true;
|
||||
|
||||
/**
|
||||
* 是否保存响应的参数
|
||||
*/
|
||||
boolean isSaveResponseData() default true;
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package com.glxp.api.admin.config;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 读取项目相关配置
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "ruoyi")
|
||||
public class RuoYiConfig {
|
||||
|
||||
/**
|
||||
* 项目名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 版本
|
||||
*/
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 版权年份
|
||||
*/
|
||||
private String copyrightYear;
|
||||
|
||||
/**
|
||||
* 实例演示开关
|
||||
*/
|
||||
private boolean demoEnabled;
|
||||
|
||||
/**
|
||||
* 缓存懒加载
|
||||
*/
|
||||
private boolean cacheLazy;
|
||||
|
||||
/**
|
||||
* 获取地址开关
|
||||
*/
|
||||
@Getter
|
||||
private static boolean addressEnabled;
|
||||
|
||||
public void setAddressEnabled(boolean addressEnabled) {
|
||||
RuoYiConfig.addressEnabled = addressEnabled;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.glxp.api.admin.constant;
|
||||
|
||||
/**
|
||||
* 操作状态
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public enum BusinessStatus {
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
SUCCESS,
|
||||
|
||||
/**
|
||||
* 失败
|
||||
*/
|
||||
FAIL,
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.glxp.api.admin.constant;
|
||||
|
||||
/**
|
||||
* 业务操作类型
|
||||
*/
|
||||
public enum BusinessType {
|
||||
/**
|
||||
* 其它
|
||||
*/
|
||||
OTHER,
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
INSERT,
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
UPDATE,
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
DELETE,
|
||||
|
||||
/**
|
||||
* 授权
|
||||
*/
|
||||
GRANT,
|
||||
|
||||
/**
|
||||
* 导出
|
||||
*/
|
||||
EXPORT,
|
||||
|
||||
/**
|
||||
* 导入
|
||||
*/
|
||||
IMPORT,
|
||||
|
||||
/**
|
||||
* 强退
|
||||
*/
|
||||
FORCE,
|
||||
|
||||
/**
|
||||
* 生成代码
|
||||
*/
|
||||
GENCODE,
|
||||
|
||||
/**
|
||||
* 清空数据
|
||||
*/
|
||||
CLEAN,
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.glxp.api.admin.constant;
|
||||
|
||||
/**
|
||||
* 操作人类别
|
||||
*/
|
||||
public enum OperatorType {
|
||||
/**
|
||||
* 其它
|
||||
*/
|
||||
OTHER,
|
||||
|
||||
/**
|
||||
* 后台用户
|
||||
*/
|
||||
MANAGE,
|
||||
|
||||
/**
|
||||
* 手机端用户
|
||||
*/
|
||||
MOBILE
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package com.glxp.api.admin.controller.monitor;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.glxp.api.admin.annotation.Log;
|
||||
import com.glxp.api.admin.constant.BusinessType;
|
||||
import com.glxp.api.admin.controller.BaseController;
|
||||
import com.glxp.api.admin.entity.monitor.SysLogininfor;
|
||||
import com.glxp.api.admin.req.monitor.SysLogininforRequest;
|
||||
import com.glxp.api.admin.res.PageSimpleResponse;
|
||||
import com.glxp.api.admin.service.monitor.ISysLogininforService;
|
||||
import com.glxp.api.common.res.BaseResponse;
|
||||
import com.glxp.api.common.util.ResultVOUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统访问记录
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/monitor/logininfor")
|
||||
public class SysLogininforController extends BaseController {
|
||||
|
||||
private final ISysLogininforService logininforService;
|
||||
|
||||
/**
|
||||
* 获取系统访问记录列表
|
||||
*/
|
||||
@SaCheckPermission("monitor:logininfor:list")
|
||||
@GetMapping("/list")
|
||||
public BaseResponse list(SysLogininforRequest sysLogininforRequest) {
|
||||
|
||||
List<SysLogininfor> selectLogininforList = logininforService.selectLogininforList(sysLogininforRequest);
|
||||
PageInfo<SysLogininfor> pageInfo;
|
||||
pageInfo = new PageInfo<>(selectLogininforList);
|
||||
PageSimpleResponse<SysLogininfor> pageSimpleResponse = new PageSimpleResponse<>();
|
||||
pageSimpleResponse.setTotal(pageInfo.getTotal());
|
||||
pageSimpleResponse.setList(selectLogininforList);
|
||||
return ResultVOUtils.success(pageSimpleResponse);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量删除登录日志
|
||||
*
|
||||
* @param infoIds 日志ids
|
||||
*/
|
||||
@SaCheckPermission("monitor:logininfor:remove")
|
||||
@Log(title = "登录日志", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{infoIds}")
|
||||
public BaseResponse remove(@PathVariable Long[] infoIds) {
|
||||
int i = logininforService.deleteLogininforByIds(Arrays.asList(infoIds));
|
||||
return ResultVOUtils.success("删除成功!");
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.glxp.api.admin.controller.monitor;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.glxp.api.admin.annotation.Log;
|
||||
import com.glxp.api.admin.constant.BusinessType;
|
||||
import com.glxp.api.admin.controller.BaseController;
|
||||
import com.glxp.api.admin.entity.info.DeviceKeyEntity;
|
||||
import com.glxp.api.admin.entity.monitor.SysOperLog;
|
||||
import com.glxp.api.admin.req.monitor.SysOperLogRequest;
|
||||
import com.glxp.api.admin.res.PageSimpleResponse;
|
||||
import com.glxp.api.admin.service.monitor.ISysOperLogService;
|
||||
import com.glxp.api.common.res.BaseResponse;
|
||||
import com.glxp.api.common.util.ResultVOUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 操作日志记录
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/monitor/operlog")
|
||||
public class SysOperlogController extends BaseController {
|
||||
|
||||
private final ISysOperLogService operLogService;
|
||||
|
||||
/**
|
||||
* 获取操作日志记录列表
|
||||
*/
|
||||
@Log(title = "操作日志", businessType = BusinessType.OTHER)
|
||||
@SaCheckPermission("monitor:operlog:list")
|
||||
@GetMapping("/list")
|
||||
public BaseResponse list(SysOperLogRequest sysOperLogRequest) {
|
||||
|
||||
List<SysOperLog> selectOperLogList = operLogService.selectOperLogList(sysOperLogRequest);
|
||||
PageInfo<SysOperLog> pageInfo;
|
||||
pageInfo = new PageInfo<>(selectOperLogList);
|
||||
PageSimpleResponse<SysOperLog> pageSimpleResponse = new PageSimpleResponse<>();
|
||||
pageSimpleResponse.setTotal(pageInfo.getTotal());
|
||||
pageSimpleResponse.setList(selectOperLogList);
|
||||
return ResultVOUtils.success(pageSimpleResponse);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量删除操作日志记录
|
||||
*
|
||||
* @param operIds 日志ids
|
||||
*/
|
||||
@Log(title = "操作日志", businessType = BusinessType.DELETE)
|
||||
@SaCheckPermission("monitor:operlog:remove")
|
||||
@DeleteMapping("/{operIds}")
|
||||
public BaseResponse remove(@PathVariable Long[] operIds) {
|
||||
|
||||
int i = operLogService.deleteOperLogByIds(operIds);
|
||||
return ResultVOUtils.success("删除成功!");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.glxp.api.admin.dao.monitor;
|
||||
|
||||
import com.glxp.api.admin.entity.monitor.SysLogininfor;
|
||||
import com.glxp.api.admin.req.monitor.SysLogininforRequest;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统访问日志情况信息 数据层
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysLogininforMapper {
|
||||
|
||||
|
||||
int insert(SysLogininfor sysLogininfor);
|
||||
|
||||
int deleteBatchIds(@Param("infoIds") List<Long> infoIds);
|
||||
|
||||
List<SysLogininfor> selectLogininforList(SysLogininforRequest logininforRequest);
|
||||
|
||||
/**
|
||||
* 新增系统登录日志
|
||||
*
|
||||
* @param logininfor 访问日志对象
|
||||
*/
|
||||
void insertLogininfor(SysLogininfor logininfor);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.glxp.api.admin.dao.monitor;
|
||||
|
||||
|
||||
import com.glxp.api.admin.entity.monitor.SysOperLog;
|
||||
import com.glxp.api.admin.req.monitor.SysOperLogRequest;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 操作日志 数据层
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysOperLogMapper {
|
||||
|
||||
List<SysOperLog> selectList(SysOperLogRequest sysOperLogRequest);
|
||||
|
||||
int insert(SysOperLog sysOperLog);
|
||||
|
||||
int deleteBatchIds(@Param("ids") List<Long> ids);
|
||||
|
||||
int delete(Long id);
|
||||
|
||||
SysOperLog selectById(Long id);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package com.glxp.api.admin.entity.monitor;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 系统访问记录表 sys_logininfor
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class SysLogininfor implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private Long infoId;
|
||||
|
||||
/**
|
||||
* 用户账号
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 登录状态 0成功 1失败
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 登录IP地址
|
||||
*/
|
||||
private String ipaddr;
|
||||
|
||||
/**
|
||||
* 登录地点
|
||||
*/
|
||||
private String loginLocation;
|
||||
|
||||
/**
|
||||
* 浏览器类型
|
||||
*/
|
||||
private String browser;
|
||||
|
||||
/**
|
||||
* 操作系统
|
||||
*/
|
||||
private String os;
|
||||
|
||||
/**
|
||||
* 提示消息
|
||||
*/
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 访问时间
|
||||
*/
|
||||
private Date loginTime;
|
||||
|
||||
/**
|
||||
* 请求参数
|
||||
*/
|
||||
private Map<String, Object> params = new HashMap<>();
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.glxp.api.admin.req.monitor;
|
||||
|
||||
import com.glxp.api.admin.req.ListPageRequest;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class SysLogininforRequest extends ListPageRequest {
|
||||
|
||||
private Long infoId;
|
||||
|
||||
private String userName;
|
||||
|
||||
private String status;
|
||||
|
||||
private String ipaddr;
|
||||
|
||||
private String loginLocation;
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.glxp.api.admin.req.monitor;
|
||||
|
||||
import com.glxp.api.admin.req.ListPageRequest;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class SysOperLogRequest extends ListPageRequest {
|
||||
|
||||
private Long operId;
|
||||
|
||||
private String title;
|
||||
|
||||
private Integer businessType;
|
||||
|
||||
private String method;
|
||||
|
||||
private String requestMethod;
|
||||
|
||||
private Integer operatorType;
|
||||
|
||||
private String operName;
|
||||
|
||||
private String deptName;
|
||||
|
||||
private String operUrl;
|
||||
|
||||
private String operIp;
|
||||
|
||||
private Integer status;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.glxp.api.admin.service.monitor;
|
||||
|
||||
|
||||
import com.glxp.api.admin.entity.monitor.SysLogininfor;
|
||||
import com.glxp.api.admin.req.monitor.SysLogininforRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统访问日志情况信息 服务层
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface ISysLogininforService {
|
||||
|
||||
|
||||
List<SysLogininfor> selectLogininforList(SysLogininforRequest logininforRequest);
|
||||
|
||||
/**
|
||||
* 新增系统登录日志
|
||||
*
|
||||
* @param logininfor 访问日志对象
|
||||
*/
|
||||
void insertLogininfor(SysLogininfor logininfor);
|
||||
|
||||
|
||||
/**
|
||||
* 批量删除系统登录日志
|
||||
*
|
||||
* @param infoIds 需要删除的登录日志ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteLogininforByIds(List<Long> infoIds);
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package com.glxp.api.admin.service.monitor;
|
||||
|
||||
|
||||
import com.glxp.api.admin.entity.monitor.SysOperLog;
|
||||
import com.glxp.api.admin.req.monitor.SysOperLogRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 操作日志 服务层
|
||||
*/
|
||||
public interface ISysOperLogService {
|
||||
|
||||
|
||||
/**
|
||||
* 新增操作日志
|
||||
*
|
||||
* @param operLog 操作日志对象
|
||||
*/
|
||||
void insertOperlog(SysOperLog operLog);
|
||||
|
||||
/**
|
||||
* 查询系统操作日志集合
|
||||
*
|
||||
* @param operLog 操作日志对象
|
||||
* @return 操作日志集合
|
||||
*/
|
||||
List<SysOperLog> selectOperLogList(SysOperLogRequest sysOperLogRequest);
|
||||
|
||||
/**
|
||||
* 批量删除系统操作日志
|
||||
*
|
||||
* @param operIds 需要删除的操作日志ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteOperLogByIds(Long[] operIds);
|
||||
|
||||
/**
|
||||
* 查询操作日志详细
|
||||
*
|
||||
* @param operId 操作ID
|
||||
* @return 操作日志对象
|
||||
*/
|
||||
SysOperLog selectOperLogById(Long operId);
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.glxp.api.admin.service.monitor;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 通用 系统访问日志
|
||||
*/
|
||||
public interface LogininforService {
|
||||
|
||||
void recordLogininfor(String username, String status, String message,
|
||||
HttpServletRequest request, Object... args);
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.glxp.api.admin.service.monitor;
|
||||
|
||||
import com.glxp.api.admin.entity.monitor.OperLogDTO;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
|
||||
/**
|
||||
* 通用 操作日志
|
||||
*/
|
||||
public interface OperLogService {
|
||||
|
||||
@Async
|
||||
void recordOper(OperLogDTO operLogDTO);
|
||||
}
|
@ -0,0 +1,113 @@
|
||||
package com.glxp.api.admin.service.monitor.impl;
|
||||
|
||||
import cn.hutool.http.useragent.UserAgent;
|
||||
import cn.hutool.http.useragent.UserAgentUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.glxp.api.admin.constant.Constant;
|
||||
import com.glxp.api.admin.dao.monitor.SysLogininforMapper;
|
||||
import com.glxp.api.admin.entity.monitor.SysLogininfor;
|
||||
import com.glxp.api.admin.req.monitor.SysLogininforRequest;
|
||||
import com.glxp.api.admin.service.monitor.ISysLogininforService;
|
||||
import com.glxp.api.admin.service.monitor.LogininforService;
|
||||
import com.glxp.api.admin.util.AddressUtils;
|
||||
import com.glxp.api.admin.util.ServletUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统访问日志情况信息 服务层处理
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SysLogininforServiceImpl implements ISysLogininforService, LogininforService {
|
||||
|
||||
private final SysLogininforMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 记录登录信息
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param status 状态
|
||||
* @param message 消息
|
||||
* @param args 列表
|
||||
*/
|
||||
@Async
|
||||
@Override
|
||||
public void recordLogininfor(final String username, final String status, final String message,
|
||||
HttpServletRequest request, final Object... args) {
|
||||
final UserAgent userAgent = UserAgentUtil.parse(request.getHeader("User-Agent"));
|
||||
final String ip = ServletUtils.getClientIP(request);
|
||||
|
||||
String address = AddressUtils.getRealAddressByIP(ip);
|
||||
StringBuilder s = new StringBuilder();
|
||||
s.append(getBlock(ip));
|
||||
s.append(address);
|
||||
s.append(getBlock(username));
|
||||
s.append(getBlock(status));
|
||||
s.append(getBlock(message));
|
||||
// 打印信息到日志
|
||||
log.info(s.toString(), args);
|
||||
// 获取客户端操作系统
|
||||
String os = userAgent.getOs().getName();
|
||||
// 获取客户端浏览器
|
||||
String browser = userAgent.getBrowser().getName();
|
||||
// 封装对象
|
||||
SysLogininfor logininfor = new SysLogininfor();
|
||||
logininfor.setUserName(username);
|
||||
logininfor.setIpaddr(ip);
|
||||
logininfor.setLoginLocation(address);
|
||||
logininfor.setBrowser(browser);
|
||||
logininfor.setOs(os);
|
||||
logininfor.setMsg(message);
|
||||
// 日志状态
|
||||
if (StringUtils.equalsAny(status, Constant.LOGIN_SUCCESS, Constant.LOGOUT, Constant.REGISTER)) {
|
||||
logininfor.setStatus(Constant.SUCCESS);
|
||||
} else if (Constant.LOGIN_FAIL.equals(status)) {
|
||||
logininfor.setStatus(Constant.FAIL);
|
||||
}
|
||||
// 插入数据
|
||||
insertLogininfor(logininfor);
|
||||
}
|
||||
|
||||
private String getBlock(Object msg) {
|
||||
if (msg == null) {
|
||||
msg = "";
|
||||
}
|
||||
return "[" + msg.toString() + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysLogininfor> selectLogininforList(SysLogininforRequest logininfor) {
|
||||
if (logininfor.getPage() != null) {
|
||||
int offset = (logininfor.getPage() - 1) * logininfor.getLimit();
|
||||
PageHelper.offsetPage(offset, logininfor.getLimit());
|
||||
}
|
||||
return baseMapper.selectLogininforList(logininfor);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增系统登录日志
|
||||
*
|
||||
* @param logininfor 访问日志对象
|
||||
*/
|
||||
@Override
|
||||
public void insertLogininfor(SysLogininfor logininfor) {
|
||||
logininfor.setLoginTime(new Date());
|
||||
baseMapper.insert(logininfor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteLogininforByIds(List<Long> infoIds) {
|
||||
return baseMapper.deleteBatchIds(infoIds);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package com.glxp.api.admin.service.monitor.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.glxp.api.admin.dao.monitor.SysOperLogMapper;
|
||||
import com.glxp.api.admin.entity.monitor.OperLogDTO;
|
||||
import com.glxp.api.admin.entity.monitor.SysOperLog;
|
||||
import com.glxp.api.admin.req.monitor.SysOperLogRequest;
|
||||
import com.glxp.api.admin.service.monitor.ISysOperLogService;
|
||||
import com.glxp.api.admin.service.monitor.OperLogService;
|
||||
import com.glxp.api.admin.util.AddressUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 操作日志 服务层处理
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class SysOperLogServiceImpl implements ISysOperLogService, OperLogService {
|
||||
|
||||
private final SysOperLogMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 操作日志记录
|
||||
*
|
||||
* @param operLogDTO 操作日志信息
|
||||
*/
|
||||
@Async
|
||||
@Override
|
||||
public void recordOper(final OperLogDTO operLogDTO) {
|
||||
SysOperLog operLog = BeanUtil.toBean(operLogDTO, SysOperLog.class);
|
||||
// 远程查询操作地点
|
||||
operLog.setOperLocation(AddressUtils.getRealAddressByIP(operLog.getOperIp()));
|
||||
insertOperlog(operLog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysOperLog> selectOperLogList(SysOperLogRequest sysOperLogRequest) {
|
||||
if (sysOperLogRequest.getPage() != null) {
|
||||
int offset = (sysOperLogRequest.getPage() - 1) * sysOperLogRequest.getLimit();
|
||||
PageHelper.offsetPage(offset, sysOperLogRequest.getLimit());
|
||||
}
|
||||
return baseMapper.selectList(sysOperLogRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增操作日志
|
||||
*
|
||||
* @param operLog 操作日志对象
|
||||
*/
|
||||
@Override
|
||||
public void insertOperlog(SysOperLog operLog) {
|
||||
operLog.setOperTime(new Date());
|
||||
baseMapper.insert(operLog);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量删除系统操作日志
|
||||
*
|
||||
* @param operIds 需要删除的操作日志ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteOperLogByIds(Long[] operIds) {
|
||||
return baseMapper.deleteBatchIds(Arrays.asList(operIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询操作日志详细
|
||||
*
|
||||
* @param operId 操作ID
|
||||
* @return 操作日志对象
|
||||
*/
|
||||
@Override
|
||||
public SysOperLog selectOperLogById(Long operId) {
|
||||
return baseMapper.selectById(operId);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package com.glxp.api.admin.util;
|
||||
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import cn.hutool.core.net.NetUtil;
|
||||
import cn.hutool.http.HtmlUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.glxp.api.admin.config.RuoYiConfig;
|
||||
import com.glxp.api.admin.constant.Constant;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.tomcat.util.bcel.Const;
|
||||
|
||||
/**
|
||||
* 获取地址类
|
||||
*/
|
||||
@Slf4j
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class AddressUtils {
|
||||
|
||||
// IP地址查询
|
||||
public static final String IP_URL = "http://whois.pconline.com.cn/ipJson.jsp";
|
||||
|
||||
// 未知地址
|
||||
public static final String UNKNOWN = "XX XX";
|
||||
|
||||
public static String getRealAddressByIP(String ip) {
|
||||
String address = UNKNOWN;
|
||||
if (StringUtils.isBlank(ip)) {
|
||||
return address;
|
||||
}
|
||||
// 内网不查询
|
||||
ip = "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : HtmlUtil.cleanHtmlTag(ip);
|
||||
if (NetUtil.isInnerIP(ip)) {
|
||||
return "内网IP";
|
||||
}
|
||||
if (RuoYiConfig.isAddressEnabled()) {
|
||||
try {
|
||||
String rspStr = HttpUtil.createGet(IP_URL)
|
||||
.body("ip=" + ip + "&json=true", Constant.GBK)
|
||||
.execute()
|
||||
.body();
|
||||
if (StringUtils.isEmpty(rspStr)) {
|
||||
log.error("获取地理位置异常 {}", ip);
|
||||
return UNKNOWN;
|
||||
}
|
||||
Dict obj = JsonUtils.parseMap(rspStr);
|
||||
String region = obj.getStr("pro");
|
||||
String city = obj.getStr("city");
|
||||
return String.format("%s %s", region, city);
|
||||
} catch (Exception e) {
|
||||
log.error("获取地理位置异常 {}", ip);
|
||||
}
|
||||
}
|
||||
return UNKNOWN;
|
||||
}
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
package com.glxp.api.admin.util;
|
||||
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* JSON 工具类
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class JsonUtils {
|
||||
|
||||
private static final ObjectMapper OBJECT_MAPPER = SpringUtils.getBean(ObjectMapper.class);
|
||||
|
||||
public static ObjectMapper getObjectMapper() {
|
||||
return OBJECT_MAPPER;
|
||||
}
|
||||
|
||||
public static String toJsonString(Object object) {
|
||||
if (ObjectUtil.isNull(object)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return OBJECT_MAPPER.writeValueAsString(object);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T parseObject(String text, Class<T> clazz) {
|
||||
if (StringUtils.isEmpty(text)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return OBJECT_MAPPER.readValue(text, clazz);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T parseObject(byte[] bytes, Class<T> clazz) {
|
||||
if (ArrayUtil.isEmpty(bytes)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return OBJECT_MAPPER.readValue(bytes, clazz);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T parseObject(String text, TypeReference<T> typeReference) {
|
||||
if (StringUtils.isBlank(text)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return OBJECT_MAPPER.readValue(text, typeReference);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Dict parseMap(String text) {
|
||||
if (StringUtils.isBlank(text)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return OBJECT_MAPPER.readValue(text, OBJECT_MAPPER.getTypeFactory().constructType(Dict.class));
|
||||
} catch (MismatchedInputException e) {
|
||||
// 类型不匹配说明不是json
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Dict> parseArrayMap(String text) {
|
||||
if (StringUtils.isBlank(text)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return OBJECT_MAPPER.readValue(text, OBJECT_MAPPER.getTypeFactory().constructCollectionType(List.class, Dict.class));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> List<T> parseArray(String text, Class<T> clazz) {
|
||||
if (StringUtils.isEmpty(text)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
try {
|
||||
return OBJECT_MAPPER.readValue(text, OBJECT_MAPPER.getTypeFactory().constructCollectionType(List.class, clazz));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.glxp.api.admin.util;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
|
||||
/**
|
||||
* 获取i18n资源文件
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class MessageUtils {
|
||||
|
||||
private static final MessageSource MESSAGE_SOURCE = SpringUtils.getBean(MessageSource.class);
|
||||
|
||||
/**
|
||||
* 根据消息键和参数 获取消息 委托给spring messageSource
|
||||
*
|
||||
* @param code 消息键
|
||||
* @param args 参数
|
||||
* @return 获取国际化翻译值
|
||||
*/
|
||||
public static String message(String code, Object... args) {
|
||||
return MESSAGE_SOURCE.getMessage(code, args, LocaleContextHolder.getLocale());
|
||||
}
|
||||
}
|
@ -0,0 +1,173 @@
|
||||
package com.glxp.api.admin.util;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.hutool.http.HttpStatus;
|
||||
import com.glxp.api.admin.constant.Constant;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* 客户端工具类
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class ServletUtils extends ServletUtil {
|
||||
|
||||
/**
|
||||
* 获取String参数
|
||||
*/
|
||||
public static String getParameter(String name) {
|
||||
return getRequest().getParameter(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取String参数
|
||||
*/
|
||||
public static String getParameter(String name, String defaultValue) {
|
||||
return Convert.toStr(getRequest().getParameter(name), defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Integer参数
|
||||
*/
|
||||
public static Integer getParameterToInt(String name) {
|
||||
return Convert.toInt(getRequest().getParameter(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Integer参数
|
||||
*/
|
||||
public static Integer getParameterToInt(String name, Integer defaultValue) {
|
||||
return Convert.toInt(getRequest().getParameter(name), defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Boolean参数
|
||||
*/
|
||||
public static Boolean getParameterToBool(String name) {
|
||||
return Convert.toBool(getRequest().getParameter(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Boolean参数
|
||||
*/
|
||||
public static Boolean getParameterToBool(String name, Boolean defaultValue) {
|
||||
return Convert.toBool(getRequest().getParameter(name), defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取request
|
||||
*/
|
||||
public static HttpServletRequest getRequest() {
|
||||
return getRequestAttributes().getRequest();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取response
|
||||
*/
|
||||
public static HttpServletResponse getResponse() {
|
||||
return getRequestAttributes().getResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取session
|
||||
*/
|
||||
public static HttpSession getSession() {
|
||||
return getRequest().getSession();
|
||||
}
|
||||
|
||||
public static ServletRequestAttributes getRequestAttributes() {
|
||||
RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
|
||||
return (ServletRequestAttributes) attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将字符串渲染到客户端
|
||||
*
|
||||
* @param response 渲染对象
|
||||
* @param string 待渲染的字符串
|
||||
*/
|
||||
public static void renderString(HttpServletResponse response, String string) {
|
||||
try {
|
||||
response.setStatus(HttpStatus.HTTP_OK);
|
||||
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
|
||||
response.setCharacterEncoding(StandardCharsets.UTF_8.toString());
|
||||
response.getWriter().print(string);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是Ajax异步请求
|
||||
*
|
||||
* @param request
|
||||
*/
|
||||
public static boolean isAjaxRequest(HttpServletRequest request) {
|
||||
|
||||
String accept = request.getHeader("accept");
|
||||
if (accept != null && accept.contains(MediaType.APPLICATION_JSON_VALUE)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String xRequestedWith = request.getHeader("X-Requested-With");
|
||||
if (xRequestedWith != null && xRequestedWith.contains("XMLHttpRequest")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String uri = request.getRequestURI();
|
||||
if (StringUtils.equalsAnyIgnoreCase(uri, ".json", ".xml")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String ajax = request.getParameter("__ajax");
|
||||
return StringUtils.equalsAnyIgnoreCase(ajax, "json", "xml");
|
||||
}
|
||||
|
||||
public static String getClientIP() {
|
||||
return getClientIP(getRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
* 内容编码
|
||||
*
|
||||
* @param str 内容
|
||||
* @return 编码后的内容
|
||||
*/
|
||||
public static String urlEncode(String str) {
|
||||
try {
|
||||
return URLEncoder.encode(str, Constant.UTF8);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 内容解码
|
||||
*
|
||||
* @param str 内容
|
||||
* @return 解码后的内容
|
||||
*/
|
||||
public static String urlDecode(String str) {
|
||||
try {
|
||||
return URLDecoder.decode(str, Constant.UTF8);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.glxp.api.admin.dao.monitor.SysLogininforMapper">
|
||||
|
||||
<resultMap type="com.glxp.api.admin.entity.monitor.SysLogininfor" id="SysLogininforResult">
|
||||
<id property="infoId" column="info_id"/>
|
||||
<result property="userName" column="user_name"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="ipaddr" column="ipaddr"/>
|
||||
<result property="loginLocation" column="login_location"/>
|
||||
<result property="browser" column="browser"/>
|
||||
<result property="os" column="os"/>
|
||||
<result property="msg" column="msg"/>
|
||||
<result property="loginTime" column="login_time"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectLogininforList" parameterType="com.glxp.api.admin.req.monitor.SysLogininforRequest"
|
||||
resultMap="SysLogininforResult">
|
||||
|
||||
select *
|
||||
FROM sys_logininfor
|
||||
<where>
|
||||
<if test="infoId != null ">
|
||||
and info_id = #{infoId}
|
||||
</if>
|
||||
<if test="userName != null and userName != '' ">
|
||||
AND `user_name` = #{userName}
|
||||
</if>
|
||||
<if test="status != null and status != '' ">
|
||||
AND `status` = #{status}
|
||||
</if>
|
||||
<if test="ipaddr != null ">
|
||||
AND `ipaddr` = #{ipaddr}
|
||||
</if>
|
||||
<if test="loginLocation != null ">
|
||||
AND `login_location` = #{loginLocation}
|
||||
</if>
|
||||
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectById" parameterType="java.lang.Long"
|
||||
resultMap="SysLogininforResult">
|
||||
select *
|
||||
FROM sys_logininfor
|
||||
WHERE oper_id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insert" keyProperty="infoId" useGeneratedKeys="true"
|
||||
parameterType="com.glxp.api.admin.entity.monitor.SysLogininfor">
|
||||
INSERT INTO sys_logininfor( `user_name`, `status`, ipaddr, `login_location`, browser, `os`, msg
|
||||
, login_time)
|
||||
values (#{userName},
|
||||
#{status}, #{ipaddr},
|
||||
#{loginLocation}, #{browser}, #{os}, #{msg}, #{loginTime})
|
||||
</insert>
|
||||
|
||||
<delete id="delete" parameterType="java.lang.Long">
|
||||
delete
|
||||
from sys_logininfor
|
||||
where info_id = #{id}
|
||||
</delete>
|
||||
|
||||
|
||||
<delete id="deleteBatchIds" parameterType="java.util.List"
|
||||
>
|
||||
delete
|
||||
from sys_logininfor
|
||||
where info_id in
|
||||
<foreach item="item" index="index" collection="infoIds" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
|
||||
</delete>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,107 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.glxp.api.admin.dao.monitor.SysOperLogMapper">
|
||||
|
||||
<resultMap type="com.glxp.api.admin.entity.monitor.SysOperLog" id="SysOperLogResult">
|
||||
<id property="operId" column="oper_id"/>
|
||||
<result property="title" column="title"/>
|
||||
<result property="businessType" column="business_type"/>
|
||||
<result property="method" column="method"/>
|
||||
<result property="requestMethod" column="request_method"/>
|
||||
<result property="operatorType" column="operator_type"/>
|
||||
<result property="operName" column="oper_name"/>
|
||||
<result property="deptName" column="dept_name"/>
|
||||
<result property="operUrl" column="oper_url"/>
|
||||
<result property="operIp" column="oper_ip"/>
|
||||
<result property="operLocation" column="oper_location"/>
|
||||
<result property="operParam" column="oper_param"/>
|
||||
<result property="jsonResult" column="json_result"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="errorMsg" column="error_msg"/>
|
||||
<result property="operTime" column="oper_time"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<select id="selectList" parameterType="com.glxp.api.admin.req.monitor.SysOperLogRequest"
|
||||
resultMap="SysOperLogResult">
|
||||
|
||||
select *
|
||||
FROM sys_oper_log
|
||||
<where>
|
||||
<if test="operId != null ">
|
||||
and oper_id = #{operId}
|
||||
</if>
|
||||
<if test="title != null and title != '' ">
|
||||
AND `title` = #{title}
|
||||
</if>
|
||||
<if test="businessType != null and businessType != '' ">
|
||||
AND `business_type` = #{businessType}
|
||||
</if>
|
||||
<if test="method != null ">
|
||||
AND `method` = #{method}
|
||||
</if>
|
||||
<if test="requestMethod != null ">
|
||||
AND `request_method` = #{requestMethod}
|
||||
</if>
|
||||
|
||||
<if test="operatorType != null ">
|
||||
AND `operator_type` = #{operatorType}
|
||||
</if>
|
||||
<if test="operName != null ">
|
||||
AND `oper_name` = #{operName}
|
||||
</if>
|
||||
<if test="deptName != null ">
|
||||
AND `dept_name` = #{deptName}
|
||||
</if>
|
||||
<if test="operUrl != null ">
|
||||
AND `oper_url` = #{operUrl}
|
||||
</if>
|
||||
<if test="operIp != null ">
|
||||
AND `oper_ip` = #{operIp}
|
||||
</if>
|
||||
<if test="status != null ">
|
||||
AND `status` = #{status}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectById" parameterType="java.lang.Long"
|
||||
resultMap="SysOperLogResult">
|
||||
select *
|
||||
FROM sys_oper_log
|
||||
WHERE oper_id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insert" keyProperty="operIp" useGeneratedKeys="true"
|
||||
parameterType="com.glxp.api.admin.entity.monitor.SysOperLog">
|
||||
INSERT INTO sys_oper_log(`oper_id`, `title`, business_type, `method`, `request_method`, operator_type
|
||||
, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status,
|
||||
error_msg, oper_time)
|
||||
values ( #{operId},
|
||||
#{title}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operName}, #{deptName}
|
||||
, #{operUrl}, #{operIp}, #{operLocation}, #{operParam}, #{jsonResult}, #{status}
|
||||
, #{errorMsg}, #{operTime})
|
||||
</insert>
|
||||
|
||||
<delete id="delete" parameterType="java.lang.Long">
|
||||
delete
|
||||
from sys_oper_log
|
||||
where oper_id = #{id}
|
||||
</delete>
|
||||
|
||||
|
||||
<delete id="deleteBatchIds" parameterType="java.util.List"
|
||||
>
|
||||
delete
|
||||
from sys_oper_log
|
||||
where oper_id in
|
||||
<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
|
||||
</delete>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue