1
0
Prechádzať zdrojové kódy

接口日志bug fix

lhm 3 rokov pred
rodič
commit
52e4bc0c23

+ 6 - 0
kmall-admin/src/main/java/com/kmall/admin/aop/InterfaceExternalAspect.java

@@ -48,6 +48,9 @@ public class InterfaceExternalAspect {
              interfaceSendLogEntity = getMethdMsg(methd);
             Object[] args = proceedingJoinPoint.getArgs();
             for (Object o : args) {
+                if (o instanceof String) {
+                    o = ((String) o).replaceAll("\r|\n", "");
+                }
                 requestLog.append(String.format("参数:%s\r\n", JSON.toJSON(o)));
             }
             interfaceSendLogEntity.setRequestDate(new Date());
@@ -57,6 +60,9 @@ public class InterfaceExternalAspect {
             exMsg = e.getMessage();
             throw e;
         } finally {
+            if (result instanceof String) {
+                result = ((String) result).replaceAll("\r|\n", "");
+            }
             saveVmcSend(interfaceSendLogEntity,requestLog.toString(),JSON.toJSONString(result),exMsg);
         }
         return result;

+ 10 - 2
kmall-admin/src/main/webapp/js/shop/interfacesendlog.js

@@ -6,8 +6,16 @@ $(function () {
 			{label: 'id', name: 'id', index: 'id', key: true, hidden: true},
 			{label: '请求/响应系统类型', name: 'sysType', index: 'sys_type', width: 80},
 			{label: '请求/响应接口类型', name: 'interfaceType', index: 'interface_type', width: 80},
-			{label: '请求信息', name: 'requestMsg', index: 'request_msg', width: 100},
-			{label: '响应结果', name: 'responseMsg', index: 'response_msg', width: 100},
+			{label: '请求信息', name: 'requestMsg', index: 'request_msg', width: 100, formatter: function (value) {
+				value = value.replace(/</g, '&lt;');
+				value = value.replace(/>/g, '&gt;');
+				return value;
+			}},
+			{label: '响应结果', name: 'responseMsg', index: 'response_msg', width: 100, formatter: function (value) {
+				value = value.replace(/</g, '&lt;');
+				value = value.replace(/>/g, '&gt;');
+				return value;
+			}},
 			{label: '发送时间', name: 'requestDate', index: 'request_date',align: 'center', width: 70,formatter:function(value){
 					return transDate(value, 'yyyy-MM-dd hh:mm:ss');
 				}},