Browse Source

Merge branch 'dev' of chenweida/jw2.0 into dev

chenweida 7 years ago
parent
commit
e4cd3d7570

+ 12 - 0
app/app-iot-server/src/main/java/com/yihu/ehr/iot/AppIotServer.java

@ -1,11 +1,23 @@
package com.yihu.ehr.iot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.ManagementWebSecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
@SpringBootApplication
@EnableAutoConfiguration(exclude = {
        SecurityAutoConfiguration.class,
        ManagementWebSecurityAutoConfiguration.class,
        DataSourceAutoConfiguration.class,
        HibernateJpaAutoConfiguration.class,
        DataSourceTransactionManagerAutoConfiguration.class})
public class AppIotServer extends SpringBootServletInitializer {
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {

+ 4 - 1
app/app-iot-server/src/main/java/com/yihu/ehr/iot/interceptor/LoginInterceptor.java

@ -1,5 +1,6 @@
package com.yihu.ehr.iot.interceptor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
@ -9,6 +10,8 @@ import javax.servlet.http.HttpServletResponse;
@Component
public class LoginInterceptor extends HandlerInterceptorAdapter {
    @Value("${server.contextPath}")
    protected String contextPath;
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        if(request.getRequestURL().indexOf("/ambulance/search")!=-1){
@ -16,7 +19,7 @@ public class LoginInterceptor extends HandlerInterceptorAdapter {
        }
        Boolean isLogin = (Boolean) request.getSession().getAttribute("isLogin");
        if (isLogin == null || !isLogin) {
            response.sendRedirect("/iot/login");
            response.sendRedirect(contextPath+"/login");
            response.setStatus(-200);
            return false;
        }