Commit b6816a0d authored by KeYong's avatar KeYong

修改前端集成接口

parent ce363564
...@@ -23,8 +23,11 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -23,8 +23,11 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
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;
...@@ -66,8 +69,11 @@ public class LoginController { ...@@ -66,8 +69,11 @@ public class LoginController {
if (ObjectUtils.isEmpty(userId)){ if (ObjectUtils.isEmpty(userId)){
throw new Exception("用户信息不存在"); throw new Exception("用户信息不存在");
} }
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder
.getRequestAttributes()).getRequest();
String token = (String) request.getHeader("token");
ReginParams reginParams; ReginParams reginParams;
reginParams = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(userId)), ReginParams.class); reginParams = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(userId, token)), ReginParams.class);
if(reginParams == null){ if(reginParams == null){
reginParams = new ReginParams(); reginParams = new ReginParams();
Map<String, String> param = new HashMap<>(); Map<String, String> param = new HashMap<>();
...@@ -79,25 +85,26 @@ public class LoginController { ...@@ -79,25 +85,26 @@ public class LoginController {
} }
Map<String ,String > re = (Map<String ,String >) result; Map<String ,String > re = (Map<String ,String >) result;
String token = re.get("token"); String amosToken = re.get("token");
privilegeFeign.warrant(appKey, product, token); privilegeFeign.warrant(appKey, product, amosToken);
RequestContext.setToken(token); RequestContext.setToken(amosToken);
RequestContext.setProduct(product); RequestContext.setProduct(product);
RequestContext.setAppKey(appKey); RequestContext.setAppKey(appKey);
AgencyUserModel userModel = (AgencyUserModel) Privilege.agencyUserClient.getme().getResult(); AgencyUserModel userModel = (AgencyUserModel) Privilege.agencyUserClient.getme().getResult();
CompanyModel companyModel = userModel.getCompanys().get(0); CompanyModel companyModel = userModel.getCompanys().get(0);
List<DepartmentModel> deptList = remoteSecurityService.getDepartmentTreeByCompanyId(token, product, appKey, companyModel.getSequenceNbr().toString()); List<DepartmentModel> deptList = remoteSecurityService.getDepartmentTreeByCompanyId(amosToken, product, appKey, companyModel.getSequenceNbr().toString());
if(deptList.size() > 0){ if(deptList.size() > 0){
CompanyBo companyBo = convertCompanyModelToBo(companyModel); CompanyBo companyBo = convertCompanyModelToBo(companyModel);
DepartmentBo departmentBo = convertDepartmentModelToBo(deptList.get(0)); DepartmentBo departmentBo = convertDepartmentModelToBo(deptList.get(0));
reginParams.setDepartment(departmentBo); reginParams.setDepartment(departmentBo);
reginParams.setCompany(companyBo); reginParams.setCompany(companyBo);
} }
reginParams.setToken(token); reginParams.setToken(amosToken);
reginParams.setUserModel(userModel); reginParams.setUserModel(userModel);
redisTemplate.opsForValue().set(buildKey(userId), JSONObject.toJSONString(reginParams)); redisTemplate.opsForValue().set(buildKey(userId, token), JSONObject.toJSONString(reginParams));
redisTemplate.opsForValue().set(buildKey(userId, amosToken), JSONObject.toJSONString(reginParams));
} }
return reginParams; return reginParams;
} }
...@@ -147,8 +154,8 @@ public class LoginController { ...@@ -147,8 +154,8 @@ public class LoginController {
return roleBo; return roleBo;
} }
private String buildKey(String userId) { private String buildKey(String userId, String token) {
return "region_" + userId; return "region_" + userId + "_" + token;
} }
} }
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