修正单点登录成功后,如果没有回跳地址,默认跳转到upms首页,而不是/

This commit is contained in:
shuzheng 2017-10-29 22:13:10 +08:00
parent 387a08fc85
commit 8a6d8bb534
15 changed files with 118 additions and 114 deletions

View File

@ -15,36 +15,36 @@ public class ApiServiceImpl implements ApiService {
private static Logger _log = LoggerFactory.getLogger(ApiServiceImpl.class); private static Logger _log = LoggerFactory.getLogger(ApiServiceImpl.class);
@Autowired // @Autowired
private UpmsSystemService upmsSystemService; // private UpmsSystemService upmsSystemService;
//
@Autowired // @Autowired
private UpmsOrganizationService upmsOrganizationService; // private UpmsOrganizationService upmsOrganizationService;
//
@Autowired // @Autowired
private UpmsUserService upmsUserService; // private UpmsUserService upmsUserService;
//
@Autowired // @Autowired
private UpmsRoleService upmsRoleService; // private UpmsRoleService upmsRoleService;
//
@Autowired // @Autowired
private UpmsPermissionService upmsPermissionService; // private UpmsPermissionService upmsPermissionService;
//
@Autowired // @Autowired
private UpmsApiService upmsApiService; // private UpmsApiService upmsApiService;
//
@Autowired // @Autowired
private CmsArticleService cmsArticleService; // private CmsArticleService cmsArticleService;
//
@Autowired // @Autowired
private CmsCategoryService cmsCategoryService; // private CmsCategoryService cmsCategoryService;
//
@Autowired // @Autowired
private CmsCommentService cmsCommentService; // private CmsCommentService cmsCommentService;
//
@Autowired // @Autowired
private CmsTagService cmsTagService; // private CmsTagService cmsTagService;
//
@Override @Override
public String hello(String name) { public String hello(String name) {
return "hello," + name + "!"; return "hello," + name + "!";

View File

@ -12,26 +12,26 @@
<!-- 订阅服务 --> <!-- 订阅服务 -->
<dubbo:consumer check="false"/> <dubbo:consumer check="false"/>
<!-- 系统 --> <!--&lt;!&ndash; 系统 &ndash;&gt;-->
<dubbo:reference id="upmsSystemService" interface="com.zheng.upms.rpc.api.UpmsSystemService" mock="true"/> <!--<dubbo:reference id="upmsSystemService" interface="com.zheng.upms.rpc.api.UpmsSystemService" mock="true"/>-->
<!-- 组织 --> <!--&lt;!&ndash; 组织 &ndash;&gt;-->
<dubbo:reference id="upmsOrganizationService" interface="com.zheng.upms.rpc.api.UpmsOrganizationService" mock="true"/> <!--<dubbo:reference id="upmsOrganizationService" interface="com.zheng.upms.rpc.api.UpmsOrganizationService" mock="true"/>-->
<!-- 用户 --> <!--&lt;!&ndash; 用户 &ndash;&gt;-->
<dubbo:reference id="upmsUserService" interface="com.zheng.upms.rpc.api.UpmsUserService" mock="true"/> <!--<dubbo:reference id="upmsUserService" interface="com.zheng.upms.rpc.api.UpmsUserService" mock="true"/>-->
<!-- 角色 --> <!--&lt;!&ndash; 角色 &ndash;&gt;-->
<dubbo:reference id="upmsRoleService" interface="com.zheng.upms.rpc.api.UpmsRoleService" mock="true"/> <!--<dubbo:reference id="upmsRoleService" interface="com.zheng.upms.rpc.api.UpmsRoleService" mock="true"/>-->
<!-- 权限 --> <!--&lt;!&ndash; 权限 &ndash;&gt;-->
<dubbo:reference id="upmsPermissionService" interface="com.zheng.upms.rpc.api.UpmsPermissionService" mock="true"/> <!--<dubbo:reference id="upmsPermissionService" interface="com.zheng.upms.rpc.api.UpmsPermissionService" mock="true"/>-->
<!-- 接口服务 --> <!--&lt;!&ndash; 接口服务 &ndash;&gt;-->
<dubbo:reference id="upmsApiService" interface="com.zheng.upms.rpc.api.UpmsApiService" mock="true"/> <!--<dubbo:reference id="upmsApiService" interface="com.zheng.upms.rpc.api.UpmsApiService" mock="true"/>-->
<!-- 文章 --> <!--&lt;!&ndash; 文章 &ndash;&gt;-->
<dubbo:reference id="cmsArticleService" interface="com.zheng.cms.rpc.api.CmsArticleService" mock="true"/> <!--<dubbo:reference id="cmsArticleService" interface="com.zheng.cms.rpc.api.CmsArticleService" mock="true"/>-->
<!-- 类目 --> <!--&lt;!&ndash; 类目 &ndash;&gt;-->
<dubbo:reference id="cmsCategoryService" interface="com.zheng.cms.rpc.api.CmsCategoryService" mock="true"/> <!--<dubbo:reference id="cmsCategoryService" interface="com.zheng.cms.rpc.api.CmsCategoryService" mock="true"/>-->
<!-- 评论 --> <!--&lt;!&ndash; 评论 &ndash;&gt;-->
<dubbo:reference id="cmsCommentService" interface="com.zheng.cms.rpc.api.CmsCommentService" mock="true"/> <!--<dubbo:reference id="cmsCommentService" interface="com.zheng.cms.rpc.api.CmsCommentService" mock="true"/>-->
<!-- 标签 --> <!--&lt;!&ndash; 标签 &ndash;&gt;-->
<dubbo:reference id="cmsTagService" interface="com.zheng.cms.rpc.api.CmsTagService" mock="true"/> <!--<dubbo:reference id="cmsTagService" interface="com.zheng.cms.rpc.api.CmsTagService" mock="true"/>-->
</beans> </beans>

View File

@ -13,10 +13,10 @@
<dubbo:protocol name="dubbo" port="20880"/> <dubbo:protocol name="dubbo" port="20880"/>
<dubbo:monitor protocol="registry"/> <!--<dubbo:monitor protocol="registry"/>-->
<!-- API总系统 --> <!-- API总系统 -->
<bean id="apiService" class="com.zheng.api.rpc.service.impl.ApiServiceImpl"/> <!--<bean id="apiService" class="com.zheng.api.rpc.service.impl.ApiServiceImpl"/>-->
<dubbo:service interface="com.zheng.api.rpc.api.ApiService" ref="apiService" timeout="10000"/> <!--<dubbo:service interface="com.zheng.api.rpc.api.ApiService" ref="apiService" timeout="10000"/>-->
</beans> </beans>

View File

@ -13,7 +13,7 @@
<dubbo:protocol name="dubbo" port="20882"/> <dubbo:protocol name="dubbo" port="20882"/>
<dubbo:monitor protocol="registry"/> <!--<dubbo:monitor protocol="registry"/>-->
<!-- 文章 --> <!-- 文章 -->
<bean id="cmsArticleServiceImpl" class="com.zheng.cms.rpc.service.impl.CmsArticleServiceImpl"/> <bean id="cmsArticleServiceImpl" class="com.zheng.cms.rpc.service.impl.CmsArticleServiceImpl"/>

View File

@ -13,7 +13,7 @@
<dubbo:protocol name="dubbo" port="20883"/> <dubbo:protocol name="dubbo" port="20883"/>
<dubbo:monitor protocol="registry"/> <!--<dubbo:monitor protocol="registry"/>-->
<!-- 支付方式服务 --> <!-- 支付方式服务 -->
<bean id="payVendorService" class="com.zheng.pay.rpc.service.impl.PayVendorServiceImpl"/> <bean id="payVendorService" class="com.zheng.pay.rpc.service.impl.PayVendorServiceImpl"/>

View File

@ -13,7 +13,7 @@
<dubbo:protocol name="dubbo" port="20884"/> <dubbo:protocol name="dubbo" port="20884"/>
<dubbo:monitor protocol="registry"/> <!--<dubbo:monitor protocol="registry"/>-->
<!-- 认证方式 --> <!-- 认证方式 -->
<bean id="ucenterOauthService" class="com.zheng.ucenter.rpc.service.impl.UcenterOauthServiceImpl"/> <bean id="ucenterOauthService" class="com.zheng.ucenter.rpc.service.impl.UcenterOauthServiceImpl"/>

View File

@ -10,4 +10,11 @@ import com.zheng.upms.dao.model.UpmsSystemExample;
*/ */
public interface UpmsSystemService extends BaseService<UpmsSystem, UpmsSystemExample> { public interface UpmsSystemService extends BaseService<UpmsSystem, UpmsSystemExample> {
/**
* 根据name获取UpmsSystem
* @param name
* @return
*/
UpmsSystem selectUpmsSystemByName(String name);
} }

View File

@ -11,4 +11,9 @@ import com.zheng.upms.dao.model.UpmsSystemExample;
*/ */
public class UpmsSystemServiceMock extends BaseServiceMock<UpmsSystemMapper, UpmsSystem, UpmsSystemExample> implements UpmsSystemService { public class UpmsSystemServiceMock extends BaseServiceMock<UpmsSystemMapper, UpmsSystem, UpmsSystemExample> implements UpmsSystemService {
@Override
public UpmsSystem selectUpmsSystemByName(String name) {
return null;
}
} }

View File

@ -12,6 +12,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/** /**
* UpmsSystemService实现 * UpmsSystemService实现
* Created by shuzheng on 2017/3/20. * Created by shuzheng on 2017/3/20.
@ -26,4 +28,16 @@ public class UpmsSystemServiceImpl extends BaseServiceImpl<UpmsSystemMapper, Upm
@Autowired @Autowired
UpmsSystemMapper upmsSystemMapper; UpmsSystemMapper upmsSystemMapper;
@Override
public UpmsSystem selectUpmsSystemByName(String name) {
UpmsSystemExample upmsSystemExample = new UpmsSystemExample();
upmsSystemExample.createCriteria()
.andNameEqualTo(name);
List<UpmsSystem> upmsSystems = upmsSystemMapper.selectByExample(upmsSystemExample);
if (null != upmsSystems && upmsSystems.size() > 0) {
return upmsSystems.get(0);
}
return null;
}
} }

View File

@ -13,7 +13,7 @@
<dubbo:protocol name="dubbo" port="20881"/> <dubbo:protocol name="dubbo" port="20881"/>
<dubbo:monitor protocol="registry"/> <!--<dubbo:monitor protocol="registry"/>-->
<!-- 系统 --> <!-- 系统 -->
<bean id="upmsSystemService" class="com.zheng.upms.rpc.service.impl.UpmsSystemServiceImpl"/> <bean id="upmsSystemService" class="com.zheng.upms.rpc.service.impl.UpmsSystemServiceImpl"/>

View File

@ -33,8 +33,8 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.servlet</groupId> <groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId> <artifactId>servlet-api</artifactId>
<version>3.1.0</version> <version>2.5</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -1,22 +0,0 @@
package com.zheng.upms.server;
import javax.servlet.DispatcherType;
import javax.servlet.annotation.WebFilter;
import javax.servlet.annotation.WebInitParam;
/**
* 强制进行转码过滤器
* Created by shuzheng on 2017/6/24.
*/
@WebFilter(
filterName = "CharacterEncodingFilter",
urlPatterns = "/*",
dispatcherTypes = {DispatcherType.REQUEST, DispatcherType.FORWARD},
initParams = {
@WebInitParam(name = "encoding", value = "UTF-8")
}
)
public class CharacterEncodingFilter extends org.springframework.web.filter.CharacterEncodingFilter {
}

View File

@ -1,20 +0,0 @@
package com.zheng.upms.server;
import javax.servlet.annotation.WebFilter;
import javax.servlet.annotation.WebInitParam;
/**
* shiroFilter
* Created by shuzheng on 2017/6/24.
*/
@WebFilter(
filterName = "shiroFilter",
urlPatterns = "/*",
initParams = {
@WebInitParam(name = "targetFilterLifecycle", value = "true")
}
)
public class ShiroFilter extends org.springframework.web.filter.DelegatingFilterProxy {
}

View File

@ -1,11 +1,13 @@
package com.zheng.upms.server.controller; package com.zheng.upms.server.controller;
import com.zheng.common.base.BaseController; import com.zheng.common.base.BaseController;
import com.zheng.common.util.PropertiesFileUtil;
import com.zheng.common.util.RedisUtil; import com.zheng.common.util.RedisUtil;
import com.zheng.upms.client.shiro.session.UpmsSession; import com.zheng.upms.client.shiro.session.UpmsSession;
import com.zheng.upms.client.shiro.session.UpmsSessionDao; import com.zheng.upms.client.shiro.session.UpmsSessionDao;
import com.zheng.upms.common.constant.UpmsResult; import com.zheng.upms.common.constant.UpmsResult;
import com.zheng.upms.common.constant.UpmsResultConstant; import com.zheng.upms.common.constant.UpmsResultConstant;
import com.zheng.upms.dao.model.UpmsSystem;
import com.zheng.upms.dao.model.UpmsSystemExample; import com.zheng.upms.dao.model.UpmsSystemExample;
import com.zheng.upms.rpc.api.UpmsSystemService; import com.zheng.upms.rpc.api.UpmsSystemService;
import com.zheng.upms.rpc.api.UpmsUserService; import com.zheng.upms.rpc.api.UpmsUserService;
@ -157,7 +159,9 @@ public class SSOController extends BaseController {
// 回跳登录前地址 // 回跳登录前地址
String backurl = request.getParameter("backurl"); String backurl = request.getParameter("backurl");
if (StringUtils.isBlank(backurl)) { if (StringUtils.isBlank(backurl)) {
return new UpmsResult(UpmsResultConstant.SUCCESS, "/"); UpmsSystem upmsSystem = upmsSystemService.selectUpmsSystemByName(PropertiesFileUtil.getInstance().get("app.name"));
backurl = null == upmsSystem ? "/" : upmsSystem.getBasepath();
return new UpmsResult(UpmsResultConstant.SUCCESS, backurl);
} else { } else {
return new UpmsResult(UpmsResultConstant.SUCCESS, backurl); return new UpmsResult(UpmsResultConstant.SUCCESS, backurl);
} }

View File

@ -4,6 +4,22 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5"> version="2.5">
<!-- 强制进行转码 -->
<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<!-- 默认的spring配置文件是在WEB-INF下的applicationContext.xml --> <!-- 默认的spring配置文件是在WEB-INF下的applicationContext.xml -->
<listener> <listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
@ -37,18 +53,18 @@
</servlet-mapping> </servlet-mapping>
<!-- shiroFilter : DelegatingFilterProxy作用是自动到spring容器查找名字为shiroFilterfilter-name的bean并把所有Filter的操作委托给它。然后将shiroFilter配置到spring容器即可 --> <!-- shiroFilter : DelegatingFilterProxy作用是自动到spring容器查找名字为shiroFilterfilter-name的bean并把所有Filter的操作委托给它。然后将shiroFilter配置到spring容器即可 -->
<!--<filter>--> <filter>
<!--<filter-name>shiroFilter</filter-name>--> <filter-name>shiroFilter</filter-name>
<!--<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>--> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<!--<init-param>--> <init-param>
<!--<param-name>targetFilterLifecycle</param-name>--> <param-name>targetFilterLifecycle</param-name>
<!--<param-value>true</param-value>--> <param-value>true</param-value>
<!--</init-param>--> </init-param>
<!--</filter>--> </filter>
<!--<filter-mapping>--> <filter-mapping>
<!--<filter-name>shiroFilter</filter-name>--> <filter-name>shiroFilter</filter-name>
<!--<url-pattern>/*</url-pattern>--> <url-pattern>/*</url-pattern>
<!--</filter-mapping>--> </filter-mapping>
<!-- session配置 --> <!-- session配置 -->
<session-config> <session-config>