Explorar o código

refactor(app):优化获取公司ID逻辑

- 移除了冗余的空值检查和异常抛出
- 简化了从Redis缓存获取companyId的流程- 删除了不必要的TimeUnit导入
- 去除了重复的companyId查询和缓存设置逻辑
xw hai 1 semana
pai
achega
c2dd165fed

+ 0 - 10
fs-company-app/src/main/java/com/fs/app/controller/AppBaseController.java

@@ -13,8 +13,6 @@ import com.fs.his.service.IFsUserService;
 import io.jsonwebtoken.Claims;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import java.util.concurrent.TimeUnit;
-
 
 public class AppBaseController {
 	@Autowired
@@ -29,16 +27,8 @@ public class AppBaseController {
 	public Long getCompanyId() {
 		String headValue =  ServletUtils.getRequest().getHeader("APPToken");
 		Claims claims=jwtUtils.getClaimByToken(headValue);
-		if (ObjectUtil.isEmpty(claims)){
-			throw new FSException("未授权,请先登录!");
-		}
 		String userId = claims.getSubject().toString();
 		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;
 	}
 	public String getUserId()