⚡ 登录历史参数化.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -46,9 +46,10 @@ public interface MineService {
|
||||
/**
|
||||
* 获取当前用户登录日志
|
||||
*
|
||||
* @param count count
|
||||
* @return 登录日志
|
||||
*/
|
||||
List<LoginHistoryVO> getCurrentLoginHistory();
|
||||
List<LoginHistoryVO> getCurrentLoginHistory(Integer count);
|
||||
|
||||
/**
|
||||
* 获取当前用户会话列表
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user