2026-04-27 23:41:58 +08:00
|
|
|
package com.xuqm.tenant.service;
|
|
|
|
|
|
|
|
|
|
import com.xuqm.common.exception.BusinessException;
|
|
|
|
|
import com.xuqm.tenant.entity.AppEntity;
|
|
|
|
|
import com.xuqm.tenant.repository.AppRepository;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class SdkAppProvisioningService {
|
|
|
|
|
|
|
|
|
|
private final AppRepository appRepository;
|
|
|
|
|
|
2026-05-22 15:33:20 +08:00
|
|
|
public SdkAppProvisioningService(AppRepository appRepository) {
|
2026-04-27 23:41:58 +08:00
|
|
|
this.appRepository = appRepository;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional
|
2026-05-07 19:39:42 +08:00
|
|
|
public AppEntity resolveApp(String appKey) {
|
|
|
|
|
return appRepository.findByAppKey(appKey)
|
|
|
|
|
.or(() -> appRepository.findById(appKey))
|
2026-05-22 15:33:20 +08:00
|
|
|
.orElseThrow(() -> new BusinessException(404, "App not found: " + appKey));
|
2026-04-27 23:41:58 +08:00
|
|
|
}
|
|
|
|
|
}
|