Compare commits

..

No commits in common. "4462de25308726e85ec7fdaa42db996cd9104536" and "6fcf473df89480faa8a781a880b80858fb776b1c" have entirely different histories.

16 changed files with 166 additions and 311 deletions

View File

@ -62,8 +62,6 @@ onMounted(() => {
<div class="main">
<el-form ref="formRef" :inline="true" :model="${lowercaseName}Store.form" class="search-form bg-bg_color w-[99/100] pl-8 pt-[12px] overflow-auto">
#foreach($item in $formList)
<!-- $item.annotation -->
<el-form-item :label="$t('${lowercaseName}_${item.name}')" prop="${item.name}">
<el-input v-model="${lowercaseName}Store.form.${item.name}" :placeholder="`$leftBrace$t('input')}$leftBrace$t('${lowercaseName}_${item.name}')}`" class="!w-[180px]" clearable />
</el-form-item>

View File

@ -14,7 +14,7 @@ import lombok.NoArgsConstructor;
@ApiModel(value = "IpEntity对象", description = "用户IP相关信息")
public class IpEntity {
@ApiModelProperty("原始地址")
private String ipAddr;
private String remoteAddr;
@ApiModelProperty("IP归属地")
private String ipRegion;

View File

@ -92,7 +92,7 @@ public class IpUtil {
ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
String remoteAddr = requestAttributes != null ? getIpAddr(requestAttributes.getRequest()) : "0:0:0:0:0:0:0:1";
String ipRegion = IpUtil.getIpRegion(remoteAddr);
return IpEntity.builder().ipAddr(remoteAddr).ipRegion(ipRegion).build();
return IpEntity.builder().remoteAddr(remoteAddr).ipRegion(ipRegion).build();
}
/**

View File

@ -22,65 +22,13 @@ public class UserLoginLogAddDto {
@Schema(name = "token", title = "登录token")
private String token;
@Schema(name = "ipAddress", title = "登录Ip")
private String ipAddress;
@Schema(name = "ip", title = "登录Ip")
private String ip;
@Schema(name = "ipRegion", title = "登录Ip归属")
private String ipRegion;
@Schema(name = "ipAddress", title = "登录Ip")
private String ipAddress;
@Schema(name = "userAgent", title = "登录时代理")
private String userAgent;
@Schema(name = "type", title = "操作类型")
private String type;
@Schema(name = "xRequestedWith", title = "标识客户端是否是通过Ajax发送请求的")
private String xRequestedWith;
@Schema(name = "secChUa", title = "用户代理的品牌和版本")
private String secChUa;
@Schema(name = "secChUaArch", title = "用户代理的底层平台架构")
private String secChUaArch;
@Schema(name = "secChUaBitness", title = "用户代理的底层CPU架构位数")
private String secChUaBitness;
@Schema(name = "secChUaMobile", title = "用户代理是否在手机设备上运行")
private String secChUaMobile;
@Schema(name = "secChUaModel", title = "用户代理的设备模型")
private String secChUaModel;
@Schema(name = "secChUaPlatform", title = "用户代理的底层操作系统/平台")
private String secChUaPlatform;
@Schema(name = "secChUaPlatformVersion", title = "用户代理的底层操作系统版本")
private String secChUaPlatformVersion;
@Schema(name = "contentDpr", title = "客户端设备像素比")
private String contentDpr;
@Schema(name = "deviceMemory", title = "客户端RAM内存的近似值")
private String deviceMemory;
@Schema(name = "dpr", title = "客户端设备像素比")
private String dpr;
@Schema(name = "viewportWidth", title = "布局视口宽度")
private String viewportWidth;
@Schema(name = "width", title = "所需资源宽度")
private String width;
@Schema(name = "downlink", title = "客户端连接到服务器的近似带宽")
private String downlink;
@Schema(name = "ect", title = "有效连接类型")
private String ect;
@Schema(name = "rtt", title = "应用层往返时间")
private String rtt;
}

View File

@ -22,29 +22,14 @@ public class UserLoginLogDto {
@Schema(name = "token", title = "登录token")
private String token;
@Schema(name = "ipAddress", title = "登录Ip")
private String ipAddress;
@Schema(name = "ip", title = "登录Ip")
private String ip;
@Schema(name = "ipRegion", title = "登录Ip归属")
private String ipRegion;
@Schema(name = "ipAddress", title = "登录Ip")
private String ipAddress;
@Schema(name = "userAgent", title = "登录时代理")
private String userAgent;
@Schema(name = "type", title = "操作类型")
private String type;
@Schema(name = "xRequestedWith", title = "标识客户端是否是通过Ajax发送请求的")
private String xRequestedWith;
@Schema(name = "secChUa", title = "用户代理的品牌和版本")
private String secChUa;
@Schema(name = "secChUaMobile", title = "用户代理是否在手机设备上运行")
private String secChUaMobile;
@Schema(name = "secChUaPlatform", title = "用户代理的底层操作系统/平台")
private String secChUaPlatform;
}

View File

@ -22,28 +22,13 @@ public class UserLoginLogUpdateDto {
@Schema(name = "token", title = "登录token")
private String token;
@Schema(name = "ipAddress", title = "登录Ip")
private String ipAddress;
@Schema(name = "ip", title = "登录Ip")
private String ip;
@Schema(name = "ipRegion", title = "登录Ip归属")
private String ipRegion;
@Schema(name = "ipAddress", title = "登录Ip")
private String ipAddress;
@Schema(name = "userAgent", title = "登录时代理")
private String userAgent;
@Schema(name = "type", title = "操作类型")
private String type;
@Schema(name = "xRequestedWith", title = "标识客户端是否是通过Ajax发送请求的")
private String xRequestedWith;
@Schema(name = "secChUa", title = "用户代理的品牌和版本")
private String secChUa;
@Schema(name = "secChUaMobile", title = "用户代理是否在手机设备上运行")
private String secChUaMobile;
@Schema(name = "secChUaPlatform", title = "用户代理的底层操作系统/平台")
private String secChUaPlatform;
}

View File

@ -13,7 +13,7 @@ import lombok.experimental.Accessors;
* </p>
*
* @author Bunny
* @since 2024-10-19
* @since 2024-10-18
*/
@Getter
@Setter
@ -31,28 +31,13 @@ public class UserLoginLog extends BaseEntity {
@Schema(name = "token", title = "登录token")
private String token;
@Schema(name = "ipAddress", title = "登录Ip")
private String ipAddress;
@Schema(name = "ip", title = "登录Ip")
private String ip;
@Schema(name = "ipRegion", title = "登录Ip归属")
private String ipRegion;
@Schema(name = "ipAddress", title = "登录Ip")
private String ipAddress;
@Schema(name = "userAgent", title = "登录时代理")
private String userAgent;
@Schema(name = "type", title = "操作类型")
private String type;
@Schema(name = "xRequestedWith", title = "标识客户端是否是通过Ajax发送请求的")
private String xRequestedWith;
@Schema(name = "secChUa", title = "用户代理的品牌和版本")
private String secChUa;
@Schema(name = "secChUaMobile", title = "用户代理是否在手机设备上运行")
private String secChUaMobile;
@Schema(name = "secChUaPlatform", title = "用户代理的底层操作系统/平台")
private String secChUaPlatform;
}

View File

@ -1,7 +1,6 @@
package cn.bunny.dao.vo.log;
import cn.bunny.dao.vo.common.BaseVo;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
@ -22,29 +21,13 @@ public class UserLoginLogVo extends BaseVo {
@Schema(name = "token", title = "登录token")
private String token;
@Schema(name = "ipAddress", title = "登录Ip")
private String ipAddress;
@Schema(name = "ip", title = "登录Ip")
private String ip;
@Schema(name = "ipRegion", title = "登录Ip归属")
private String ipRegion;
@Schema(name = "ipAddress", title = "登录Ip")
private String ipAddress;
@Schema(name = "userAgent", title = "登录时代理")
private String userAgent;
@Schema(name = "type", title = "操作类型")
private String type;
@Schema(name = "xRequestedWith", title = "标识客户端是否是通过Ajax发送请求的")
@JsonProperty("xRequestedWith")
private String xRequestedWith;
@Schema(name = "secChUa", title = "用户代理的品牌和版本")
private String secChUa;
@Schema(name = "secChUaMobile", title = "用户代理是否在手机设备上运行")
private String secChUaMobile;
@Schema(name = "secChUaPlatform", title = "用户代理的底层操作系统/平台")
private String secChUaPlatform;
}

View File

@ -0,0 +1,20 @@
package cn.bunny.services.controller;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 部门用户关系 前端控制器
* </p>
*
* @author Bunny
* @since 2024-10-04
*/
@Tag(name = "用户和部门", description = "用户和部门相关接口")
@RestController
@RequestMapping("admin/userDept")
public class UserDeptController {
}

View File

@ -1,6 +1,8 @@
package cn.bunny.services.controller;
import cn.bunny.dao.dto.log.UserLoginLogAddDto;
import cn.bunny.dao.dto.log.UserLoginLogDto;
import cn.bunny.dao.dto.log.UserLoginLogUpdateDto;
import cn.bunny.dao.entity.log.UserLoginLog;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.pojo.result.Result;
@ -11,6 +13,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;
@ -23,7 +26,7 @@ import java.util.List;
* </p>
*
* @author Bunny
* @since 2024-10-19 01:01:01
* @since 2024-10-18 22:36:07
*/
@Tag(name = "用户登录日志", description = "用户登录日志相关接口")
@RestController
@ -46,6 +49,20 @@ public class UserLoginLogController {
return Mono.just(Result.success(pageResult));
}
@Operation(summary = "添加用户登录日志", description = "添加用户登录日志")
@PostMapping("addUserLoginLog")
public Mono<Result<String>> addUserLoginLog(@Valid @RequestBody UserLoginLogAddDto dto) {
userLoginLogService.addUserLoginLog(dto);
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
}
@Operation(summary = "更新用户登录日志", description = "更新用户登录日志")
@PutMapping("updateUserLoginLog")
public Mono<Result<String>> updateUserLoginLog(@Valid @RequestBody UserLoginLogUpdateDto dto) {
userLoginLogService.updateUserLoginLog(dto);
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
}
@Operation(summary = "删除用户登录日志", description = "删除用户登录日志")
@DeleteMapping("deleteUserLoginLog")
public Mono<Result<String>> deleteUserLoginLog(@RequestBody List<Long> ids) {

View File

@ -3,7 +3,6 @@ package cn.bunny.services.factory;
import cn.bunny.common.service.utils.JwtHelper;
import cn.bunny.common.service.utils.ip.IpUtil;
import cn.bunny.common.service.utils.minio.MinioUtil;
import cn.bunny.dao.entity.log.UserLoginLog;
import cn.bunny.dao.entity.system.AdminUser;
import cn.bunny.dao.entity.system.Power;
import cn.bunny.dao.entity.system.Role;
@ -13,18 +12,14 @@ import cn.bunny.dao.pojo.constant.UserConstant;
import cn.bunny.dao.vo.system.user.LoginVo;
import cn.bunny.services.mapper.PowerMapper;
import cn.bunny.services.mapper.RoleMapper;
import cn.bunny.services.mapper.UserLoginLogMapper;
import cn.bunny.services.mapper.UserMapper;
import cn.bunny.services.security.custom.CustomCheckIsAdmin;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@ -41,65 +36,39 @@ public class UserFactory {
@Autowired
private RoleMapper roleMapper;
@Autowired
private UserMapper userMapper;
@Autowired
private UserLoginLogMapper userLoginLogMapper;
@Autowired
private RedisTemplate<String, Object> redisTemplate;
@Autowired
private MinioUtil minioUtil;
@Autowired
private UserMapper userMapper;
public LoginVo buildUserVo(AdminUser user, long readMeDay) {
// 创建token
Long userId = user.getId();
String email = user.getEmail();
String token = JwtHelper.createToken(userId, email, (int) readMeDay);
// 获取IP地址
String ipAddr = IpUtil.getCurrentUserIpAddress().getIpAddr();
String avatar = user.getAvatar();
String remoteAddr = IpUtil.getCurrentUserIpAddress().getRemoteAddr();
String ipRegion = IpUtil.getCurrentUserIpAddress().getIpRegion();
// 更新用户登录信息
setUpdateUser(userId, ipAddr, ipRegion);
// 设置用户返回信息
LoginVo loginVo = setLoginVo(user, token, readMeDay, ipAddr, ipRegion);
// 将用户登录保存在用户登录日志表中
UserLoginLog userLoginLog = new UserLoginLog();
userLoginLog.setUsername(user.getUsername());
userLoginLog.setUserId(userId);
userLoginLog.setIpAddress(ipAddr);
userLoginLog.setIpRegion(ipRegion);
userLoginLog.setToken(token);
userLoginLog.setType("login");
setUserLoginLog(userLoginLog);
userLoginLogMapper.insert(userLoginLog);
// 将信息保存在Redis中
redisTemplate.opsForValue().set(RedisUserConstant.getAdminLoginInfoPrefix(email), loginVo, readMeDay, TimeUnit.DAYS);
// 将Redis中验证码删除
redisTemplate.delete(RedisUserConstant.getAdminUserEmailCodePrefix(email));
return loginVo;
}
/**
* * 设置更新用户设置内容
*/
public LoginVo setLoginVo(AdminUser user, String token, long readMeDay, String ipAddr, String ipRegion) {
Long userId = user.getId();
// 判断用户是否有头像如果没有头像设置默认头像
String avatar = user.getAvatar();
avatar = StringUtils.hasText(avatar) ? minioUtil.getObjectNameFullPath(avatar) : UserConstant.USER_AVATAR;
// 设置用户IP地址并更新用户信息
AdminUser updateUser = new AdminUser();
updateUser.setId(userId);
updateUser.setLastLoginIp(remoteAddr);
updateUser.setLastLoginIpAddress(ipRegion);
userMapper.updateById(updateUser);
// 计算过期时间并格式化返回
LocalDateTime localDateTime = LocalDateTime.now();
LocalDateTime plusDay = localDateTime.plusDays(readMeDay);
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(LocalDateTimeConstant.YYYY_MM_DD_HH_MM_SS_SLASH);
String expires = plusDay.format(dateTimeFormatter);
// 查找用户橘色
List<String> roles = new ArrayList<>(roleMapper.selectListByUserId(userId).stream().map(Role::getRoleCode).toList());
List<String> permissions = new ArrayList<>();
@ -110,12 +79,6 @@ public class UserFactory {
permissions = powerMapper.selectListByUserId(userId).stream().map(Power::getPowerCode).toList();
}
// 计算过期时间并格式化返回
LocalDateTime localDateTime = LocalDateTime.now();
LocalDateTime plusDay = localDateTime.plusDays(readMeDay);
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(LocalDateTimeConstant.YYYY_MM_DD_HH_MM_SS_SLASH);
String expires = plusDay.format(dateTimeFormatter);
// 构建返回对象设置用户需要内容
LoginVo loginVo = new LoginVo();
BeanUtils.copyProperties(user, loginVo);
@ -123,60 +86,19 @@ public class UserFactory {
loginVo.setAvatar(avatar);
loginVo.setToken(token);
loginVo.setRefreshToken(token);
loginVo.setLastLoginIp(ipAddr);
loginVo.setLastLoginIp(remoteAddr);
loginVo.setLastLoginIpAddress(ipRegion);
loginVo.setRoles(roles);
loginVo.setPermissions(permissions);
loginVo.setUpdateUser(userId);
loginVo.setExpires(expires);
// 将信息保存在Redis中
redisTemplate.opsForValue().set(RedisUserConstant.getAdminLoginInfoPrefix(email), loginVo, readMeDay, TimeUnit.DAYS);
// 将Redis中验证码删除
redisTemplate.delete(RedisUserConstant.getAdminUserEmailCodePrefix(email));
return loginVo;
}
/**
* * 设置更新用户设置内容
*
* @param userId 用户ID
*/
public void setUpdateUser(Long userId, String ipAddr, String ipRegion) {
// 设置用户IP地址并更新用户信息
AdminUser updateUser = new AdminUser();
updateUser.setId(userId);
updateUser.setLastLoginIp(ipAddr);
updateUser.setLastLoginIpAddress(ipRegion);
userMapper.updateById(updateUser);
}
/**
* * 设置用户登录日志内容
*
* @param userLoginLog 用户登录日志
*/
public void setUserLoginLog(UserLoginLog userLoginLog) {
// 当前请求request
ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
if (requestAttributes == null) return;
HttpServletRequest request = requestAttributes.getRequest();
// 获取User-Agent
String userAgent = request.getHeader("User-Agent");
userLoginLog.setUserAgent(userAgent);
// 获取X-Requested-With
String xRequestedWith = request.getHeader("X-Requested-With");
userLoginLog.setXRequestedWith(xRequestedWith);
// 获取Sec-CH-UA
String secCHUA = request.getHeader("sec-ch-ua");
userLoginLog.setSecChUa(secCHUA);
// 获取Sec-CH-UA-Mobile
String secCHUAMobile = request.getHeader("Sec-CH-UA-Mobile");
userLoginLog.setSecChUaMobile(secCHUAMobile);
// 获取Sec-CH-UA-Platform
String secCHUAPlatform = request.getHeader("Sec-CH-UA-Platform");
userLoginLog.setSecChUaPlatform(secCHUAPlatform);
}
}

View File

@ -16,7 +16,7 @@ import java.util.List;
* </p>
*
* @author Bunny
* @since 2024-10-19 01:01:01
* @since 2024-10-18 22:36:07
*/
@Mapper
public interface UserLoginLogMapper extends BaseMapper<UserLoginLog> {

View File

@ -1,11 +1,14 @@
package cn.bunny.services.service;
import cn.bunny.dao.dto.log.UserLoginLogAddDto;
import cn.bunny.dao.dto.log.UserLoginLogDto;
import cn.bunny.dao.dto.log.UserLoginLogUpdateDto;
import cn.bunny.dao.entity.log.UserLoginLog;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.vo.log.UserLoginLogVo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import jakarta.validation.Valid;
import java.util.List;
@ -15,7 +18,7 @@ import java.util.List;
* </p>
*
* @author Bunny
* @since 2024-10-19 01:01:01
* @since 2024-10-18 22:36:07
*/
public interface UserLoginLogService extends IService<UserLoginLog> {
@ -26,6 +29,20 @@ public interface UserLoginLogService extends IService<UserLoginLog> {
*/
PageResult<UserLoginLogVo> getUserLoginLogList(Page<UserLoginLog> pageParams, UserLoginLogDto dto);
/**
* * 添加用户登录日志
*
* @param dto 添加表单
*/
void addUserLoginLog(@Valid UserLoginLogAddDto dto);
/**
* * 更新用户登录日志
*
* @param dto 更新表单
*/
void updateUserLoginLog(@Valid UserLoginLogUpdateDto dto);
/**
* * 删除|批量删除用户登录日志类型
*

View File

@ -1,6 +1,8 @@
package cn.bunny.services.service.impl;
import cn.bunny.dao.dto.log.UserLoginLogAddDto;
import cn.bunny.dao.dto.log.UserLoginLogDto;
import cn.bunny.dao.dto.log.UserLoginLogUpdateDto;
import cn.bunny.dao.entity.log.UserLoginLog;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.vo.log.UserLoginLogVo;
@ -9,6 +11,7 @@ import cn.bunny.services.service.UserLoginLogService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.validation.Valid;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
@ -20,7 +23,7 @@ import java.util.List;
* </p>
*
* @author Bunny
* @since 2024-10-19 01:01:01
* @since 2024-10-18 22:36:07
*/
@Service
public class UserLoginLogServiceImpl extends ServiceImpl<UserLoginLogMapper, UserLoginLog> implements UserLoginLogService {
@ -51,6 +54,32 @@ public class UserLoginLogServiceImpl extends ServiceImpl<UserLoginLogMapper, Use
.build();
}
/**
* 添加用户登录日志
*
* @param dto 用户登录日志添加
*/
@Override
public void addUserLoginLog(@Valid UserLoginLogAddDto dto) {
// 保存数据
UserLoginLog userLoginLog = new UserLoginLog();
BeanUtils.copyProperties(dto, userLoginLog);
save(userLoginLog);
}
/**
* 更新用户登录日志
*
* @param dto 用户登录日志更新
*/
@Override
public void updateUserLoginLog(@Valid UserLoginLogUpdateDto dto) {
// 更新内容
UserLoginLog userLoginLog = new UserLoginLog();
BeanUtils.copyProperties(dto, userLoginLog);
updateById(userLoginLog);
}
/**
* 删除|批量删除用户登录日志
*

View File

@ -6,7 +6,6 @@ import cn.bunny.common.service.utils.JwtHelper;
import cn.bunny.common.service.utils.minio.MinioUtil;
import cn.bunny.dao.dto.system.files.FileUploadDto;
import cn.bunny.dao.dto.system.user.*;
import cn.bunny.dao.entity.log.UserLoginLog;
import cn.bunny.dao.entity.system.AdminUser;
import cn.bunny.dao.entity.system.AdminUserAndDept;
import cn.bunny.dao.entity.system.UserDept;
@ -22,7 +21,6 @@ import cn.bunny.dao.vo.system.user.UserVo;
import cn.bunny.services.factory.EmailFactory;
import cn.bunny.services.factory.UserFactory;
import cn.bunny.services.mapper.UserDeptMapper;
import cn.bunny.services.mapper.UserLoginLogMapper;
import cn.bunny.services.mapper.UserMapper;
import cn.bunny.services.mapper.UserRoleMapper;
import cn.bunny.services.service.FilesService;
@ -78,9 +76,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, AdminUser> implemen
@Autowired
private UserRoleMapper userRoleMapper;
@Autowired
private UserLoginLogMapper userLoginLogMapper;
/**
* 登录发送邮件验证码
*
@ -216,16 +211,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, AdminUser> implemen
String email = adminUser.getEmail();
String adminLoginInfoPrefix = RedisUserConstant.getAdminLoginInfoPrefix(email);
// 将用户登录保存在用户登录日志表中
UserLoginLog userLoginLog = new UserLoginLog();
BeanUtils.copyProperties(adminUser, userLoginLog);
userLoginLog.setUserId(adminUser.getId());
userLoginLog.setIpAddress(adminUser.getLastLoginIp());
userLoginLog.setIpRegion(adminUser.getLastLoginIpAddress());
userLoginLog.setToken(null);
userLoginLog.setType("forcedOffline");
userLoginLogMapper.insert(userLoginLog);
redisTemplate.delete(adminLoginInfoPrefix);
}

View File

@ -4,28 +4,23 @@
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="cn.bunny.dao.entity.log.UserLoginLog">
<id column="id" property="id"/>
<id column="create_time" property="createTime"/>
<id column="update_time" property="updateTime"/>
<id column="create_user" property="createUser"/>
<id column="update_user" property="updateUser"/>
<id column="is_deleted" property="isDeleted"/>
<id column="user_id" property="userId"/>
<id column="username" property="username"/>
<id column="token" property="token"/>
<id column="ip_address" property="ipAddress"/>
<id column="ip_region" property="ipRegion"/>
<id column="user_agent" property="userAgent"/>
<id column="type" property="type"/>
<id column="x_requested_with" property="xRequestedWith"/>
<id column="sec_ch_ua" property="secChUa"/>
<id column="sec_ch_ua_mobile" property="secChUaMobile"/>
<id column="sec_ch_ua_platform" property="secChUaPlatform"/>
<id column="id" property="id"/>
<id column="create_time" property="createTime"/>
<id column="update_time" property="updateTime"/>
<id column="create_user" property="createUser"/>
<id column="update_user" property="updateUser"/>
<id column="is_deleted" property="isDeleted"/>
<id column="user_id" property="userId"/>
<id column="username" property="username"/>
<id column="token" property="token"/>
<id column="ip" property="ip"/>
<id column="ip_address" property="ipAddress"/>
<id column="user_agent" property="userAgent"/>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, create_time, update_time, create_user, update_user, is_deleted, user_id, username, token, ip_address, ip_region, user_agent, type, x_requested_with, sec_ch_ua, sec_ch_ua_mobile, sec_ch_ua_platform
id, create_time, update_time, create_user, update_user, is_deleted, user_id, username, token, ip, ip_address, user_agent
</sql>
<!-- 分页查询用户登录日志内容 -->
@ -34,40 +29,26 @@
<include refid="Base_Column_List"/>
from log_user_login
<where>
<if test="dto.userId != null and dto.userId != ''">
and user_id like CONCAT('%',#{dto.userId},'%')
</if>
<if test="dto.username != null and dto.username != ''">
and username like CONCAT('%',#{dto.username},'%')
</if>
<if test="dto.token != null and dto.token != ''">
and token like CONCAT('%',#{dto.token},'%')
</if>
<if test="dto.ipAddress != null and dto.ipAddress != ''">
and ip_address like CONCAT('%',#{dto.ipAddress},'%')
</if>
<if test="dto.ipRegion != null and dto.ipRegion != ''">
and ip_region like CONCAT('%',#{dto.ipRegion},'%')
</if>
<if test="dto.userAgent != null and dto.userAgent != ''">
and user_agent like CONCAT('%',#{dto.userAgent},'%')
</if>
<if test="dto.type != null and dto.type != ''">
and type like CONCAT('%',#{dto.type},'%')
</if>
<if test="dto.xRequestedWith != null and dto.xRequestedWith != ''">
and x_requested_with like CONCAT('%',#{dto.xRequestedWith},'%')
</if>
<if test="dto.secChUa != null and dto.secChUa != ''">
and sec_ch_ua like CONCAT('%',#{dto.secChUa},'%')
</if>
<if test="dto.secChUaMobile != null and dto.secChUaMobile != ''">
and sec_ch_ua_mobile like CONCAT('%',#{dto.secChUaMobile},'%')
</if>
<if test="dto.secChUaPlatform != null and dto.secChUaPlatform != ''">
and sec_ch_ua_platform like CONCAT('%',#{dto.secChUaPlatform},'%')
</if>
<if test="dto.userId != null and dto.userId != ''">
and user_id like CONCAT('%',#{dto.userId},'%')
</if>
<if test="dto.username != null and dto.username != ''">
and username like CONCAT('%',#{dto.username},'%')
</if>
<if test="dto.token != null and dto.token != ''">
and token like CONCAT('%',#{dto.token},'%')
</if>
<if test="dto.ip != null and dto.ip != ''">
and ip like CONCAT('%',#{dto.ip},'%')
</if>
<if test="dto.ipAddress != null and dto.ipAddress != ''">
and ip_address like CONCAT('%',#{dto.ipAddress},'%')
</if>
<if test="dto.userAgent != null and dto.userAgent != ''">
and user_agent like CONCAT('%',#{dto.userAgent},'%')
</if>
</where>
order by update_time desc
</select>
<!-- 物理删除用户登录日志 -->