处理后台管理系统、修复BUG、处理权限

This commit is contained in:
super
2026-04-22 01:09:28 +08:00
parent d691e53886
commit 236b73755c
77 changed files with 5157 additions and 522 deletions
@@ -142,6 +142,26 @@ public class ZiniaoAuthService {
return getOrLoadUserStores(apiKey, companyId, userId);
}
public boolean isIpWhitelistError(BusinessException ex) {
String message = ex == null ? null : ex.getMessage();
if (message == null || message.isBlank()) {
return false;
}
String lowerMessage = message.toLowerCase();
return message.contains("白名单")
|| message.contains("IP白名单")
|| message.contains("ip白名单")
|| message.contains("当前ip")
|| message.contains("当前IP")
|| message.contains("禁止当前ip")
|| message.contains("禁止当前IP")
|| message.contains("禁止访问")
|| lowerMessage.contains("whitelist")
|| lowerMessage.contains("current ip")
|| lowerMessage.contains("forbid")
|| lowerMessage.contains("forbidden");
}
public boolean isInvalidUserStoresError(BusinessException ex) {
String message = ex == null ? null : ex.getMessage();
if (message == null || message.isBlank()) {
@@ -190,12 +190,19 @@ public class ZiniaoShopIndexService {
try {
companyId = ziniaoAuthService.resolveCompanyIdForIndex(apiKey);
} catch (BusinessException ex) {
rethrowIfIpWhitelistError(ex);
log.warn("[ziniao-index] skip apiKey while resolving companyId, msg={}", ex.getMessage());
continue;
}
Set<Long> invalidUserIds = new LinkedHashSet<>();
List<ZiniaoStaffItemVo> staff = ziniaoAuthService.getOrLoadStaffForIndex(apiKey, companyId);
List<ZiniaoStaffItemVo> staff;
try {
staff = ziniaoAuthService.getOrLoadStaffForIndex(apiKey, companyId);
} catch (BusinessException ex) {
rethrowIfIpWhitelistError(ex);
throw ex;
}
for (Long userId : buildUserIds(staff)) {
if (invalidUserIds.contains(userId)) {
continue;
@@ -204,6 +211,7 @@ public class ZiniaoShopIndexService {
try {
stores = ziniaoAuthService.getOrLoadUserStoresForIndex(apiKey, companyId, userId);
} catch (BusinessException ex) {
rethrowIfIpWhitelistError(ex);
if (ziniaoAuthService.isInvalidUserStoresError(ex)) {
invalidUserIds.add(userId);
allInvalidUserIds.add(userId);
@@ -662,4 +670,10 @@ public class ZiniaoShopIndexService {
throw new BusinessException("生成紫鸟 apiKey 缓存键失败");
}
}
private void rethrowIfIpWhitelistError(BusinessException ex) {
if (ziniaoAuthService.isIpWhitelistError(ex)) {
throw new BusinessException("紫鸟刷新店铺索引失败:当前服务器 IP 未加入紫鸟白名单,已停止本轮刷新且不会更新索引数据");
}
}
}