mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-08 01:48:33 +08:00
remove old message
This commit is contained in:
parent
fbca926ad1
commit
8213ffb8a0
@ -34,7 +34,6 @@ import org.maxkey.configuration.ApplicationConfig;
|
||||
import org.maxkey.entity.Institutions;
|
||||
import org.maxkey.util.DateUtils;
|
||||
import org.maxkey.util.IdGenerator;
|
||||
import org.maxkey.web.message.Message;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeansException;
|
||||
@ -98,26 +97,6 @@ public final class WebContext {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* set Message to session,session id is Constants.MESSAGE
|
||||
*
|
||||
* @see WebConstants.MESSAGE
|
||||
* @param message Message
|
||||
*/
|
||||
public static void setMessage(Message message) {
|
||||
setAttribute(WebConstants.CURRENT_MESSAGE, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* get message from session,session id is Constants.MESSAGE
|
||||
*
|
||||
* @see WebConstants.MESSAGE
|
||||
* @return Message
|
||||
*/
|
||||
public static Message getMessage() {
|
||||
return ((Message) getAttribute(WebConstants.CURRENT_MESSAGE));
|
||||
}
|
||||
|
||||
/**
|
||||
* clear session Message ,session id is Constants.MESSAGE
|
||||
*
|
||||
|
||||
@ -1,246 +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.message;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.maxkey.web.WebContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.FieldError;
|
||||
|
||||
/**
|
||||
* message类定义
|
||||
*
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
public class Message {
|
||||
static final Logger _logger = LoggerFactory.getLogger(Message.class);
|
||||
// 服务名称
|
||||
private String topic;
|
||||
// 信息内容
|
||||
private String message;
|
||||
// 信息代码
|
||||
private String code;
|
||||
// 信息对象
|
||||
private Object messageObject;
|
||||
// 错误信息
|
||||
private ArrayList<HashMap<String, Object>> errors;
|
||||
// 类型
|
||||
private MessageType messageType = MessageType.info;
|
||||
// 操作类型
|
||||
private OperateType operateType = OperateType.unknown;
|
||||
// 范围
|
||||
MessageScope messageScope = MessageScope.JSON;
|
||||
|
||||
public Message() {
|
||||
|
||||
}
|
||||
|
||||
public Message(String message) {
|
||||
this.message = message;
|
||||
this.messageType = MessageType.info;
|
||||
}
|
||||
|
||||
public Message(BindingResult result) {
|
||||
setFieldErrors(result);
|
||||
}
|
||||
|
||||
public Message(String message, String code) {
|
||||
this.message = message;
|
||||
this.code = code;
|
||||
this.messageType = MessageType.info;
|
||||
}
|
||||
|
||||
public Message(String message, MessageType messageType) {
|
||||
this.message = message;
|
||||
this.messageType = messageType;
|
||||
}
|
||||
|
||||
public Message(String message, BindingResult result) {
|
||||
this.message = message;
|
||||
setFieldErrors(result);
|
||||
}
|
||||
|
||||
public Message(String message, String code, MessageType messageType) {
|
||||
this.message = message;
|
||||
this.code = code;
|
||||
this.messageType = messageType;
|
||||
}
|
||||
|
||||
public Message(String message, Object messageObject, MessageType messageType, OperateType operateType) {
|
||||
this.message = message;
|
||||
this.messageType = messageType;
|
||||
this.operateType = operateType;
|
||||
this.messageObject = messageObject;
|
||||
WebContext.setMessage(this);
|
||||
}
|
||||
|
||||
public Message(String message, Object messageObject, MessageType messageType, OperateType operateType,
|
||||
MessageScope messageScope) {
|
||||
this.message = message;
|
||||
this.messageObject = messageObject;
|
||||
this.messageType = messageType;
|
||||
this.operateType = operateType;
|
||||
this.messageScope = messageScope;
|
||||
WebContext.setMessage(this);
|
||||
}
|
||||
|
||||
public Message(String message, Object messageObject, BindingResult result, MessageType messageType,
|
||||
OperateType operateType, MessageScope messageScope) {
|
||||
this.message = message;
|
||||
this.messageObject = messageObject;
|
||||
this.operateType = operateType;
|
||||
this.messageScope = messageScope;
|
||||
setFieldErrors(result);
|
||||
this.messageType = messageType;
|
||||
WebContext.setMessage(this);
|
||||
}
|
||||
|
||||
public Message(String topic, String message, Object messageObject, BindingResult result,
|
||||
MessageType messageType, OperateType operateType, MessageScope messageScope) {
|
||||
this.topic = topic;
|
||||
this.message = message;
|
||||
this.messageObject = messageObject;
|
||||
this.operateType = operateType;
|
||||
this.messageScope = messageScope;
|
||||
setFieldErrors(result);
|
||||
this.messageType = messageType;
|
||||
WebContext.setMessage(this);
|
||||
}
|
||||
|
||||
public Message(String serviceName, String message, Object messageObject, BindingResult result,
|
||||
MessageType messageType, OperateType operateType, MessageScope messageScope, String code) {
|
||||
this(serviceName, message, messageObject, result, messageType, operateType, messageScope);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证错误组装
|
||||
*
|
||||
* @param result
|
||||
*/
|
||||
public void setFieldErrors(BindingResult result) {
|
||||
if (result == null)
|
||||
return;
|
||||
this.messageType = MessageType.error;
|
||||
this.errors = new ArrayList<HashMap<String, Object>>();
|
||||
List<FieldError> listFieldError = result.getFieldErrors();
|
||||
|
||||
for (FieldError fieldError : listFieldError) {
|
||||
HashMap<String, Object> error = new HashMap<String, Object>();
|
||||
error.put("field", fieldError.getField());
|
||||
error.put("type", fieldError.getCode());
|
||||
error.put("objectName", fieldError.getObjectName());
|
||||
String defaultMessageSourceResolvable = fieldError.getCodes()[0];
|
||||
String errorMessage = WebContext.getI18nValue(defaultMessageSourceResolvable);
|
||||
if (errorMessage == null) {
|
||||
error.put("message", /* fieldError.getField()+" "+ */fieldError.getDefaultMessage());
|
||||
} else {
|
||||
error.put("message", errorMessage);
|
||||
}
|
||||
_logger.debug("" + error);
|
||||
this.errors.add(error);
|
||||
}
|
||||
_logger.debug("" + this.errors);
|
||||
}
|
||||
|
||||
public void setApplication() {
|
||||
WebContext.setMessage(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the code
|
||||
*/
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param code the code to set
|
||||
*/
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public MessageType getMessageType() {
|
||||
return messageType;
|
||||
}
|
||||
|
||||
public void setMessageType(MessageType messageType) {
|
||||
this.messageType = messageType;
|
||||
}
|
||||
|
||||
public ArrayList<HashMap<String, Object>> getErrors() {
|
||||
return errors;
|
||||
}
|
||||
|
||||
public void setErrors(ArrayList<HashMap<String, Object>> errors) {
|
||||
this.errors = errors;
|
||||
}
|
||||
|
||||
public OperateType getOperateType() {
|
||||
return operateType;
|
||||
}
|
||||
|
||||
public void setOperateType(OperateType operateType) {
|
||||
this.operateType = operateType;
|
||||
}
|
||||
|
||||
public Object getMessageObject() {
|
||||
return messageObject;
|
||||
}
|
||||
|
||||
public void setMessageObject(Object messageObject) {
|
||||
this.messageObject = messageObject;
|
||||
}
|
||||
|
||||
public MessageScope getMessageScope() {
|
||||
return messageScope;
|
||||
}
|
||||
|
||||
public void setMessageScope(MessageScope messageScope) {
|
||||
this.messageScope = messageScope;
|
||||
}
|
||||
|
||||
public String getTopic() {
|
||||
return topic;
|
||||
}
|
||||
|
||||
public void setTopic(String topic) {
|
||||
this.topic = topic;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,30 +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.message;
|
||||
|
||||
/**
|
||||
* message范围
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
public enum MessageScope {
|
||||
JSON,//仅json
|
||||
DB,//插入数据库
|
||||
CLIENT,//仅前端页面
|
||||
DB_CLIENT//数据库和前端页面
|
||||
}
|
||||
@ -1,32 +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.message;
|
||||
|
||||
/**
|
||||
* message类型
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
public enum MessageType {
|
||||
success ,//成功
|
||||
error ,//错误
|
||||
fail ,//失败
|
||||
info ,//信息
|
||||
prompt ,//提示
|
||||
warning //警告
|
||||
}
|
||||
@ -1,33 +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.message;
|
||||
|
||||
/**
|
||||
* message操作类型
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
public enum OperateType {
|
||||
unknown,//未知
|
||||
add,//新增
|
||||
update,//修改
|
||||
query,//查询
|
||||
delete,//删除
|
||||
audit,//审核
|
||||
view,//查看
|
||||
}
|
||||
@ -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)
|
||||
|
||||
@ -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();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -23,7 +23,6 @@ import org.maxkey.authn.provider.AbstractAuthenticationProvider;
|
||||
import org.maxkey.authn.web.CurrentUserMethodArgumentResolver;
|
||||
import org.maxkey.authn.web.interceptor.PermissionInterceptor;
|
||||
import org.maxkey.configuration.ApplicationConfig;
|
||||
import org.maxkey.web.interceptor.HistoryLogsAdapter;
|
||||
import org.maxkey.web.interceptor.RestApiPermissionAdapter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -50,9 +49,6 @@ public class MaxKeyMgtMvcConfig implements WebMvcConfigurer {
|
||||
@Autowired
|
||||
PermissionInterceptor permissionInterceptor;
|
||||
|
||||
@Autowired
|
||||
HistoryLogsAdapter historyLogsAdapter;
|
||||
|
||||
@Autowired
|
||||
RestApiPermissionAdapter restApiPermissionAdapter;
|
||||
|
||||
@ -119,20 +115,7 @@ public class MaxKeyMgtMvcConfig implements WebMvcConfigurer {
|
||||
;
|
||||
|
||||
_logger.debug("add Permission Adapter");
|
||||
|
||||
registry.addInterceptor(historyLogsAdapter)
|
||||
.addPathPatterns("/userinfo/**")
|
||||
.addPathPatterns("/enterprises/**")
|
||||
.addPathPatterns("/employees/**")
|
||||
.addPathPatterns("/authInfo/**")
|
||||
.addPathPatterns("/usercenter/**")
|
||||
.addPathPatterns("/retrievePassword/**")
|
||||
.addPathPatterns("/roles/**")
|
||||
.addPathPatterns("/apps/**")
|
||||
.addPathPatterns("/approles/**")
|
||||
;
|
||||
_logger.debug("add History Logs Adapter");
|
||||
|
||||
|
||||
/*
|
||||
* api
|
||||
* idm
|
||||
|
||||
@ -19,16 +19,15 @@ package org.maxkey.web.config.contorller;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.maxkey.authn.annotation.CurrentUser;
|
||||
import org.maxkey.constants.ConstsOperateResult;
|
||||
import org.maxkey.entity.Localization;
|
||||
import org.maxkey.entity.Message;
|
||||
import org.maxkey.entity.UserInfo;
|
||||
import org.maxkey.entity.UserInfoAdjoint;
|
||||
import org.maxkey.persistence.repository.LocalizationRepository;
|
||||
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.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
@ -67,21 +66,21 @@ public class LocalizationController {
|
||||
*/
|
||||
@RequestMapping(value={"/update"})
|
||||
@ResponseBody
|
||||
public Message updat(@ModelAttribute("localization") Localization localization,@CurrentUser UserInfo currentUser,BindingResult result) {
|
||||
public ResponseEntity<?> update(@ModelAttribute("localization") Localization localization,@CurrentUser UserInfo currentUser,BindingResult result) {
|
||||
_logger.debug("update localization : "+localization);
|
||||
localization.setInstId(currentUser.getInstId());
|
||||
if(StringUtils.isBlank(localization.getId())){
|
||||
localization.setId(localization.generateId());
|
||||
if(localizationRepository.insert(localization)) {
|
||||
return new Message(WebContext.getI18nValue(ConstsOperateResult.SUCCESS),MessageType.success);
|
||||
return new Message<UserInfoAdjoint>(Message.SUCCESS).buildResponse();
|
||||
} else {
|
||||
return new Message(WebContext.getI18nValue(ConstsOperateResult.ERROR),MessageType.error);
|
||||
return new Message<UserInfoAdjoint>(Message.FAIL).buildResponse();
|
||||
}
|
||||
}else {
|
||||
if(localizationRepository.update(localization)) {
|
||||
return new Message(WebContext.getI18nValue(ConstsOperateResult.SUCCESS),MessageType.success);
|
||||
return new Message<UserInfoAdjoint>(Message.SUCCESS).buildResponse();
|
||||
} else {
|
||||
return new Message(WebContext.getI18nValue(ConstsOperateResult.ERROR),MessageType.error);
|
||||
return new Message<UserInfoAdjoint>(Message.FAIL).buildResponse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,16 +19,14 @@ package org.maxkey.web.contorller;
|
||||
|
||||
import org.apache.mybatis.jpa.persistence.JpaPageResults;
|
||||
import org.maxkey.authn.annotation.CurrentUser;
|
||||
import org.maxkey.constants.ConstsOperateResult;
|
||||
import org.maxkey.entity.Message;
|
||||
import org.maxkey.entity.UserInfo;
|
||||
import org.maxkey.entity.UserInfoAdjoint;
|
||||
import org.maxkey.persistence.service.UserInfoAdjointService;
|
||||
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.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@ -82,16 +80,16 @@ public class UserAdjointController {
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value={"/add"})
|
||||
public Message insert(
|
||||
public ResponseEntity<?> insert(
|
||||
@ModelAttribute("userInfoAdjoint") UserInfoAdjoint userInfoAdjoint,
|
||||
@CurrentUser UserInfo currentUser) {
|
||||
_logger.debug("-Add :" + userInfoAdjoint);
|
||||
userInfoAdjoint.setInstId(currentUser.getInstId());
|
||||
if (userInfoAdjointService.insert(userInfoAdjoint)) {
|
||||
return new Message(WebContext.getI18nValue(ConstsOperateResult.SUCCESS),MessageType.success);
|
||||
return new Message<UserInfoAdjoint>(Message.SUCCESS).buildResponse();
|
||||
|
||||
} else {
|
||||
return new Message(WebContext.getI18nValue(ConstsOperateResult.SUCCESS),MessageType.error);
|
||||
return new Message<UserInfoAdjoint>(Message.FAIL).buildResponse();
|
||||
}
|
||||
|
||||
}
|
||||
@ -103,16 +101,16 @@ public class UserAdjointController {
|
||||
*/
|
||||
@ResponseBody
|
||||
@RequestMapping(value={"/query"})
|
||||
public Message query(
|
||||
public ResponseEntity<?> query(
|
||||
@ModelAttribute("userInfoAdjoint") UserInfoAdjoint userInfoAdjoint,
|
||||
@CurrentUser UserInfo currentUser) {
|
||||
_logger.debug("-query :" + userInfoAdjoint);
|
||||
userInfoAdjoint.setInstId(currentUser.getInstId());
|
||||
if (userInfoAdjointService.load(userInfoAdjoint)!=null) {
|
||||
return new Message(WebContext.getI18nValue(ConstsOperateResult.SUCCESS),MessageType.success);
|
||||
return new Message<UserInfoAdjoint>(Message.SUCCESS).buildResponse();
|
||||
|
||||
} else {
|
||||
return new Message(WebContext.getI18nValue(ConstsOperateResult.SUCCESS),MessageType.error);
|
||||
return new Message<UserInfoAdjoint>(Message.FAIL).buildResponse();
|
||||
}
|
||||
|
||||
}
|
||||
@ -124,16 +122,16 @@ public class UserAdjointController {
|
||||
*/
|
||||
@ResponseBody
|
||||
@RequestMapping(value={"/update"})
|
||||
public Message update(
|
||||
public ResponseEntity<?> update(
|
||||
@ModelAttribute("userInfoAdjoint") UserInfoAdjoint userInfoAdjoint,
|
||||
@CurrentUser UserInfo currentUser) {
|
||||
_logger.debug("-update userInfoAdjoint :" + userInfoAdjoint);
|
||||
userInfoAdjoint.setInstId(currentUser.getInstId());
|
||||
if (userInfoAdjointService.update(userInfoAdjoint)) {
|
||||
return new Message(WebContext.getI18nValue(ConstsOperateResult.SUCCESS),MessageType.success);
|
||||
return new Message<UserInfoAdjoint>(Message.SUCCESS).buildResponse();
|
||||
|
||||
} else {
|
||||
return new Message(WebContext.getI18nValue(ConstsOperateResult.ERROR),MessageType.error);
|
||||
return new Message<UserInfoAdjoint>(Message.FAIL).buildResponse();
|
||||
}
|
||||
|
||||
}
|
||||
@ -141,13 +139,13 @@ public class UserAdjointController {
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value={"/delete"})
|
||||
public Message delete(@ModelAttribute("userInfoAdjoint") UserInfoAdjoint userInfoAdjoint) {
|
||||
public ResponseEntity<?> delete(@ModelAttribute("userInfoAdjoint") UserInfoAdjoint userInfoAdjoint) {
|
||||
_logger.debug("-delete group :" + userInfoAdjoint);
|
||||
|
||||
if (userInfoAdjointService.deleteBatch(userInfoAdjoint.getId())) {
|
||||
return new Message(WebContext.getI18nValue(ConstsOperateResult.SUCCESS),MessageType.success);
|
||||
return new Message<UserInfoAdjoint>(Message.SUCCESS).buildResponse();
|
||||
} else {
|
||||
return new Message(WebContext.getI18nValue(ConstsOperateResult.ERROR),MessageType.error);
|
||||
return new Message<UserInfoAdjoint>(Message.FAIL).buildResponse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,76 +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 HistoryLogsAdapter implements AsyncHandlerInterceptor {
|
||||
|
||||
private static final Logger _logger = LoggerFactory.getLogger(HistoryLogsAdapter.class);
|
||||
|
||||
@Autowired
|
||||
private HistorySystemLogsService historySystemLogsService;
|
||||
|
||||
// after the handler is executed
|
||||
@Override
|
||||
public void postHandle(HttpServletRequest request,HttpServletResponse response, Object handler,ModelAndView modelAndView) throws Exception {
|
||||
Message message = WebContext.getMessage();//读取session中message
|
||||
|
||||
if(message != null){
|
||||
if(message.getMessageScope() == MessageScope.DB || message.getMessageScope() == MessageScope.DB_CLIENT) {//判断message类型
|
||||
UserInfo userInfo = AuthorizationUtils.getUserInfo();//取得当前用户信息
|
||||
//创建日志记录
|
||||
HistorySystemLogs historySystemLog = new HistorySystemLogs();
|
||||
historySystemLog.setTopic(message.getTopic());
|
||||
historySystemLog.setUserId(userInfo.getId());
|
||||
historySystemLog.setUsername(userInfo.getUsername());
|
||||
historySystemLog.setDisplayName(userInfo.getDisplayName());
|
||||
historySystemLog.setInstId(userInfo.getInstId());
|
||||
_logger.debug("insert db logs content : " + historySystemLog);
|
||||
historySystemLogsService.insert(historySystemLog);//日志插入数据库
|
||||
if(message.getMessageScope() == MessageScope.DB) {//message类型仅插入数据库
|
||||
WebContext.clearMessage();//清除message
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user