remove old message

This commit is contained in:
MaxKey
2022-12-25 16:54:29 +08:00
parent fbca926ad1
commit 8213ffb8a0
12 changed files with 28 additions and 576 deletions

View File

@@ -28,7 +28,6 @@ import org.maxkey.authn.web.CurrentUserMethodArgumentResolver;
import org.maxkey.authn.web.interceptor.PermissionInterceptor;
import org.maxkey.configuration.ApplicationConfig;
import org.maxkey.web.interceptor.HistorySignOnAppInterceptor;
import org.maxkey.web.interceptor.HistoryLogsInterceptor;
import org.maxkey.web.interceptor.SingleSignOnInterceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -66,11 +65,7 @@ public class MaxKeyMvcConfig implements WebMvcConfigurer {
KerberosService kerberosService;
@Autowired
PermissionInterceptor permissionInterceptor;
@Autowired
HistoryLogsInterceptor historyLogsInterceptor;
PermissionInterceptor permissionInterceptor;
@Autowired
SingleSignOnInterceptor singleSignOnInterceptor;
@@ -143,11 +138,6 @@ public class MaxKeyMvcConfig implements WebMvcConfigurer {
;
_logger.debug("add Permission Interceptor");
registry.addInterceptor(historyLogsInterceptor)
.addPathPatterns("/config/changePassword/**")
;
_logger.debug("add historyLogs Interceptor");
//for Single Sign On
registry.addInterceptor(singleSignOnInterceptor)

View File

@@ -21,17 +21,16 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.maxkey.authn.annotation.CurrentUser;
import org.maxkey.constants.ConstsOperateResult;
import org.maxkey.constants.ConstsTimeInterval;
import org.maxkey.entity.Message;
import org.maxkey.entity.UserInfo;
import org.maxkey.persistence.service.UserInfoService;
import org.maxkey.web.WebConstants;
import org.maxkey.web.WebContext;
import org.maxkey.web.message.Message;
import org.maxkey.web.message.MessageType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@@ -55,7 +54,7 @@ public class SafeController {
@ResponseBody
@RequestMapping(value="/setting")
public Message setting(
public ResponseEntity<?> setting(
HttpServletRequest request,
HttpServletResponse response,
@RequestParam("authnType") String authnType,
@@ -79,7 +78,7 @@ public class SafeController {
userInfoService.updateEmail(currentUser);
return new Message(WebContext.getI18nValue(ConstsOperateResult.SUCCESS),MessageType.success);
return new Message<UserInfo>(Message.SUCCESS).buildResponse();
}

View File

@@ -1,79 +0,0 @@
/*
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
*
* 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.
*/
package org.maxkey.web.interceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.maxkey.authn.web.AuthorizationUtils;
import org.maxkey.entity.HistorySystemLogs;
import org.maxkey.entity.UserInfo;
import org.maxkey.persistence.service.HistorySystemLogsService;
import org.maxkey.web.WebContext;
import org.maxkey.web.message.Message;
import org.maxkey.web.message.MessageScope;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.AsyncHandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
/**
* Contorller调用完成后进行日志操作
* 日志处理需在parasec-servlet.xml中配置
* mvc:interceptors log
* @author Crystal.Sea
*
*/
@Component
public class HistoryLogsInterceptor implements AsyncHandlerInterceptor {
private static final Logger _logger = LoggerFactory.getLogger(HistoryLogsInterceptor.class);
@Autowired
private HistorySystemLogsService historySystemLogsService;
/**
* after the handler is executed.
*/
public void postHandle(HttpServletRequest request,
HttpServletResponse response,
Object handler,ModelAndView modelAndView) throws Exception {
_logger.debug("postHandle");
Message message = WebContext.getMessage();//读取session中message
if (message != null) {
//判断message类型
if (message.getMessageScope() == MessageScope.DB
|| message.getMessageScope() == MessageScope.DB_CLIENT) {
UserInfo userInfo = AuthorizationUtils.getUserInfo();//取得当前用户信息
//创建日志记录
HistorySystemLogs historySystemLogs = new HistorySystemLogs();
historySystemLogs.setInstId(userInfo.getInstId());
_logger.debug("insert db historyLogs content : " + historySystemLogs);
historySystemLogsService.insert(historySystemLogs);//日志插入数据库
//message类型仅插入数据库
if (message.getMessageScope() == MessageScope.DB) {
WebContext.clearMessage();//清除message
}
}
}
}
}