mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-14 21:52:07 +08:00
1、恢复operationlog;2、登录性能优化;
This commit is contained in:
+1
@@ -1 +1,2 @@
|
|||||||
com.cf.imes.framework.operatelog.config.ChenfengOperateLogRpcAutoConfiguration
|
com.cf.imes.framework.operatelog.config.ChenfengOperateLogRpcAutoConfiguration
|
||||||
|
com.cf.imes.framework.operatelog.config.ChenfengOperateLogAutoConfiguration
|
||||||
+2
-2
@@ -31,12 +31,12 @@ public class OperateLogDO extends BaseDO {
|
|||||||
/**
|
/**
|
||||||
* {@link #javaMethodArgs} 的最大长度
|
* {@link #javaMethodArgs} 的最大长度
|
||||||
*/
|
*/
|
||||||
public static final Integer JAVA_METHOD_ARGS_MAX_LENGTH = 8000;
|
public static final Integer JAVA_METHOD_ARGS_MAX_LENGTH = 1000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link #resultData} 的最大长度
|
* {@link #resultData} 的最大长度
|
||||||
*/
|
*/
|
||||||
public static final Integer RESULT_MAX_LENGTH = 4000;
|
public static final Integer RESULT_MAX_LENGTH = 1000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日志主键
|
* 日志主键
|
||||||
|
|||||||
+20
-4
@@ -12,6 +12,8 @@ import com.cf.imes.framework.common.util.servlet.ServletUtils;
|
|||||||
import com.cf.imes.framework.common.util.validation.ValidationUtils;
|
import com.cf.imes.framework.common.util.validation.ValidationUtils;
|
||||||
import com.cf.imes.framework.ip.core.service.IPQueryService;
|
import com.cf.imes.framework.ip.core.service.IPQueryService;
|
||||||
import com.cf.imes.framework.ip.core.service.dto.IPQueryDataRespDTO;
|
import com.cf.imes.framework.ip.core.service.dto.IPQueryDataRespDTO;
|
||||||
|
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||||
|
import com.cf.imes.framework.organ.core.service.OrganFrameworkService;
|
||||||
import com.cf.imes.module.system.api.logger.dto.LoginLogCreateReqDTO;
|
import com.cf.imes.module.system.api.logger.dto.LoginLogCreateReqDTO;
|
||||||
import com.cf.imes.module.system.api.sms.SmsCodeApi;
|
import com.cf.imes.module.system.api.sms.SmsCodeApi;
|
||||||
import com.cf.imes.module.system.api.social.dto.SocialUserRespDTO;
|
import com.cf.imes.module.system.api.social.dto.SocialUserRespDTO;
|
||||||
@@ -29,7 +31,6 @@ import com.cf.imes.module.system.enums.logger.LoginLogTypeEnum;
|
|||||||
import com.cf.imes.module.system.enums.logger.LoginResultEnum;
|
import com.cf.imes.module.system.enums.logger.LoginResultEnum;
|
||||||
import com.cf.imes.module.system.enums.oauth2.OAuth2ClientConstants;
|
import com.cf.imes.module.system.enums.oauth2.OAuth2ClientConstants;
|
||||||
import com.cf.imes.module.system.enums.sms.SmsSceneEnum;
|
import com.cf.imes.module.system.enums.sms.SmsSceneEnum;
|
||||||
import com.cf.imes.module.system.service.dept.DeptService;
|
|
||||||
import com.cf.imes.module.system.service.logger.LoginLogService;
|
import com.cf.imes.module.system.service.logger.LoginLogService;
|
||||||
import com.cf.imes.module.system.service.member.MemberService;
|
import com.cf.imes.module.system.service.member.MemberService;
|
||||||
import com.cf.imes.module.system.service.oauth2.OAuth2TokenService;
|
import com.cf.imes.module.system.service.oauth2.OAuth2TokenService;
|
||||||
@@ -41,12 +42,15 @@ import com.cf.imes.module.system.enums.ErrorCodeConstants;
|
|||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.validation.Validator;
|
import jakarta.validation.Validator;
|
||||||
|
import org.springframework.transaction.support.TransactionTemplate;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
@@ -82,7 +86,7 @@ public class AdminAuthServiceImpl implements AdminAuthService {
|
|||||||
@Resource
|
@Resource
|
||||||
private OrganService organService;
|
private OrganService organService;
|
||||||
@Resource
|
@Resource
|
||||||
private DeptService deptService;
|
private OrganFrameworkService organFrameworkService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SmsCodeService smsCodeService;
|
private SmsCodeService smsCodeService;
|
||||||
@@ -90,6 +94,9 @@ public class AdminAuthServiceImpl implements AdminAuthService {
|
|||||||
@Resource
|
@Resource
|
||||||
private IPQueryService ipQueryService;
|
private IPQueryService ipQueryService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TransactionTemplate transactionTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证码的开关,默认为 true
|
* 验证码的开关,默认为 true
|
||||||
*/
|
*/
|
||||||
@@ -116,9 +123,10 @@ public class AdminAuthServiceImpl implements AdminAuthService {
|
|||||||
}
|
}
|
||||||
Long organId = user.getOrganId();
|
Long organId = user.getOrganId();
|
||||||
// 校验机构有效性
|
// 校验机构有效性
|
||||||
organService.validOrgan(organId);
|
organFrameworkService.validOrgan(organId);
|
||||||
// 校验部门有效性
|
// 校验部门有效性
|
||||||
deptService.validUserLoginDept(user.getDeptId());
|
OrganContextHolder.setOrganId(organId);
|
||||||
|
organFrameworkService.validDept(user.getDeptId());
|
||||||
// 校验密码
|
// 校验密码
|
||||||
if (!userService.isPasswordMatch(password, user.getPassword())) {
|
if (!userService.isPasswordMatch(password, user.getPassword())) {
|
||||||
createLoginLog(user.getId(), username, organId, logTypeEnum, LoginResultEnum.BAD_CREDENTIALS);
|
createLoginLog(user.getId(), username, organId, logTypeEnum, LoginResultEnum.BAD_CREDENTIALS);
|
||||||
@@ -222,6 +230,9 @@ public class AdminAuthServiceImpl implements AdminAuthService {
|
|||||||
|
|
||||||
private void createLoginLog(Long userId, String username, Long organId,
|
private void createLoginLog(Long userId, String username, Long organId,
|
||||||
LoginLogTypeEnum logTypeEnum, LoginResultEnum loginResult) {
|
LoginLogTypeEnum logTypeEnum, LoginResultEnum loginResult) {
|
||||||
|
// 手动控制事务
|
||||||
|
transactionTemplate.executeWithoutResult(status -> {
|
||||||
|
try {
|
||||||
String clientIP = getClientIP();
|
String clientIP = getClientIP();
|
||||||
// 插入登录日志
|
// 插入登录日志
|
||||||
LoginLogCreateReqDTO reqDTO = new LoginLogCreateReqDTO();
|
LoginLogCreateReqDTO reqDTO = new LoginLogCreateReqDTO();
|
||||||
@@ -244,6 +255,11 @@ public class AdminAuthServiceImpl implements AdminAuthService {
|
|||||||
if (userId != null && Objects.equals(LoginResultEnum.SUCCESS.getResult(), loginResult.getResult())) {
|
if (userId != null && Objects.equals(LoginResultEnum.SUCCESS.getResult(), loginResult.getResult())) {
|
||||||
userService.updateUserLogin(userId, clientIP);
|
userService.updateUserLogin(userId, clientIP);
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
status.setRollbackOnly(); // 显式标记事务回滚
|
||||||
|
log.error("login log record error", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+4
-1
@@ -254,7 +254,10 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateUserLogin(Long id, String loginIp) {
|
public void updateUserLogin(Long id, String loginIp) {
|
||||||
userMapper.updateById(new AdminUserDO().setId(id).setLoginIp(loginIp).setLoginDate(LocalDateTime.now()));
|
userMapper.update(new LambdaUpdateWrapper<AdminUserDO>()
|
||||||
|
.eq(AdminUserDO::getId, id)
|
||||||
|
.set(AdminUserDO::getLoginIp, loginIp)
|
||||||
|
.set(AdminUserDO::getLoginDate, LocalDateTime.now()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user