commit
1e761f48d4
@ -0,0 +1,23 @@ |
||||
package com.hai.user.service; |
||||
|
||||
import com.hai.entity.HighUserLoginLog; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 用户登录日志 |
||||
* @className: UserLoginService |
||||
* @author: HuRui |
||||
* @date: 2022/10/25 |
||||
**/ |
||||
public interface UserLoginLogService { |
||||
|
||||
/** |
||||
* 查询用户登录日志列表 |
||||
* @param param |
||||
* @return |
||||
*/ |
||||
List<HighUserLoginLog> getUserLoginLogList(Map<String, Object> param); |
||||
|
||||
} |
@ -0,0 +1,37 @@ |
||||
package com.hai.user.service.impl; |
||||
|
||||
import com.hai.dao.HighUserLoginLogMapper; |
||||
import com.hai.entity.HighUserLoginLog; |
||||
import com.hai.entity.HighUserLoginLogExample; |
||||
import com.hai.user.service.UserLoginLogService; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @className: UserLoginLogServiceImpl |
||||
* @author: HuRui |
||||
* @date: 2022/10/25 |
||||
**/ |
||||
@Service("userLoginLogService") |
||||
public class UserLoginLogServiceImpl implements UserLoginLogService { |
||||
|
||||
@Resource |
||||
private HighUserLoginLogMapper userLoginLogMapper; |
||||
|
||||
@Override |
||||
public List<HighUserLoginLog> getUserLoginLogList(Map<String, Object> param) { |
||||
HighUserLoginLogExample example = new HighUserLoginLogExample(); |
||||
HighUserLoginLogExample.Criteria criteria = example.createCriteria().andStatusNotEqualTo(0); |
||||
|
||||
if (MapUtils.getLong(param, "userId") != null) { |
||||
criteria.andUserIdEqualTo(MapUtils.getLong(param, "userId")); |
||||
} |
||||
|
||||
example.setOrderByClause("create_time desc"); |
||||
return userLoginLogMapper.selectByExample(example); |
||||
} |
||||
} |
File diff suppressed because one or more lines are too long
@ -0,0 +1 @@ |
||||
package com.web.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.security.UserCenter;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.model.HighUserModel;
import com.hai.model.ResponseData;
import com.hai.user.service.UserLoginLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
/**
* @Auther: 胡锐
* @Description:
* @Date: 2021/3/26 23:08
*/
@Controller
@RequestMapping(value = "/loginLog")
@Api(value = "登录日志")
public class LoginLogController {
private static Logger log = LoggerFactory.getLogger(LoginLogController.class);
@Resource
private UserCenter userCenter;
@Resource
private UserLoginLogService userLoginLogService;
@RequestMapping(value = "/getUserLoginLogList", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "获取用户登录日志列表")
public ResponseData getUserLoginLogList(@RequestParam(value = "pageNum", required = true) Integer pageNum,
@RequestParam(value = "pageSize", required = true) Integer pageSize) {
try {
HighUserModel userInfoModel = userCenter.getSessionModel(HighUserModel.class);
if (userInfoModel == null) {
log.error("CoresController --> outLogin() error!", "用户身份错误或已过期");
throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, "");
}
Map<String, Object> param = new HashMap<>();
param.put("userId", userInfoModel.getHighUser().getId());
PageHelper.startPage(pageNum, pageSize);
return ResponseMsgUtil.success(new PageInfo<>(userLoginLogService.getUserLoginLogList(param)));
} catch (Exception e) {
log.error("loginLog --> getUserLoginLogList() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}
|
Loading…
Reference in new issue