Skip to content

Commit

Permalink
修正单点登录成功后,如果没有回跳地址,默认跳转到upms首页,而不是/
Browse files Browse the repository at this point in the history
  • Loading branch information
shuzheng committed Oct 29, 2017
1 parent 387a08f commit 8a6d8bb
Show file tree
Hide file tree
Showing 15 changed files with 118 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 + "!";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,11 @@
*/
public interface UpmsSystemService extends BaseService<UpmsSystem, UpmsSystemExample> {

/**
* 根据name获取UpmsSystem
* @param name
* @return
*/
UpmsSystem selectUpmsSystemByName(String name);

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@
*/
public class UpmsSystemServiceMock extends BaseServiceMock<UpmsSystemMapper, UpmsSystem, UpmsSystemExample> implements UpmsSystemService {

@Override
public UpmsSystem selectUpmsSystemByName(String name) {
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
* UpmsSystemService实现
* Created by shuzheng on 2017/3/20.
Expand All @@ -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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
Expand Down
4 changes: 2 additions & 2 deletions zheng-upms/zheng-upms-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -157,7 +159,9 @@ public Object login(HttpServletRequest request, HttpServletResponse response, Mo
// 回跳登录前地址
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);
}
Expand Down
40 changes: 28 additions & 12 deletions zheng-upms/zheng-upms-server/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -37,18 +53,18 @@
</servlet-mapping>

<!-- shiroFilter : DelegatingFilterProxy作用是自动到spring容器查找名字为shiroFilter(filter-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>
Expand Down

0 comments on commit 8a6d8bb

Please sign in to comment.