登录历史参数化.

This commit is contained in:
lijiahang
2024-06-11 12:28:24 +08:00
parent 07e8e63ee6
commit 4b060a864a
12 changed files with 35 additions and 28 deletions

View File

@@ -70,8 +70,8 @@ public class MineController {
@IgnoreLog(IgnoreLogMode.RET)
@GetMapping("/login-history")
@Operation(summary = "查询当前用户登录日志")
public List<LoginHistoryVO> getCurrentLoginHistory() {
return mineService.getCurrentLoginHistory();
public List<LoginHistoryVO> getCurrentLoginHistory(@RequestParam("count") Integer count) {
return mineService.getCurrentLoginHistory(count);
}
@IgnoreLog(IgnoreLogMode.RET)

View File

@@ -182,8 +182,9 @@ public class SystemUserController {
@GetMapping("/login-history")
@Operation(summary = "查询用户登录日志")
@PreAuthorize("@ss.hasPermission('infra:system-user:login-history')")
public List<LoginHistoryVO> getLoginHistory(@RequestParam("username") String username) {
return operatorLogService.getLoginHistory(username);
public List<LoginHistoryVO> getLoginHistory(@RequestParam("username") String username,
@RequestParam("count") Integer count) {
return operatorLogService.getLoginHistory(username, count);
}
}

View File

@@ -46,9 +46,10 @@ public interface MineService {
/**
* 获取当前用户登录日志
*
* @param count count
* @return 登录日志
*/
List<LoginHistoryVO> getCurrentLoginHistory();
List<LoginHistoryVO> getCurrentLoginHistory(Integer count);
/**
* 获取当前用户会话列表

View File

@@ -60,8 +60,9 @@ public interface OperatorLogService {
* 查询用户登录日志
*
* @param username username
* @param count count
* @return rows
*/
List<LoginHistoryVO> getLoginHistory(String username);
List<LoginHistoryVO> getLoginHistory(String username, Integer count);
}

View File

@@ -77,9 +77,9 @@ public class MineServiceImpl implements MineService {
}
@Override
public List<LoginHistoryVO> getCurrentLoginHistory() {
public List<LoginHistoryVO> getCurrentLoginHistory(Integer count) {
String username = SecurityUtils.getLoginUsername();
return operatorLogService.getLoginHistory(username);
return operatorLogService.getLoginHistory(username, count);
}
@Override

View File

@@ -4,9 +4,10 @@ import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.orion.lang.define.wrapper.DataGrid;
import com.orion.lang.utils.Arrays1;
import com.orion.lang.utils.Valid;
import com.orion.visor.framework.biz.operator.log.core.model.OperatorLogModel;
import com.orion.visor.framework.biz.operator.log.core.utils.OperatorLogs;
import com.orion.visor.framework.common.constant.Const;
import com.orion.visor.framework.common.constant.ErrorMessage;
import com.orion.visor.module.infra.convert.OperatorLogConvert;
import com.orion.visor.module.infra.dao.OperatorLogDAO;
import com.orion.visor.module.infra.define.operator.AuthenticationOperatorType;
@@ -81,7 +82,8 @@ public class OperatorLogServiceImpl implements OperatorLogService {
}
@Override
public List<LoginHistoryVO> getLoginHistory(String username) {
public List<LoginHistoryVO> getLoginHistory(String username, Integer count) {
Valid.gt(count, 0, ErrorMessage.PARAM_ERROR);
// 条件
OperatorLogQueryRequest request = new OperatorLogQueryRequest();
request.setUsername(username);
@@ -89,7 +91,7 @@ public class OperatorLogServiceImpl implements OperatorLogService {
LambdaQueryWrapper<OperatorLogDO> wrapper = this.buildQueryWrapper(request);
// 查询
return operatorLogDAO.of(wrapper)
.limit(Const.LOGIN_HISTORY_COUNT)
.limit(count)
.list(OperatorLogConvert.MAPPER::toLoginHistory);
}