Commit 4fe26238 authored by maoying's avatar maoying

修改数字换流站集成页面默认登录接口

parent 2ee7154a
...@@ -2,6 +2,7 @@ package com.yeejoin.amos.fas.business.controller; ...@@ -2,6 +2,7 @@ package com.yeejoin.amos.fas.business.controller;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.component.feign.config.TokenOperation;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.fas.business.feign.OutTokenLoginFeign; import com.yeejoin.amos.fas.business.feign.OutTokenLoginFeign;
import com.yeejoin.amos.fas.business.feign.PrivilegeFeign; import com.yeejoin.amos.fas.business.feign.PrivilegeFeign;
...@@ -10,6 +11,7 @@ import com.yeejoin.amos.fas.business.vo.CompanyBo; ...@@ -10,6 +11,7 @@ import com.yeejoin.amos.fas.business.vo.CompanyBo;
import com.yeejoin.amos.fas.business.vo.DepartmentBo; import com.yeejoin.amos.fas.business.vo.DepartmentBo;
import com.yeejoin.amos.fas.business.vo.ReginParams; import com.yeejoin.amos.fas.business.vo.ReginParams;
import com.yeejoin.amos.fas.business.vo.RoleBo; import com.yeejoin.amos.fas.business.vo.RoleBo;
import com.yeejoin.amos.fas.business.vo.Toke;
import com.yeejoin.amos.feign.privilege.Privilege; import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.ApplicationModel; import com.yeejoin.amos.feign.privilege.model.ApplicationModel;
...@@ -36,6 +38,7 @@ import javax.servlet.http.HttpServletRequest; ...@@ -36,6 +38,7 @@ import javax.servlet.http.HttpServletRequest;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit;
/** /**
* @author zjw * @author zjw
...@@ -76,42 +79,55 @@ public class LoginController { ...@@ -76,42 +79,55 @@ public class LoginController {
} }
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder
.getRequestAttributes()).getRequest(); .getRequestAttributes()).getRequest();
String token = (String) request.getHeader("token"); String token = ObjectUtils.isEmpty(request.getHeader("token"))?"szhlz":request.getHeader("token").toString() ;
ReginParams reginParams; ReginParams reginParams;
reginParams = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(userId, token)), ReginParams.class); reginParams = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(userId, token)), ReginParams.class);
if(reginParams == null){ if(reginParams == null){
reginParams = new ReginParams(); reginParams = getLogin(userId, token);
IdPasswordAuthModel dPasswordAuthModel = new IdPasswordAuthModel(); }else{
dPasswordAuthModel.setLoginId(userId); RequestContext.setProduct(product);
dPasswordAuthModel.setPassword(DesUtil.encode(password, "qaz")); if (!TokenOperation.refresh(reginParams.getToken())) {
RequestContext.setProduct(product); reginParams = getLogin(userId, token);
FeignClientResult feignClientResult = Privilege.authClient.idpassword(dPasswordAuthModel); }
if (ObjectUtils.isEmpty(feignClientResult.getResult())){
throw new Exception("缺失登录信息");
}
Map<String ,String > re = (Map<String, String>) feignClientResult.getResult();
String amosToken = re.get("token");
privilegeFeign.warrant(appKey, product, amosToken);
RequestContext.setToken(amosToken);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
AgencyUserModel userModel = (AgencyUserModel) Privilege.agencyUserClient.getme().getResult();
CompanyModel companyModel = userModel.getCompanys().get(0);
List<DepartmentModel> deptList = remoteSecurityService.getDepartmentTreeByCompanyId(amosToken, product, appKey, companyModel.getSequenceNbr().toString());
if(deptList.size() > 0){
CompanyBo companyBo = convertCompanyModelToBo(companyModel);
DepartmentBo departmentBo = convertDepartmentModelToBo(deptList.get(0));
reginParams.setDepartment(departmentBo);
reginParams.setCompany(companyBo);
}
reginParams.setToken(amosToken);
reginParams.setUserModel(userModel);
redisTemplate.opsForValue().set(buildKey(userId, token), JSONObject.toJSONString(reginParams));
redisTemplate.opsForValue().set(buildKey(userId, amosToken), JSONObject.toJSONString(reginParams));
} }
return reginParams; return reginParams;
} }
private ReginParams getLogin(String userId, String token) throws Exception{
ReginParams reginParams = new ReginParams();
IdPasswordAuthModel dPasswordAuthModel = new IdPasswordAuthModel();
dPasswordAuthModel.setLoginId(userId);
dPasswordAuthModel.setPassword(DesUtil.encode(password, "qaz"));
RequestContext.setProduct(product);
FeignClientResult feignClientResult = Privilege.authClient.idpassword(dPasswordAuthModel);
if (ObjectUtils.isEmpty(feignClientResult.getResult())){
throw new Exception("缺失登录信息");
}
Map<String ,String > re = (Map<String, String>) feignClientResult.getResult();
String amosToken = re.get("token");
privilegeFeign.warrant(appKey, product, amosToken);
RequestContext.setToken(amosToken);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
AgencyUserModel userModel = (AgencyUserModel) Privilege.agencyUserClient.getme().getResult();
CompanyModel companyModel = userModel.getCompanys().get(0);
List<DepartmentModel> deptList = remoteSecurityService.getDepartmentTreeByCompanyId(amosToken, product, appKey, companyModel.getSequenceNbr().toString());
if(deptList.size() > 0){
CompanyBo companyBo = convertCompanyModelToBo(companyModel);
DepartmentBo departmentBo = convertDepartmentModelToBo(deptList.get(0));
reginParams.setDepartment(departmentBo);
reginParams.setCompany(companyBo);
}
reginParams.setToken(amosToken);
reginParams.setUserModel(userModel);
redisTemplate.opsForValue().set(buildKey(userId, token), JSONObject.toJSONString(reginParams),28, TimeUnit.DAYS);
redisTemplate.opsForValue().set(buildKey(userId, amosToken), JSONObject.toJSONString(reginParams),28, TimeUnit.DAYS);
return reginParams;
}
private DepartmentBo convertDepartmentModelToBo(DepartmentModel departmentModel){ private DepartmentBo convertDepartmentModelToBo(DepartmentModel departmentModel){
DepartmentBo departmentBo = new DepartmentBo(); DepartmentBo departmentBo = new DepartmentBo();
if(departmentModel != null) { if(departmentModel != null) {
......
...@@ -34,6 +34,7 @@ import org.typroject.tyboot.core.foundation.context.RequestContext; ...@@ -34,6 +34,7 @@ import org.typroject.tyboot.core.foundation.context.RequestContext;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit;
@Aspect @Aspect
@Component @Component
...@@ -101,7 +102,7 @@ public class PermissionAspect { ...@@ -101,7 +102,7 @@ public class PermissionAspect {
if(!ObjectUtils.isEmpty(roleModels)){ if(!ObjectUtils.isEmpty(roleModels)){
regionParam.setRole(convertRoleModelToBo(roleModels.get(0))); regionParam.setRole(convertRoleModelToBo(roleModels.get(0)));
} }
redisTemplate.opsForValue().set(buildKey(userId, token), JSONObject.toJSONString(regionParam)); redisTemplate.opsForValue().set(buildKey(userId, token), JSONObject.toJSONString(regionParam),28, TimeUnit.DAYS);
} }
} }
} catch (InnerInvokException e) { } catch (InnerInvokException e) {
......
...@@ -550,14 +550,16 @@ ...@@ -550,14 +550,16 @@
alter table `f_risk_source` add column `source_id` bigint(20) DEFAULT NULL AFTER `status`; alter table `f_risk_source` add column `source_id` bigint(20) DEFAULT NULL AFTER `status`;
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="shg" id="1609226808866-2"> <changeSet author="shg" id="1609226808867-2">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<columnExists tableName="f_risk_source" columnName="source_id"/> <not>
<indexExists indexName="unique_idx_source_id" />
</not>
</preConditions> </preConditions>
<comment>f_risk_source add UNIQUE source_id</comment> <comment>f_risk_source add UNIQUE source_id</comment>
<sql> <sql>
ALTER TABLE `f_risk_source` ADD UNIQUE unique_idx_source_id(source_id); ALTER TABLE `f_risk_source` ADD UNIQUE unique_idx_source_id(source_id);
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="gaojianqiang" id="1609989898-1"> <changeSet author="gaojianqiang" id="1609989898-1">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
......
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