完成菜单权限添加和软件菜单改造

This commit is contained in:
super
2026-04-12 17:15:15 +08:00
parent 7589b4e418
commit e53eaf738e
17 changed files with 814 additions and 297 deletions
@@ -1,23 +1,36 @@
package com.nanri.aiimage.modules.ziniao.service;
import com.nanri.aiimage.common.service.DistributedJobLockService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import java.time.Duration;
@Service
@RequiredArgsConstructor
@Slf4j
public class ZiniaoShopIndexRefreshService {
private static final Duration REFRESH_LOCK_TTL = Duration.ofMinutes(30);
private final ZiniaoShopIndexService ziniaoShopIndexService;
private final DistributedJobLockService distributedJobLockService;
@Scheduled(cron = "${aiimage.ziniao.shop-index-refresh-cron:0 */10 * * * *}")
public void refreshShopIndex() {
try {
ziniaoShopIndexService.refreshShopIndex();
} catch (Exception ex) {
log.warn("[ziniao-index] refresh failed: {}", ex.getMessage());
DistributedJobLockService.LockHandle lockHandle = distributedJobLockService.tryLock("ziniao:shop-index-refresh", REFRESH_LOCK_TTL);
if (lockHandle == null) {
log.info("[ziniao-index] skip refresh because another instance holds the distributed lock");
return;
}
try (lockHandle) {
try {
ziniaoShopIndexService.refreshShopIndex();
} catch (Exception ex) {
log.warn("[ziniao-index] refresh failed: {}", ex.getMessage());
}
}
}
}