Commit 42e4ee18 authored by Quxl's avatar Quxl

x

parent 25180b48
......@@ -8,5 +8,7 @@ import com.egolm.common.jdbc.Page;
public interface LogService {
List<Map<String, Object>> queryLogList(String type, String username, Page page);
void saveErrorLog(Throwable ex);
}
package com.egolm.film.api.service.impl;
import java.util.Date;
import java.util.List;
import java.util.Map;
......@@ -10,6 +11,7 @@ import com.egolm.common.StringUtil;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page;
import com.egolm.film.api.service.LogService;
import com.egolm.film.bean.Fc_error;
import com.egolm.film.util.SqlWhere;
@Service
......@@ -26,4 +28,18 @@ public class LogServiceImpl implements LogService {
return jdbcTemplate.limit(sql, page, where.getObjectArray());
}
@Override
public void saveErrorLog(Throwable ex) {
StringBuffer stack = new StringBuffer();
stack.append(ex.getMessage()).append("\n");
StackTraceElement[] elms = ex.getStackTrace();
for(StackTraceElement elm : elms) {
stack.append(elm.getClassName() + "." + elm.getMethodName() + "(" + elm.getFileName() + " " + elm.getLineNumber() + ")").append("\n");
}
Fc_error error = new Fc_error();
error.setError(stack.toString());
error.setCreate_time(new Date());
jdbcTemplate.save(error);
}
}
......@@ -29,7 +29,7 @@ public class Fc_review implements java.io.Serializable {
@Column(columnDefinition="int(11) COMMENT '评委分配状态 0未分配评委 1已分配评委评选中'")
private Integer allot_state;
@Column(columnDefinition="int(11) COMMENT '审片结论 1通过 2否决 3参赛 4参赛备选 5参展'")
@Column(columnDefinition="int(11) COMMENT '审片结论 0未评选 1通过 2否决 3参赛 4参赛备选 5参展'")
private Integer review_state;
@Column(columnDefinition="int(11) COMMENT '评选状态 0未评选 1有争议 2管理员分配 3审片完成'")
......
......@@ -4,21 +4,27 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.json.MappingJackson2JsonView;
import com.egolm.common.bean.Rjx;
import com.egolm.film.api.service.LogService;
@Component
public class ExceptionHandler implements HandlerExceptionResolver {
private static final Logger logger = Logger.getLogger(ExceptionHandler.class);
@Autowired
LogService logService;
@Override
public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
boolean displayInLog = true;
logService.saveErrorLog(ex);
ModelAndView mav = new ModelAndView(new MappingJackson2JsonView());
try {
response.setContentType("application/json");
......@@ -30,7 +36,7 @@ public class ExceptionHandler implements HandlerExceptionResolver {
logger.debug(ex.getMessage());
}
} else {
mav.addAllObjects(Rjx.jsonErr().setMessage("未处理异常[" + ex.getClass().getName() + ":" + ex.getMessage() + "]"));
mav.addAllObjects(Rjx.jsonErr().setMessage("未处理异常"));
}
} catch (Exception e) {
mav.addAllObjects(Rjx.jsonErr().setMessage("异常处理失败"));
......
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