bug fix
This commit is contained in:
parent
69f500f6d0
commit
c21fdefb60
|
|
@ -1,81 +1,89 @@
|
||||||
package com.smallchill.core.beetl;
|
package com.smallchill.core.beetl;
|
||||||
|
|
||||||
import org.beetl.sql.core.InterceptorContext;
|
import org.beetl.sql.core.InterceptorContext;
|
||||||
import org.beetl.sql.ext.DebugInterceptor;
|
import org.beetl.sql.ext.DebugInterceptor;
|
||||||
|
|
||||||
import com.smallchill.core.constant.Cst;
|
import com.smallchill.core.constant.Cst;
|
||||||
import com.smallchill.core.toolbox.kit.DateKit;
|
import com.smallchill.core.toolbox.kit.DateKit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重写beetlsql输出的sql语句格式
|
* 重写beetlsql输出的sql语句格式
|
||||||
*/
|
*/
|
||||||
public class ReportInterceptor extends DebugInterceptor {
|
public class ReportInterceptor extends DebugInterceptor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void before(InterceptorContext ctx) {
|
public void before(InterceptorContext ctx) {
|
||||||
if (!Cst.me().isDevMode()) {
|
if (!Cst.me().isDevMode()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String sqlId = ctx.getSqlId();
|
String sqlId = ctx.getSqlId();
|
||||||
if (this.isDebugEanble(sqlId)) {
|
if (this.isDebugEanble(sqlId)) {
|
||||||
ctx.put("debug.time", System.currentTimeMillis());
|
ctx.put("debug.time", System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("\nBlade beetlsql --------------------- " + DateKit.getTime() + " --------------------------------\n")
|
sb.append("\nBlade beetlsql --------------------- " + DateKit.getTime() + " --------------------------------\n")
|
||||||
.append("索引: " + ctx.getSqlId().replaceAll("\\s+", " ")).append("\n")
|
.append("索引: " + ctx.getSqlId().replaceAll("\\s+", " ")).append("\n")
|
||||||
.append("语句: " + ctx.getSql().replaceAll("\\s+", " ")).append("\n")
|
.append("语句: " + ctx.getSql().replaceAll("\\s+", " ")).append("\n")
|
||||||
.append("参数: " + formatParas(ctx.getParas()))
|
.append("参数: " + formatParas(ctx.getParas()))
|
||||||
.append("\n");
|
.append("\n");
|
||||||
|
|
||||||
RuntimeException ex = new RuntimeException();
|
RuntimeException ex = new RuntimeException();
|
||||||
StackTraceElement[] traces = ex.getStackTrace();
|
StackTraceElement[] traces = ex.getStackTrace();
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (StackTraceElement tr : traces) {
|
for (StackTraceElement tr : traces) {
|
||||||
if (!found && tr.getClassName().indexOf("SQLManager") != -1) {
|
if (!found && tr.getClassName().indexOf("SQLManager") != -1) {
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
if (found && !tr.getClassName().startsWith("org.beetl.sql.core") && !tr.getClassName().startsWith("com.sun")) {
|
if (found && !tr.getClassName().startsWith("org.beetl.sql.core") && !tr.getClassName().startsWith("com.sun")) {
|
||||||
String className = tr.getClassName();
|
String className = tr.getClassName();
|
||||||
String mehodName = tr.getMethodName();
|
String mehodName = tr.getMethodName();
|
||||||
int line = tr.getLineNumber();
|
int line = tr.getLineNumber();
|
||||||
sb.append("位置: " + className + "." + mehodName + "(" + tr.getFileName() + ":" + line + ")").append("\n");
|
sb.append("位置: " + className + "." + mehodName + "(" + tr.getFileName() + ":" + line + ")").append("\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ctx.put("debug.sb", sb);
|
ctx.put("debug.sb", sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void after(InterceptorContext ctx) {
|
public void after(InterceptorContext ctx) {
|
||||||
if (!Cst.me().isDevMode()) {
|
if (!Cst.me().isDevMode()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
long start = (Long) ctx.get("debug.time");
|
long start = (Long) ctx.get("debug.time");
|
||||||
|
|
||||||
StringBuilder sb = (StringBuilder) ctx.get("debug.sb");
|
StringBuilder sb = (StringBuilder) ctx.get("debug.sb");
|
||||||
sb.append("时间: " + (time - start) + "ms").append("\n");
|
sb.append("时间: " + (time - start) + "ms").append("\n");
|
||||||
|
|
||||||
if (ctx.isUpdate()) {
|
if (ctx.isUpdate()) {
|
||||||
sb.append("更新: [");
|
sb.append("更新: [");
|
||||||
if (ctx.getResult().getClass().isArray()) {
|
if (ctx.getResult().getClass().isArray()) {
|
||||||
int[] ret = (int[]) ctx.getResult();
|
int[] ret = (int[]) ctx.getResult();
|
||||||
for (int i = 0; i < ret.length; i++) {
|
for (int i = 0; i < ret.length; i++) {
|
||||||
sb.append(ret[i]);
|
sb.append(ret[i]);
|
||||||
if (i != ret.length - 1) {
|
if (i != ret.length - 1) {
|
||||||
sb.append(",");
|
sb.append(",");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sb.append(ctx.getResult());
|
sb.append(ctx.getResult());
|
||||||
}
|
}
|
||||||
sb.append("]");
|
sb.append("]");
|
||||||
} else {
|
} else {
|
||||||
sb.append("返回: ").append(ctx.getResult()).append("");
|
sb.append("返回: ").append(ctx.getResult()).append("");
|
||||||
}
|
}
|
||||||
sb.append("\n").append("-----------------------------------------------------------------------------------------");
|
sb.append("\n").append("-----------------------------------------------------------------------------------------");
|
||||||
println(sb.toString());
|
println(sb.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public void exception(InterceptorContext ctx, Exception ex) {
|
||||||
|
StringBuilder sb =(StringBuilder) ctx.get("debug.sb");
|
||||||
|
sb.append("错误: ").append(ex!=null?ex.getMessage():"");
|
||||||
|
sb.append("\n").append("-----------------------------------------------------------------------------------------");
|
||||||
|
println(sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ public class UploadifyController extends BladeController {
|
||||||
|
|
||||||
@Json
|
@Json
|
||||||
@RequestMapping("/upload")
|
@RequestMapping("/upload")
|
||||||
public CMap upload(@RequestParam("imgFile") MultipartFile file) {
|
public CMap upload(@RequestParam("Filedata") MultipartFile file) {
|
||||||
CMap cmap = CMap.init();
|
CMap cmap = CMap.init();
|
||||||
if (null == file) {
|
if (null == file) {
|
||||||
cmap.set("error", 1);
|
cmap.set("error", 1);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user