|
|
@@ -0,0 +1,78 @@
|
|
|
+package com.fdkankan.scene.Interceptor;
|
|
|
+
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.fdkankan.common.constant.CommonStatus;
|
|
|
+import com.fdkankan.common.constant.ErrorCode;
|
|
|
+import com.fdkankan.common.constant.ServerCode;
|
|
|
+import com.fdkankan.common.exception.BusinessException;
|
|
|
+import com.fdkankan.common.response.Result;
|
|
|
+import com.fdkankan.common.user.SSOLoginHelper;
|
|
|
+import com.fdkankan.common.util.WebUtil;
|
|
|
+import com.fdkankan.redis.constant.RedisKey;
|
|
|
+import com.fdkankan.redis.util.RedisUtil;
|
|
|
+import com.fdkankan.scene.callback.FdkkMiniReqErrorCallback;
|
|
|
+import com.fdkankan.scene.callback.FdkkMiniReqSuccessCallback;
|
|
|
+import com.fdkankan.scene.entity.ScenePlus;
|
|
|
+import com.fdkankan.scene.httpclient.FdkankanMiniClient;
|
|
|
+import com.fdkankan.scene.service.IScenePlusService;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import lombok.extern.log4j.Log4j2;
|
|
|
+import org.aspectj.lang.JoinPoint;
|
|
|
+import org.aspectj.lang.annotation.Aspect;
|
|
|
+import org.aspectj.lang.annotation.Before;
|
|
|
+import org.aspectj.lang.annotation.Pointcut;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.core.annotation.Order;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.web.context.request.RequestContextHolder;
|
|
|
+import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
+
|
|
|
+@Log4j2
|
|
|
+@Aspect
|
|
|
+@Component
|
|
|
+@Order(101)
|
|
|
+public class CheckPermitAspect {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SSOLoginHelper ssoLoginHelper;
|
|
|
+ @Autowired
|
|
|
+ private RedisUtil redisUtil;
|
|
|
+ @Autowired
|
|
|
+ private IScenePlusService scenePlusService;
|
|
|
+
|
|
|
+ @Value("${http.host.4dkankanMini}")
|
|
|
+ private String fkankanMiniHost;
|
|
|
+ @Value("${http.api.isLogin}")
|
|
|
+ private String URL_ISLOGIN;
|
|
|
+ @Autowired
|
|
|
+ private FdkankanMiniClient fdkankanMiniClient;
|
|
|
+
|
|
|
+
|
|
|
+ @Pointcut("@annotation(com.fdkankan.scene.annotation.CheckCooperationPermit)")
|
|
|
+ public void checkCooperationPermit() {
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 前置通知 用于判断用户协作场景是否有协作权限
|
|
|
+ *
|
|
|
+ * @param joinPoint
|
|
|
+ * 切点
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ @Before("checkCooperationPermit()")
|
|
|
+ public void doBefore(JoinPoint joinPoint) throws Exception {
|
|
|
+ HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
|
|
+ // 读取session中的用户
|
|
|
+// com.fdkankan.common.model.SSOUser user = ssoLoginHelper.loginCheckV3(request.getHeader("token"));
|
|
|
+ String num = WebUtil.getNum(joinPoint, request);
|
|
|
+ String url = fkankanMiniHost + URL_ISLOGIN + num;
|
|
|
+ Result<Map<String, Object>> isLoginResult = fdkankanMiniClient
|
|
|
+ .getIsLogin(url, request.getHeader("token"), new FdkkMiniReqSuccessCallback(),
|
|
|
+ new FdkkMiniReqErrorCallback());
|
|
|
+ }
|
|
|
+
|
|
|
+}
|