mirror of https://gitee.com/stylefeng/roses
Merge remote-tracking branch 'origin/group2-loginlog'
# Conflicts: # kernel-s-system/system-business-notice/pom.xmlpull/3/head
commit
3a2d344734
|
@ -17,6 +17,7 @@ import cn.stylefeng.roses.kernel.jwt.api.exception.JwtException;
|
|||
import cn.stylefeng.roses.kernel.jwt.api.exception.enums.JwtExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.jwt.api.pojo.payload.DefaultJwtPayload;
|
||||
import cn.stylefeng.roses.kernel.rule.util.HttpServletUtil;
|
||||
import cn.stylefeng.roses.kernel.system.LoginLogServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.UserServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.enums.UserStatusEnum;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.UserLoginInfoDTO;
|
||||
|
@ -54,6 +55,9 @@ public class AuthServiceImpl implements AuthServiceApi {
|
|||
@Resource
|
||||
private PasswordTransferEncryptApi passwordTransferEncryptApi;
|
||||
|
||||
@Resource
|
||||
private LoginLogServiceApi loginLogServiceApi;
|
||||
|
||||
@Override
|
||||
public LoginResponse login(LoginRequest loginRequest) {
|
||||
return loginAction(loginRequest, true);
|
||||
|
@ -69,8 +73,13 @@ public class AuthServiceImpl implements AuthServiceApi {
|
|||
@Override
|
||||
public void logout() {
|
||||
String token = LoginContext.me().getToken();
|
||||
//退出日志
|
||||
if (StrUtil.isNotEmpty(token)) {
|
||||
loginLogServiceApi.loginOutSuccess(LoginContext.me().getLoginUser().getUserId());
|
||||
}
|
||||
logoutWithToken(token);
|
||||
sessionManagerApi.destroySessionCookie();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -198,7 +207,9 @@ public class AuthServiceImpl implements AuthServiceApi {
|
|||
String ip = HttpServletUtil.getRequestClientIp(HttpServletUtil.getRequest());
|
||||
userServiceApi.updateUserLoginInfo(loginUser.getUserId(), new Date(), ip);
|
||||
|
||||
// 11. 组装返回结果
|
||||
// 11.登录成功日志
|
||||
loginLogServiceApi.loginSuccess(loginUser.getUserId());
|
||||
// 12. 组装返回结果
|
||||
return new LoginResponse(loginUser, jwtToken, defaultJwtPayload.getExpirationDate());
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
<module>system-business-role</module>
|
||||
<module>system-business-menu</module>
|
||||
<module>system-business-notice</module>
|
||||
<module>system-business-login-log</module>
|
||||
<module>system-spring-boot-starter</module>
|
||||
</modules>
|
||||
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
package cn.stylefeng.roses.kernel.system;
|
||||
|
||||
import cn.stylefeng.roses.kernel.system.pojo.loginlog.request.SysLoginLogRequest;
|
||||
|
||||
/**
|
||||
* 登录日志api接口
|
||||
*
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/13 11:12
|
||||
*/
|
||||
public interface LoginLogServiceApi {
|
||||
|
||||
/**
|
||||
* 添加日志
|
||||
*
|
||||
* @param sysLoginLogRequest 参数
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/13 10:56
|
||||
*/
|
||||
void add(SysLoginLogRequest sysLoginLogRequest);
|
||||
|
||||
/**
|
||||
* 登录成功
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/13 11:36
|
||||
*/
|
||||
void loginSuccess(Long userId);
|
||||
|
||||
/**
|
||||
* 登录失败
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param llgMessage 错误信息
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/13 11:36
|
||||
*/
|
||||
void loginFail(Long userId, String llgMessage);
|
||||
|
||||
/**
|
||||
* 登出成功
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/13 11:36
|
||||
*/
|
||||
void loginOutSuccess(Long userId);
|
||||
|
||||
/**
|
||||
* 登出失败
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/13 11:36
|
||||
*/
|
||||
void loginOutFail(Long userId);
|
||||
|
||||
/**
|
||||
* 清空
|
||||
*
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/13 10:55
|
||||
*/
|
||||
void deleteAll();
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package cn.stylefeng.roses.kernel.system.pojo.loginlog.request;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 登录日志表
|
||||
*
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/13 11:06
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class SysLoginLogRequest extends BaseRequest {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@NotNull(message = "llgId不能为空", groups = {detail.class})
|
||||
private Long llgId;
|
||||
|
||||
/**
|
||||
* 日志名称
|
||||
*/
|
||||
private String llgName;
|
||||
|
||||
/**
|
||||
* 是否执行成功
|
||||
*/
|
||||
private String llgSucceed;
|
||||
|
||||
/**
|
||||
* 具体消息
|
||||
*/
|
||||
private String llgMessage;
|
||||
|
||||
/**
|
||||
* 登录ip
|
||||
*/
|
||||
private String llgIpAddress;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
private String beginTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private String endTime;
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package cn.stylefeng.roses.kernel.system.pojo.loginlog.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 登录日志表
|
||||
*
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/13 11:06
|
||||
*/
|
||||
@Data
|
||||
public class SysLoginLogResponse implements Serializable {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long llgId;
|
||||
|
||||
/**
|
||||
* 日志名称
|
||||
*/
|
||||
private String llgName;
|
||||
|
||||
/**
|
||||
* 是否执行成功
|
||||
*/
|
||||
private String llgSucceed;
|
||||
|
||||
/**
|
||||
* 具体消息
|
||||
*/
|
||||
private String llgMessage;
|
||||
|
||||
/**
|
||||
* 登录ip
|
||||
*/
|
||||
private String llgIpAddress;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
登录日志相关业务
|
|
@ -0,0 +1,59 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>kernel-s-system</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>system-business-login-log</artifactId>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!--系统管理的api-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>system-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!--资源api模块-->
|
||||
<!--用在资源控制器,资源扫描上-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>scanner-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!--参数校验模块-->
|
||||
<!--用在控制器,参数校验-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>validator-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!--数据库sdk-->
|
||||
<!--数据库dao框架-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>db-sdk-mp</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!--web模块-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,20 @@
|
|||
package cn.stylefeng.roses.kernel.loginlog.modular.constants;
|
||||
|
||||
public interface LoginLogConstant {
|
||||
|
||||
String LOGIN_IN_LOGINNAME = "登录日志";
|
||||
|
||||
String LOGIN_OUT_LOGINNAME = "退出日志";
|
||||
|
||||
String OPERATION_SUCCESS = "成功";
|
||||
|
||||
String OPERATION_FAIL = "失败";
|
||||
|
||||
String LOGIN_IN_SUCCESS_MESSAGE = "系统登录成功!";
|
||||
|
||||
String LOGIN_IN_SUCCESS_FAIL = "系统登录失败!";
|
||||
|
||||
String LOGIN_OUT_SUCCESS_MESSAGE = "系统退出成功!";
|
||||
|
||||
String LOGIN_OUT_SUCCESS_FAIL = "系统退出失败!";
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package cn.stylefeng.roses.kernel.loginlog.modular.controller;
|
||||
|
||||
import cn.stylefeng.roses.kernel.loginlog.modular.service.SysLoginLogService;
|
||||
import cn.stylefeng.roses.kernel.resource.api.annotation.ApiResource;
|
||||
import cn.stylefeng.roses.kernel.resource.api.annotation.GetResource;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.loginlog.request.SysLoginLogRequest;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 登陆日志控制器
|
||||
*
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/13 17:51
|
||||
*/
|
||||
@RestController
|
||||
@ApiResource(name = "登录日志")
|
||||
public class SysLoginLogController {
|
||||
|
||||
@Resource
|
||||
private SysLoginLogService sysLoginLogService;
|
||||
|
||||
|
||||
/**
|
||||
* 清空登录日志
|
||||
*
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/13 17:51
|
||||
*/
|
||||
@GetResource(name = "清空登录日志", path = "/loginLog/deleteAll")
|
||||
public ResponseData deleteAll() {
|
||||
sysLoginLogService.deleteAll();
|
||||
return new SuccessResponseData();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询登录日志详情
|
||||
*
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/13 17:51
|
||||
*/
|
||||
@GetResource(name = "查看详情登录日志", path = "/loginLog/detail")
|
||||
public ResponseData detail(@Validated(SysLoginLogRequest.detail.class) SysLoginLogRequest sysLoginLogRequest) {
|
||||
return new SuccessResponseData(sysLoginLogService.detail(sysLoginLogRequest));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询登录日志
|
||||
*
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/13 17:51
|
||||
*/
|
||||
@GetResource(name = "分页查询登录日志", path = "/loginLog/page")
|
||||
public ResponseData page(SysLoginLogRequest sysLoginLogRequest) {
|
||||
return new SuccessResponseData(sysLoginLogService.page(sysLoginLogRequest));
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package cn.stylefeng.roses.kernel.loginlog.modular.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 登录日志表
|
||||
*
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/13 11:05
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_login_log")
|
||||
public class SysLoginLog {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId("llg_id")
|
||||
private Long llgId;
|
||||
|
||||
/**
|
||||
* 日志名称
|
||||
*/
|
||||
@TableField("llg_name")
|
||||
private String llgName;
|
||||
|
||||
/**
|
||||
* 是否执行成功
|
||||
*/
|
||||
@TableField("llg_succeed")
|
||||
private String llgSucceed;
|
||||
|
||||
/**
|
||||
* 具体消息
|
||||
*/
|
||||
@TableField("llg_message")
|
||||
private String llgMessage;
|
||||
|
||||
/**
|
||||
* 登录ip
|
||||
*/
|
||||
@TableField("llg_ip_address")
|
||||
private String llgIpAddress;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@TableField(value = "user_id")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package cn.stylefeng.roses.kernel.loginlog.modular.factory;
|
||||
|
||||
public class SysLoginLogFactory {
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
Copyright [2020] [https://www.stylefeng.cn]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
|
||||
1.请不要删除和修改根目录下的LICENSE文件。
|
||||
2.请不要删除和修改Guns源码头部的版权声明。
|
||||
3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns-separation
|
||||
5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns-separation
|
||||
6.若您的项目无法满足以上几点,可申请商业授权,获取Guns商业授权许可,请在官网购买授权,地址为 https://www.stylefeng.cn
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.loginlog.modular.mapper;
|
||||
|
||||
import cn.stylefeng.roses.kernel.loginlog.modular.entity.SysLoginLog;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* 系统应用mapper接口
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/3/13 16:17
|
||||
*/
|
||||
public interface SysLoginLogMapper extends BaseMapper<SysLoginLog> {
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
<?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="cn.stylefeng.roses.kernel.loginlog.modular.mapper.SysLoginLogMapper">
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
Copyright [2020] [https://www.stylefeng.cn]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
|
||||
1.请不要删除和修改根目录下的LICENSE文件。
|
||||
2.请不要删除和修改Guns源码头部的版权声明。
|
||||
3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns-separation
|
||||
5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns-separation
|
||||
6.若您的项目无法满足以上几点,可申请商业授权,获取Guns商业授权许可,请在官网购买授权,地址为 https://www.stylefeng.cn
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.loginlog.modular.service;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.loginlog.modular.entity.SysLoginLog;
|
||||
import cn.stylefeng.roses.kernel.system.LoginLogServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.loginlog.request.SysLoginLogRequest;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* 登录日志service接口
|
||||
*
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/13 10:56
|
||||
*/
|
||||
public interface SysLoginLogService extends IService<SysLoginLog>, LoginLogServiceApi {
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param sysLoginLogRequest 参数
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/13 10:55
|
||||
*/
|
||||
void delete(SysLoginLogRequest sysLoginLogRequest);
|
||||
|
||||
|
||||
/**
|
||||
* 查看相信
|
||||
*
|
||||
* @param sysLoginLogRequest 参数
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/13 10:56
|
||||
*/
|
||||
SysLoginLog detail(SysLoginLogRequest sysLoginLogRequest);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param sysLoginLogRequest 参数
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/13 10:57
|
||||
*/
|
||||
PageResult<SysLoginLog> page(SysLoginLogRequest sysLoginLogRequest);
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,133 @@
|
|||
package cn.stylefeng.roses.kernel.loginlog.modular.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.loginlog.modular.constants.LoginLogConstant;
|
||||
import cn.stylefeng.roses.kernel.loginlog.modular.entity.SysLoginLog;
|
||||
import cn.stylefeng.roses.kernel.loginlog.modular.mapper.SysLoginLogMapper;
|
||||
import cn.stylefeng.roses.kernel.loginlog.modular.service.SysLoginLogService;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
import cn.stylefeng.roses.kernel.rule.util.HttpServletUtil;
|
||||
import cn.stylefeng.roses.kernel.system.exception.enums.AppExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.loginlog.request.SysLoginLogRequest;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 系统应用service接口实现类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/3/13 16:15
|
||||
*/
|
||||
@Service
|
||||
public class SysLoginLogServiceImpl extends ServiceImpl<SysLoginLogMapper, SysLoginLog> implements SysLoginLogService {
|
||||
|
||||
@Override
|
||||
public void add(SysLoginLogRequest sysLoginLogRequest) {
|
||||
SysLoginLog sysLoginLog = new SysLoginLog();
|
||||
BeanUtil.copyProperties(sysLoginLogRequest, sysLoginLog);
|
||||
this.save(sysLoginLog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loginSuccess(Long userId) {
|
||||
SysLoginLog sysLoginLog = new SysLoginLog();
|
||||
sysLoginLog.setLlgName(LoginLogConstant.LOGIN_IN_LOGINNAME);
|
||||
sysLoginLog.setUserId(userId);
|
||||
sysLoginLog.setLlgIpAddress(HttpServletUtil.getRequestClientIp(HttpServletUtil.getRequest()));
|
||||
sysLoginLog.setLlgSucceed(LoginLogConstant.OPERATION_SUCCESS);
|
||||
sysLoginLog.setLlgMessage(LoginLogConstant.LOGIN_IN_SUCCESS_MESSAGE);
|
||||
this.save(sysLoginLog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loginFail(Long userId, String llgMessage) {
|
||||
SysLoginLog sysLoginLog = new SysLoginLog();
|
||||
sysLoginLog.setLlgName(LoginLogConstant.LOGIN_IN_LOGINNAME);
|
||||
sysLoginLog.setUserId(userId);
|
||||
sysLoginLog.setLlgIpAddress(HttpServletUtil.getRequestClientIp(HttpServletUtil.getRequest()));
|
||||
sysLoginLog.setLlgSucceed(LoginLogConstant.OPERATION_FAIL);
|
||||
sysLoginLog.setLlgMessage(llgMessage);
|
||||
this.save(sysLoginLog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loginOutSuccess(Long userId) {
|
||||
SysLoginLog sysLoginLog = new SysLoginLog();
|
||||
sysLoginLog.setLlgName(LoginLogConstant.LOGIN_OUT_LOGINNAME);
|
||||
sysLoginLog.setUserId(userId);
|
||||
sysLoginLog.setLlgIpAddress(HttpServletUtil.getRequestClientIp(HttpServletUtil.getRequest()));
|
||||
sysLoginLog.setLlgSucceed(LoginLogConstant.OPERATION_SUCCESS);
|
||||
sysLoginLog.setLlgMessage(LoginLogConstant.LOGIN_OUT_SUCCESS_MESSAGE);
|
||||
this.save(sysLoginLog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loginOutFail(Long userId) {
|
||||
SysLoginLog sysLoginLog = new SysLoginLog();
|
||||
sysLoginLog.setLlgName(LoginLogConstant.LOGIN_OUT_LOGINNAME);
|
||||
sysLoginLog.setUserId(userId);
|
||||
sysLoginLog.setLlgIpAddress(HttpServletUtil.getRequestClientIp(HttpServletUtil.getRequest()));
|
||||
sysLoginLog.setLlgSucceed(LoginLogConstant.OPERATION_FAIL);
|
||||
sysLoginLog.setLlgMessage(LoginLogConstant.LOGIN_OUT_SUCCESS_FAIL);
|
||||
this.save(sysLoginLog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(SysLoginLogRequest sysLoginLogRequest) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll() {
|
||||
this.remove(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysLoginLog detail(SysLoginLogRequest sysLoginLogRequest) {
|
||||
return this.querySysLoginLog(sysLoginLogRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<SysLoginLog> page(SysLoginLogRequest sysLoginLogRequest) {
|
||||
LambdaQueryWrapper<SysLoginLog> wrapper = createWrapper(sysLoginLogRequest);
|
||||
wrapper.orderByDesc(SysLoginLog::getCreateTime);
|
||||
Page<SysLoginLog> page = this.page(PageFactory.defaultPage(), wrapper);
|
||||
return PageResultFactory.createPageResult(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取详细信息
|
||||
*
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/13 10:50
|
||||
*/
|
||||
private SysLoginLog querySysLoginLog(SysLoginLogRequest sysLoginLogRequest) {
|
||||
SysLoginLog sysLoginLog = this.getById(sysLoginLogRequest.getLlgId());
|
||||
if (ObjectUtil.isNull(sysLoginLog)) {
|
||||
throw new ServiceException(AppExceptionEnum.APP_NOT_EXIST);
|
||||
}
|
||||
return sysLoginLog;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建wrapper
|
||||
*
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/13 10:50
|
||||
*/
|
||||
private LambdaQueryWrapper<SysLoginLog> createWrapper(SysLoginLogRequest sysLoginLogRequest) {
|
||||
LambdaQueryWrapper<SysLoginLog> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(StrUtil.isNotBlank(sysLoginLogRequest.getLlgName()), SysLoginLog::getLlgName, sysLoginLogRequest.getLlgName());
|
||||
queryWrapper.ge(StrUtil.isNotBlank(sysLoginLogRequest.getBeginTime()), SysLoginLog::getCreateTime, sysLoginLogRequest.getBeginTime());
|
||||
queryWrapper.le(StrUtil.isNotBlank(sysLoginLogRequest.getEndTime()), SysLoginLog::getCreateTime, sysLoginLogRequest.getEndTime());
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
}
|
|
@ -19,9 +19,9 @@ import cn.stylefeng.roses.kernel.system.pojo.notice.SysNoticeRequest;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -36,15 +36,14 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
|
|||
|
||||
private static String NOTICE_SCOPE_ALL = "all";
|
||||
|
||||
@Autowired
|
||||
private SysNoticeMapper noticeMapper;
|
||||
|
||||
/**
|
||||
* 系统消息api
|
||||
*/
|
||||
@Autowired
|
||||
@Resource
|
||||
private MessageApi messageApi;
|
||||
|
||||
private void sendMessage(SysNotice sysNotice){
|
||||
private void sendMessage(SysNotice sysNotice) {
|
||||
MessageSendParam message = new MessageSendParam();
|
||||
// 消息标题
|
||||
message.setMessageTitle(sysNotice.getNoticeTitle());
|
||||
|
@ -64,12 +63,12 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
|
|||
public void add(SysNoticeRequest sysNoticeRequest) {
|
||||
SysNotice sysNotice = new SysNotice();
|
||||
BeanUtil.copyProperties(sysNoticeRequest, sysNotice);
|
||||
if(StrUtil.isBlank(sysNotice.getNoticeScope())){
|
||||
if (StrUtil.isBlank(sysNotice.getNoticeScope())) {
|
||||
sysNotice.setNoticeScope(NOTICE_SCOPE_ALL);
|
||||
}
|
||||
|
||||
// 如果保存成功调用发送消息
|
||||
if(this.save(sysNotice)){
|
||||
if (this.save(sysNotice)) {
|
||||
sendMessage(sysNotice);
|
||||
}
|
||||
}
|
||||
|
@ -79,10 +78,10 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
|
|||
|
||||
SysNotice sysNotice = this.querySysNotice(sysNoticeRequest);
|
||||
String noticeScope = sysNotice.getNoticeScope();
|
||||
if(StrUtil.isBlank(sysNoticeRequest.getNoticeScope())){
|
||||
if (StrUtil.isBlank(sysNoticeRequest.getNoticeScope())) {
|
||||
sysNoticeRequest.setNoticeScope(NOTICE_SCOPE_ALL);
|
||||
}
|
||||
if(sysNoticeRequest.equals(sysNotice.getNoticeScope())){
|
||||
if (sysNoticeRequest.equals(sysNotice.getNoticeScope())) {
|
||||
throw new ServiceException(NoticeExceptionEnum.NOTICE_SCOPE_NOT_EDIT);
|
||||
}
|
||||
BeanUtil.copyProperties(sysNoticeRequest, sysNotice);
|
||||
|
@ -90,7 +89,7 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
|
|||
// 通知范围不允许修改
|
||||
sysNotice.setNoticeScope(noticeScope);
|
||||
|
||||
if(this.updateById(sysNotice)){
|
||||
if (this.updateById(sysNotice)) {
|
||||
sendMessage(sysNotice);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,6 +66,14 @@
|
|||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!--登录日志的业务-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>system-business-login-log</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
Loading…
Reference in New Issue