parent
47d9d86be3
commit
4ae0e806fc
@ -0,0 +1,16 @@
|
|||||||
|
package com.mashibing.common.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author heqijun
|
||||||
|
* @ClassName: SearchConstant
|
||||||
|
* @Description: 搜索模块常量
|
||||||
|
* @date 2025/6/18 20:30
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface SearchConstant {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信日志索引前缀
|
||||||
|
*/
|
||||||
|
String INDEX_PREFIX = "sms_submit_log_";
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.mashibing.smsgateway.client;
|
||||||
|
|
||||||
|
import com.mashibing.common.clients.BeaconCacheClient;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author heqijun
|
||||||
|
* @ClassName: CacheClient
|
||||||
|
* @Description: 缓存模块openFeignClient接口
|
||||||
|
* @date 2025/6/17 20:28
|
||||||
|
*/
|
||||||
|
|
||||||
|
@FeignClient("beacon-cache")
|
||||||
|
public interface CacheClient extends BeaconCacheClient {
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package com.mashibing.smsgateway.utils;
|
||||||
|
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.ApplicationContextAware;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author heqijun
|
||||||
|
* @ClassName: SpringUtil
|
||||||
|
* @Description: 用于在非ioc管理的类中使用spring中的bean
|
||||||
|
* @date 2025/6/17 18:36
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class SpringUtil implements ApplicationContextAware {
|
||||||
|
|
||||||
|
private static ApplicationContext applicationContext;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||||
|
SpringUtil.applicationContext = applicationContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T getBeanByName(String beanName, Class<T> clazz) {
|
||||||
|
Object bean = applicationContext.getBean(beanName);
|
||||||
|
if (clazz.isInstance(bean)) {
|
||||||
|
return clazz.cast(bean);
|
||||||
|
} else {
|
||||||
|
throw new NoSuchBeanDefinitionException("No bean with name = " + beanName + " and type = " + clazz.getSimpleName() + " found");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T getBeanByClass(Class<T> clazz) {
|
||||||
|
return applicationContext.getBean(clazz);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue