Commit 50ea25d4 by guojuxing

运维后台淡点登录到gic后台sdk

parent 0638cd2a
...@@ -159,6 +159,11 @@ ...@@ -159,6 +159,11 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.gic</groupId> <groupId>com.gic</groupId>
<artifactId>gic-enterprise-sso</artifactId>
<version>${gic-enterprise-sso}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-platform-finance-api</artifactId> <artifactId>gic-platform-finance-api</artifactId>
<version>${gic-platform-finance-api}</version> <version>${gic-platform-finance-api}</version>
</dependency> </dependency>
......
...@@ -27,7 +27,8 @@ import com.gic.dubbo.util.DubboContextUtil; ...@@ -27,7 +27,8 @@ import com.gic.dubbo.util.DubboContextUtil;
"classpath*:dubbo-setting.xml", "classpath*:dubbo-setting.xml",
"classpath*:dubbo-gic-platform-operation-web.xml", "classpath*:dubbo-gic-platform-operation-web.xml",
"classpath*:spring-interceptor.xml", "classpath*:spring-interceptor.xml",
"classpath*:redis-init.xml" "classpath*:redis-init.xml",
"classpath*:dubbo-gic-enterprise-sso-service.xml"
}) })
@EnableApolloConfig({ "application", "BUZ.oauth.4.0" }) @EnableApolloConfig({ "application", "BUZ.oauth.4.0" })
@EnableGicOAuth2Sso @EnableGicOAuth2Sso
......
...@@ -7,6 +7,7 @@ import java.util.stream.Collectors; ...@@ -7,6 +7,7 @@ import java.util.stream.Collectors;
import com.ctrip.framework.apollo.Config; import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.ConfigService; import com.ctrip.framework.apollo.ConfigService;
import com.gic.redis.data.util.RedisUtil; import com.gic.redis.data.util.RedisUtil;
import com.gic.sso.utils.LoginGicSsoUtils;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
...@@ -60,7 +61,6 @@ public class LoginController { ...@@ -60,7 +61,6 @@ public class LoginController {
private static final String MENU_LOCAL_CACHE_KEY = "auth:menu:list:all"; private static final String MENU_LOCAL_CACHE_KEY = "auth:menu:list:all";
/** /**
* 商户绑定服务市场 * 商户绑定服务市场
* @Title: bind
 * @Title: bind

...@@ -102,79 +102,7 @@ public class LoginController { ...@@ -102,79 +102,7 @@ public class LoginController {
@RequestMapping("login-gic") @RequestMapping("login-gic")
public RestResponse login(Integer enterpriseId, String redirectUrl) throws IOException { public RestResponse login(Integer enterpriseId, String redirectUrl) throws IOException {
long startTime = System.currentTimeMillis(); return RestResponse.success(LoginGicSsoUtils.sso(enterpriseId, redirectUrl));
String nameSpace = "COMMON.4.0-gic-properties";
Config config = ConfigService.getConfig(nameSpace);
String url = config.getProperty("service_host", "").replace("/gic", "");
if (StringUtils.isBlank(redirectUrl)) {
redirectUrl = url + "/damo-system";
// redirectUrl = "https://four.gicdev.com/cost-center/billing-center/overview";
}
String token;
UserDetailsVO userDetailsVO = UserUtils.getUser();
String phone = userDetailsVO.getUserMobile();
//运营人员国内,默认数据
ServiceResponse<UserDTO> userResult = userApiService.getUserByPhoneNumber(Constants.NATION_CODE, phone, enterpriseId);
if (userResult.isSuccess()) {
//获取运营实施信息
UserDTO user = userResult.getResult();
if (user == null) {
//新建运营实施账号
UserDTO temp = new UserDTO();
temp.setEnterpriseId(enterpriseId);
temp.setPhoneNumber(phone);
temp.setUserName(userDetailsVO.getRealName());
temp.setPhoneAreaCode(Constants.NATION_CODE);
temp.setSuperAdmin(1);
temp.setLoginType(1);
ServiceResponse<Integer> saveResult = userApiService.saveOperationUser(temp);
user = temp;
user.setUserId(saveResult.getResult());
} else {
//更新运营人名称
if (!user.getUserName().equals(userDetailsVO.getRealName())) {
userApiService.updateOperationUser(user.getUserId(), userDetailsVO.getRealName());
}
}
//gic用户信息塞入
UserDetail userDetail = new UserDetail();
//设置登录用户信息
userDetail.setUserId(user.getUserId());
userDetail.setUserInfo(EntityUtil.changeEntityNew(UserInfo.class, user));
//设置企业资料
ServiceResponse<EnterpriseDTO> enterprise = this.enterpriseApiService.getEnterpriseById(enterpriseId);
if (enterprise.isSuccess()) {
EnterpriseDTO enterpriseDTO = enterprise.getResult();
if (enterpriseDTO != null) {
userDetail.setEnterpriseInfo(EntityUtil.changeEntityNew(EnterpriseInfo.class, enterpriseDTO));
}
//设置权限
ServiceResponse<List<MenuDTO>> menuResult = menuApiService.listUserMenu(user.getUserId(),
enterpriseDTO.getVersionCode());
if (menuResult.isSuccess()) {
List<MenuDTO> menuList = menuResult.getResult();
Set<Integer> menuIdSet = new HashSet<>(2);
if (CollectionUtils.isNotEmpty(menuList)) {
menuIdSet = menuList.stream().filter(e -> StringUtils.isNotBlank(e.getMenuUrl()))
.map(e -> e.getMenuId()).collect(Collectors.toSet());
}
//塞用户权限菜单值
userDetail.setMenuIdSet(menuIdSet);
//塞本地缓存
setAllMenuToLocaleCache();
}
}
//塞缓存
token = UserDetailUtils.setUserDetail(userDetail);
LOGGER.info("单点登录所花时间:{}", System.currentTimeMillis() - startTime);
String ssoLoginUrl = url + "/gic-auth-web/login-for-operation";
return RestResponse.success(ssoLoginUrl + "?token=" + token + "&redirectUrl=" + redirectUrl);
}
return RestResponse.success();
} }
/** /**
......
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