添加了自定义banner

修复了一个bug
This commit is contained in:
wind 2023-03-27 23:17:52 +08:00
parent 8cbe9c9599
commit 7effd46826
3 changed files with 34 additions and 3 deletions

View File

@ -0,0 +1,17 @@
package kim.wind.sms.comm.config;
public class SmsBanner {
private static final String banner =
" _____ __ __ _____ _____ _____ _____ ______ _____ _______ _____ ____ _ _ \n" +
" / ____| | \\/ | / ____| /\\ / ____| / ____| | __ \\ | ____| / ____| /\\ |__ __| |_ _| / __ \\ | \\ | |\n" +
" | (___ | \\ / | | (___ / \\ | | __ | | __ | |__) | | |__ | | __ / \\ | | | | | | | | | \\| |\n" +
" \\___ \\ | |\\/| | \\___ \\ / /\\ \\ | | |_ | | | |_ | | _ / | __| | | |_ | / /\\ \\ | | | | | | | | | . ` |\n" +
" ____) | | | | | ____) | / ____ \\ | |__| | | |__| | | | \\ \\ | |____ | |__| | / ____ \\ | | _| |_ | |__| | | |\\ |\n" +
" |_____/ |_| |_| |_____/ /_/ \\_\\ \\_____| \\_____| |_| \\_\\ |______| \\_____| /_/ \\_\\ |_| |_____| \\____/ |_| \\_|\n" +
" \n" +
" V1.0.1";
public static void PrintBanner() {
System.out.println(banner);
}
}

View File

@ -1,6 +1,7 @@
package kim.wind.sms.comm.utils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
@ -12,7 +13,11 @@ import java.util.concurrent.TimeUnit;
@Slf4j
public class RedisUtils {
private final RedisTemplate<String, Object> redisTemplate;
@Autowired
private RedisTemplate<String, Object> redisTemplate;
public RedisUtils() {
}
public RedisUtils(RedisTemplate<String, Object> redisTemplate) {
this.redisTemplate = redisTemplate;

View File

@ -3,11 +3,14 @@ package kim.wind.sms.starter.config;
import com.example.sms.unisms.service.UniSmsImpl;
import kim.wind.sms.aliyun.service.AlibabaSmsImpl;
import kim.wind.sms.api.SmsBlend;
import kim.wind.sms.comm.config.SmsBanner;
import kim.wind.sms.comm.delayedTime.DelayedTime;
import kim.wind.sms.comm.utils.RedisUtils;
import kim.wind.sms.comm.utils.SpringUtil;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.Banner;
import org.springframework.boot.ResourceBanner;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
@ -28,6 +31,8 @@ public class SmsMainConfig {
/** 短信服务商*/
@Value("${sms.supplier}")
private String supplier;
/** 打印banner*/
private String isPrint = "true";
/** 是否开启短信限制*/
private String restricted;
@ -66,6 +71,9 @@ public class SmsMainConfig {
@Bean
public SmsBlend smsBlend(){
if ("true".equals(isPrint)){
SmsBanner.PrintBanner();
}
SmsBlend smsBlend = null;
switch (supplier){
case "alibaba":
@ -104,8 +112,8 @@ public class SmsMainConfig {
/** 如果启用了redis作为缓存则注入redis工具类*/
@Bean
@ConditionalOnProperty(prefix = "sms", name = "redisCache", havingValue = "true")
public RedisUtils redisUtils(RedisTemplate<String, Object> redisTemplate){
return new RedisUtils(redisTemplate);
public RedisUtils redisUtils(){
return new RedisUtils();
}
/** 注入一个定时器*/
@ -113,4 +121,5 @@ public class SmsMainConfig {
public DelayedTime delayedTime(){
return new DelayedTime();
}
}