Commit 2045887c authored by hanfeng's avatar hanfeng

Merge remote-tracking branch 'origin/dev' into dev

parents f8f00d50 76f82596
...@@ -40,6 +40,15 @@ public class GlobalExceptionHandler extends ResponseEntityExceptionHandler { ...@@ -40,6 +40,15 @@ public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
private Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class); private Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);
@Value("${spring.application.name}") @Value("${spring.application.name}")
private String applicationName; private String applicationName;
@Value("${email.log.account}")
private String emailLogAccount;
@Value("${email.log.title}")
private String emailLogTitle;
@Value("${email.log.host}")
private String emailLogHost;
/** /**
* 在controller里面内容执行之前,校验一些参数不匹配啊,Get post方法不对啊之类的 * 在controller里面内容执行之前,校验一些参数不匹配啊,Get post方法不对啊之类的
*/ */
...@@ -77,15 +86,6 @@ public class GlobalExceptionHandler extends ResponseEntityExceptionHandler { ...@@ -77,15 +86,6 @@ public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
if(0 == ex.getStatus()) { if(0 == ex.getStatus()) {
response.setStatus(500); response.setStatus(500);
} }
Map<String, String> map = new HashMap<>();
map.put("toUser", "jiaoruizhen@126.com");
map.put("subject", "服务器异常");
map.put("content", ex.toString() + ":" +ex.getMessage());
try {
HttpUtils.doPost("http://10.5.52.3:8765","/api/universal/mail/app/unauth/send", map);
} catch (Exception e) {
logger.error(e.getMessage());
}
return new BaseResponse(ex.getStatus(), ex.getMessage()); return new BaseResponse(ex.getStatus(), ex.getMessage());
} }
...@@ -99,22 +99,22 @@ public class GlobalExceptionHandler extends ResponseEntityExceptionHandler { ...@@ -99,22 +99,22 @@ public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
cause.printStackTrace(new PrintWriter(stringWriter)); cause.printStackTrace(new PrintWriter(stringWriter));
logger.error(cause.getMessage(), ex); logger.error(cause.getMessage(), ex);
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("toUser", "jiaoruizhen@126.com"); map.put("toUser", emailLogAccount);
map.put("subject", "服务器异常"); map.put("subject", emailLogTitle);
map.put("content", initCommonLogPrePart()+ ":" +stringWriter.toString()); map.put("content", initCommonLogPrePart()+ ":" +stringWriter.toString());
try { try {
HttpUtils.doPost("http://10.5.52.3:8765","/api/universal/mail/app/unauth/send", map); HttpUtils.doPost(emailLogHost,"/api/universal/mail/app/unauth/send", map);
} catch (Exception e) { } catch (Exception e) {
logger.error(e.getMessage()); logger.error(e.getMessage());
} }
return new BaseResponse(5000, "Server exception: " + ex.getMessage()); return new BaseResponse(5000, "Server exception: " + ex.getMessage());
} }
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("toUser", "jiaoruizhen@126.com"); map.put("toUser", emailLogAccount);
map.put("subject", "服务器异常"); map.put("subject", emailLogTitle);
map.put("content", initCommonLogPrePart()+ ":" + ex.toString() + ":" + ex.getMessage()); map.put("content", initCommonLogPrePart()+ ":" + ex.toString() + ":" + ex.getMessage());
try { try {
HttpUtils.doPost("http://10.5.52.3:8765","/api/universal/mail/app/unauth/send", map); HttpUtils.doPost(emailLogHost,"/api/universal/mail/app/unauth/send", map);
} catch (Exception e) { } catch (Exception e) {
logger.error(e.getMessage()); logger.error(e.getMessage());
} }
......
...@@ -26,6 +26,15 @@ public class PlatformExceptionHandler { ...@@ -26,6 +26,15 @@ public class PlatformExceptionHandler {
@Value("${spring.application.name}") @Value("${spring.application.name}")
private String applicationName; private String applicationName;
@Value("${email.log.account}")
private String emailLogAccount;
@Value("${email.log.title}")
private String emailLogTitle;
@Value("${email.log.host}")
private String emailLogHost;
@ExceptionHandler(value = {BaseException.class}) @ExceptionHandler(value = {BaseException.class})
public BaseResponse baseExceptionHandler(Exception e) { public BaseResponse baseExceptionHandler(Exception e) {
if (e instanceof BaseException){ if (e instanceof BaseException){
...@@ -45,11 +54,11 @@ public class PlatformExceptionHandler { ...@@ -45,11 +54,11 @@ public class PlatformExceptionHandler {
cause.printStackTrace(new PrintWriter(stringWriter)); cause.printStackTrace(new PrintWriter(stringWriter));
log.error(cause.getMessage(), e); log.error(cause.getMessage(), e);
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("toUser", "jiaoruizhen@126.com"); map.put("toUser", emailLogAccount);
map.put("subject", "服务器异常"); map.put("subject", emailLogTitle);
map.put("content", initCommonLogPrePart()+ ":" +stringWriter.toString()); map.put("content", initCommonLogPrePart()+ ":" +stringWriter.toString());
try { try {
HttpUtils.doPost("http://10.5.52.3:8765","/api/universal/mail/app/unauth/send", map); HttpUtils.doPost(emailLogHost,"/api/universal/mail/app/unauth/send", map);
} catch (Exception ex) { } catch (Exception ex) {
log.error(ex.getMessage()); log.error(ex.getMessage());
} }
...@@ -57,11 +66,11 @@ public class PlatformExceptionHandler { ...@@ -57,11 +66,11 @@ public class PlatformExceptionHandler {
} }
log.error("Server exception: ", e); log.error("Server exception: ", e);
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("toUser", "jiaoruizhen@126.com"); map.put("toUser", emailLogAccount);
map.put("subject", "服务器异常"); map.put("subject", emailLogTitle);
map.put("content", initCommonLogPrePart()+ ":" + e.toString() + ":" + e.getMessage()); map.put("content", initCommonLogPrePart()+ ":" + e.toString() + ":" + e.getMessage());
try { try {
HttpUtils.doPost("http://10.5.52.3:8765","/api/universal/mail/app/unauth/send", map); HttpUtils.doPost(emailLogHost,"/api/universal/mail/app/unauth/send", map);
} catch (Exception ex) { } catch (Exception ex) {
log.error(ex.getMessage()); log.error(ex.getMessage());
} }
...@@ -83,7 +92,6 @@ public class PlatformExceptionHandler { ...@@ -83,7 +92,6 @@ public class PlatformExceptionHandler {
HttpServletRequest request = servletRequestAttributes.getRequest();//获取request HttpServletRequest request = servletRequestAttributes.getRequest();//获取request
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
//request 获得头部 //request 获得头部
stringBuilder.append(request.getHeader("app"));
LocalDateTime startTime= LocalDateTime.now();//开始时间 LocalDateTime startTime= LocalDateTime.now();//开始时间
stringBuilder.append("》》" +startTime.toString()); stringBuilder.append("》》" +startTime.toString());
stringBuilder.append("》》" +request.getServletPath()); stringBuilder.append("》》" +request.getServletPath());
...@@ -91,4 +99,5 @@ public class PlatformExceptionHandler { ...@@ -91,4 +99,5 @@ public class PlatformExceptionHandler {
return stringBuilder.toString(); return stringBuilder.toString();
} }
} }
...@@ -3,9 +3,7 @@ package com.github.wxiaoqi.security.common.log; ...@@ -3,9 +3,7 @@ package com.github.wxiaoqi.security.common.log;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.common.exception.BaseException; import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.log.CommonLogService;
import com.github.wxiaoqi.security.common.log.entity.XxLogEntity; import com.github.wxiaoqi.security.common.log.entity.XxLogEntity;
import com.github.wxiaoqi.security.common.msg.BaseResponse;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
...@@ -16,7 +14,6 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -16,7 +14,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -36,7 +33,7 @@ public class XxLogInterceptor{ ...@@ -36,7 +33,7 @@ public class XxLogInterceptor{
CommonLogService commonLogService; CommonLogService commonLogService;
//触发条件为:com.xxfc.platform包下面所有controller //触发条件为:com.xxfc.platform包下面所有controller
@Around("within(com.xxfc.platform.*.rest..* || com.xxfc.platform.*.controller..*)") @Around("within(com.xxfc.platform.*.rest..* || com.xxfc.platform.*.controller..* || com.github.wxiaoqi.security.admin.rest..* || com.github.wxiaoqi.security.admin.rest..*)")
public Object doAroundXxControllerLog(ProceedingJoinPoint pjp) throws Throwable { public Object doAroundXxControllerLog(ProceedingJoinPoint pjp) throws Throwable {
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = servletRequestAttributes.getRequest();//获取request HttpServletRequest request = servletRequestAttributes.getRequest();//获取request
...@@ -60,6 +57,7 @@ public class XxLogInterceptor{ ...@@ -60,6 +57,7 @@ public class XxLogInterceptor{
try{ try{
//###################上面代码为方法执行前##################### //###################上面代码为方法执行前#####################
result = pjp.proceed();//执行方法,获取返回参数 result = pjp.proceed();//执行方法,获取返回参数
log.info("接口调用返回:{}", xxLogEntity.toString());
//###################下面代码为方法执行后##################### //###################下面代码为方法执行后#####################
if(result instanceof JSONObject) { if(result instanceof JSONObject) {
commonLogService.initCommonLogLastPart(xxLogEntity, ((JSONObject) result).toJSONString()); commonLogService.initCommonLogLastPart(xxLogEntity, ((JSONObject) result).toJSONString());
......
...@@ -23,7 +23,10 @@ import tk.mybatis.spring.annotation.MapperScan; ...@@ -23,7 +23,10 @@ import tk.mybatis.spring.annotation.MapperScan;
*/ */
@EnableDiscoveryClient @EnableDiscoveryClient
@EnableCircuitBreaker @EnableCircuitBreaker
@SpringBootApplication @SpringBootApplication(scanBasePackages = {
"com.github.wxiaoqi.security.common.log",
"com.github.wxiaoqi.security.admin"
})
@EnableFeignClients(value = {"com.github.wxiaoqi.security","com.xxfc.platform"},defaultConfiguration = HeaderConfig.class) @EnableFeignClients(value = {"com.github.wxiaoqi.security","com.xxfc.platform"},defaultConfiguration = HeaderConfig.class)
@EnableScheduling @EnableScheduling
@EnableAceAuthClient @EnableAceAuthClient
......
...@@ -534,7 +534,7 @@ ...@@ -534,7 +534,7 @@
and book_end_date &gt;= now() and book_end_date &gt;= now()
</if> </if>
<!--增加时间限制,已审核的未出车小于当前时间的不显示, 已出车的结束时间延后两天小于当前时间的不显示--> <!--增加时间限制,已审核的未出车小于当前时间的不显示, 已出车的结束时间延后两天小于当前时间的不显示-->
<if test="flag == true and status == 2"> <if test="flag == true and (status == 3 or status == 5 or status == 2)">
and ( (v4.id IS NOT NULL and DATE_ADD(v1.book_end_date,INTERVAL '2' DAY) >= now()) OR (v4.id IS NULL AND v1.book_end_date &gt;= now())) and ( (v4.id IS NOT NULL and DATE_ADD(v1.book_end_date,INTERVAL '2' DAY) >= now()) OR (v4.id IS NULL AND v1.book_end_date &gt;= now()))
</if> </if>
<if test="flag == true"> <if test="flag == true">
......
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