Commit 01b796a5 by fsn

日志详情的展示

parent 75cb219b
...@@ -3,6 +3,7 @@ package com.stylefeng.guns.modular.system.controller; ...@@ -3,6 +3,7 @@ package com.stylefeng.guns.modular.system.controller;
import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.common.constant.factory.PageFactory; import com.stylefeng.guns.common.constant.factory.PageFactory;
import com.stylefeng.guns.common.controller.BaseController; import com.stylefeng.guns.common.controller.BaseController;
import com.stylefeng.guns.core.support.BeanKit;
import com.stylefeng.guns.modular.system.warpper.LogWarpper; import com.stylefeng.guns.modular.system.warpper.LogWarpper;
import com.stylefeng.guns.persistence.dao.OperationLogMapper; import com.stylefeng.guns.persistence.dao.OperationLogMapper;
import com.stylefeng.guns.persistence.model.OperationLog; import com.stylefeng.guns.persistence.model.OperationLog;
...@@ -56,6 +57,8 @@ public class LogController extends BaseController { ...@@ -56,6 +57,8 @@ public class LogController extends BaseController {
@RequestMapping("/detail/{id}") @RequestMapping("/detail/{id}")
@ResponseBody @ResponseBody
public Object detail(@PathVariable Integer id){ public Object detail(@PathVariable Integer id){
return operationLogMapper.selectById(id); OperationLog operationLog = operationLogMapper.selectById(id);
Map<String, Object> stringObjectMap = BeanKit.beanToMap(operationLog);
return super.warpObject(new LogWarpper(stringObjectMap));
} }
} }
package com.stylefeng.guns.modular.system.warpper; package com.stylefeng.guns.modular.system.warpper;
import com.stylefeng.guns.common.warpper.BaseControllerWarpper; import com.stylefeng.guns.common.warpper.BaseControllerWarpper;
import com.stylefeng.guns.core.util.Contrast;
import com.stylefeng.guns.core.util.ToolUtil; import com.stylefeng.guns.core.util.ToolUtil;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -14,18 +14,26 @@ import java.util.Map; ...@@ -14,18 +14,26 @@ import java.util.Map;
*/ */
public class LogWarpper extends BaseControllerWarpper { public class LogWarpper extends BaseControllerWarpper {
public LogWarpper(List<Map<String, Object>> list) { public LogWarpper(Object list) {
super(list); super(list);
} }
@Override @Override
public void warpTheMap(Map<String, Object> map) { public void warpTheMap(Map<String, Object> map) {
String message = (String) map.get("message"); String message = (String) map.get("message");
//如果信息过长,则只截取前100位字符串
if (ToolUtil.isNotEmpty(message) && message.length() >= 100) { if (ToolUtil.isNotEmpty(message) && message.length() >= 100) {
message = message.substring(0, 100) + "..."; String subMessage = message.substring(0, 100) + "...";
map.put("message", message); map.put("message", subMessage);
} else { }
return;
//如果信息中包含分割符号;;; 则分割字符串返给前台
if (message.indexOf(Contrast.separator) != -1) {
String[] msgs = message.split(Contrast.separator);
map.put("regularMessage",msgs);
}else{
map.put("regularMessage",message);
} }
} }
......
...@@ -23,12 +23,23 @@ var Feng = { ...@@ -23,12 +23,23 @@ var Feng = {
Feng.alert(info, 2); Feng.alert(info, 2);
}, },
infoDetail: function (title, info) { infoDetail: function (title, info) {
var display = "";
if (typeof info == "string") {
display = info;
} else {
if (info instanceof Array) {
for (var i = 0; i < info.length; i++) {
display = display + info[i] + "<br/>";
}
}
}
var index = parent.layer.open({ var index = parent.layer.open({
title: title, title: title,
type: 1, type: 1,
skin: 'layui-layer-rim', //加上边框 skin: 'layui-layer-rim', //加上边框
area: ['950px', '600px'], //宽高 area: ['950px', '600px'], //宽高
content: '<div style="padding: 20px;">' + info + '</div>' content: '<div style="padding: 20px;">' + display + '</div>'
}); });
}, },
writeObj: function (obj) { writeObj: function (obj) {
......
...@@ -51,7 +51,7 @@ OptLog.check = function () { ...@@ -51,7 +51,7 @@ OptLog.check = function () {
OptLog.detail = function () { OptLog.detail = function () {
if (this.check()) { if (this.check()) {
var ajax = new $ax(Feng.ctxPath + "/log/detail/" + this.seItem.id, function (data) { var ajax = new $ax(Feng.ctxPath + "/log/detail/" + this.seItem.id, function (data) {
Feng.infoDetail("日志详情", data.message); Feng.infoDetail("日志详情", data.regularMessage);
}, function (data) { }, function (data) {
Feng.error("获取详情失败!"); Feng.error("获取详情失败!");
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment