修正单点登录成功后,如果没有回跳地址,默认跳转到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);
@Autowired
private UpmsSystemService upmsSystemService;
@Autowired
private UpmsOrganizationService upmsOrganizationService;
@Autowired
private UpmsUserService upmsUserService;
@Autowired
private UpmsRoleService upmsRoleService;
@Autowired
private UpmsPermissionService upmsPermissionService;
@Autowired
private UpmsApiService upmsApiService;
@Autowired
private CmsArticleService cmsArticleService;
@Autowired
private CmsCategoryService cmsCategoryService;
@Autowired
private CmsCommentService cmsCommentService;
@Autowired
private CmsTagService cmsTagService;
// @Autowired
// private UpmsSystemService upmsSystemService;
//
// @Autowired
// private UpmsOrganizationService upmsOrganizationService;
//
// @Autowired
// private UpmsUserService upmsUserService;
//
// @Autowired
// private UpmsRoleService upmsRoleService;
//
// @Autowired
// private UpmsPermissionService upmsPermissionService;
//
// @Autowired
// private UpmsApiService upmsApiService;
//
// @Autowired
// private CmsArticleService cmsArticleService;
//
// @Autowired
// private CmsCategoryService cmsCategoryService;
//
// @Autowired
// private CmsCommentService cmsCommentService;
//
// @Autowired
// private CmsTagService cmsTagService;
//
@Override
public String hello(String name) {
return "hello," + name + "!";

View File

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

View File

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

View File

@ -13,7 +13,7 @@
<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"/>

View File

@ -13,7 +13,7 @@
<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"/>

View File

@ -13,7 +13,7 @@
<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"/>

View File

@ -10,4 +10,11 @@ import com.zheng.upms.dao.model.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 {
@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.transaction.annotation.Transactional;
import java.util.List;
/**
* UpmsSystemService实现
* Created by shuzheng on 2017/3/20.
@ -26,4 +28,16 @@ public class UpmsSystemServiceImpl extends BaseServiceImpl<UpmsSystemMapper, Upm
@Autowired
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:monitor protocol="registry"/>
<!--<dubbo:monitor protocol="registry"/>-->
<!-- 系统 -->
<bean id="upmsSystemService" class="com.zheng.upms.rpc.service.impl.UpmsSystemServiceImpl"/>

View File

@ -33,8 +33,8 @@
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</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;
import com.zheng.common.base.BaseController;
import com.zheng.common.util.PropertiesFileUtil;
import com.zheng.common.util.RedisUtil;
import com.zheng.upms.client.shiro.session.UpmsSession;
import com.zheng.upms.client.shiro.session.UpmsSessionDao;
import com.zheng.upms.common.constant.UpmsResult;
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.rpc.api.UpmsSystemService;
import com.zheng.upms.rpc.api.UpmsUserService;
@ -157,7 +159,9 @@ public class SSOController extends BaseController {
// 回跳登录前地址
String backurl = request.getParameter("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 {
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"
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 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
@ -37,18 +53,18 @@
</servlet-mapping>
<!-- shiroFilter : DelegatingFilterProxy作用是自动到spring容器查找名字为shiroFilterfilter-name的bean并把所有Filter的操作委托给它。然后将shiroFilter配置到spring容器即可 -->
<!--<filter>-->
<!--<filter-name>shiroFilter</filter-name>-->
<!--<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>-->
<!--<init-param>-->
<!--<param-name>targetFilterLifecycle</param-name>-->
<!--<param-value>true</param-value>-->
<!--</init-param>-->
<!--</filter>-->
<!--<filter-mapping>-->
<!--<filter-name>shiroFilter</filter-name>-->
<!--<url-pattern>/*</url-pattern>-->
<!--</filter-mapping>-->
<filter>
<filter-name>shiroFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<init-param>
<param-name>targetFilterLifecycle</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>shiroFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- session配置 -->
<session-config>