|
@@ -13,6 +13,8 @@ import com.fs.his.service.IFsUserService;
|
|
import io.jsonwebtoken.Claims;
|
|
import io.jsonwebtoken.Claims;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
+
|
|
|
|
|
|
public class AppBaseController {
|
|
public class AppBaseController {
|
|
@Autowired
|
|
@Autowired
|
|
@@ -27,8 +29,16 @@ public class AppBaseController {
|
|
public Long getCompanyId() {
|
|
public Long getCompanyId() {
|
|
String headValue = ServletUtils.getRequest().getHeader("APPToken");
|
|
String headValue = ServletUtils.getRequest().getHeader("APPToken");
|
|
Claims claims=jwtUtils.getClaimByToken(headValue);
|
|
Claims claims=jwtUtils.getClaimByToken(headValue);
|
|
|
|
+ if (ObjectUtil.isEmpty(claims)){
|
|
|
|
+ throw new FSException("未授权,请先登录!");
|
|
|
|
+ }
|
|
String userId = claims.getSubject().toString();
|
|
String userId = claims.getSubject().toString();
|
|
Long companyId =(Long)redisCache.getCacheObject("companyId:"+userId);
|
|
Long companyId =(Long)redisCache.getCacheObject("companyId:"+userId);
|
|
|
|
+ if (companyId==null){
|
|
|
|
+ CompanyUser companyUser = companyUserService.selectCompanyUserById(Long.parseLong(userId));
|
|
|
|
+ companyId = companyUser.getCompanyId();
|
|
|
|
+ redisCache.setCacheObject("companyId:" + companyUser.getUserId(), companyUser.getCompanyId(), 604800, TimeUnit.SECONDS);
|
|
|
|
+ }
|
|
return companyId;
|
|
return companyId;
|
|
}
|
|
}
|
|
public String getUserId()
|
|
public String getUserId()
|