|
@@ -0,0 +1,35 @@
|
|
|
+package com.xynet.marketing.utils;
|
|
|
+
|
|
|
+import com.cow.support.dto.UserSessionModel;
|
|
|
+import com.xynet.marketing.utils.redis.utils.RedisService;
|
|
|
+
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 会员权限工具类
|
|
|
+ *
|
|
|
+ * @author hechunping
|
|
|
+ * @date 2025/2/17
|
|
|
+ */
|
|
|
+public class MemberAuthUtils {
|
|
|
+ private static String redisPrefix = "userSession-";
|
|
|
+
|
|
|
+ public static String getUserId(Map<String, String> headers) {
|
|
|
+ //获取token
|
|
|
+ String token = headers.get("token");
|
|
|
+ String providerId = headers.get("provider_id");
|
|
|
+ RedisService<UserSessionModel> redisService = SpringBeanUtils.getBean(RedisService.class);
|
|
|
+ if (!Emptys.check(token)) {
|
|
|
+ throw new RuntimeException("token不能为空");
|
|
|
+ }
|
|
|
+ if (!Emptys.check(providerId)) {
|
|
|
+ throw new RuntimeException("服务商ID不能为空");
|
|
|
+ }
|
|
|
+ //判断redis里是否有对应的商户ID
|
|
|
+ UserSessionModel userSession = redisService.get(redisPrefix + token);
|
|
|
+ if (!Emptys.check(userSession)) {
|
|
|
+ throw new RuntimeException("token已过期");
|
|
|
+ }
|
|
|
+ return userSession.getUserInfo().getAuthlevel();
|
|
|
+ }
|
|
|
+}
|